diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/TagCustomerDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/TagCustomerDTO.java index 0012b13dfb..84080d204e 100644 --- a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/TagCustomerDTO.java +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/TagCustomerDTO.java @@ -17,8 +17,11 @@ package com.epmet.dto; +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; import lombok.Data; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; import java.io.Serializable; import java.util.Date; @@ -34,9 +37,12 @@ public class TagCustomerDTO implements Serializable { private static final long serialVersionUID = 1L; + public interface ChangeShowFlagGroup extends CustomerClientShowGroup { + } /** * 主键ID */ + @NotBlank(message = "id不能为空",groups = ChangeShowFlagGroup.class) private String id; /** @@ -57,6 +63,7 @@ public class TagCustomerDTO implements Serializable { /** * 1:展示;0:隐藏;0302因烟台需求增加此列默认1 */ + @NotNull(message = "showFlag不能为空",groups = ChangeShowFlagGroup.class) private Integer showFlag; /** diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/TagScopeDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/TagScopeDTO.java new file mode 100644 index 0000000000..a4e5052273 --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/TagScopeDTO.java @@ -0,0 +1,33 @@ +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description + * @Author yzm + * @Date 2023/3/2 13:52 + */ +@Data +public class TagScopeDTO implements Serializable { + /** + * 标签ID + */ + private String tagId; + + /** + * 应用范围,这里只能是社区id + */ + private String agencyId; + /** + * agency_id全路径,包含自身 + */ + private String orgIdPath; + + /** + * 组织名称 + */ + private String agencyName; +} + diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/TagCustomerFormDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/TagCustomerFormDTO.java new file mode 100644 index 0000000000..403b30094d --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/TagCustomerFormDTO.java @@ -0,0 +1,56 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import com.epmet.dto.TagScopeDTO; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.List; + +/** + * @Description + * @Author yzm + * @Date 2023/3/2 12:47 + */ +@Data +public class TagCustomerFormDTO implements Serializable { + private static final long serialVersionUID = -5631868409077026783L; + + public interface AddUserInternalGroup { + } + + public interface AddUserShowGroup extends CustomerClientShowGroup { + } + + public interface UpdateUserInternalGroup { + } + + public interface UpdateUserShowGroup extends CustomerClientShowGroup { + } + + + /** + * 主键ID + */ + @NotBlank(message = "id不能为空", groups = {UpdateUserInternalGroup.class}) + private String id; + + /** + * 标签名称 + */ + @Length(max = 30, message = "标签名称最多输入30字", groups = {AddUserShowGroup.class, UpdateUserShowGroup.class}) + @NotBlank(message = "标签名称不能为空", groups = {AddUserShowGroup.class, UpdateUserShowGroup.class}) + private String tagName; + + /** + * 应用范围,只能选社区 + */ + private List agencyIds; + /** + * 客户ID + */ + private String customerId; +} + diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/TagCustomerPageFormDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/TagCustomerPageFormDTO.java new file mode 100644 index 0000000000..04ee2370eb --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/TagCustomerPageFormDTO.java @@ -0,0 +1,44 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * @Description pc标签管理-分页查询入参 + * @Author yzm + * @Date 2023/3/2 11:34 + */ +@Data +public class TagCustomerPageFormDTO implements Serializable { + private static final long serialVersionUID = -2311491158902019019L; + + public interface PageUserInternalGroup { + } + + public interface PageUserShowGroup extends CustomerClientShowGroup { + } + + + /** + * 客户ID + */ + @NotBlank(message = "customerId不能为空", groups = PageUserInternalGroup.class) + private String customerId; + + /** + * 标签名称 + */ + private String tagName; + + + @NotNull(message = "页码不能为空", groups = PageUserInternalGroup.class) + private Integer pageNo; + + @NotNull(message = "每页数量不能为空", groups = PageUserInternalGroup.class) + private Integer pageSize; +} + diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/TagController.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/TagController.java index bd2603685b..b73213752b 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/TagController.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/TagController.java @@ -1,15 +1,15 @@ package com.epmet.controller; import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; -import com.epmet.dto.form.CorrelationTagListFormDTO; -import com.epmet.dto.form.InitTagFormDTO; -import com.epmet.dto.form.ResiTagListFormDTO; -import com.epmet.dto.form.TagCascadeListFormDTO; +import com.epmet.dto.TagCustomerDTO; +import com.epmet.dto.form.*; import com.epmet.dto.result.CorrelationTagListResultDTO; import com.epmet.dto.result.TagInfoResultDTO; +import com.epmet.service.TagCustomerService; import com.epmet.service.TagService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; @@ -25,6 +25,8 @@ public class TagController { @Autowired private TagService tagService; + @Autowired + private TagCustomerService tagCustomerService; /** * @Description 已发布列表页的标签——政府端 @@ -81,4 +83,55 @@ public class TagController { return new Result().ok(tagService.initTag(formDto)); } + /** + * pc标签管理-分页查询 + * @param formDTO + * @return + */ + @PostMapping("page-list") + public Result> pageList(@LoginUser TokenDto tokenDto,@RequestBody TagCustomerPageFormDTO formDTO){ + tokenDto.setCustomerId(formDTO.getCustomerId()); + ValidatorUtils.validateEntity(formDTO,TagCustomerPageFormDTO.PageUserInternalGroup.class,TagCustomerPageFormDTO.PageUserShowGroup.class); + return new Result>().ok(tagCustomerService.page(formDTO)); + } + + /** + * 新增标签 + * @param tokenDto + * @param formDTO + * @return + */ + @PostMapping("save") + public Result save(@LoginUser TokenDto tokenDto,@RequestBody TagCustomerFormDTO formDTO){ + formDTO.setCustomerId(tokenDto.getCustomerId()); + ValidatorUtils.validateEntity(formDTO,TagCustomerFormDTO.AddUserShowGroup.class,TagCustomerFormDTO.AddUserInternalGroup.class); + tagCustomerService.save(formDTO); + return new Result(); + } + + /** + * 修改标签 + * @param tokenDto + * @param formDTO + * @return + */ + @PostMapping("update") + public Result update(@LoginUser TokenDto tokenDto,@RequestBody TagCustomerFormDTO formDTO){ + formDTO.setCustomerId(tokenDto.getCustomerId()); + ValidatorUtils.validateEntity(formDTO,TagCustomerFormDTO.UpdateUserShowGroup.class,TagCustomerFormDTO.UpdateUserInternalGroup.class); + tagCustomerService.update(formDTO); + return new Result(); + } + + /** + * 隐藏、显示 + * @param tagCustomerDTO + * @return + */ + @PostMapping("change-show-flag") + public Result changeShowFlag(@RequestBody TagCustomerDTO tagCustomerDTO){ + tagCustomerService.changeShowFlag(tagCustomerDTO.getId(),tagCustomerDTO.getShowFlag()); + return new Result(); + } + } diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/TagCustomerDao.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/TagCustomerDao.java index 595f2a9a18..70c29ec8a2 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/TagCustomerDao.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/TagCustomerDao.java @@ -18,6 +18,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.TagCustomerDTO; import com.epmet.dto.form.InitTagsFormDTO; import com.epmet.dto.form.UpdateTagFormDTO; import com.epmet.entity.TagCustomerEntity; @@ -55,4 +56,12 @@ public interface TagCustomerDao extends BaseDao { * @return */ List selectInitData(@Param("customerIdList") List customerIdList); + + /** + * pc标签管理-分页查询 + * @param customerId + * @param tagName + * @return + */ + List pageList(@Param("customerId") String customerId, @Param("tagName")String tagName); } diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/TagCustomerService.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/TagCustomerService.java index 3ecb3c49c1..099df16cab 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/TagCustomerService.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/TagCustomerService.java @@ -20,6 +20,8 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.dto.TagCustomerDTO; +import com.epmet.dto.form.TagCustomerFormDTO; +import com.epmet.dto.form.TagCustomerPageFormDTO; import com.epmet.dto.result.UpdateTagUseCountsResultDTO; import com.epmet.entity.TagCustomerEntity; @@ -35,14 +37,14 @@ import java.util.Map; public interface TagCustomerService extends BaseService { /** - * 默认分页 + * pc标签管理-分页查询 * - * @param params + * @param formDTO * @return PageData * @author generator * @date 2020-06-02 */ - PageData page(Map params); + PageData page(TagCustomerPageFormDTO formDTO); /** * 默认查询 @@ -65,24 +67,24 @@ public interface TagCustomerService extends BaseService { TagCustomerDTO get(String id); /** - * 默认保存 + * 新增标签 * * @param dto * @return void * @author generator * @date 2020-06-02 */ - void save(TagCustomerDTO dto); + void save(TagCustomerFormDTO dto); /** - * 默认更新 + * 修改标签 * * @param dto * @return void * @author generator * @date 2020-06-02 */ - void update(TagCustomerDTO dto); + void update(TagCustomerFormDTO dto); /** * 批量删除 @@ -100,4 +102,11 @@ public interface TagCustomerService extends BaseService { * @author zxc */ UpdateTagUseCountsResultDTO checkTagInfo(String tagName,String customerId,String userId); + + /** + * 隐藏、显示 + * @param id + * @param showFlag + */ + void changeShowFlag(String id, Integer showFlag); } \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/TagCustomerServiceImpl.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/TagCustomerServiceImpl.java index b5c69d76c1..219cc7616c 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/TagCustomerServiceImpl.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/TagCustomerServiceImpl.java @@ -17,24 +17,39 @@ package com.epmet.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; 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.EpmetException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.EpmetRequestHolder; import com.epmet.dao.TagCustomerDao; +import com.epmet.dao.TagScopeDao; import com.epmet.dto.TagCustomerDTO; +import com.epmet.dto.form.TagCustomerFormDTO; +import com.epmet.dto.form.TagCustomerPageFormDTO; import com.epmet.dto.form.UpdateTagFormDTO; import com.epmet.dto.result.UpdateTagUseCountsResultDTO; import com.epmet.entity.TagCustomerEntity; +import com.epmet.entity.TagScopeEntity; import com.epmet.service.TagCustomerService; import com.epmet.utils.TagColorUtils; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +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.Arrays; +import java.util.Date; import java.util.List; import java.util.Map; @@ -46,14 +61,21 @@ import java.util.Map; */ @Service public class TagCustomerServiceImpl extends BaseServiceImpl implements TagCustomerService { + @Autowired + private TagScopeDao tagScopeDao; + + /** + * pc标签管理-分页查询 + * @param formDTO + * @return + */ @Override - public PageData page(Map params) { - IPage page = baseDao.selectPage( - getPage(params, FieldConstant.CREATED_TIME, false), - getWrapper(params) - ); - return getPageData(page, TagCustomerDTO.class); + public PageData page(TagCustomerPageFormDTO formDTO) { + PageHelper.startPage(formDTO.getPageNo(),formDTO.getPageSize()); + List list=baseDao.pageList(formDTO.getCustomerId(),formDTO.getTagName()); + PageInfo pageInfo = new PageInfo<>(list); + return new PageData<>(list, pageInfo.getTotal()); } @Override @@ -78,18 +100,68 @@ public class TagCustomerServiceImpl extends BaseServiceImpl queryWrapper=new LambdaQueryWrapper<>(); + queryWrapper.eq(TagCustomerEntity::getCustomerId,dto.getCustomerId()) + .eq(TagCustomerEntity::getTagName,dto.getTagName()); + if(baseDao.selectCount(queryWrapper)>0){ + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"标签名称已存在","标签名称已存在"); + } TagCustomerEntity entity = ConvertUtils.sourceToTarget(dto, TagCustomerEntity.class); + entity.setTagColor(StrConstant.EPMETY_STR); + entity.setUseCount(NumConstant.ZERO); + entity.setShowFlag(NumConstant.ONE); insert(entity); + if(CollectionUtils.isNotEmpty(dto.getAgencyIds())){ + dto.getAgencyIds().forEach(tagScopeDTO->{ + TagScopeEntity tagScopeEntity=new TagScopeEntity(); + tagScopeEntity.setCustomerId(entity.getCustomerId()); + tagScopeEntity.setTagId(entity.getId()); + tagScopeEntity.setAgencyId(tagScopeDTO.getAgencyId()); + tagScopeEntity.setAgencyName(tagScopeDTO.getAgencyName()); + tagScopeEntity.setOrgIdPath(tagScopeDTO.getOrgIdPath()); + tagScopeDao.insert(tagScopeEntity); + }); + } } + /** + * pc标签管理-修改 + * @param dto + */ @Override @Transactional(rollbackFor = Exception.class) - public void update(TagCustomerDTO dto) { + public void update(TagCustomerFormDTO dto) { + // 标签名称是否存在 + LambdaQueryWrapper queryWrapper=new LambdaQueryWrapper<>(); + queryWrapper.eq(TagCustomerEntity::getCustomerId,dto.getCustomerId()) + .eq(TagCustomerEntity::getTagName,dto.getTagName()) + .ne(TagCustomerEntity::getId,dto.getId()); + if(baseDao.selectCount(queryWrapper)>0){ + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"标签名称已存在","标签名称已存在"); + } TagCustomerEntity entity = ConvertUtils.sourceToTarget(dto, TagCustomerEntity.class); updateById(entity); + //删除应用范围 + tagScopeDao.deleteByTagId(entity.getId(),entity.getCustomerId()); + if(CollectionUtils.isNotEmpty(dto.getAgencyIds())){ + dto.getAgencyIds().forEach(tagScopeDTO->{ + TagScopeEntity tagScopeEntity=new TagScopeEntity(); + tagScopeEntity.setCustomerId(entity.getCustomerId()); + tagScopeEntity.setTagId(entity.getId()); + tagScopeEntity.setAgencyId(tagScopeDTO.getAgencyId()); + tagScopeEntity.setAgencyName(tagScopeDTO.getAgencyName()); + tagScopeEntity.setOrgIdPath(tagScopeDTO.getOrgIdPath()); + tagScopeDao.insert(tagScopeEntity); + }); + } } @Override @@ -126,4 +198,19 @@ public class TagCustomerServiceImpl extends BaseServiceImpl tagCustomerUpdateWrapper = new LambdaUpdateWrapper<>(); + tagCustomerUpdateWrapper.eq(TagCustomerEntity::getId, id) + .set(TagCustomerEntity::getUpdatedBy, EpmetRequestHolder.getLoginUserId()) + .set(TagCustomerEntity::getUpdatedTime, new Date()) + .set(TagCustomerEntity::getShowFlag,showFlag); + baseDao.update(null,tagCustomerUpdateWrapper); + } } diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/TagCustomerDao.xml b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/TagCustomerDao.xml index 83ed4289ad..a73ca7d5b8 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/TagCustomerDao.xml +++ b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/TagCustomerDao.xml @@ -56,4 +56,14 @@ ORDER BY CUSTOMER_ID + +