diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index 43c5468cc3..3a213b5191 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -138,7 +138,9 @@ public enum EpmetErrorCode { REPEATED_SUBMIT_ERROR(8804, "请勿重复提交"), CUSTOMER_VALIDATE_ERROR(8805, "内部数据校验异常"), CATEGORY_IS_NULL(8806, "请设置分类"), - + EXISTED_SPECIAL_PROJECT(8807, "已经添加过此专题"), + CAN_NOT_DEL_SPECIAL_PROJECT(8808, "您没有权限删除此专题"), + TAG_NOT_EXIST(8809,"标签不存在"), //公众号 865..开头的码 PUBLIC_NOT_EXISTS(8651,"手机号未注册,请先完成信息注册"), diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java index 1b99ac96f3..a79519837b 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java @@ -352,4 +352,13 @@ public interface GovOrgOpenFeignClient { **/ @GetMapping(value = "/gov/org/customeragency/getareacodeswitch/{customerId}") Result getAreaCodeSwitch(@PathVariable("customerId")String customerId); + + /** + * @Description 根据网格ID查询pids + * @Param gridId + * @author zxc + * @date 2021/7/16 9:52 上午 + */ + @PostMapping(value = "/gov/org/customergrid/pidsbygrid") + Result selectPidsByGridId(@RequestParam("gridId") String gridId); } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java index 0d13438885..f767c0ec69 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java @@ -209,4 +209,9 @@ public class GovOrgOpenFeignClientFallback implements GovOrgOpenFeignClient { public Result getAreaCodeSwitch(String customerId) { return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getAreaCodeSwitch", customerId); } + + @Override + public Result selectPidsByGridId(String gridId) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "selectPidsByGridId", gridId); + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java index eec27314ba..bb06477812 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java @@ -241,4 +241,15 @@ public class CustomerGridController { List resultDTOS = customerGridService.listGridIdsInCommunity(gridId); return new Result>().ok(resultDTOS); } + + /** + * @Description 根据网格ID查询pids + * @Param gridId + * @author zxc + * @date 2021/7/16 9:52 上午 + */ + @PostMapping("pidsbygrid") + public Result selectPidsByGridId(@RequestParam("gridId") String gridId){ + return new Result().ok(customerGridService.selectPidsByGridId(gridId)); + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java index 4277be98c6..ec16bf0dcd 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java @@ -268,4 +268,12 @@ public interface CustomerGridDao extends BaseDao { * @date 2021/4/19 11:56 上午 */ CustomerGridDTO getGridBaseInfoById(@Param("gridId") String gridId); + + /** + * @Description 根据网格ID查询pids + * @Param gridId + * @author zxc + * @date 2021/7/16 9:52 上午 + */ + String selectPidsByGridId(@Param("gridId")String gridId); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java index 4799c38890..b892fa84f8 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java @@ -287,4 +287,12 @@ public interface CustomerGridService extends BaseService { * @date 2021/4/19 11:53 上午 */ Result getBaseInfo(CustomerGridFormDTO customerGridFormDTO); + + /** + * @Description 根据网格ID查询pids + * @Param gridId + * @author zxc + * @date 2021/7/16 9:52 上午 + */ + String selectPidsByGridId(String gridId); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java index c0a987206b..007aabd4b9 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java @@ -707,4 +707,18 @@ public class CustomerGridServiceImpl extends BaseServiceImpl getBaseInfo(CustomerGridFormDTO customerGridFormDTO) { return new Result().ok(ConvertUtils.sourceToTarget(baseDao.selectById(customerGridFormDTO.getGridId()), CustomerGridDTO.class)); } + + /** + * @Description 根据网格ID查询pids + * @Param gridId + * @author zxc + * @date 2021/7/16 9:52 上午 + */ + @Override + public String selectPidsByGridId(String gridId) { + if (StringUtils.isNotBlank(gridId)){ + return baseDao.selectPidsByGridId(gridId); + } + return ""; + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml index 2036e76fa6..2738538cbf 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml @@ -576,4 +576,9 @@ cg.ID = #{gridId} AND cg.DEL_FLAG = '0' + + + diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/SpecialSubjectDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/SpecialSubjectDTO.java new file mode 100644 index 0000000000..96cb4a1bdf --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/SpecialSubjectDTO.java @@ -0,0 +1,108 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 专题表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-07-15 + */ +@Data +public class SpecialSubjectDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键(专题id) + */ + private String id; + + /** + * 客户id + */ + private String customerId; + + /** + * 标签id + */ + private String tagId; + + /** + * 新增此专题的用户id + */ + private String addUserId; + + /** + * 新增此专题时用户所在的组织id或者网格id + */ + private String addOrgId; + + /** + * 网格:grid;社区级:community, +乡(镇、街道)级:street, +区县级: district, +市级: city +省级:province + */ + private String orgLevel; + + /** + * 新增此专题用户所属的组织id + */ + private String addUserAgencyId; + + /** + * 删除标识 0未删除;1已删除 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + + // 扩展属性 + private String tagName; +} \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/AddSpecialSubjectFormDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/AddSpecialSubjectFormDTO.java new file mode 100644 index 0000000000..ba663245db --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/AddSpecialSubjectFormDTO.java @@ -0,0 +1,54 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * 【专题管理】添加专题 + * + * @author yinzuomei@elink-cn.com + * @date 2021/7/15 14:24 + */ +@Data +public class AddSpecialSubjectFormDTO implements Serializable { + private static final long serialVersionUID = -4469613386814496224L; + + public interface AddUserInternalGroup { + } + + /** + * 当前所在网格或者组织id + */ + @NotBlank(message = "orgId不能为空", groups = AddUserInternalGroup.class) + private String orgId; + + /** + * 网格:grid;社区级:community, 乡(镇、街道)级:street, 区县级: district, 市级: city 省级:province + */ + @NotBlank(message = "orgLevel不能为空", groups = AddUserInternalGroup.class) + private String orgLevel; + + /** + * 所选的标签id + */ + @NotBlank(message = "tagId不能为空", groups = AddUserInternalGroup.class) + private String tagId; + + // 以下属性从token中获取 + /** + * 从TokenDto中获取当前用户id + */ + @NotBlank(message = "从token中获取userId为空", groups = AddUserInternalGroup.class) + private String addUserId; + + /** + * 从TokenDto中获取当前用户所属的agencyId + */ + @NotBlank(message = "从token中获取用户所属组织id为空", groups = AddUserInternalGroup.class) + private String addUserAgencyId; + + @NotBlank(message = "从token中获取客户id为空", groups = AddUserInternalGroup.class) + private String customerId; +} diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/DelSpecialSubjectFormDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/DelSpecialSubjectFormDTO.java new file mode 100644 index 0000000000..4c3d964bc0 --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/DelSpecialSubjectFormDTO.java @@ -0,0 +1,39 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * 【专题管理】删除专题 + * + * @author yinzuomei@elink-cn.com + * @date 2021/7/15 20:50 + */ +@Data +public class DelSpecialSubjectFormDTO implements Serializable { + private static final long serialVersionUID = -2305529822756834522L; + + public interface AddUserInternalGroup { + } + + /** + * 专题id + */ + @NotBlank(message = "specialSubjectId不能为空", groups = AddUserInternalGroup.class) + private String specialSubjectId; + + /** + * 当前所在网格或者组织id + */ + @NotBlank(message = "orgId不能为空", groups = AddUserInternalGroup.class) + private String orgId; + + + /** + * 从TokenDto中获取当前用户id + */ + @NotBlank(message = "从token中获取userId为空", groups = AddSpecialSubjectFormDTO.AddUserInternalGroup.class) + private String userId; +} diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/QuerySpecialSubFormDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/QuerySpecialSubFormDTO.java new file mode 100644 index 0000000000..02ec4d2e6f --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/QuerySpecialSubFormDTO.java @@ -0,0 +1,32 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * 【专题管理】已有专题列表 + * + * @author yinzuomei@elink-cn.com + * @date 2021/7/15 21:09 + */ +@Data +public class QuerySpecialSubFormDTO implements Serializable { + private static final long serialVersionUID = -436139256753489157L; + + public interface AddUserInternalGroup { + } + + /** + * 当前所在网格或者组织id + */ + @NotBlank(message = "orgId不能为空", groups = AddUserInternalGroup.class) + private String orgId; + + /** + * orgId的所有上级id + */ + @NotBlank(message = "pids不能为空", groups = AddUserInternalGroup.class) + private String pids; +} diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/AddSpecialSubjectResultDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/AddSpecialSubjectResultDTO.java new file mode 100644 index 0000000000..6e31d7fa46 --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/AddSpecialSubjectResultDTO.java @@ -0,0 +1,23 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 【专题管理】添加专题 + * + * @author yinzuomei@elink-cn.com + * @date 2021/7/15 17:46 + */ +@Data +public class AddSpecialSubjectResultDTO implements Serializable { + /** + * 刚添加成功的专题id + * */ + private String specialSubjectId; + + public AddSpecialSubjectResultDTO(String id) { + this.specialSubjectId=id; + } +} diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/WorkSpecialSubjectResultDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/WorkSpecialSubjectResultDTO.java new file mode 100644 index 0000000000..451a44c296 --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/WorkSpecialSubjectResultDTO.java @@ -0,0 +1,35 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 【专题管理】已有专题列表 + * + * @author yinzuomei@elink-cn.com + * @date 2021/7/15 21:14 + */ +@Data +public class WorkSpecialSubjectResultDTO implements Serializable { + private static final long serialVersionUID = 8147664815754574860L; + /** + * 标签id + */ + private String tagId; + + /** + * 标签名称 + */ + private String tagName; + + /** + * true代表可以删除。false不可删除,隐藏减号 + */ + private Boolean canDel; + + /** + * 专题id + */ + private String specialSubjectId; +} diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/SpecialSubjectController.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/SpecialSubjectController.java new file mode 100644 index 0000000000..018c88bc33 --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/SpecialSubjectController.java @@ -0,0 +1,94 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.controller; + +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.security.dto.GovTokenDto; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.form.AddSpecialSubjectFormDTO; +import com.epmet.dto.form.DelSpecialSubjectFormDTO; +import com.epmet.dto.form.QuerySpecialSubFormDTO; +import com.epmet.dto.result.AddSpecialSubjectResultDTO; +import com.epmet.dto.result.WorkSpecialSubjectResultDTO; +import com.epmet.service.SpecialSubjectService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + + +/** + * 专题表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-07-15 + */ +@RestController +@RequestMapping("specialsubject") +public class SpecialSubjectController { + + @Autowired + private SpecialSubjectService specialSubjectService; + + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @author yinzuomei + * @description 添加专题 + * @Date 2021/7/15 15:31 + **/ + @PostMapping("add") + public Result addSpecialSubject(@LoginUser GovTokenDto tokenDto, @RequestBody AddSpecialSubjectFormDTO formDTO) { + formDTO.setAddUserId(tokenDto.getUserId()); + formDTO.setAddUserAgencyId(tokenDto.getAgencyId()); + ValidatorUtils.validateEntity(formDTO, AddSpecialSubjectFormDTO.AddUserInternalGroup.class); + return new Result().ok(specialSubjectService.addSpecialSubject(formDTO)); + } + + /** + * @return com.epmet.commons.tools.utils.Result + * @param + * @author yinzuomei + * @description 【专题管理】删除专题 + * @Date 2021/7/15 20:49 + **/ + @PostMapping("del") + public Result delSpecialSubject(@RequestBody DelSpecialSubjectFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO); + specialSubjectService.delSpecialSubject(formDTO); + return new Result(); + } + + + /** + * @return com.epmet.commons.tools.utils.Result> + * @param formDTO + * @author yinzuomei + * @description 【专题管理】已有专题列表 + * @Date 2021/7/15 21:17 + **/ + @PostMapping("existedlist") + public Result> queryExistedList(@RequestBody QuerySpecialSubFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, QuerySpecialSubFormDTO.AddUserInternalGroup.class); + return new Result>().ok(specialSubjectService.queryExistedList(formDTO)); + } +} \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/SpecialSubjectDao.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/SpecialSubjectDao.java new file mode 100644 index 0000000000..a759dd78fd --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/SpecialSubjectDao.java @@ -0,0 +1,42 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.SpecialSubjectDTO; +import com.epmet.entity.SpecialSubjectEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 专题表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-07-15 + */ +@Mapper +public interface SpecialSubjectDao extends BaseDao { + + SpecialSubjectEntity selectByOrgIdAndTagId(@Param("orgId") String orgId, @Param("tagId") String tagId); + + int delSpecialSubject(@Param("id") String id, @Param("userId") String userId); + + List queryExistedList(@Param("orgId") String orgId,@Param("notList")List notList); +} \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/SpecialSubjectEntity.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/SpecialSubjectEntity.java new file mode 100644 index 0000000000..fd35ce2950 --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/SpecialSubjectEntity.java @@ -0,0 +1,75 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 专题表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-07-15 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("special_subject") +public class SpecialSubjectEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户id + */ + private String customerId; + + /** + * 标签id + */ + private String tagId; + + /** + * 新增此专题的用户id + */ + private String addUserId; + + /** + * 新增此专题时用户所在的组织id或者网格id + */ + private String addOrgId; + + /** + * 网格:grid;社区级:community, +乡(镇、街道)级:street, +区县级: district, +市级: city +省级:province + */ + private String orgLevel; + + /** + * 新增此专题用户所属的组织id + */ + private String addUserAgencyId; + +} diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/SpecialSubjectService.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/SpecialSubjectService.java new file mode 100644 index 0000000000..3d64580035 --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/SpecialSubjectService.java @@ -0,0 +1,130 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.SpecialSubjectDTO; +import com.epmet.dto.form.AddSpecialSubjectFormDTO; +import com.epmet.dto.form.DelSpecialSubjectFormDTO; +import com.epmet.dto.form.QuerySpecialSubFormDTO; +import com.epmet.dto.result.AddSpecialSubjectResultDTO; +import com.epmet.dto.result.WorkSpecialSubjectResultDTO; +import com.epmet.entity.SpecialSubjectEntity; + +import java.util.List; +import java.util.Map; + +/** + * 专题表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-07-15 + */ +public interface SpecialSubjectService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2021-07-15 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2021-07-15 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return SpecialSubjectDTO + * @author generator + * @date 2021-07-15 + */ + SpecialSubjectDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2021-07-15 + */ + void save(SpecialSubjectDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2021-07-15 + */ + void update(SpecialSubjectDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2021-07-15 + */ + void delete(String[] ids); + + /** + * 添加专题 + * + * @param formDTO + * @return void + * @author yinzuomei + * @date 2021-07-15 + */ + AddSpecialSubjectResultDTO addSpecialSubject(AddSpecialSubjectFormDTO formDTO); + + /** + * 【专题管理】删除专题 + * + * @param formDTO + * @return void + * @author yinzuomei + * @date 2021-07-15 + */ + void delSpecialSubject(DelSpecialSubjectFormDTO formDTO); + + /** + * 【专题管理】已有专题列表 + * + * @param formDTO + * @return void + * @author yinzuomei + * @date 2021-07-15 + */ + List queryExistedList(QuerySpecialSubFormDTO formDTO); +} \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/SpecialSubjectServiceImpl.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/SpecialSubjectServiceImpl.java new file mode 100644 index 0000000000..09b7230c6a --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/SpecialSubjectServiceImpl.java @@ -0,0 +1,213 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.dao.SpecialSubjectDao; +import com.epmet.dto.SpecialSubjectDTO; +import com.epmet.dto.TagCustomerDTO; +import com.epmet.dto.form.AddSpecialSubjectFormDTO; +import com.epmet.dto.form.DelSpecialSubjectFormDTO; +import com.epmet.dto.form.QuerySpecialSubFormDTO; +import com.epmet.dto.result.AddSpecialSubjectResultDTO; +import com.epmet.dto.result.WorkSpecialSubjectResultDTO; +import com.epmet.entity.SpecialSubjectEntity; +import com.epmet.service.SpecialSubjectService; +import com.epmet.service.TagCustomerService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 专题表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-07-15 + */ +@Slf4j +@Service +public class SpecialSubjectServiceImpl extends BaseServiceImpl implements SpecialSubjectService { + @Autowired + private TagCustomerService tagCustomerService; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, SpecialSubjectDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, SpecialSubjectDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public SpecialSubjectDTO get(String id) { + SpecialSubjectEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, SpecialSubjectDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(SpecialSubjectDTO dto) { + SpecialSubjectEntity entity = ConvertUtils.sourceToTarget(dto, SpecialSubjectEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(SpecialSubjectDTO dto) { + SpecialSubjectEntity entity = ConvertUtils.sourceToTarget(dto, SpecialSubjectEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + /** + * 添加专题 + * + * @param formDTO + * @return void + * @author yinzuomei + * @date 2021-07-15 + */ + @Override + public AddSpecialSubjectResultDTO addSpecialSubject(AddSpecialSubjectFormDTO formDTO) { + // 1、标签是否存在 + TagCustomerDTO tagCustomerDTO=tagCustomerService.get(formDTO.getTagId()); + if(null==tagCustomerDTO){ + throw new RenException(EpmetErrorCode.TAG_NOT_EXIST.getCode(), EpmetErrorCode.TAG_NOT_EXIST.getMsg()); + } + //2、校验当前组织是否添加过此专题 + SpecialSubjectEntity havedEntity = baseDao.selectByOrgIdAndTagId(formDTO.getOrgId(), formDTO.getTagId()); + if (null != havedEntity) { + throw new RenException(EpmetErrorCode.EXISTED_SPECIAL_PROJECT.getCode(), EpmetErrorCode.EXISTED_SPECIAL_PROJECT.getMsg()); + } + // 3、保存 + SpecialSubjectEntity insertEntity = ConvertUtils.sourceToTarget(formDTO, SpecialSubjectEntity.class); + insertEntity.setAddOrgId(formDTO.getOrgId()); + baseDao.insert(insertEntity); + return new AddSpecialSubjectResultDTO(insertEntity.getId()); + } + + /** + * 【专题管理】删除专题 + * + * @param formDTO + * @return void + * @author yinzuomei + * @date 2021-07-15 + */ + @Override + public void delSpecialSubject(DelSpecialSubjectFormDTO formDTO) { + SpecialSubjectEntity original = baseDao.selectById(formDTO.getSpecialSubjectId()); + if (null != original) { + if (!original.getAddOrgId().equals(formDTO.getOrgId())) { + throw new RenException(EpmetErrorCode.CAN_NOT_DEL_SPECIAL_PROJECT.getCode(), EpmetErrorCode.CAN_NOT_DEL_SPECIAL_PROJECT.getMsg()); + } + baseDao.delSpecialSubject(formDTO.getSpecialSubjectId(), formDTO.getUserId()); + } + log.warn(String.format("special_subject is null id=%s", formDTO.getSpecialSubjectId())); + } + + /** + * 【专题管理】已有专题列表 + * + * @param formDTO + * @return void + * @author yinzuomei + * @date 2021-07-15 + */ + @Override + public List queryExistedList(QuerySpecialSubFormDTO formDTO) { + List resultDTOList = new ArrayList<>(); + List notList = new ArrayList<>(); + //当前组织或者网格自己建立的 + List currentOrgList = new ArrayList<>(); + List currentOrgCreatedList = baseDao.queryExistedList(formDTO.getOrgId(), notList); + currentOrgCreatedList.forEach(dto -> { + WorkSpecialSubjectResultDTO result = new WorkSpecialSubjectResultDTO(); + result.setSpecialSubjectId(dto.getId()); + result.setTagId(dto.getTagId()); + result.setTagName(dto.getTagName()); + result.setCanDel(true); + currentOrgList.add(result); + }); + if (CollectionUtils.isNotEmpty(currentOrgList)) { + notList = currentOrgList.stream().map(WorkSpecialSubjectResultDTO::getSpecialSubjectId).distinct().collect(Collectors.toList()); + } + if (!NumConstant.ZERO_STR.equals(formDTO.getPids())) { + //存在上级组织...,从上往下查 + List pidList = Arrays.asList(formDTO.getPids().split(StrConstant.COLON)); + for (String pid : pidList) { + //优先展示自己的,所以要排除掉 领导们给我建立的专题 + List list = baseDao.queryExistedList(pid, notList); + list.forEach(dto -> { + WorkSpecialSubjectResultDTO result = new WorkSpecialSubjectResultDTO(); + result.setSpecialSubjectId(dto.getId()); + result.setTagId(dto.getTagId()); + result.setTagName(dto.getTagName()); + result.setCanDel(false); + resultDTOList.add(result); + }); + } + } + //自己建立的在最后面 + if (CollectionUtils.isNotEmpty(currentOrgList)) { + resultDTOList.addAll(currentOrgList); + } + return resultDTOList; + } +} \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/resources/db/migration/V0.0.4__create_specialsubject.sql b/epmet-module/gov-voice/gov-voice-server/src/main/resources/db/migration/V0.0.4__create_specialsubject.sql new file mode 100644 index 0000000000..388674a0dc --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-server/src/main/resources/db/migration/V0.0.4__create_specialsubject.sql @@ -0,0 +1,16 @@ +CREATE TABLE `special_subject` ( + `ID` varchar(64) NOT NULL COMMENT '主键(专题id)', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户id', + `TAG_ID` varchar(64) NOT NULL COMMENT '标签id', + `ADD_USER_ID` varchar(64) NOT NULL COMMENT '新增此专题的用户id', + `ADD_ORG_ID` varchar(64) NOT NULL COMMENT '新增此专题时用户所在的组织id或者网格id', + `ORG_LEVEL` varchar(10) NOT NULL COMMENT '网格:grid;社区级:community,\r\n乡(镇、街道)级:street,\r\n区县级: district,\r\n市级: city\r\n省级:province', + `ADD_USER_AGENCY_ID` varchar(64) NOT NULL COMMENT '新增此专题用户所属的组织id', + `DEL_FLAG` char(1) NOT NULL DEFAULT '0' COMMENT '删除标识 0未删除;1已删除', + `REVISION` int(11) NOT NULL DEFAULT '0' COMMENT '乐观锁', + `CREATED_BY` varchar(64) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(64) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='专题表'; \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/SpecialSubjectDao.xml b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/SpecialSubjectDao.xml new file mode 100644 index 0000000000..c40828ae10 --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/SpecialSubjectDao.xml @@ -0,0 +1,40 @@ + + + + + + + + update special_subject set del_flag='1',UPDATED_BY=#{userId},UPDATED_TIME=Now() + where id=#{id} + + + + \ No newline at end of file