From 4cc01f64e9ba4900874ba9f894617b5b726177e1 Mon Sep 17 00:00:00 2001 From: wenc000 <450292408@qq.com> Date: Sun, 3 May 2020 21:08:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BC=81=E4=B8=9A=E5=9C=BA?= =?UTF-8?q?=E6=89=80=E6=80=A7=E8=B4=A8=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../enterprise/EnterpriseAppController.java | 15 +++++++ .../dao/enterprise/IEnterpriseDao.java | 10 ++++- .../vos/enterprise/EnterpriseNatureVO.java | 40 +++++++++++++++++++ .../enterprise/IEnterpriseService.java | 12 ++++++ .../impl/EnterpriseServiceImpl.java | 28 +++++++++++-- .../mapper/enterprise/enterprise-mapper.xml | 17 ++++++++ .../route/enterprise/update-enterprise.html | 2 +- 7 files changed, 118 insertions(+), 6 deletions(-) create mode 100644 src/main/java/com/cm/inspection/pojo/vos/enterprise/EnterpriseNatureVO.java diff --git a/src/main/java/com/cm/inspection/controller/app/apis/enterprise/EnterpriseAppController.java b/src/main/java/com/cm/inspection/controller/app/apis/enterprise/EnterpriseAppController.java index 78255d3..2f2bfa2 100644 --- a/src/main/java/com/cm/inspection/controller/app/apis/enterprise/EnterpriseAppController.java +++ b/src/main/java/com/cm/inspection/controller/app/apis/enterprise/EnterpriseAppController.java @@ -11,6 +11,7 @@ import com.cm.common.result.SuccessResult; import com.cm.common.result.SuccessResultData; import com.cm.common.result.SuccessResultList; import com.cm.inspection.pojo.dtos.enterprise.EnterpriseDTO; +import com.cm.inspection.pojo.vos.enterprise.EnterpriseNatureVO; import com.cm.inspection.pojo.vos.enterprise.EnterpriseVO; import com.cm.inspection.service.enterprise.IEnterpriseService; import io.swagger.annotations.*; @@ -70,6 +71,20 @@ public class EnterpriseAppController extends AbstractController { return enterpriseService.updateEnterpriseByToken(token, enterpriseId, enterpriseVO); } + @ApiOperation(value = "更新企业场所性质", notes = "更新企业场所性质接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "token", value = "token", paramType = "header"), + @ApiImplicitParam(name = "enterpriseId", value = "企业ID", paramType = "path") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @PutMapping("updateenterprisenature/{enterpriseId}") + @CheckRequestBodyAnnotation + public SuccessResult updateEnterpriseNature(@RequestHeader("token") String token, + @PathVariable("enterpriseId") String enterpriseId, + @RequestBody EnterpriseNatureVO enterpriseNatureVO) throws Exception { + return enterpriseService.updateEnterpriseNatureByToken(token, enterpriseId, enterpriseNatureVO); + } + @ApiOperation(value = "企业详情(通过ID)", notes = "企业详情(通过ID)接口") @ApiImplicitParams({ @ApiImplicitParam(name = "token", value = "token", paramType = "header"), diff --git a/src/main/java/com/cm/inspection/dao/enterprise/IEnterpriseDao.java b/src/main/java/com/cm/inspection/dao/enterprise/IEnterpriseDao.java index 058b09a..f569f3a 100644 --- a/src/main/java/com/cm/inspection/dao/enterprise/IEnterpriseDao.java +++ b/src/main/java/com/cm/inspection/dao/enterprise/IEnterpriseDao.java @@ -53,6 +53,14 @@ public interface IEnterpriseDao { */ void updateEnterpriseLocation(Map params) throws UpdateException; + /** + * 修改企业场所性质 + * + * @param params + * @throws UpdateException + */ + void updateEnterpriseNature(Map params) throws UpdateException; + /** * 企业详情 * @@ -81,10 +89,10 @@ public interface IEnterpriseDao { List listEnterprise(Map params) throws SearchException; /** - * * @param params * @return * @throws SearchException */ Integer countEnterprise(Map params) throws SearchException; + } diff --git a/src/main/java/com/cm/inspection/pojo/vos/enterprise/EnterpriseNatureVO.java b/src/main/java/com/cm/inspection/pojo/vos/enterprise/EnterpriseNatureVO.java new file mode 100644 index 0000000..75f8999 --- /dev/null +++ b/src/main/java/com/cm/inspection/pojo/vos/enterprise/EnterpriseNatureVO.java @@ -0,0 +1,40 @@ +package com.cm.inspection.pojo.vos.enterprise; + +import com.cm.common.annotation.CheckEmptyAnnotation; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: EnterpriseNatureVO + * @Description: 企业场所性质 + * @Author: WangGeng + * @Date: 2020/5/3 20:00 + * @Version: 1.0 + **/ +@ApiModel +public class EnterpriseNatureVO { + + @ApiModelProperty(name = "natureId", value = "场所性质") + @CheckEmptyAnnotation(name = "场所性质") + private String natureId; + + public String getNatureId() { + return natureId == null ? "" : natureId; + } + + public void setNatureId(String natureId) { + this.natureId = natureId; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"natureId\":") + .append(natureId); + sb.append('}'); + return sb.toString(); + } +} diff --git a/src/main/java/com/cm/inspection/service/enterprise/IEnterpriseService.java b/src/main/java/com/cm/inspection/service/enterprise/IEnterpriseService.java index 41da7a1..f188fd1 100644 --- a/src/main/java/com/cm/inspection/service/enterprise/IEnterpriseService.java +++ b/src/main/java/com/cm/inspection/service/enterprise/IEnterpriseService.java @@ -9,6 +9,7 @@ import com.cm.common.result.SuccessResult; import com.cm.common.result.SuccessResultData; import com.cm.common.result.SuccessResultList; import com.cm.inspection.pojo.dtos.enterprise.EnterpriseDTO; +import com.cm.inspection.pojo.vos.enterprise.EnterpriseNatureVO; import com.cm.inspection.pojo.vos.enterprise.EnterpriseVO; import java.util.List; @@ -92,6 +93,17 @@ public interface IEnterpriseService { */ SuccessResult updateEnterpriseByToken(String token, String enterpriseId, EnterpriseVO enterpriseVO) throws Exception; + /** + * 更新企业场所性质 + * + * @param token + * @param enterpriseId + * @param enterpriseNatureVO + * @return + * @throws Exception + */ + SuccessResult updateEnterpriseNatureByToken(String token, String enterpriseId, EnterpriseNatureVO enterpriseNatureVO) throws Exception; + /** * 更新企业位置 * diff --git a/src/main/java/com/cm/inspection/service/enterprise/impl/EnterpriseServiceImpl.java b/src/main/java/com/cm/inspection/service/enterprise/impl/EnterpriseServiceImpl.java index d2d73dc..47605e1 100644 --- a/src/main/java/com/cm/inspection/service/enterprise/impl/EnterpriseServiceImpl.java +++ b/src/main/java/com/cm/inspection/service/enterprise/impl/EnterpriseServiceImpl.java @@ -1,9 +1,6 @@ package com.cm.inspection.service.enterprise.impl; -import com.cm.common.exception.RemoveException; -import com.cm.common.exception.SaveException; -import com.cm.common.exception.SearchException; -import com.cm.common.exception.UpdateException; +import com.cm.common.exception.*; import com.cm.common.plugin.pojo.dtos.datadictionary.DataDictionaryDTO; import com.cm.common.plugin.service.datadictionary.IDataDictionaryService; import com.cm.common.pojo.ListPage; @@ -14,6 +11,7 @@ import com.cm.common.utils.HashMapUtil; import com.cm.common.utils.UUIDUtil; import com.cm.inspection.dao.enterprise.IEnterpriseDao; import com.cm.inspection.pojo.dtos.enterprise.EnterpriseDTO; +import com.cm.inspection.pojo.vos.enterprise.EnterpriseNatureVO; import com.cm.inspection.pojo.vos.enterprise.EnterpriseVO; import com.cm.inspection.pojo.vos.enterpriseofgridoperator.EnterpriseOfGridOperatorVO; import com.cm.inspection.service.BaseService; @@ -141,6 +139,28 @@ public class EnterpriseServiceImpl extends BaseService implements IEnterpriseSer return new SuccessResult(); } + @Override + public SuccessResult updateEnterpriseNatureByToken(String token, String enterpriseId, EnterpriseNatureVO enterpriseNatureVO) throws Exception { + EnterpriseDTO enterpriseDTO = getEnterpriseById(enterpriseId); + if (enterpriseDTO == null) { + throw new ParamsException("企业不存在"); + } + if (StringUtils.isBlank(enterpriseDTO.getNature())) { + throw new ParamsException("企业已经绑定场所性质"); + } + DataDictionaryDTO dataDictionaryDTO = dataDictionaryService.getDictionaryById(enterpriseNatureVO.getNatureId()); + if (dataDictionaryDTO == null) { + throw new ParamsException("场所性质不存在"); + } + Map params = getHashMap(5); + params.put("enterpriseId", enterpriseId); + params.put("nature", enterpriseNatureVO.getNatureId()); + params.put("natureDictionaryName", dataDictionaryDTO.getDictionaryName()); + setUpdateInfo(token, params); + enterpriseDao.updateEnterpriseNature(params); + return new SuccessResult(); + } + @Override public void updateEnterpriseLocationByEnterpriseId(String enterpriseId, String checkLng, String checkLat) throws UpdateException { updateEnterpriseLocationByTokenAndEnterpriseId(null, enterpriseId, checkLng, checkLat); diff --git a/src/main/resources/mybatis/mapper/enterprise/enterprise-mapper.xml b/src/main/resources/mybatis/mapper/enterprise/enterprise-mapper.xml index f264de9..fd14374 100644 --- a/src/main/resources/mybatis/mapper/enterprise/enterprise-mapper.xml +++ b/src/main/resources/mybatis/mapper/enterprise/enterprise-mapper.xml @@ -270,6 +270,23 @@ enterprise_id = #{enterpriseId} + + + UPDATE + gen_enterprise + SET + + nature = #{nature}, + + + nature_dictionary_name = #{natureDictionaryName}, + + modifier = #{modifier}, + gmt_modified = #{gmtModified} + WHERE + enterprise_id = #{enterpriseId} + +