12 changed files with 471 additions and 1 deletions
@ -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; |
||||
|
} |
@ -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; |
||||
|
} |
@ -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; |
||||
|
} |
@ -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<PageData<ServiceItemResultDTO>> page(@RequestBody ServiceItemPageFormDTO formDTO){ |
||||
|
ValidatorUtils.validateEntity(formDTO,ServiceItemPageFormDTO.AddUserInternalGroup.class); |
||||
|
PageData<ServiceItemResultDTO> page = icServiceItemDictService.page(formDTO); |
||||
|
return new Result<PageData<ServiceItemResultDTO>>().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(); |
||||
|
} |
||||
|
} |
@ -0,0 +1,37 @@ |
|||||
|
/** |
||||
|
* 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.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<IcServiceItemDictEntity> { |
||||
|
|
||||
|
List<ServiceItemResultDTO> pageList(String customerId); |
||||
|
} |
@ -0,0 +1,83 @@ |
|||||
|
/** |
||||
|
* 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; |
||||
|
|
||||
|
/** |
||||
|
* 服务事项分类字典表 |
||||
|
* |
||||
|
* @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; |
||||
|
|
||||
|
} |
@ -0,0 +1,55 @@ |
|||||
|
/** |
||||
|
* 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.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<IcServiceItemDictEntity> { |
||||
|
|
||||
|
/** |
||||
|
* 01、列表查询 |
||||
|
* @param formDTO |
||||
|
* @return |
||||
|
*/ |
||||
|
PageData<ServiceItemResultDTO> page(ServiceItemPageFormDTO formDTO); |
||||
|
|
||||
|
/** |
||||
|
* 02、添加或者修改分类 |
||||
|
* @param formDTO |
||||
|
*/ |
||||
|
void addOrUpdate(ServiceItemAddFormDTO formDTO); |
||||
|
|
||||
|
/** |
||||
|
* 03、启用或者禁用分类 |
||||
|
* @param formDTO |
||||
|
* @return |
||||
|
*/ |
||||
|
void updateStatus(StatusFormDTO formDTO); |
||||
|
} |
@ -0,0 +1,126 @@ |
|||||
|
/** |
||||
|
* 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.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<IcServiceItemDictDao, IcServiceItemDictEntity> implements IcServiceItemDictService { |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 列表查询 |
||||
|
* |
||||
|
* @param formDTO |
||||
|
* @return |
||||
|
*/ |
||||
|
@Override |
||||
|
public PageData<ServiceItemResultDTO> page(ServiceItemPageFormDTO formDTO) { |
||||
|
//目前不分页,只是接口支持分页
|
||||
|
List<ServiceItemResultDTO> 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<IcServiceItemDictEntity> 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<IcServiceItemDictEntity> 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<IcServiceItemDictEntity> 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<IcServiceItemDictEntity> 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); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,21 @@ |
|||||
|
<?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.IcServiceItemDictDao"> |
||||
|
|
||||
|
<select id="pageList" parameterType="java.lang.String" resultType="com.epmet.dto.result.demand.ServiceItemResultDTO"> |
||||
|
SELECT |
||||
|
d.id AS categoryId, |
||||
|
d.CATEGORY_NAME AS categoryName, |
||||
|
d.AWARD_POINT AS awardPoint, |
||||
|
d.USABLE_FLAG AS usableFlag |
||||
|
FROM |
||||
|
ic_service_item_dict d |
||||
|
WHERE |
||||
|
d.DEL_FLAG = '0' |
||||
|
AND d.CUSTOMER_ID = #{customerId} |
||||
|
ORDER BY |
||||
|
d.SORT DESC |
||||
|
</select> |
||||
|
|
||||
|
</mapper> |
Loading…
Reference in new issue