chore: 导入后端 s-file(alita-bjy-uygur, f分支)至 backend/
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package com.senmesh.codesetting.constant;
|
||||
|
||||
public interface CodeSettingConstants {
|
||||
/**
|
||||
* 编码配置数据类型
|
||||
*/
|
||||
public static final String CODE_SETTING_DATA_TYPE = "code_setting_data_type";
|
||||
|
||||
public class CodeSettingDataType {
|
||||
|
||||
public static final String STRING = "1";
|
||||
|
||||
public static final String NUMBER = "2";
|
||||
|
||||
public static final String DATE = "3";
|
||||
|
||||
public static final String BOOL = "4";
|
||||
|
||||
public static final String RADIO = "5";
|
||||
|
||||
public static final String CHECKBOX = "6";
|
||||
|
||||
public static final String FILE = "7";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 编码配置模块:机构配置
|
||||
**/
|
||||
public static final String CODE_SETTING_TYPE_CONFIG = "1";
|
||||
|
||||
/**
|
||||
* 编码配置默认级别
|
||||
**/
|
||||
public static final String CODE_SETTING_LEVEL_DEFAULT = "1,2,3,4";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.senmesh.codesetting.controller;
|
||||
|
||||
import com.senmesh.codesetting.dto.CodeSettingDTO;
|
||||
import com.senmesh.codesetting.dto.CodeSettingOperatorDTO;
|
||||
import com.senmesh.codesetting.dto.CodeSettingPageQueryDTO;
|
||||
import com.senmesh.codesetting.dto.CodeSettingQueryDTO;
|
||||
import com.senmesh.codesetting.service.CodeSettingService;
|
||||
import com.senmesh.common.AlitaResult;
|
||||
import com.senmesh.tkmybatis.pojo.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 编码表
|
||||
*
|
||||
* @author chenyun chenyun.home@outlook.com
|
||||
* @since 1.0.0 2023-01-04
|
||||
*/
|
||||
@Api(tags = "编码表")
|
||||
@RestController
|
||||
@RequestMapping("code_setting")
|
||||
public class CodeSettingController {
|
||||
|
||||
@Autowired
|
||||
private CodeSettingService codeSettingService;
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation("编码表-创建")
|
||||
public AlitaResult<CodeSettingDTO> create(@RequestBody CodeSettingOperatorDTO operatorDTO) {
|
||||
return AlitaResult.success(codeSettingService.create(operatorDTO));
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@ApiOperation("编码表-修改")
|
||||
public AlitaResult<CodeSettingDTO> modify(@RequestBody CodeSettingOperatorDTO operatorDTO) {
|
||||
return AlitaResult.success(codeSettingService.modify(operatorDTO));
|
||||
}
|
||||
|
||||
@DeleteMapping("{id}")
|
||||
@ApiOperation("编码表-删除")
|
||||
public AlitaResult<CodeSettingDTO> delete(@PathVariable("id") Long id) {
|
||||
return AlitaResult.success(codeSettingService.delete(id));
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
@ApiOperation("编码表-查询单个")
|
||||
public AlitaResult<CodeSettingDTO> findById(@PathVariable("id") Long id) {
|
||||
return AlitaResult.success(codeSettingService.findById(id));
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
@ApiOperation("编码表-列表查询")
|
||||
public AlitaResult<List<CodeSettingDTO>> list(CodeSettingQueryDTO queryDTO) {
|
||||
return AlitaResult.success(codeSettingService.list(queryDTO));
|
||||
}
|
||||
|
||||
@GetMapping("page")
|
||||
@ApiOperation("编码表-分页查询")
|
||||
public AlitaResult<Page<CodeSettingDTO>> page(CodeSettingPageQueryDTO queryDTO) {
|
||||
codeSettingService.page(queryDTO);
|
||||
return AlitaResult.success(queryDTO.getPageResult());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.senmesh.codesetting.convert;
|
||||
|
||||
import com.senmesh.codesetting.dto.CodeSettingDTO;
|
||||
import com.senmesh.codesetting.dto.CodeSettingOperatorDTO;
|
||||
import com.senmesh.codesetting.entity.CodeSetting;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* 编码表
|
||||
*
|
||||
* @author chenyun chenyun.home@outlook.com
|
||||
* @since 1.0.0 2023-01-04
|
||||
*/
|
||||
@Mapper
|
||||
public interface CodeSettingConvert {
|
||||
CodeSettingConvert INSTANCE = Mappers.getMapper(CodeSettingConvert.class);
|
||||
|
||||
CodeSetting convert(CodeSettingDTO dto);
|
||||
|
||||
CodeSettingDTO convert(CodeSetting entity);
|
||||
|
||||
CodeSetting convert(CodeSettingOperatorDTO dto);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.senmesh.codesetting.dao;
|
||||
|
||||
import com.senmesh.codesetting.dto.CodeSettingDTO;
|
||||
import com.senmesh.codesetting.dto.CodeSettingPageQueryDTO;
|
||||
import com.senmesh.codesetting.dto.CodeSettingQueryDTO;
|
||||
import com.senmesh.codesetting.entity.CodeSetting;
|
||||
import com.senmesh.tkmybatis.mybatis.MyMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 编码表
|
||||
*
|
||||
* @author chenyun chenyun.home@outlook.com
|
||||
* @since 1.0.0 2023-01-04
|
||||
*/
|
||||
@Mapper
|
||||
public interface CodeSettingMapper extends MyMapper<CodeSetting> {
|
||||
|
||||
List<CodeSettingDTO> page(@Param("param") CodeSettingPageQueryDTO queryDTO);
|
||||
|
||||
List<CodeSettingDTO> list(@Param("param") CodeSettingQueryDTO queryDTO);
|
||||
|
||||
/**
|
||||
* 根据类型查询
|
||||
*
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
@Select("select * from xs_code_setting where type = #{type} and deleted = 0")
|
||||
List<CodeSetting> queryByType(String type);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.senmesh.codesetting.dto;
|
||||
|
||||
import com.senmesh.common.dto.BaseDTO;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 编码表
|
||||
*
|
||||
* @author chenyun chenyun.home@outlook.com
|
||||
* @since 1.0.0 2023-01-04
|
||||
*/
|
||||
@ApiModel("编码表")
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CodeSettingDTO extends BaseDTO {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("编码")
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty("名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty("类型 模板编码、配置编码")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty("数据类型")
|
||||
private String dataType;
|
||||
|
||||
@ApiModelProperty("级别 平台、渠道、定制机构、普通机构")
|
||||
private String level;
|
||||
|
||||
@ApiModelProperty("数据值")
|
||||
private String dataFormat;
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.senmesh.codesetting.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 编码表
|
||||
*
|
||||
* @author chenyun chenyun.home@outlook.com
|
||||
* @since 1.0.0 2023-01-04
|
||||
*/
|
||||
@ApiModel("编码表")
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CodeSettingOperatorDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 8836210011277521607L;
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("编码")
|
||||
@NotEmpty(message = "配置项编码不能为空")
|
||||
@Length(min = 1, max = 64, message = "配置项编码长度超限")
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty("名称")
|
||||
@NotEmpty(message = "配置项名称不能为空")
|
||||
@Length(min = 1, max = 128, message = "配置项名称长度超限")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
// @NotEmpty(message = "备注不能为空")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty("数据值")
|
||||
private String dataFormat;
|
||||
|
||||
@ApiModelProperty("类型 模板编码、配置编码")
|
||||
@NotEmpty(message = "配置类型不能为空")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty("数据类型")
|
||||
@NotEmpty(message = "配置参数类型不能为空")
|
||||
private String dataType;
|
||||
|
||||
@ApiModelProperty("级别 平台、渠道、定制机构、普通机构")
|
||||
@NotEmpty(message = "配置应用级别不能为空")
|
||||
private String level;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.senmesh.codesetting.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.senmesh.common.annotation.trimAndUpper.TrimAndUpper;
|
||||
import com.senmesh.common.dto.PageQueryDTO;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 编码表
|
||||
*
|
||||
* @author chenyun chenyun.home@outlook.com
|
||||
* @since 1.0.0 2023-01-04
|
||||
*/
|
||||
|
||||
@ApiModel("编码表")
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CodeSettingPageQueryDTO extends PageQueryDTO<CodeSettingDTO> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("主键ID")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("编码")
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty("编码 (模糊匹配)")
|
||||
@TrimAndUpper(TrimAndUpper.ExecuteType.TRIM)
|
||||
private String codeLike;
|
||||
|
||||
@ApiModelProperty("名称 (模糊匹配)")
|
||||
@TrimAndUpper(TrimAndUpper.ExecuteType.TRIM)
|
||||
private String nameLike;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty("类型 模板编码、配置编码")
|
||||
@TrimAndUpper(TrimAndUpper.ExecuteType.TRIM)
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty("数据类型")
|
||||
private String dataType;
|
||||
|
||||
@ApiModelProperty("级别 平台、渠道、定制机构、普通机构")
|
||||
private String level;
|
||||
|
||||
@ApiModelProperty("创建时间起,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTimeStart;
|
||||
|
||||
@ApiModelProperty("创建时间止,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTimeEnd;
|
||||
|
||||
@ApiModelProperty("修改时间起,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date updateTimeStart;
|
||||
|
||||
@ApiModelProperty("修改时间止,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date updateTimeEnd;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.senmesh.codesetting.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 编码表
|
||||
*
|
||||
* @author chenyun chenyun.home@outlook.com
|
||||
* @since 1.0.0 2023-01-04
|
||||
*/
|
||||
@ApiModel("编码表")
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CodeSettingQueryDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("主键ID")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("编码")
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty("编码 (模糊匹配)")
|
||||
private String codeLike;
|
||||
|
||||
@ApiModelProperty("名称 (模糊匹配)")
|
||||
private String nameLike;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty("类型 模板编码、配置编码")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty("数据类型")
|
||||
private String dataType;
|
||||
|
||||
@ApiModelProperty("级别 平台、渠道、定制机构、普通机构")
|
||||
private String level;
|
||||
|
||||
@ApiModelProperty("创建时间起,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTimeStart;
|
||||
|
||||
@ApiModelProperty("创建时间止,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTimeEnd;
|
||||
|
||||
@ApiModelProperty("修改时间起,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date updateTimeStart;
|
||||
|
||||
@ApiModelProperty("修改时间止,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date updateTimeEnd;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.senmesh.codesetting.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.senmesh.common.entity.BaseEntity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 编码表
|
||||
*
|
||||
* @author chenyun chenyun.home@outlook.com
|
||||
* @since 1.0.0 2023-01-04
|
||||
*/
|
||||
@TableName("xs_code_setting")
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CodeSetting extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 类型 模板编码、配置编码
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 数据类型
|
||||
*/
|
||||
private String dataType;
|
||||
/**
|
||||
* 数据格式编号
|
||||
*/
|
||||
private String dataFormat;
|
||||
/**
|
||||
* 级别 平台、渠道、定制机构、普通机构
|
||||
*/
|
||||
private String level;
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?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.senmesh.codesetting.dao.CodeSettingMapper">
|
||||
|
||||
<select id="list" resultType="com.senmesh.codesetting.dto.CodeSettingDTO">
|
||||
SELECT t.*
|
||||
<include refid="queryFromSql"></include>
|
||||
</select>
|
||||
|
||||
<select id="page" resultType="com.senmesh.codesetting.dto.CodeSettingDTO">
|
||||
SELECT t.*
|
||||
<include refid="queryFromSql"></include>
|
||||
</select>
|
||||
|
||||
<sql id="queryFromSql">
|
||||
FROM
|
||||
xs_code_setting t
|
||||
WHERE t.deleted = FALSE
|
||||
<if test='param.id != null'>
|
||||
AND t.id = #{param.id}
|
||||
</if>
|
||||
<if test='param.code != null and param.code.trim() != ""'>
|
||||
AND t.code = #{param.code}
|
||||
</if>
|
||||
<if test='param.codeLike != null and param.codeLike.trim() != ""'>
|
||||
<bind name="codeLike" value="'%' + param.codeLike + '%'"/>
|
||||
AND t.code like #{codeLike}
|
||||
</if>
|
||||
<if test='param.nameLike != null and param.nameLike.trim() != ""'>
|
||||
<bind name="nameLike" value="'%' + param.nameLike + '%'"/>
|
||||
AND t.name like #{nameLike}
|
||||
</if>
|
||||
<if test='param.remark != null and param.remark.trim() != ""'>
|
||||
AND t.remark = #{param.remark}
|
||||
</if>
|
||||
<if test='param.type != null and param.type.trim() != ""'>
|
||||
AND t.type = #{param.type}
|
||||
</if>
|
||||
<if test='param.dataType != null and param.dataType.trim() != ""'>
|
||||
AND t.data_type = #{param.dataType}
|
||||
</if>
|
||||
<if test='param.level != null and param.level.trim() != ""'>
|
||||
AND FIND_IN_SET(CONCAT(#{param.level},""),t.level)
|
||||
</if>
|
||||
<if test='param.createTimeStart != null'>
|
||||
AND t.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test='param.createTimeEnd != null'>
|
||||
AND t.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<if test='param.updateTimeStart != null'>
|
||||
AND t.update_time >= #{param.updateTimeStart}
|
||||
</if>
|
||||
<if test='param.updateTimeEnd != null'>
|
||||
AND t.update_time <= #{param.updateTimeEnd}
|
||||
</if>
|
||||
ORDER BY t.id DESC
|
||||
</sql>
|
||||
</mapper>
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.senmesh.codesetting.service;
|
||||
|
||||
import com.senmesh.codesetting.dto.CodeSettingDTO;
|
||||
import com.senmesh.codesetting.dto.CodeSettingOperatorDTO;
|
||||
import com.senmesh.codesetting.dto.CodeSettingPageQueryDTO;
|
||||
import com.senmesh.codesetting.dto.CodeSettingQueryDTO;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.groups.Default;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 编码表
|
||||
*
|
||||
* @author chenyun chenyun.home@outlook.com
|
||||
* @since 1.0.0 2023-01-04
|
||||
*/
|
||||
@Validated(Default.class)
|
||||
public interface CodeSettingService {
|
||||
|
||||
/**
|
||||
* 编码表 - 创建
|
||||
*
|
||||
* @param operatorDto 操作dto
|
||||
* @return {@link CodeSettingDTO}
|
||||
*/
|
||||
CodeSettingDTO create(@Valid CodeSettingOperatorDTO operatorDto);
|
||||
|
||||
/**
|
||||
* 校验编码是否存在
|
||||
*
|
||||
* @param code 代码
|
||||
* @param codeSettingId 编码ID
|
||||
* @return boolean true: 存在重复编码
|
||||
*/
|
||||
boolean checkCode(String code, Long codeSettingId);
|
||||
|
||||
/**
|
||||
* 编码表 - 修改
|
||||
*
|
||||
* @param operatorDto 操作dto
|
||||
* @return {@link CodeSettingDTO}
|
||||
*/
|
||||
CodeSettingDTO modify(@Valid CodeSettingOperatorDTO operatorDto);
|
||||
|
||||
/**
|
||||
* 编码表 - 删除
|
||||
*
|
||||
* @param id id
|
||||
* @return {@link CodeSettingDTO}
|
||||
*/
|
||||
CodeSettingDTO delete(Long id);
|
||||
|
||||
/**
|
||||
* 编码表 - 根据ID查询单个
|
||||
*
|
||||
* @param id id
|
||||
* @return {@link CodeSettingDTO}
|
||||
*/
|
||||
CodeSettingDTO findById(Long id);
|
||||
|
||||
/**
|
||||
* 编码表 - 列表查询
|
||||
*
|
||||
* @param queryDTO 列表查询dto
|
||||
* @return {@link List}<{@link CodeSettingDTO}>
|
||||
*/
|
||||
List<CodeSettingDTO> list(CodeSettingQueryDTO queryDTO);
|
||||
|
||||
/**
|
||||
* 编码表 - 分页查询
|
||||
*
|
||||
* @param queryDTO 分页查询dto
|
||||
* @return {@link CodeSettingDTO}
|
||||
*/
|
||||
List<CodeSettingDTO> page(CodeSettingPageQueryDTO queryDTO);
|
||||
|
||||
/**
|
||||
* 根据type和code查询
|
||||
*
|
||||
* @param codeSettingType
|
||||
* @param orgType
|
||||
* @return
|
||||
*/
|
||||
List<com.senmesh.codesetting.dto.CodeSettingDTO> queryCode(String codeSettingType, String orgType);
|
||||
|
||||
/**
|
||||
* 根据code查询
|
||||
*
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
CodeSettingDTO getByCode(String code);
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package com.senmesh.codesetting.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.senmesh.codesetting.convert.CodeSettingConvert;
|
||||
import com.senmesh.codesetting.dao.CodeSettingMapper;
|
||||
import com.senmesh.codesetting.dto.CodeSettingDTO;
|
||||
import com.senmesh.codesetting.dto.CodeSettingOperatorDTO;
|
||||
import com.senmesh.codesetting.dto.CodeSettingPageQueryDTO;
|
||||
import com.senmesh.codesetting.dto.CodeSettingQueryDTO;
|
||||
import com.senmesh.codesetting.entity.CodeSetting;
|
||||
import com.senmesh.codesetting.service.CodeSettingService;
|
||||
import com.senmesh.common.constant.CommonConstants;
|
||||
import com.senmesh.common.exception.util.Assert;
|
||||
import com.senmesh.common.util.UserContextHolder;
|
||||
import com.senmesh.config.dao.ConfigMapper;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 编码表
|
||||
*
|
||||
* @author chenyun chenyun.home@outlook.com
|
||||
* @since 1.0.0 2023-01-04
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class CodeSettingServiceImpl implements CodeSettingService {
|
||||
|
||||
@Resource
|
||||
private CodeSettingMapper codeSettingMapper;
|
||||
|
||||
@Resource
|
||||
private ConfigMapper configMapper;
|
||||
|
||||
@Override
|
||||
public CodeSettingDTO create(CodeSettingOperatorDTO operatorDto) {
|
||||
Assert.isTrue(!checkCode(operatorDto.getCode(), null), "配置项编码已存在");
|
||||
CodeSetting codeSetting = CodeSettingConvert.INSTANCE.convert(operatorDto);
|
||||
codeSettingMapper.saveEntity(codeSetting);
|
||||
return CodeSettingConvert.INSTANCE.convert(codeSetting);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkCode(String code, Long codeSettingId) {
|
||||
return codeSettingMapper.existsEntity(CodeSetting.builder().code(code).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodeSettingDTO modify(CodeSettingOperatorDTO operatorDto) {
|
||||
CodeSettingDTO codeSettingDto = this.findById(operatorDto.getId());
|
||||
if (Objects.isNull(codeSettingDto)) {
|
||||
return null;
|
||||
}
|
||||
Assert.isTrue(!checkCode(operatorDto.getCode(), operatorDto.getId()), "配置项编码已存在");
|
||||
CodeSetting codeSetting = CodeSettingConvert.INSTANCE.convert(operatorDto);
|
||||
codeSettingMapper.updateEntity(codeSetting);
|
||||
return this.findById(operatorDto.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodeSettingDTO delete(Long id) {
|
||||
CodeSettingDTO codeSettingDto = this.findById(id);
|
||||
if (Objects.isNull(codeSettingDto)) {
|
||||
return null;
|
||||
}
|
||||
CodeSetting codeSetting = CodeSetting.builder().build();
|
||||
codeSetting.setId(id);
|
||||
codeSettingMapper.deleteEntity(codeSetting, UserContextHolder.getLoginUserId());
|
||||
// 删除配置项的时候,同步删除配置项下的配置
|
||||
configMapper.batchDelete(codeSettingDto.getCode(), UserContextHolder.getExistLoginUserId());
|
||||
return codeSettingDto;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodeSettingDTO findById(Long id) {
|
||||
CodeSetting codeSetting = codeSettingMapper.getById(id);
|
||||
if (Objects.isNull(codeSetting)) {
|
||||
return null;
|
||||
}
|
||||
return CodeSettingConvert.INSTANCE.convert(codeSetting);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CodeSettingDTO> list(CodeSettingQueryDTO queryDTO) {
|
||||
return codeSettingMapper.list(queryDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CodeSettingDTO> page(CodeSettingPageQueryDTO queryDTO) {
|
||||
return codeSettingMapper.page(queryDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CodeSettingDTO> queryCode(String codeSettingType, String orgType) {
|
||||
List<CodeSetting> codeSettings = codeSettingMapper.queryByType(codeSettingType);
|
||||
return codeSettings.stream()
|
||||
.filter(codeSetting -> ArrayUtils
|
||||
.contains(codeSetting.getLevel().split(CommonConstants.COMMA), orgType))
|
||||
.map(CodeSettingConvert.INSTANCE::convert).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodeSettingDTO getByCode(String code) {
|
||||
List<CodeSettingDTO> list = this.list(CodeSettingQueryDTO.builder().code(code).build());
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return null;
|
||||
}
|
||||
return list.get(0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user