diff --git a/src/main/java/com/cm/inspection/controller/apis/enterpriseofgridoperator/EnterpriseOfGridOperatorController.java b/src/main/java/com/cm/inspection/controller/apis/enterpriseofgridoperator/EnterpriseOfGridOperatorController.java index ccf0775..3f5d1cd 100644 --- a/src/main/java/com/cm/inspection/controller/apis/enterpriseofgridoperator/EnterpriseOfGridOperatorController.java +++ b/src/main/java/com/cm/inspection/controller/apis/enterpriseofgridoperator/EnterpriseOfGridOperatorController.java @@ -67,6 +67,17 @@ public class EnterpriseOfGridOperatorController extends AbstractController { return enterpriseOfGridOperatorService.deleteEnterpriseOfGridOperator(ids); } + @ApiOperation(value = "删除网格员的企业(通过企业ID,和用户ID,物理)", notes = "删除网格员的企业(通过企业ID,和用户ID,物理)接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "enterpriseId", value = "企业ID", paramType = "path"), + @ApiImplicitParam(name = "userId", value = "用户ID", paramType = "path") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @DeleteMapping("deleteenterpriseofgridoperator/{enterpriseId}/{userId}") + public SuccessResult deleteEnterpriseOfGridOperatorById(@PathVariable("enterpriseId") String enterpriseId, @PathVariable("userId") String userId) throws RemoveException { + return enterpriseOfGridOperatorService.deleteEnterpriseOfGridOperatorByEnterpriseIdAndUserId(enterpriseId, userId); + } + @ApiOperation(value = "修改网格员的企业", notes = "修改网格员的企业接口") @ApiImplicitParams({ @ApiImplicitParam(name = "enterpriseOfGridOperatorId", value = "网格员的企业ID", paramType = "path") diff --git a/src/main/java/com/cm/inspection/controller/app/apis/enterpriseofgridoperator/EnterpriseOfGridOperatorAppController.java b/src/main/java/com/cm/inspection/controller/app/apis/enterpriseofgridoperator/EnterpriseOfGridOperatorAppController.java index f844ebd..045a325 100644 --- a/src/main/java/com/cm/inspection/controller/app/apis/enterpriseofgridoperator/EnterpriseOfGridOperatorAppController.java +++ b/src/main/java/com/cm/inspection/controller/app/apis/enterpriseofgridoperator/EnterpriseOfGridOperatorAppController.java @@ -2,6 +2,7 @@ package com.cm.inspection.controller.app.apis.enterpriseofgridoperator; import com.cm.common.annotation.CheckRequestBodyAnnotation; import com.cm.common.base.AbstractController; +import com.cm.common.component.SecurityComponent; import com.cm.common.constants.ISystemConstant; import com.cm.common.exception.RemoveException; import com.cm.common.exception.SearchException; @@ -10,6 +11,7 @@ import com.cm.common.result.ErrorResult; import com.cm.common.result.SuccessResult; import com.cm.common.result.SuccessResultData; import com.cm.common.result.SuccessResultList; +import com.cm.common.token.app.entity.AppToken; import com.cm.inspection.pojo.dtos.enterpriseofgridoperator.EnterpriseOfGridOperatorDTO; import com.cm.inspection.pojo.vos.enterpriseofgridoperator.EnterpriseOfGridOperatorVO; import com.cm.inspection.service.enterpriseofgridoperator.IEnterpriseOfGridOperatorService; @@ -61,12 +63,12 @@ public class EnterpriseOfGridOperatorAppController extends AbstractController { @ApiOperation(value = "删除网格员的企业(通过id,物理)", notes = "删除网格员的企业(通过id,物理)接口") @ApiImplicitParams({ @ApiImplicitParam(name = "token", value = "token", paramType = "header"), - @ApiImplicitParam(name = "ids", value = "ID列表,用下划线分隔", paramType = "path", example = "1_2_3") + @ApiImplicitParam(name = "enterpriseId", value = "企业ID", paramType = "path") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @DeleteMapping("deleteenterpriseofgridoperator/{ids}") - public SuccessResult deleteEnterpriseOfGridOperatorById(@RequestHeader("token") String token, @PathVariable("ids") String ids) throws RemoveException { - return enterpriseOfGridOperatorService.deleteEnterpriseOfGridOperator(ids); + @DeleteMapping("deleteenterpriseofgridoperator/{enterpriseId}") + public SuccessResult deleteEnterpriseOfGridOperatorById(@RequestHeader("token") String token, @PathVariable("enterpriseId") String enterpriseId) throws RemoveException { + return enterpriseOfGridOperatorService.deleteEnterpriseOfGridOperatorByTokenAndEnterpriseId(token, enterpriseId); } @ApiOperation(value = "修改网格员的企业", notes = "修改网格员的企业接口") diff --git a/src/main/java/com/cm/inspection/pojo/dtos/enterpriseofgridoperator/EnterpriseOfGridOperatorDTO.java b/src/main/java/com/cm/inspection/pojo/dtos/enterpriseofgridoperator/EnterpriseOfGridOperatorDTO.java index f750d6b..5112e2b 100644 --- a/src/main/java/com/cm/inspection/pojo/dtos/enterpriseofgridoperator/EnterpriseOfGridOperatorDTO.java +++ b/src/main/java/com/cm/inspection/pojo/dtos/enterpriseofgridoperator/EnterpriseOfGridOperatorDTO.java @@ -77,6 +77,8 @@ public class EnterpriseOfGridOperatorDTO { private String natureDictionaryName; @ApiModelProperty(name = "isLogOffByEnterpriseId", value = "是否注销") private Integer isLogOffByEnterpriseId; + @ApiModelProperty(name = "userCount", value = "绑定用户数") + private Integer userCount; public String getEnterpriseOfGridOperatorId() { return enterpriseOfGridOperatorId == null ? "" : enterpriseOfGridOperatorId; @@ -334,6 +336,14 @@ public class EnterpriseOfGridOperatorDTO { this.isLogOffByEnterpriseId = isLogOffByEnterpriseId; } + public Integer getUserCount() { + return userCount; + } + + public void setUserCount(Integer userCount) { + this.userCount = userCount; + } + @Override public String toString() { final StringBuilder sb = new StringBuilder("{"); @@ -401,6 +411,8 @@ public class EnterpriseOfGridOperatorDTO { .append(natureDictionaryName).append('\"'); sb.append(",\"isLogOffByEnterpriseId\":") .append(isLogOffByEnterpriseId); + sb.append(",\"userCount\":") + .append(userCount); sb.append('}'); return sb.toString(); } 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 47605e1..b629812 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 @@ -145,7 +145,7 @@ public class EnterpriseServiceImpl extends BaseService implements IEnterpriseSer if (enterpriseDTO == null) { throw new ParamsException("企业不存在"); } - if (StringUtils.isBlank(enterpriseDTO.getNature())) { + if (!StringUtils.isBlank(enterpriseDTO.getNature())) { throw new ParamsException("企业已经绑定场所性质"); } DataDictionaryDTO dataDictionaryDTO = dataDictionaryService.getDictionaryById(enterpriseNatureVO.getNatureId()); diff --git a/src/main/java/com/cm/inspection/service/enterpriseofgridoperator/IEnterpriseOfGridOperatorService.java b/src/main/java/com/cm/inspection/service/enterpriseofgridoperator/IEnterpriseOfGridOperatorService.java index 80b0542..5a2ffcb 100644 --- a/src/main/java/com/cm/inspection/service/enterpriseofgridoperator/IEnterpriseOfGridOperatorService.java +++ b/src/main/java/com/cm/inspection/service/enterpriseofgridoperator/IEnterpriseOfGridOperatorService.java @@ -59,6 +59,26 @@ public interface IEnterpriseOfGridOperatorService { */ SuccessResult deleteEnterpriseOfGridOperator(String ids) throws RemoveException; + /** + * 删除网格员的企业(通过token, 企业ID,物理) + * + * @param token + * @param enterpriseId + * @return + * @throws RemoveException + */ + SuccessResult deleteEnterpriseOfGridOperatorByTokenAndEnterpriseId(String token, String enterpriseId) throws RemoveException; + + /** + * 删除网格员的企业(通过企业ID,和用户ID,物理) + * + * @param enterpriseId + * @param userId + * @return + * @throws RemoveException + */ + SuccessResult deleteEnterpriseOfGridOperatorByEnterpriseIdAndUserId(String enterpriseId, String userId) throws RemoveException; + /** * 删除网格员的企业(APP) * @@ -169,4 +189,5 @@ public interface IEnterpriseOfGridOperatorService { * @throws SearchException */ List listGridPersonnel(Map params) throws SearchException; + } diff --git a/src/main/java/com/cm/inspection/service/enterpriseofgridoperator/impl/EnterpriseOfGridOperatorServiceImpl.java b/src/main/java/com/cm/inspection/service/enterpriseofgridoperator/impl/EnterpriseOfGridOperatorServiceImpl.java index b04d826..88322a2 100644 --- a/src/main/java/com/cm/inspection/service/enterpriseofgridoperator/impl/EnterpriseOfGridOperatorServiceImpl.java +++ b/src/main/java/com/cm/inspection/service/enterpriseofgridoperator/impl/EnterpriseOfGridOperatorServiceImpl.java @@ -10,6 +10,7 @@ import com.cm.common.result.SuccessResult; import com.cm.common.result.SuccessResultData; import com.cm.common.result.SuccessResultList; import com.cm.common.token.app.AppTokenManager; +import com.cm.common.token.app.entity.AppToken; import com.cm.common.utils.HashMapUtil; import com.cm.common.utils.UUIDUtil; import com.cm.inspection.dao.enterpriseofgridoperator.IEnterpriseOfGridOperatorDao; @@ -90,6 +91,20 @@ public class EnterpriseOfGridOperatorServiceImpl extends BaseService implements return new SuccessResult(); } + @Override + public SuccessResult deleteEnterpriseOfGridOperatorByTokenAndEnterpriseId(String token, String enterpriseId) throws RemoveException { + return deleteEnterpriseOfGridOperatorByEnterpriseIdAndUserId(enterpriseId, AppTokenManager.getInstance().getToken(token).getAppTokenUser().getId()); + } + + @Override + public SuccessResult deleteEnterpriseOfGridOperatorByEnterpriseIdAndUserId(String enterpriseId, String userId) throws RemoveException { + Map params = getHashMap(1); + params.put("enterpriseId", enterpriseId); + params.put("userId", userId); + enterpriseOfGridOperatorDao.deleteEnterpriseOfGridOperator(params); + return new SuccessResult(); + } + @Override public SuccessResult removeEnterpriseOfGridOperatorByToken(String token, String ids) throws RemoveException { removeEnterpriseOfGridOperatorInfo(token, ids); diff --git a/src/main/resources/mybatis/mapper/enterpriseofgridoperator/enterpriseofgridoperator-mapper.xml b/src/main/resources/mybatis/mapper/enterpriseofgridoperator/enterpriseofgridoperator-mapper.xml index 435e169..0ca11e7 100644 --- a/src/main/resources/mybatis/mapper/enterpriseofgridoperator/enterpriseofgridoperator-mapper.xml +++ b/src/main/resources/mybatis/mapper/enterpriseofgridoperator/enterpriseofgridoperator-mapper.xml @@ -5,6 +5,7 @@ + @@ -108,10 +109,17 @@ DELETE FROM gen_enterprise_of_grid_operator WHERE + enterprise_of_grid_operator_id IN - - #{enterpriseOfGridOperatorIds[${index}]} - + + #{enterpriseOfGridOperatorIds[${index}]} + + + + enterprise_id = #{enterpriseId} + AND + user_id = #{userId} + @@ -235,8 +243,8 @@ - - SELECT t1.enterprise_id, t1.name name_join_by_enterprise_id, @@ -313,6 +321,100 @@ + + +