21 changed files with 964 additions and 1 deletions
@ -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; |
|||
} |
@ -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; |
|||
} |
@ -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; |
|||
} |
@ -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; |
|||
} |
@ -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; |
|||
} |
|||
} |
@ -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; |
|||
} |
@ -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)); |
|||
} |
|||
} |
@ -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); |
|||
} |
@ -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; |
|||
|
|||
} |
@ -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); |
|||
} |
@ -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; |
|||
} |
|||
} |
@ -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='专题表'; |
@ -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…
Reference in new issue