Browse Source

Merge remote-tracking branch 'origin/dev_special_subject' into develop

dev_shibei_match
zxc 4 years ago
parent
commit
3b0d487ee7
  1. 4
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  2. 9
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java
  3. 5
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java
  4. 11
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java
  5. 8
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java
  6. 8
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java
  7. 14
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java
  8. 5
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml
  9. 108
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/SpecialSubjectDTO.java
  10. 54
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/AddSpecialSubjectFormDTO.java
  11. 39
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/DelSpecialSubjectFormDTO.java
  12. 32
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/QuerySpecialSubFormDTO.java
  13. 23
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/AddSpecialSubjectResultDTO.java
  14. 35
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/result/WorkSpecialSubjectResultDTO.java
  15. 94
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/SpecialSubjectController.java
  16. 42
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/SpecialSubjectDao.java
  17. 75
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/SpecialSubjectEntity.java
  18. 130
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/SpecialSubjectService.java
  19. 213
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/SpecialSubjectServiceImpl.java
  20. 16
      epmet-module/gov-voice/gov-voice-server/src/main/resources/db/migration/V0.0.4__create_specialsubject.sql
  21. 40
      epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/SpecialSubjectDao.xml

4
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, "请勿重复提交"), REPEATED_SUBMIT_ERROR(8804, "请勿重复提交"),
CUSTOMER_VALIDATE_ERROR(8805, "内部数据校验异常"), CUSTOMER_VALIDATE_ERROR(8805, "内部数据校验异常"),
CATEGORY_IS_NULL(8806, "请设置分类"), CATEGORY_IS_NULL(8806, "请设置分类"),
EXISTED_SPECIAL_PROJECT(8807, "已经添加过此专题"),
CAN_NOT_DEL_SPECIAL_PROJECT(8808, "您没有权限删除此专题"),
TAG_NOT_EXIST(8809,"标签不存在"),
//公众号 865..开头的码 //公众号 865..开头的码
PUBLIC_NOT_EXISTS(8651,"手机号未注册,请先完成信息注册"), PUBLIC_NOT_EXISTS(8651,"手机号未注册,请先完成信息注册"),

9
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}") @GetMapping(value = "/gov/org/customeragency/getareacodeswitch/{customerId}")
Result<String> getAreaCodeSwitch(@PathVariable("customerId")String customerId); Result<String> 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<String> selectPidsByGridId(@RequestParam("gridId") String gridId);
} }

5
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<String> getAreaCodeSwitch(String customerId) { public Result<String> getAreaCodeSwitch(String customerId) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getAreaCodeSwitch", customerId); return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getAreaCodeSwitch", customerId);
} }
@Override
public Result<String> selectPidsByGridId(String gridId) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "selectPidsByGridId", gridId);
}
} }

11
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java

@ -241,4 +241,15 @@ public class CustomerGridController {
List<String> resultDTOS = customerGridService.listGridIdsInCommunity(gridId); List<String> resultDTOS = customerGridService.listGridIdsInCommunity(gridId);
return new Result<List<String>>().ok(resultDTOS); return new Result<List<String>>().ok(resultDTOS);
} }
/**
* @Description 根据网格ID查询pids
* @Param gridId
* @author zxc
* @date 2021/7/16 9:52 上午
*/
@PostMapping("pidsbygrid")
public Result<String> selectPidsByGridId(@RequestParam("gridId") String gridId){
return new Result<String>().ok(customerGridService.selectPidsByGridId(gridId));
}
} }

8
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java

@ -268,4 +268,12 @@ public interface CustomerGridDao extends BaseDao<CustomerGridEntity> {
* @date 2021/4/19 11:56 上午 * @date 2021/4/19 11:56 上午
*/ */
CustomerGridDTO getGridBaseInfoById(@Param("gridId") String gridId); 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);
} }

8
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java

@ -287,4 +287,12 @@ public interface CustomerGridService extends BaseService<CustomerGridEntity> {
* @date 2021/4/19 11:53 上午 * @date 2021/4/19 11:53 上午
*/ */
Result<CustomerGridDTO> getBaseInfo(CustomerGridFormDTO customerGridFormDTO); Result<CustomerGridDTO> getBaseInfo(CustomerGridFormDTO customerGridFormDTO);
/**
* @Description 根据网格ID查询pids
* @Param gridId
* @author zxc
* @date 2021/7/16 9:52 上午
*/
String selectPidsByGridId(String gridId);
} }

14
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<CustomerGridDao, Cu
public Result<CustomerGridDTO> getBaseInfo(CustomerGridFormDTO customerGridFormDTO) { public Result<CustomerGridDTO> getBaseInfo(CustomerGridFormDTO customerGridFormDTO) {
return new Result<CustomerGridDTO>().ok(ConvertUtils.sourceToTarget(baseDao.selectById(customerGridFormDTO.getGridId()), CustomerGridDTO.class)); return new Result<CustomerGridDTO>().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 "";
}
} }

5
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml

@ -576,4 +576,9 @@
cg.ID = #{gridId} cg.ID = #{gridId}
AND cg.DEL_FLAG = '0' AND cg.DEL_FLAG = '0'
</select> </select>
<!-- 根据网格ID查询pids -->
<select id="selectPidsByGridId" resultType="java.lang.String">
SELECT PIDS FROM customer_grid WHERE DEL_FLAG = '0' AND ID = #{gridId}
</select>
</mapper> </mapper>

108
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}

54
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;
}

39
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;
}

32
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;
}

23
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;
}
}

35
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;
}

94
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<AddSpecialSubjectResultDTO> addSpecialSubject(@LoginUser GovTokenDto tokenDto, @RequestBody AddSpecialSubjectFormDTO formDTO) {
formDTO.setAddUserId(tokenDto.getUserId());
formDTO.setAddUserAgencyId(tokenDto.getAgencyId());
ValidatorUtils.validateEntity(formDTO, AddSpecialSubjectFormDTO.AddUserInternalGroup.class);
return new Result<AddSpecialSubjectResultDTO>().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<java.util.List<com.epmet.dto.result.WorkSpecialSubjectResultDTO>>
* @param formDTO
* @author yinzuomei
* @description 专题管理已有专题列表
* @Date 2021/7/15 21:17
**/
@PostMapping("existedlist")
public Result<List<WorkSpecialSubjectResultDTO>> queryExistedList(@RequestBody QuerySpecialSubFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, QuerySpecialSubFormDTO.AddUserInternalGroup.class);
return new Result<List<WorkSpecialSubjectResultDTO>>().ok(specialSubjectService.queryExistedList(formDTO));
}
}

42
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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> {
SpecialSubjectEntity selectByOrgIdAndTagId(@Param("orgId") String orgId, @Param("tagId") String tagId);
int delSpecialSubject(@Param("id") String id, @Param("userId") String userId);
List<SpecialSubjectDTO> queryExistedList(@Param("orgId") String orgId,@Param("notList")List<String> notList);
}

75
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}

130
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<SpecialSubjectEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<SpecialSubjectDTO>
* @author generator
* @date 2021-07-15
*/
PageData<SpecialSubjectDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<SpecialSubjectDTO>
* @author generator
* @date 2021-07-15
*/
List<SpecialSubjectDTO> list(Map<String, Object> 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<WorkSpecialSubjectResultDTO> queryExistedList(QuerySpecialSubFormDTO formDTO);
}

213
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<SpecialSubjectDao, SpecialSubjectEntity> implements SpecialSubjectService {
@Autowired
private TagCustomerService tagCustomerService;
@Override
public PageData<SpecialSubjectDTO> page(Map<String, Object> params) {
IPage<SpecialSubjectEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, SpecialSubjectDTO.class);
}
@Override
public List<SpecialSubjectDTO> list(Map<String, Object> params) {
List<SpecialSubjectEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, SpecialSubjectDTO.class);
}
private QueryWrapper<SpecialSubjectEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<SpecialSubjectEntity> 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<WorkSpecialSubjectResultDTO> queryExistedList(QuerySpecialSubFormDTO formDTO) {
List<WorkSpecialSubjectResultDTO> resultDTOList = new ArrayList<>();
List<String> notList = new ArrayList<>();
//当前组织或者网格自己建立的
List<WorkSpecialSubjectResultDTO> currentOrgList = new ArrayList<>();
List<SpecialSubjectDTO> 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<String> pidList = Arrays.asList(formDTO.getPids().split(StrConstant.COLON));
for (String pid : pidList) {
//优先展示自己的,所以要排除掉 领导们给我建立的专题
List<SpecialSubjectDTO> 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;
}
}

16
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='专题表';

40
epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/SpecialSubjectDao.xml

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.SpecialSubjectDao">
<select id="selectByOrgIdAndTagId" parameterType="map" resultType="com.epmet.entity.SpecialSubjectEntity">
SELECT
*
FROM
special_subject ss
WHERE
ss.DEL_FLAG = '0'
AND ss.ADD_ORG_ID = #{orgId}
AND ss.TAG_ID = #{tagId}
</select>
<update id="delSpecialSubject" parameterType="map">
update special_subject set del_flag='1',UPDATED_BY=#{userId},UPDATED_TIME=Now()
where id=#{id}
</update>
<select id="queryExistedList" parameterType="map" resultType="com.epmet.dto.SpecialSubjectDTO">
SELECT
ss.*,
tc.TAG_NAME AS tagName
FROM
special_subject ss
INNER JOIN tag_customer tc ON ( ss.CUSTOMER_ID = tc.CUSTOMER_ID AND ss.TAG_ID = tc.id )
WHERE
ss.DEL_FLAG = '0'
AND tc.DEL_FLAG = '0'
AND ss.ADD_ORG_ID = #{orgId}
<if test="null != notList and notList.size()>0">
and ss.id not in
<foreach item="id" collection="notList" open="(" separator="," close=")">
#{id}
</foreach>
</if>
order by ss.CREATED_TIME desc
</select>
</mapper>
Loading…
Cancel
Save