mirror of
https://gitee.com/dromara/dax-pay.git
synced 2025-10-13 21:30:25 +00:00
ref 脚手架同步为最新版本
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>cn.bootx.platform</groupId>
|
||||
<artifactId>bootx-platform-service</artifactId>
|
||||
<version>3.0.0.beta1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>service-baseapi</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<!-- 数据持久层依赖 -->
|
||||
<dependency>
|
||||
<groupId>cn.bootx.platform</groupId>
|
||||
<artifactId>common-mybatis-plus</artifactId>
|
||||
<version>${bootx-platform.version}</version>
|
||||
</dependency>
|
||||
<!-- 异常处理器 -->
|
||||
<dependency>
|
||||
<groupId>cn.bootx.platform</groupId>
|
||||
<artifactId>common-exception-handler</artifactId>
|
||||
<version>${bootx-platform.version}</version>
|
||||
</dependency>
|
||||
<!-- json 序列化配置 -->
|
||||
<dependency>
|
||||
<groupId>cn.bootx.platform</groupId>
|
||||
<artifactId>common-jackson</artifactId>
|
||||
<version>${bootx-platform.version}</version>
|
||||
</dependency>
|
||||
<!-- Spring 封装 -->
|
||||
<dependency>
|
||||
<groupId>cn.bootx.platform</groupId>
|
||||
<artifactId>common-spring</artifactId>
|
||||
<version>${bootx-platform.version}</version>
|
||||
</dependency>
|
||||
<!-- Redis配置-->
|
||||
<dependency>
|
||||
<groupId>cn.bootx.platform</groupId>
|
||||
<artifactId>common-redis</artifactId>
|
||||
<version>${bootx-platform.version}</version>
|
||||
</dependency>
|
||||
<!-- Spring 缓存配置 -->
|
||||
<dependency>
|
||||
<groupId>cn.bootx.platform</groupId>
|
||||
<artifactId>common-cache</artifactId>
|
||||
<version>${bootx-platform.version}</version>
|
||||
</dependency>
|
||||
<!-- hutool 缓存 -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-cache</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<!-- hutool 请求工具类 -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-http</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<!-- 安全认证 -->
|
||||
<dependency>
|
||||
<groupId>cn.bootx.platform</groupId>
|
||||
<artifactId>starter-auth</artifactId>
|
||||
<version>${bootx-platform.version}</version>
|
||||
</dependency>
|
||||
<!-- 审计日志 -->
|
||||
<dependency>
|
||||
<groupId>cn.bootx.platform</groupId>
|
||||
<artifactId>starter-audit-log</artifactId>
|
||||
<version>${bootx-platform.version}</version>
|
||||
</dependency>
|
||||
<!-- 文件存储 -->
|
||||
<dependency>
|
||||
<groupId>cn.bootx.platform</groupId>
|
||||
<artifactId>starter-file</artifactId>
|
||||
<version>${bootx-platform.version}</version>
|
||||
</dependency>
|
||||
<!-- 表格工具 -->
|
||||
<dependency>
|
||||
<groupId>cn.afterturn</groupId>
|
||||
<artifactId>easypoi-base</artifactId>
|
||||
<version>${easypoi.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@@ -0,0 +1,17 @@
|
||||
package cn.bootx.platform.baseapi;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
/**
|
||||
* 框架基础功能
|
||||
*
|
||||
* @author xxm
|
||||
* @since 2021/8/4
|
||||
*/
|
||||
@ComponentScan
|
||||
@MapperScan(annotationClass = Mapper.class)
|
||||
public class BaseApiApplication {
|
||||
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
package cn.bootx.platform.baseapi.controller;
|
||||
|
||||
import cn.bootx.platform.core.annotation.IgnoreAuth;
|
||||
import cn.bootx.platform.core.rest.Res;
|
||||
import cn.bootx.platform.core.rest.result.Result;
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* 系统基础接口
|
||||
* @author xxm
|
||||
* @since 2023/10/14
|
||||
*/
|
||||
@Tag(name = "系统基础接口")
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class BaseController {
|
||||
|
||||
@IgnoreAuth
|
||||
@Operation(summary = "回声测试")
|
||||
@GetMapping("/echo")
|
||||
public String echo(String msg){
|
||||
return "echo: "+msg;
|
||||
}
|
||||
|
||||
@IgnoreAuth(login = true)
|
||||
@Operation(summary = "回声测试(必须要进行登录)")
|
||||
@GetMapping("/auth/echo")
|
||||
public String authEcho(String msg){
|
||||
return "echo: "+msg;
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@IgnoreAuth
|
||||
@Operation(summary = "读取文件文本内容")
|
||||
@PostMapping("/readText")
|
||||
public Result<String> readText(MultipartFile file){
|
||||
return Res.ok(new String(file.getBytes(), StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@IgnoreAuth
|
||||
@Operation(summary = "将文件转换成base64")
|
||||
@PostMapping("/readBase64")
|
||||
public Result<String> readBase64(MultipartFile file){
|
||||
return Res.ok(Base64.encode(file.getBytes()));
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,96 @@
|
||||
package cn.bootx.platform.baseapi.controller.dict;
|
||||
|
||||
import cn.bootx.platform.baseapi.param.dict.DictionaryParam;
|
||||
import cn.bootx.platform.baseapi.result.dict.DictionaryResult;
|
||||
import cn.bootx.platform.baseapi.service.dict.DictionaryService;
|
||||
import cn.bootx.platform.core.annotation.RequestGroup;
|
||||
import cn.bootx.platform.core.annotation.RequestPath;
|
||||
import cn.bootx.platform.core.validation.ValidationGroup;
|
||||
import cn.bootx.platform.core.rest.Res;
|
||||
import cn.bootx.platform.core.rest.param.PageParam;
|
||||
import cn.bootx.platform.core.rest.result.PageResult;
|
||||
import cn.bootx.platform.core.rest.result.Result;
|
||||
import cn.bootx.platform.core.util.ValidationUtil;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
*
|
||||
* @author xxm
|
||||
* @since 2021/8/4
|
||||
*/
|
||||
@Tag(name = "字典")
|
||||
@RestController
|
||||
@RequestGroup(groupCode = "dict", groupName = "字典管理", moduleCode = "baseapi", moduleName = "基础API" )
|
||||
@RequestMapping("/dict")
|
||||
@RequiredArgsConstructor
|
||||
public class DictionaryController {
|
||||
|
||||
private final DictionaryService dictionaryService;
|
||||
|
||||
@RequestPath("添加字典")
|
||||
@Operation(summary = "添加字典")
|
||||
@PostMapping("/add")
|
||||
public Result<DictionaryResult> add(@RequestBody DictionaryParam param) {
|
||||
ValidationUtil.validateParam(param, ValidationGroup.add.class);
|
||||
return Res.ok(dictionaryService.add(param));
|
||||
}
|
||||
|
||||
@RequestPath("根据主键删除字典")
|
||||
@Operation(summary = "根据主键删除")
|
||||
@PostMapping("/delete")
|
||||
public Result<Boolean> delete(Long id) {
|
||||
dictionaryService.delete(id);
|
||||
return Res.ok();
|
||||
}
|
||||
|
||||
@RequestPath("更新字典")
|
||||
@Operation(summary = "更新字典")
|
||||
@PostMapping("/update")
|
||||
public Result<DictionaryResult> update(@RequestBody DictionaryParam param) {
|
||||
ValidationUtil.validateParam(param, ValidationGroup.edit.class);
|
||||
return Res.ok(dictionaryService.update(param));
|
||||
}
|
||||
|
||||
@RequestPath("根据主键获取字典")
|
||||
@Operation(summary = "根据主键获取字典")
|
||||
@GetMapping("/findById")
|
||||
public Result<DictionaryResult> findById(Long id) {
|
||||
return Res.ok(dictionaryService.findById(id));
|
||||
}
|
||||
|
||||
@RequestPath("查询全部字典")
|
||||
@Operation(summary = "查询全部字典")
|
||||
@GetMapping("/findAll")
|
||||
public Result<List<DictionaryResult>> findAll() {
|
||||
return Res.ok(dictionaryService.findAll());
|
||||
}
|
||||
|
||||
@RequestPath("字典分页")
|
||||
@Operation(summary = "字典分页")
|
||||
@GetMapping("/page")
|
||||
public Result<PageResult<DictionaryResult>> page(@ParameterObject PageParam pageParam, DictionaryParam param) {
|
||||
return Res.ok(dictionaryService.page(pageParam, param));
|
||||
}
|
||||
|
||||
@RequestPath("字典编码是否被使用")
|
||||
@Operation(summary = "字典编码是否被使用")
|
||||
@GetMapping("/existsByCode")
|
||||
public Result<Boolean> existsByCode(String code) {
|
||||
return Res.ok(dictionaryService.existsByCode(code));
|
||||
}
|
||||
|
||||
@RequestPath("编码是否被使用(不包含自己)")
|
||||
@Operation(summary = "编码是否被使用(不包含自己)")
|
||||
@GetMapping("/existsByCodeNotId")
|
||||
public Result<Boolean> existsByCode(String code, Long id) {
|
||||
return Res.ok(dictionaryService.existsByCode(code, id));
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,113 @@
|
||||
package cn.bootx.platform.baseapi.controller.dict;
|
||||
|
||||
import cn.bootx.platform.baseapi.param.dict.DictionaryItemParam;
|
||||
import cn.bootx.platform.baseapi.result.dict.DictionaryItemResult;
|
||||
import cn.bootx.platform.baseapi.service.dict.DictionaryItemService;
|
||||
import cn.bootx.platform.core.annotation.IgnoreAuth;
|
||||
import cn.bootx.platform.core.annotation.RequestGroup;
|
||||
import cn.bootx.platform.core.annotation.RequestPath;
|
||||
import cn.bootx.platform.core.validation.ValidationGroup;
|
||||
import cn.bootx.platform.core.rest.Res;
|
||||
import cn.bootx.platform.core.rest.param.PageParam;
|
||||
import cn.bootx.platform.core.rest.result.PageResult;
|
||||
import cn.bootx.platform.core.rest.result.Result;
|
||||
import cn.bootx.platform.core.util.ValidationUtil;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xxm
|
||||
* @since 2020/4/18 19:03
|
||||
*/
|
||||
@Tag(name = "字典项")
|
||||
@RequestGroup(groupCode = "dict", groupName = "字典管理", moduleCode = "baseapi", moduleName = "基础API" )
|
||||
@RestController
|
||||
@RequestMapping("/dict/item")
|
||||
@AllArgsConstructor
|
||||
public class DictionaryItemController {
|
||||
|
||||
private final DictionaryItemService dictionaryItemService;
|
||||
|
||||
@RequestPath("添加字典项")
|
||||
@Operation(summary = "添加字典项")
|
||||
@PostMapping("/add")
|
||||
public Result<Void> add(@RequestBody DictionaryItemParam param) {
|
||||
ValidationUtil.validateParam(param, ValidationGroup.add.class);
|
||||
dictionaryItemService.add(param);
|
||||
return Res.ok();
|
||||
}
|
||||
|
||||
@RequestPath("添加字典项")
|
||||
@Operation(summary = "修改字典项(返回字典项对象)")
|
||||
@PostMapping(value = "/update")
|
||||
public Result<DictionaryItemResult> update(@RequestBody DictionaryItemParam param) {
|
||||
ValidationUtil.validateParam(param, ValidationGroup.edit.class);
|
||||
dictionaryItemService.update(param);
|
||||
return Res.ok();
|
||||
}
|
||||
|
||||
@RequestPath("删除字典项")
|
||||
@Operation(summary = "删除字典项")
|
||||
@PostMapping(value = "/delete")
|
||||
public Result<Void> delete(Long id) {
|
||||
dictionaryItemService.delete(id);
|
||||
return Res.ok();
|
||||
}
|
||||
|
||||
@RequestPath("查询字典项")
|
||||
@Operation(summary = "根据字典项ID查询")
|
||||
@GetMapping("/findById")
|
||||
public Result<DictionaryItemResult> findById(@Parameter(description = "字典项ID") Long id) {
|
||||
return Res.ok(dictionaryItemService.findById(id));
|
||||
}
|
||||
|
||||
@RequestPath("查询字典项列表")
|
||||
@Operation(summary = "查询指定字典ID下的所有字典项")
|
||||
@GetMapping("/findByDictionaryId")
|
||||
public Result<List<DictionaryItemResult>> findByDictionaryId(@Parameter(description = "字典ID") Long dictId) {
|
||||
return Res.ok(dictionaryItemService.findByDictionaryId(dictId));
|
||||
}
|
||||
|
||||
@RequestPath("字典项分页")
|
||||
@Operation(summary = "分页查询指定字典下的字典项")
|
||||
@GetMapping("/pageByDictionaryId")
|
||||
public Result<PageResult<DictionaryItemResult>> pageByDictionaryId(PageParam pageParam, @Parameter(description = "字典ID") Long dictId) {
|
||||
return Res.ok(dictionaryItemService.pageByDictionaryId(dictId, pageParam));
|
||||
}
|
||||
|
||||
@RequestPath("获取全部字典项")
|
||||
@Operation(summary = "获取全部字典项")
|
||||
@GetMapping("/findAll")
|
||||
public Result<List<DictionaryItemResult>> findAll() {
|
||||
return Res.ok(dictionaryItemService.findAll());
|
||||
}
|
||||
|
||||
@IgnoreAuth
|
||||
@Operation(summary = "获取启用的字典项列表")
|
||||
@GetMapping("/findAllByEnable")
|
||||
public Result<List<DictionaryItemResult>> findAllByEnable() {
|
||||
return Res.ok(dictionaryItemService.findAllByEnable());
|
||||
}
|
||||
|
||||
@RequestPath("字典项编码是否被使用")
|
||||
@Operation(summary = "字典项编码是否被使用")
|
||||
@GetMapping("/existsByCode")
|
||||
public Result<Boolean> existsByCode(@Parameter(description = "编码") String code,@Parameter(description = "字典ID") Long dictId) {
|
||||
return Res.ok(dictionaryItemService.existsByCode(code, dictId));
|
||||
}
|
||||
|
||||
@RequestPath("字典项编码是否被使用(不包含自己)")
|
||||
@Operation(summary = "字典项编码是否被使用(不包含自己)")
|
||||
@GetMapping("/existsByCodeNotId")
|
||||
public Result<Boolean> existsByCode(@Parameter(description = "编码") String code,
|
||||
@Parameter(description = "字典ID") Long dictId,
|
||||
@Parameter(description = "字典项ID") Long id) {
|
||||
return Res.ok(dictionaryItemService.existsByCode(code, dictId, id));
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,97 @@
|
||||
package cn.bootx.platform.baseapi.controller.parameter;
|
||||
|
||||
import cn.bootx.platform.baseapi.param.parameter.SystemParameterParam;
|
||||
import cn.bootx.platform.baseapi.result.parameter.SystemParameterResult;
|
||||
import cn.bootx.platform.baseapi.service.parameter.SystemParamService;
|
||||
import cn.bootx.platform.core.annotation.IgnoreAuth;
|
||||
import cn.bootx.platform.core.annotation.RequestGroup;
|
||||
import cn.bootx.platform.core.annotation.RequestPath;
|
||||
import cn.bootx.platform.core.rest.Res;
|
||||
import cn.bootx.platform.core.rest.param.PageParam;
|
||||
import cn.bootx.platform.core.rest.result.PageResult;
|
||||
import cn.bootx.platform.core.rest.result.Result;
|
||||
import cn.bootx.platform.core.util.ValidationUtil;
|
||||
import cn.bootx.platform.core.validation.ValidationGroup;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 系统参数
|
||||
*
|
||||
* @author xxm
|
||||
* @since 2021/10/25
|
||||
*/
|
||||
@Tag(name = "系统参数")
|
||||
@RequestGroup(groupCode = "params", groupName = "系统参数", moduleCode = "baseapi" )
|
||||
@RestController
|
||||
@RequestMapping("/system/param")
|
||||
@RequiredArgsConstructor
|
||||
public class SystemParamController {
|
||||
|
||||
private final SystemParamService systemParamService;
|
||||
|
||||
@RequestPath("添加")
|
||||
@Operation(summary = "添加")
|
||||
@PostMapping("/add")
|
||||
public Result<Void> add(@RequestBody SystemParameterParam param) {
|
||||
ValidationUtil.validateParam(param, ValidationGroup.add.class);
|
||||
systemParamService.add(param);
|
||||
return Res.ok();
|
||||
}
|
||||
|
||||
@RequestPath("更新")
|
||||
@Operation(summary = "更新")
|
||||
@PostMapping("/update")
|
||||
public Result<Void> update(@RequestBody SystemParameterParam param) {
|
||||
ValidationUtil.validateParam(param, ValidationGroup.edit.class);
|
||||
systemParamService.update(param);
|
||||
return Res.ok();
|
||||
}
|
||||
|
||||
@RequestPath("分页")
|
||||
@Operation(summary = "分页")
|
||||
@GetMapping("/page")
|
||||
public Result<PageResult<SystemParameterResult>> page(PageParam pageParam, SystemParameterParam param) {
|
||||
return Res.ok(systemParamService.page(pageParam, param));
|
||||
}
|
||||
|
||||
@RequestPath("获取单条")
|
||||
@Operation(summary = "获取单条")
|
||||
@GetMapping("/findById")
|
||||
public Result<SystemParameterResult> findById(@Parameter(description = "主键") Long id) {
|
||||
return Res.ok(systemParamService.findById(id));
|
||||
}
|
||||
|
||||
@RequestPath("删除")
|
||||
@Operation(summary = "删除")
|
||||
@PostMapping("/delete")
|
||||
public Result<Void> delete(Long id) {
|
||||
systemParamService.delete(id);
|
||||
return Res.ok();
|
||||
}
|
||||
|
||||
@RequestPath("判断编码是否存在")
|
||||
@Operation(summary = "判断编码是否存在")
|
||||
@GetMapping("/existsByKey")
|
||||
public Result<Boolean> existsByKey(String key) {
|
||||
return Res.ok(systemParamService.existsByKey(key));
|
||||
}
|
||||
|
||||
@RequestPath("判断编码是否存在(不包含自己)")
|
||||
@Operation(summary = "判断编码是否存在(不包含自己)")
|
||||
@GetMapping("/existsByKeyNotId")
|
||||
public Result<Boolean> existsByKeyNotId(String key, Long id) {
|
||||
return Res.ok(systemParamService.existsByKey(key, id));
|
||||
}
|
||||
|
||||
@IgnoreAuth
|
||||
@Operation(summary = "根据键名获取键值")
|
||||
@GetMapping("/findByKey")
|
||||
public Result<String> findByKey(String key) {
|
||||
return Res.ok(systemParamService.findByKey(key));
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
package cn.bootx.platform.baseapi.convert.dict;
|
||||
|
||||
import cn.bootx.platform.baseapi.entity.dict.Dictionary;
|
||||
import cn.bootx.platform.baseapi.entity.dict.DictionaryItem;
|
||||
import cn.bootx.platform.baseapi.param.dict.DictionaryItemParam;
|
||||
import cn.bootx.platform.baseapi.param.dict.DictionaryParam;
|
||||
import cn.bootx.platform.baseapi.result.dict.DictionaryItemResult;
|
||||
import cn.bootx.platform.baseapi.result.dict.DictionaryResult;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* 字典转换
|
||||
*
|
||||
* @author xxm
|
||||
* @since 2021/7/6
|
||||
*/
|
||||
@Mapper
|
||||
public interface DictionaryConvert {
|
||||
|
||||
DictionaryConvert CONVERT = Mappers.getMapper(DictionaryConvert.class);
|
||||
|
||||
Dictionary convert(DictionaryParam in);
|
||||
|
||||
DictionaryResult convert(Dictionary in);
|
||||
|
||||
DictionaryItem convert(DictionaryItemParam in);
|
||||
|
||||
DictionaryItemResult convert(DictionaryItem in);
|
||||
|
||||
DictionaryItem convertSimple(DictionaryItemParam in);
|
||||
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
package cn.bootx.platform.baseapi.convert.parameter;
|
||||
|
||||
import cn.bootx.platform.baseapi.entity.parameter.SystemParameter;
|
||||
import cn.bootx.platform.baseapi.param.parameter.SystemParameterParam;
|
||||
import cn.bootx.platform.baseapi.result.parameter.SystemParameterResult;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* 系统参数和系统配置实体类转换
|
||||
*
|
||||
* @author xxm
|
||||
* @since 2021/10/25
|
||||
*/
|
||||
@Mapper
|
||||
public interface SystemConvert {
|
||||
|
||||
SystemConvert CONVERT = Mappers.getMapper(SystemConvert.class);
|
||||
|
||||
SystemParameterResult convert(SystemParameter in);
|
||||
|
||||
SystemParameter convert(SystemParameterParam in);
|
||||
|
||||
}
|
@@ -0,0 +1,80 @@
|
||||
package cn.bootx.platform.baseapi.dao.dict;
|
||||
|
||||
import cn.bootx.platform.baseapi.entity.dict.DictionaryItem;
|
||||
import cn.bootx.platform.common.mybatisplus.base.MpIdEntity;
|
||||
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
|
||||
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
|
||||
import cn.bootx.platform.core.rest.param.PageParam;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 字典项
|
||||
*
|
||||
* @author xxm
|
||||
* @since 2020/4/21 14:08
|
||||
*/
|
||||
@Repository
|
||||
@AllArgsConstructor
|
||||
public class DictionaryItemManager extends BaseManager<DictionaryItemMapper, DictionaryItem> {
|
||||
|
||||
public boolean existsByDictId(Long dictId) {
|
||||
return existedByField(DictionaryItem::getDictId, dictId);
|
||||
}
|
||||
|
||||
public boolean existsByCode(String code, Long dictId) {
|
||||
return lambdaQuery().eq(DictionaryItem::getCode, code).eq(DictionaryItem::getDictId, dictId).exists();
|
||||
}
|
||||
|
||||
public boolean existsByCode(String code, Long dictId, Long itemId) {
|
||||
return lambdaQuery().eq(DictionaryItem::getCode, code)
|
||||
.eq(DictionaryItem::getDictId, dictId)
|
||||
.ne(MpIdEntity::getId, itemId)
|
||||
.exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询指定字典下的所有内容
|
||||
*/
|
||||
public List<DictionaryItem> findByDictId(Long dictId) {
|
||||
return findAllByField(DictionaryItem::getDictId, dictId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询指定字典下的所有内容
|
||||
*/
|
||||
public List<DictionaryItem> findByDictCodeAndEnable(String dictCode, boolean enable) {
|
||||
return lambdaQuery().eq(DictionaryItem::getDictCode, dictCode).eq(DictionaryItem::getEnable, enable).list();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询,根据字典Id
|
||||
*/
|
||||
public Page<DictionaryItem> findAllByDictionaryId(Long dictId, PageParam pageParam) {
|
||||
Page<DictionaryItem> mpPage = MpUtil.getMpPage(pageParam);
|
||||
return lambdaQuery().eq(DictionaryItem::getDictId, dictId)
|
||||
.orderByAsc(DictionaryItem::getSortNo)
|
||||
.orderByDesc(MpIdEntity::getId)
|
||||
.page(mpPage);
|
||||
}
|
||||
|
||||
public void updateDictCode(Long dictId, String dictCode) {
|
||||
lambdaUpdate().set(DictionaryItem::getDictCode, dictCode).eq(DictionaryItem::getDictId, dictId).update();
|
||||
}
|
||||
|
||||
public List<DictionaryItem> findAllByEnable(boolean enable) {
|
||||
return lambdaQuery().eq(DictionaryItem::getEnable, enable).list();
|
||||
}
|
||||
|
||||
public Optional<DictionaryItem> findByCodeAndEnable(String dictCode, String code, boolean enable) {
|
||||
return lambdaQuery().eq(DictionaryItem::getDictCode, dictCode)
|
||||
.eq(DictionaryItem::getCode, code)
|
||||
.eq(DictionaryItem::getEnable, enable)
|
||||
.oneOpt();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
package cn.bootx.platform.baseapi.dao.dict;
|
||||
|
||||
import cn.bootx.platform.baseapi.entity.dict.DictionaryItem;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 字典项
|
||||
*
|
||||
* @author xxm
|
||||
* @since 2020/11/13
|
||||
*/
|
||||
@Mapper
|
||||
public interface DictionaryItemMapper extends MPJBaseMapper<DictionaryItem> {
|
||||
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
package cn.bootx.platform.baseapi.dao.dict;
|
||||
|
||||
import cn.bootx.platform.baseapi.entity.dict.Dictionary;
|
||||
import cn.bootx.platform.baseapi.param.dict.DictionaryParam;
|
||||
import cn.bootx.platform.common.mybatisplus.base.MpIdEntity;
|
||||
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
|
||||
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
|
||||
import cn.bootx.platform.core.rest.param.PageParam;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
*
|
||||
* @author xxm
|
||||
* @since 2020/11/13
|
||||
*/
|
||||
@Repository
|
||||
@AllArgsConstructor
|
||||
public class DictionaryManager extends BaseManager<DictionaryMapper, Dictionary> {
|
||||
|
||||
/**
|
||||
* 根据code查询重复
|
||||
*/
|
||||
public boolean existsByCode(String code) {
|
||||
return existedByField(Dictionary::getCode, code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据code查询重复 排除id
|
||||
*/
|
||||
public boolean existsByCode(String code, Long id) {
|
||||
return existedByField(Dictionary::getCode, code, id);
|
||||
}
|
||||
|
||||
public Page<Dictionary> page(PageParam pageParam, DictionaryParam param) {
|
||||
Page<Dictionary> mpPage = MpUtil.getMpPage(pageParam);
|
||||
return lambdaQuery().orderByDesc(MpIdEntity::getId)
|
||||
.like(StrUtil.isNotBlank(param.getCode()), Dictionary::getCode, param.getCode())
|
||||
.like(StrUtil.isNotBlank(param.getName()), Dictionary::getName, param.getName())
|
||||
.like(StrUtil.isNotBlank(param.getGroupTag()), Dictionary::getGroupTag, param.getGroupTag())
|
||||
.page(mpPage);
|
||||
}
|
||||
|
||||
public List<Dictionary> findAllByEnable(boolean enable) {
|
||||
return lambdaQuery().eq(Dictionary::getEnable, enable).list();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
package cn.bootx.platform.baseapi.dao.dict;
|
||||
|
||||
import cn.bootx.platform.baseapi.entity.dict.Dictionary;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
*
|
||||
* @author xxm
|
||||
* @since 2021/8/4
|
||||
*/
|
||||
@Mapper
|
||||
public interface DictionaryMapper extends MPJBaseMapper<Dictionary> {
|
||||
|
||||
}
|
@@ -0,0 +1,61 @@
|
||||
package cn.bootx.platform.baseapi.dao.parameter;
|
||||
|
||||
import cn.bootx.platform.baseapi.entity.parameter.SystemParameter;
|
||||
import cn.bootx.platform.baseapi.param.parameter.SystemParameterParam;
|
||||
import cn.bootx.platform.common.mybatisplus.base.MpIdEntity;
|
||||
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
|
||||
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
|
||||
import cn.bootx.platform.core.rest.param.PageParam;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 系统参数
|
||||
*
|
||||
* @author xxm
|
||||
* @since 2021/10/25
|
||||
*/
|
||||
@Slf4j
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
public class SystemParamManager extends BaseManager<SystemParamMapper, SystemParameter> {
|
||||
|
||||
|
||||
/**
|
||||
* 根据键名获取键值
|
||||
*/
|
||||
public Optional<SystemParameter> findByKey(String key) {
|
||||
return this.findByField(SystemParameter::getKey, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* key重复检查
|
||||
*/
|
||||
public boolean existsByKey(String key) {
|
||||
return existedByField(SystemParameter::getKey, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* key重复检查
|
||||
*/
|
||||
public boolean existsByKey(String key, Long id) {
|
||||
return existedByField(SystemParameter::getKey, key, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
public Page<SystemParameter> page(PageParam pageParam, SystemParameterParam param) {
|
||||
Page<SystemParameter> mpPage = MpUtil.getMpPage(pageParam);
|
||||
return lambdaQuery().orderByDesc(MpIdEntity::getId)
|
||||
.like(StrUtil.isNotBlank(param.getName()), SystemParameter::getName, param.getName())
|
||||
.like(StrUtil.isNotBlank(param.getKey()), SystemParameter::getKey, param.getKey())
|
||||
.page(mpPage);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
package cn.bootx.platform.baseapi.dao.parameter;
|
||||
|
||||
import cn.bootx.platform.baseapi.entity.parameter.SystemParameter;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author xxm
|
||||
* @since 2021/10/25
|
||||
*/
|
||||
@Mapper
|
||||
public interface SystemParamMapper extends MPJBaseMapper<SystemParameter> {
|
||||
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
package cn.bootx.platform.baseapi.entity.dict;
|
||||
|
||||
import cn.bootx.platform.baseapi.convert.dict.DictionaryConvert;
|
||||
import cn.bootx.platform.baseapi.result.dict.DictionaryResult;
|
||||
import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity;
|
||||
import cn.bootx.platform.common.mybatisplus.function.ToResult;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
*
|
||||
* @author xxm
|
||||
* @since 2020/11/13
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("base_dict")
|
||||
public class Dictionary extends MpBaseEntity implements ToResult<DictionaryResult> {
|
||||
|
||||
/** 名称 */
|
||||
private String name;
|
||||
|
||||
/** 分类标签 */
|
||||
private String groupTag;
|
||||
|
||||
/** 编码 */
|
||||
private String code;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
/** 是否启用 */
|
||||
private Boolean enable;
|
||||
|
||||
@Override
|
||||
public DictionaryResult toResult() {
|
||||
return DictionaryConvert.CONVERT.convert(this);
|
||||
}
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
package cn.bootx.platform.baseapi.entity.dict;
|
||||
|
||||
import cn.bootx.platform.baseapi.convert.dict.DictionaryConvert;
|
||||
import cn.bootx.platform.baseapi.result.dict.DictionaryItemResult;
|
||||
import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity;
|
||||
import cn.bootx.platform.common.mybatisplus.function.ToResult;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 字典项
|
||||
*
|
||||
* @author xxm
|
||||
* @since 2020/4/15 17:45
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName("base_dict_item")
|
||||
public class DictionaryItem extends MpBaseEntity implements ToResult<DictionaryItemResult> {
|
||||
|
||||
/** 字典ID */
|
||||
private Long dictId;
|
||||
|
||||
/** 字典编码 */
|
||||
private String dictCode;
|
||||
|
||||
/** 字典项编码 */
|
||||
private String code;
|
||||
|
||||
/** 名称 */
|
||||
private String name;
|
||||
|
||||
/** 字典项排序 */
|
||||
private Integer sortNo;
|
||||
|
||||
/** 是否启用 */
|
||||
private Boolean enable;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
|
||||
@Override
|
||||
public DictionaryItemResult toResult() {
|
||||
return DictionaryConvert.CONVERT.convert(this);
|
||||
}
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
package cn.bootx.platform.baseapi.entity.parameter;
|
||||
|
||||
import cn.bootx.platform.baseapi.convert.parameter.SystemConvert;
|
||||
import cn.bootx.platform.baseapi.param.parameter.SystemParameterParam;
|
||||
import cn.bootx.platform.baseapi.result.parameter.SystemParameterResult;
|
||||
import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity;
|
||||
import cn.bootx.platform.common.mybatisplus.function.ToResult;
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 系统参数
|
||||
*
|
||||
* @author xxm
|
||||
* @since 2021/10/25
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName("base_param")
|
||||
public class SystemParameter extends MpBaseEntity implements ToResult<SystemParameterResult> {
|
||||
|
||||
/** 参数名称 */
|
||||
private String name;
|
||||
|
||||
/** 参数键名 */
|
||||
private String key;
|
||||
|
||||
/** 参数值 */
|
||||
private String value;
|
||||
|
||||
/** 参数类型 */
|
||||
private String type;
|
||||
|
||||
/** 是否启用 */
|
||||
private Boolean enable;
|
||||
|
||||
/** 内置参数 */
|
||||
@TableField(updateStrategy = FieldStrategy.NEVER)
|
||||
private boolean internal;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
@Override
|
||||
public SystemParameterResult toResult() {
|
||||
return SystemConvert.CONVERT.convert(this);
|
||||
}
|
||||
|
||||
public static SystemParameter init(SystemParameterParam in) {
|
||||
return SystemConvert.CONVERT.convert(in);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
package cn.bootx.platform.baseapi.handler.mp;
|
||||
|
||||
import cn.bootx.platform.common.mybatisplus.function.MetaObjectFill;
|
||||
import cn.bootx.platform.core.code.CommonCode;
|
||||
import cn.bootx.platform.starter.auth.util.SecurityUtil;
|
||||
import cn.hutool.core.util.DesensitizedUtil;
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 基础信息自动填填充
|
||||
*
|
||||
* @author xxm
|
||||
* @since 2021/7/27
|
||||
*/
|
||||
@Component
|
||||
public class BaseMetaObjectHandler implements MetaObjectFill {
|
||||
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject, MetaObjectHandler metaObjectHandler) {
|
||||
metaObjectHandler.strictInsertFill(metaObject, CommonCode.CREATE_TIME, LocalDateTime::now, LocalDateTime.class);
|
||||
metaObjectHandler.strictInsertFill(metaObject, CommonCode.CREATOR, this::getUserid, Long.class);
|
||||
metaObjectHandler.strictInsertFill(metaObject, CommonCode.LAST_MODIFIED_TIME, LocalDateTime::now, LocalDateTime.class);
|
||||
metaObjectHandler.strictInsertFill(metaObject, CommonCode.LAST_MODIFIER, this::getUserid, Long.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject, MetaObjectHandler metaObjectHandler) {
|
||||
// mp默认策略如果字段有值则不会赋值, 所以要强制设置值一下
|
||||
metaObjectHandler.setFieldValByName(CommonCode.LAST_MODIFIED_TIME, LocalDateTime.now(), metaObject);
|
||||
metaObjectHandler.setFieldValByName(CommonCode.LAST_MODIFIER, this.getUserid(), metaObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户Id
|
||||
*/
|
||||
public Long getUserid() {
|
||||
try {
|
||||
return SecurityUtil.getUserIdOrDefaultId();
|
||||
} catch (Exception e) {
|
||||
return DesensitizedUtil.userId();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
package cn.bootx.platform.baseapi.param.dict;
|
||||
|
||||
import cn.bootx.platform.core.validation.ValidationGroup;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Null;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 字典项参数
|
||||
*
|
||||
* @author xxm
|
||||
* @since 2021/8/4
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "字典项参数")
|
||||
public class DictionaryItemParam {
|
||||
|
||||
@Null(message = "Id需要为空", groups = ValidationGroup.add.class)
|
||||
@NotNull(message = "Id不可为空", groups = ValidationGroup.edit.class)
|
||||
@Schema(description = "主键")
|
||||
private Long id;
|
||||
|
||||
@NotNull(message = "字典ID不可为空")
|
||||
@Schema(description = "字典ID")
|
||||
private Long dictId;
|
||||
|
||||
@Schema(description = "字典编码")
|
||||
private String dictCode;
|
||||
|
||||
@NotEmpty(message = "字典项编码不可为空", groups = ValidationGroup.add.class)
|
||||
@Schema(description = "字典项编码")
|
||||
private String code;
|
||||
|
||||
@NotEmpty(message = "字典项编码不可为空", groups = ValidationGroup.add.class)
|
||||
@Schema(description = "名称")
|
||||
private String name;
|
||||
|
||||
@NotNull(message = "启用状态不可为空", groups = ValidationGroup.add.class)
|
||||
@Schema(description = "启用状态")
|
||||
private Boolean enable;
|
||||
|
||||
@Schema(description = "字典项排序")
|
||||
private Double sortNo;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
package cn.bootx.platform.baseapi.param.dict;
|
||||
|
||||
import cn.bootx.platform.core.validation.ValidationGroup;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Null;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author xxm
|
||||
* @since 2020/4/10 14:46
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "数据字典目录")
|
||||
public class DictionaryParam implements Serializable {
|
||||
|
||||
@Null(message = "Id需要为空", groups = ValidationGroup.add.class)
|
||||
@NotNull(message = "Id不可为空", groups = ValidationGroup.edit.class)
|
||||
@Schema(description = "主键")
|
||||
private Long id;
|
||||
|
||||
@NotEmpty(message = "编码不可以为空", groups = ValidationGroup.add.class)
|
||||
@Schema(description = "编码")
|
||||
private String code;
|
||||
|
||||
@NotEmpty(message = "编码不可以为空", groups = ValidationGroup.add.class)
|
||||
@Schema(description = "名称")
|
||||
private String name;
|
||||
|
||||
@NotNull(message = "启用状态不可为空", groups = ValidationGroup.add.class)
|
||||
@Schema(description = "启用状态")
|
||||
private Boolean enable;
|
||||
|
||||
@Schema(description = "分类标签")
|
||||
private String groupTag;
|
||||
|
||||
@Schema(description = "描述")
|
||||
private String remark;
|
||||
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
package cn.bootx.platform.baseapi.param.parameter;
|
||||
|
||||
import cn.bootx.platform.core.validation.ValidationGroup;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Null;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
|
||||
/**
|
||||
* 系统参数
|
||||
*
|
||||
* @author xxm
|
||||
* @since 2021/10/25
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "系统参数")
|
||||
public class SystemParameterParam {
|
||||
|
||||
@Null(message = "Id需要为空", groups = ValidationGroup.add.class)
|
||||
@NotNull(message = "Id不可为空", groups = ValidationGroup.edit.class)
|
||||
@Schema(description = "主键")
|
||||
private Long id;
|
||||
|
||||
@NotEmpty(message = "参数名称不可为空", groups = ValidationGroup.add.class)
|
||||
@Schema(description = "参数名称")
|
||||
private String name;
|
||||
|
||||
@NotEmpty(message = "参数键名不可为空", groups = ValidationGroup.add.class)
|
||||
@Schema(description = "参数键名")
|
||||
private String key;
|
||||
|
||||
@NotEmpty(message = "参数值不可为空", groups = ValidationGroup.add.class)
|
||||
@Schema(description = "参数值")
|
||||
private String value;
|
||||
|
||||
@NotNull(message = "启用状态不可为空", groups = ValidationGroup.add.class)
|
||||
@Schema(description = "启用状态")
|
||||
private Boolean enable;
|
||||
|
||||
@Schema(description = "参数键类型")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "是否是系统参数")
|
||||
private boolean internal;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
package cn.bootx.platform.baseapi.result.dict;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 数据字典项
|
||||
*
|
||||
* @author xxm
|
||||
* @since 2020/4/15 17:55
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "数据字典项Dto")
|
||||
public class DictionaryItemResult {
|
||||
|
||||
@Schema(description = "主键")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "字典ID")
|
||||
private Long dictId;
|
||||
|
||||
@Schema(description = "字典编码")
|
||||
private String dictCode;
|
||||
|
||||
@Schema(description = "字典项编码")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "启用状态")
|
||||
private Boolean enable;
|
||||
|
||||
@Schema(description = "字典项排序")
|
||||
private Double sortNo;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
package cn.bootx.platform.baseapi.result.dict;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author xxm
|
||||
* @since 2020/4/10 14:46
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "数据字典目录")
|
||||
public class DictionaryResult {
|
||||
|
||||
@Schema(description = "主键")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "编码")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "启用状态")
|
||||
private Boolean enable;
|
||||
|
||||
@Schema(description = "分类标签")
|
||||
private String groupTag;
|
||||
|
||||
@Schema(description = "描述")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
package cn.bootx.platform.baseapi.result.parameter;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 系统参数
|
||||
*
|
||||
* @author xxm
|
||||
* @since 2021/10/25
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(title = "系统参数")
|
||||
public class SystemParameterResult {
|
||||
|
||||
@Schema(description = "主键")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "参数名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "参数键名")
|
||||
private String key;
|
||||
|
||||
@Schema(description = "参数值")
|
||||
private String value;
|
||||
|
||||
@Schema(description = "参数类型")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "启用状态")
|
||||
private boolean enable;
|
||||
|
||||
@Schema(description = "是否系统参数")
|
||||
private boolean internal;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@@ -0,0 +1,180 @@
|
||||
package cn.bootx.platform.baseapi.service.dict;
|
||||
|
||||
import cn.bootx.platform.baseapi.convert.dict.DictionaryConvert;
|
||||
import cn.bootx.platform.baseapi.dao.dict.DictionaryItemManager;
|
||||
import cn.bootx.platform.baseapi.dao.dict.DictionaryManager;
|
||||
import cn.bootx.platform.baseapi.entity.dict.Dictionary;
|
||||
import cn.bootx.platform.baseapi.entity.dict.DictionaryItem;
|
||||
import cn.bootx.platform.baseapi.param.dict.DictionaryItemParam;
|
||||
import cn.bootx.platform.baseapi.result.dict.DictionaryItemResult;
|
||||
import cn.bootx.platform.common.mybatisplus.base.MpIdEntity;
|
||||
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
|
||||
import cn.bootx.platform.core.exception.BizException;
|
||||
import cn.bootx.platform.core.exception.DataNotExistException;
|
||||
import cn.bootx.platform.core.rest.param.PageParam;
|
||||
import cn.bootx.platform.core.rest.result.PageResult;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author xxm
|
||||
* @since 2020/4/16 21:16
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class DictionaryItemService {
|
||||
|
||||
private final DictionaryItemManager dictionaryItemManager;
|
||||
|
||||
private final DictionaryManager dictionaryManager;
|
||||
|
||||
/**
|
||||
* 添加内容
|
||||
*/
|
||||
@CacheEvict(value = "cache:dict", allEntries = true)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void add(DictionaryItemParam param) {
|
||||
|
||||
// 在同一个Dictionary不允许存在相同code的DictionaryItem
|
||||
if (dictionaryItemManager.existsByCode(param.getCode(), param.getDictId())) {
|
||||
throw new BizException("字典项编码重复");
|
||||
}
|
||||
|
||||
Dictionary dictionary = dictionaryManager.findById(param.getDictId())
|
||||
.orElseThrow(() -> new BizException("字典不存在"));
|
||||
param.setDictCode(dictionary.getCode());
|
||||
DictionaryItem dictionaryItem = DictionaryConvert.CONVERT.convert(param);
|
||||
dictionaryItemManager.save(dictionaryItem);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改内容
|
||||
*/
|
||||
@CacheEvict(value = "cache:dict", allEntries = true)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(DictionaryItemParam param) {
|
||||
// 判断字典item是否存在
|
||||
DictionaryItem dictionaryItem = dictionaryItemManager.findById(param.getId())
|
||||
.orElseThrow(() -> new BizException("字典项不存在"));
|
||||
|
||||
// 判断是否有重复code的Item
|
||||
if (dictionaryItemManager.existsByCode(dictionaryItem.getDictCode(), param.getDictId(), param.getId())) {
|
||||
throw new BizException("字典项编码重复");
|
||||
}
|
||||
BeanUtil.copyProperties(param, dictionaryItem, CopyOptions.create().ignoreNullValue());
|
||||
dictionaryItemManager.updateById(dictionaryItem);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除内容
|
||||
*/
|
||||
@CacheEvict(value = "cache:dict", allEntries = true)
|
||||
public void delete(Long id) {
|
||||
dictionaryItemManager.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询指定内容
|
||||
*/
|
||||
public DictionaryItemResult findById(Long id) {
|
||||
return dictionaryItemManager.findById(id).map(DictionaryItem::toResult).orElseThrow(() -> new DataNotExistException("字典项不存在"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典编码和字典项编码查询启用的菜单项
|
||||
*/
|
||||
public Optional<DictionaryItem> findEnableByCode(String dictCode, String code) {
|
||||
return dictionaryItemManager.findByCodeAndEnable(dictCode, code, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询指定目录下的所有内容
|
||||
*/
|
||||
public List<DictionaryItemResult> findByDictionaryId(Long dictionaryId) {
|
||||
return dictionaryItemManager.findByDictId(dictionaryId)
|
||||
.stream()
|
||||
.sorted(Comparator.comparingDouble(DictionaryItem::getSortNo))
|
||||
.map(DictionaryItem::toResult)
|
||||
.toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询指定目录下的所有内容
|
||||
*/
|
||||
public List<DictionaryItemResult> findEnableByDictCode(String dictCode) {
|
||||
return dictionaryItemManager.findByDictCodeAndEnable(dictCode, true)
|
||||
.stream()
|
||||
.map(DictionaryItem::toResult)
|
||||
.toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询指定目录下的内容
|
||||
*/
|
||||
public PageResult<DictionaryItemResult> pageByDictionaryId(Long dictionaryId, PageParam pageParam) {
|
||||
Page<DictionaryItem> dictionaryItems = dictionaryItemManager.findAllByDictionaryId(dictionaryId, pageParam);
|
||||
return MpUtil.toPageResult(dictionaryItems);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断编码是否存在
|
||||
*/
|
||||
public boolean existsByCode(String code, Long dictId) {
|
||||
return dictionaryItemManager.existsByCode(code, dictId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断编码是否存在
|
||||
*/
|
||||
public boolean existsByCode(String code, Long dictId, Long id) {
|
||||
return dictionaryItemManager.existsByCode(code, dictId, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部字典项
|
||||
*/
|
||||
public List<DictionaryItemResult> findAll() {
|
||||
return dictionaryItemManager.findAll()
|
||||
.stream()
|
||||
.sorted(Comparator.comparing(DictionaryItem::getDictId)
|
||||
.thenComparing(DictionaryItem::getSortNo)
|
||||
.thenComparing(MpIdEntity::getId))
|
||||
.map(DictionaryItem::toResult)
|
||||
.toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取启用的字典项列表
|
||||
*/
|
||||
@Cacheable(value = "cache:dict", key = "'all'")
|
||||
public List<DictionaryItemResult> findAllByEnable() {
|
||||
|
||||
// 获取被停用的字典
|
||||
List<Long> disableDictIds = dictionaryManager.findAllByEnable(false)
|
||||
.stream()
|
||||
.map(MpIdEntity::getId)
|
||||
.toList();
|
||||
|
||||
// 过滤掉被停用的字典项
|
||||
return dictionaryItemManager.findAllByEnable(true)
|
||||
.stream()
|
||||
.filter(o -> !disableDictIds.contains(o.getDictId()))
|
||||
.sorted(Comparator.comparing(DictionaryItem::getDictId)
|
||||
.thenComparing(DictionaryItem::getSortNo)
|
||||
.thenComparing(MpIdEntity::getId))
|
||||
.map(DictionaryItem::toResult)
|
||||
.peek(item -> item.setEnable(null).setId(null).setCreateTime(null).setDictId(null).setRemark(null))
|
||||
.toList();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,123 @@
|
||||
package cn.bootx.platform.baseapi.service.dict;
|
||||
|
||||
import cn.bootx.platform.baseapi.convert.dict.DictionaryConvert;
|
||||
import cn.bootx.platform.baseapi.dao.dict.DictionaryItemManager;
|
||||
import cn.bootx.platform.baseapi.dao.dict.DictionaryManager;
|
||||
import cn.bootx.platform.baseapi.entity.dict.Dictionary;
|
||||
import cn.bootx.platform.baseapi.param.dict.DictionaryParam;
|
||||
import cn.bootx.platform.baseapi.result.dict.DictionaryResult;
|
||||
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
|
||||
import cn.bootx.platform.core.exception.BizException;
|
||||
import cn.bootx.platform.core.exception.DataNotExistException;
|
||||
import cn.bootx.platform.core.rest.param.PageParam;
|
||||
import cn.bootx.platform.core.rest.result.PageResult;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author xxm
|
||||
* @since 2020/4/10 15:52
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class DictionaryService {
|
||||
|
||||
private final DictionaryManager dictionaryManager;
|
||||
|
||||
private final DictionaryItemManager dictionaryItemManager;
|
||||
|
||||
/**
|
||||
* 添加字典
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@CacheEvict(value = "cache:dict", allEntries = true)
|
||||
public DictionaryResult add(DictionaryParam param) {
|
||||
if (dictionaryManager.existsByCode(param.getCode())) {
|
||||
throw new BizException("字典编码已存在");
|
||||
}
|
||||
Dictionary dictionary = DictionaryConvert.CONVERT.convert(param);
|
||||
dictionaryManager.save(dictionary);
|
||||
return dictionary.toResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字典
|
||||
*/
|
||||
@CacheEvict(value = "cache:dict", allEntries = true)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Long id) {
|
||||
|
||||
if (!dictionaryManager.existedById(id)) {
|
||||
throw new BizException("字典不存在");
|
||||
}
|
||||
if (dictionaryItemManager.existsByDictId(id)) {
|
||||
throw new BizException("字典下有字典项,不能删除");
|
||||
}
|
||||
dictionaryManager.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*/
|
||||
@CacheEvict(value = "cache:dict", allEntries = true)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public DictionaryResult update(DictionaryParam param) {
|
||||
|
||||
Dictionary dictionary = dictionaryManager.findById(param.getId())
|
||||
.orElseThrow(()->new DataNotExistException("字典不存在"));
|
||||
|
||||
// 判断字典是否重名
|
||||
if (dictionaryManager.existsByCode(param.getCode(), param.getId())) {
|
||||
throw new BizException("字典编码已存在");
|
||||
}
|
||||
// 更新字典项
|
||||
BeanUtil.copyProperties(param, dictionary, CopyOptions.create().ignoreNullValue());
|
||||
dictionaryItemManager.updateDictCode(dictionary.getId(), dictionary.getCode());
|
||||
dictionaryManager.updateById(dictionary);
|
||||
return dictionary.toResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断编码是否存在
|
||||
*/
|
||||
public boolean existsByCode(String code) {
|
||||
return dictionaryManager.existsByCode(code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断编码是否存在
|
||||
*/
|
||||
public boolean existsByCode(String code, Long id) {
|
||||
return dictionaryManager.existsByCode(code, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询指定字典
|
||||
*/
|
||||
public DictionaryResult findById(Long id) {
|
||||
return dictionaryManager.findById(id).map(Dictionary:: toResult).orElseThrow(DataNotExistException::new);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有字典
|
||||
*/
|
||||
public List<DictionaryResult> findAll() {
|
||||
List<Dictionary> dictionaries = dictionaryManager.findAll();
|
||||
return dictionaries.stream().map(Dictionary::toResult).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有字典
|
||||
*/
|
||||
public PageResult<DictionaryResult> page(PageParam pageParam, DictionaryParam param) {
|
||||
return MpUtil.toPageResult(dictionaryManager.page(pageParam, param));
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,112 @@
|
||||
package cn.bootx.platform.baseapi.service.parameter;
|
||||
|
||||
import cn.bootx.platform.baseapi.dao.parameter.SystemParamManager;
|
||||
import cn.bootx.platform.baseapi.entity.parameter.SystemParameter;
|
||||
import cn.bootx.platform.baseapi.param.parameter.SystemParameterParam;
|
||||
import cn.bootx.platform.baseapi.result.parameter.SystemParameterResult;
|
||||
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
|
||||
import cn.bootx.platform.core.exception.BizException;
|
||||
import cn.bootx.platform.core.exception.DataNotExistException;
|
||||
import cn.bootx.platform.core.rest.param.PageParam;
|
||||
import cn.bootx.platform.core.rest.result.PageResult;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 系统参数
|
||||
*
|
||||
* @author xxm
|
||||
* @since 2021/10/25
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SystemParamService {
|
||||
|
||||
private final SystemParamManager systemParamManager;
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public void add(SystemParameterParam param) {
|
||||
SystemParameter systemParameter = SystemParameter.init(param);
|
||||
if (systemParamManager.existsByKey(systemParameter.getKey())) {
|
||||
throw new BizException("key重复");
|
||||
}
|
||||
// 默认非内置
|
||||
systemParameter.setInternal(false);
|
||||
systemParamManager.save(systemParameter);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(SystemParameterParam param) {
|
||||
SystemParameter systemParameter = systemParamManager.findById(param.getId())
|
||||
.orElseThrow(() -> new BizException("参数项不存在"));
|
||||
|
||||
if (systemParamManager.existsByKey(param.getKey(), param.getId())) {
|
||||
throw new BizException("key重复");
|
||||
}
|
||||
BeanUtil.copyProperties(param, systemParameter, CopyOptions.create().ignoreNullValue());
|
||||
systemParamManager.updateById(systemParameter);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
public PageResult<SystemParameterResult> page(PageParam pageParam, SystemParameterParam param) {
|
||||
return MpUtil.toPageResult(systemParamManager.page(pageParam, param));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单条
|
||||
*/
|
||||
public SystemParameterResult findById(Long id) {
|
||||
return systemParamManager.findById(id).map(SystemParameter::toResult).orElseThrow(DataNotExistException::new);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据键名获取键值
|
||||
*/
|
||||
public String findByKey(String key) {
|
||||
var param = systemParamManager.findByKey(key).orElseThrow(DataNotExistException::new);
|
||||
if (Objects.equals(param.getEnable(), false)) {
|
||||
throw new BizException("该参数已停用");
|
||||
}
|
||||
return param.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public void delete(Long id) {
|
||||
SystemParameter systemParameter = systemParamManager.findById(id)
|
||||
.orElseThrow(() -> new BizException("系统参数不存在"));
|
||||
if (systemParameter.isInternal()) {
|
||||
throw new BizException("内置参数不可以被删除");
|
||||
}
|
||||
systemParamManager.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断编码是否存在
|
||||
*/
|
||||
public boolean existsByKey(String key) {
|
||||
return systemParamManager.existsByKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断编码是否存在
|
||||
*/
|
||||
public boolean existsByKey(String key, Long id) {
|
||||
return systemParamManager.existsByKey(key, id);
|
||||
}
|
||||
}
|
@@ -0,0 +1 @@
|
||||
cn.bootx.platform.baseapi.BaseApiApplication
|
Reference in New Issue
Block a user