From 5846ce237a3529d08acf3d70130debc9f962af1a Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Mon, 17 Jan 2022 11:18:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E4=BA=8B=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/demand/ServiceItemAddFormDTO.java | 33 +++++ .../form/demand/ServiceItemPageFormDTO.java | 20 +++ .../epmet/dto/form/demand/StatusFormDTO.java | 3 + .../result/demand/ServiceItemResultDTO.java | 19 +++ .../IcResiDemandDictController.java | 3 +- .../IcServiceItemDictController.java | 71 ++++++++++ .../com/epmet/dao/IcServiceItemDictDao.java | 37 +++++ .../epmet/entity/IcServiceItemDictEntity.java | 83 ++++++++++++ .../service/IcServiceItemDictService.java | 55 ++++++++ .../impl/IcResiDemandDictServiceImpl.java | 1 + .../impl/IcServiceItemDictServiceImpl.java | 126 ++++++++++++++++++ .../resources/mapper/IcServiceItemDictDao.xml | 21 +++ 12 files changed, 471 insertions(+), 1 deletion(-) create mode 100644 epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/ServiceItemAddFormDTO.java create mode 100644 epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/ServiceItemPageFormDTO.java create mode 100644 epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/ServiceItemResultDTO.java create mode 100644 epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcServiceItemDictController.java create mode 100644 epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcServiceItemDictDao.java create mode 100644 epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcServiceItemDictEntity.java create mode 100644 epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcServiceItemDictService.java create mode 100644 epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcServiceItemDictServiceImpl.java create mode 100644 epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcServiceItemDictDao.xml diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/ServiceItemAddFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/ServiceItemAddFormDTO.java new file mode 100644 index 0000000000..6ac82ec0db --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/ServiceItemAddFormDTO.java @@ -0,0 +1,33 @@ +package com.epmet.dto.form.demand; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * 新增或者修改服务事项分类 + */ +@Data +public class ServiceItemAddFormDTO implements Serializable { + public interface AddUserInternalGroup { + } + + public interface AddUserShowGroup extends CustomerClientShowGroup { + } + + @NotBlank(message = "customerId不能为空", groups = AddUserInternalGroup.class) + private String customerId; + + @NotBlank(message = "分类名称不能为空", groups = AddUserShowGroup.class) + @Length(max = 100, message = "分类名称至多输入100字", groups = AddUserShowGroup.class) + private String categoryName; + + @NotNull(message = "", groups = AddUserShowGroup.class) + private Integer awardPoint; + + private String categoryId; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/ServiceItemPageFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/ServiceItemPageFormDTO.java new file mode 100644 index 0000000000..cb1586d413 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/ServiceItemPageFormDTO.java @@ -0,0 +1,20 @@ +package com.epmet.dto.form.demand; + +import com.epmet.commons.tools.dto.form.PageFormDTO; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + + +/** + * 服务事项分类列表查询入参 + * 目前不分页 + */ +@Data +public class ServiceItemPageFormDTO extends PageFormDTO implements Serializable { + public interface AddUserInternalGroup {} + + @NotBlank(message = "客户id不能为空",groups = AddUserInternalGroup.class) + private String customerId; +} diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/StatusFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/StatusFormDTO.java index 879d632cc7..2e8e95db04 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/StatusFormDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/demand/StatusFormDTO.java @@ -17,4 +17,7 @@ public class StatusFormDTO implements Serializable { @NotNull(message = "usableFlag不能为空", groups = AddUserInternalGroup.class) private Boolean usableFlag; + + @NotBlank(message = "userId不能为空", groups = AddUserInternalGroup.class) + private String userId; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/ServiceItemResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/ServiceItemResultDTO.java new file mode 100644 index 0000000000..3408b5f724 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/demand/ServiceItemResultDTO.java @@ -0,0 +1,19 @@ +package com.epmet.dto.result.demand; + +import lombok.Data; + +import java.io.Serializable; + + +/** + * 服务事项分类列表查询返参 + * 目前不分页 + */ +@Data +public class ServiceItemResultDTO implements Serializable { + private static final long serialVersionUID = -590440160577071133L; + private String categoryId; + private String categoryName; + private Integer awardPoint; + private Boolean usableFlag; +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcResiDemandDictController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcResiDemandDictController.java index 4bb3a8c969..2fb6ad864f 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcResiDemandDictController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcResiDemandDictController.java @@ -114,7 +114,8 @@ public class IcResiDemandDictController { * @return */ @PostMapping("updatestatus") - public Result updateStatus(@RequestBody StatusFormDTO formDTO){ + public Result updateStatus(@LoginUser TokenDto tokenDto,@RequestBody StatusFormDTO formDTO){ + formDTO.setUserId(tokenDto.getUserId()); ValidatorUtils.validateEntity(formDTO,StatusFormDTO.AddUserInternalGroup.class); icResiDemandDictService.updateStatus(formDTO); return new Result(); diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcServiceItemDictController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcServiceItemDictController.java new file mode 100644 index 0000000000..d2f9f6d412 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcServiceItemDictController.java @@ -0,0 +1,71 @@ +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.demand.ServiceItemAddFormDTO; +import com.epmet.dto.form.demand.ServiceItemPageFormDTO; +import com.epmet.dto.form.demand.StatusFormDTO; +import com.epmet.dto.result.demand.ServiceItemResultDTO; +import com.epmet.service.IcServiceItemDictService; +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; + +/** + * 服务事项分类字典表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-27 + */ +@RestController +@RequestMapping("serviceitem") +public class IcServiceItemDictController { + + @Autowired + private IcServiceItemDictService icServiceItemDictService; + + + /** + * 01、分页列表查询 + * + * @param formDTO + * @return + */ + @PostMapping("list") + public Result> page(@RequestBody ServiceItemPageFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO,ServiceItemPageFormDTO.AddUserInternalGroup.class); + PageData page = icServiceItemDictService.page(formDTO); + return new Result>().ok(page); + } + + /** + * 02、新增分类 + * @param formDTO + * @return + */ + @PostMapping("saveorupdate") + public Result addOrUpdate(@RequestBody ServiceItemAddFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO, ServiceItemAddFormDTO.AddUserShowGroup.class,ServiceItemAddFormDTO.AddUserInternalGroup.class); + icServiceItemDictService.addOrUpdate(formDTO); + return new Result(); + } + + /** + * 03、启用或者禁用分类 + * @param formDTO + * @return + */ + @PostMapping("updatestatus") + public Result updateStatus(@LoginUser TokenDto tokenDto, @RequestBody StatusFormDTO formDTO){ + formDTO.setUserId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(formDTO,StatusFormDTO.AddUserInternalGroup.class); + icServiceItemDictService.updateStatus(formDTO); + return new Result(); + } +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcServiceItemDictDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcServiceItemDictDao.java new file mode 100644 index 0000000000..5837b45aea --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcServiceItemDictDao.java @@ -0,0 +1,37 @@ +/** + * 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.result.demand.ServiceItemResultDTO; +import com.epmet.entity.IcServiceItemDictEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 服务事项分类字典表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-01-14 + */ +@Mapper +public interface IcServiceItemDictDao extends BaseDao { + + List pageList(String customerId); +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcServiceItemDictEntity.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcServiceItemDictEntity.java new file mode 100644 index 0000000000..c0b34489f5 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/IcServiceItemDictEntity.java @@ -0,0 +1,83 @@ +/** + * 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; + +/** + * 服务事项分类字典表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-01-14 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("ic_service_item_dict") +public class IcServiceItemDictEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户Id + */ + private String customerId; + + /** + * 父级,一级默认为0 + */ + private String parentCode; + + /** + * 分类编码 + */ + private String categoryCode; + + /** + * 分类名称 + */ + private String categoryName; + + /** + * 级别 + */ + private Integer level; + + /** + * 备注 + */ + private String remark; + + /** + * 排序 + */ + private Integer sort; + + /** + * 1可用,0不可用 + */ + private Boolean usableFlag; + + /** + * 奖励积分 + */ + private Integer awardPoint; + +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcServiceItemDictService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcServiceItemDictService.java new file mode 100644 index 0000000000..a93e50aaff --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcServiceItemDictService.java @@ -0,0 +1,55 @@ +/** + * 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.form.demand.ServiceItemAddFormDTO; +import com.epmet.dto.form.demand.ServiceItemPageFormDTO; +import com.epmet.dto.form.demand.StatusFormDTO; +import com.epmet.dto.result.demand.ServiceItemResultDTO; +import com.epmet.entity.IcServiceItemDictEntity; + +/** + * 服务事项分类字典表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-01-14 + */ +public interface IcServiceItemDictService extends BaseService { + + /** + * 01、列表查询 + * @param formDTO + * @return + */ + PageData page(ServiceItemPageFormDTO formDTO); + + /** + * 02、添加或者修改分类 + * @param formDTO + */ + void addOrUpdate(ServiceItemAddFormDTO formDTO); + + /** + * 03、启用或者禁用分类 + * @param formDTO + * @return + */ + void updateStatus(StatusFormDTO formDTO); +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcResiDemandDictServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcResiDemandDictServiceImpl.java index 0e352910c6..493004ce71 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcResiDemandDictServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcResiDemandDictServiceImpl.java @@ -217,6 +217,7 @@ public class IcResiDemandDictServiceImpl extends BaseServiceImpl + * 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.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dao.IcServiceItemDictDao; +import com.epmet.dto.form.demand.ServiceItemAddFormDTO; +import com.epmet.dto.form.demand.ServiceItemPageFormDTO; +import com.epmet.dto.form.demand.StatusFormDTO; +import com.epmet.dto.result.demand.ServiceItemResultDTO; +import com.epmet.entity.IcServiceItemDictEntity; +import com.epmet.service.IcServiceItemDictService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.List; + +/** + * 服务事项分类字典表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-01-14 + */ +@Slf4j +@Service +public class IcServiceItemDictServiceImpl extends BaseServiceImpl implements IcServiceItemDictService { + + + /** + * 列表查询 + * + * @param formDTO + * @return + */ + @Override + public PageData page(ServiceItemPageFormDTO formDTO) { + //目前不分页,只是接口支持分页 + List list = baseDao.pageList(formDTO.getCustomerId()); + return new PageData<>(list, CollectionUtils.isNotEmpty(list) ? list.size() : NumConstant.ZERO); + } + + /** + * 02、添加或者修改分类 + * + * @param formDTO + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void addOrUpdate(ServiceItemAddFormDTO formDTO) { + //分类名称是否唯一 + LambdaQueryWrapper nameQuery = new LambdaQueryWrapper<>(); + nameQuery.eq(IcServiceItemDictEntity::getCustomerId, formDTO.getCustomerId()) + .eq(IcServiceItemDictEntity::getCategoryName, formDTO.getCategoryName()) + .ne(StringUtils.isNotBlank(formDTO.getCategoryId()), IcServiceItemDictEntity::getId, formDTO.getCategoryId()); + if (baseDao.selectCount(nameQuery) > 0) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "当前客户下,分类名称已存在", "分类名称已存在"); + } + if (StringUtils.isNotBlank(formDTO.getCategoryId())) { + LambdaUpdateWrapper update = new LambdaUpdateWrapper<>(); + update.eq(IcServiceItemDictEntity::getId, formDTO.getCategoryId()); + update.set(IcServiceItemDictEntity::getCategoryName, formDTO.getCategoryName()) + .set(IcServiceItemDictEntity::getAwardPoint, formDTO.getAwardPoint()); + baseDao.update(null, update); + return; + } + LambdaQueryWrapper maxQuery = new LambdaQueryWrapper<>(); + maxQuery.eq(IcServiceItemDictEntity::getCustomerId, formDTO.getCustomerId()) + .orderByDesc(IcServiceItemDictEntity::getCategoryCode).last("limit 1"); + IcServiceItemDictEntity max = baseDao.selectOne(maxQuery); + // 获取编码 + IcServiceItemDictEntity insert = new IcServiceItemDictEntity(); + insert.setCustomerId(formDTO.getCustomerId()); + insert.setAwardPoint(formDTO.getAwardPoint()); + insert.setCategoryName(formDTO.getCategoryName()); + insert.setUsableFlag(true); + insert.setParentCode(NumConstant.ZERO_STR); + insert.setLevel(NumConstant.ONE); + insert.setSort(null != max ? max.getSort() + 1 : NumConstant.ONE); + insert.setCategoryCode(null != max ? String.valueOf(Integer.valueOf(max.getCategoryCode()) + 1) : "1001"); + baseDao.insert(insert); + } + + /** + * 03、启用或者禁用分类 + * + * @param formDTO + * @return + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void updateStatus(StatusFormDTO formDTO) { + LambdaUpdateWrapper update = new LambdaUpdateWrapper<>(); + update.eq(IcServiceItemDictEntity::getId, formDTO.getCategoryId()) + .set(IcServiceItemDictEntity::getUsableFlag, formDTO.getUsableFlag()) + .set(IcServiceItemDictEntity::getUpdatedTime, new Date()) + .set(IcServiceItemDictEntity::getUpdatedBy, formDTO.getUserId()); + baseDao.update(null, update); + } + + +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcServiceItemDictDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcServiceItemDictDao.xml new file mode 100644 index 0000000000..f89b3c6a83 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcServiceItemDictDao.xml @@ -0,0 +1,21 @@ + + + + + + + + \ No newline at end of file