Merge branch 'feature/REQ-2186' into 'master'
Feature/req 2186 See merge request universal/infrastructure/backend/nanopart!37
This commit is contained in:
commit
24b9ffb820
33
dictionary/.gitignore
vendored
Normal file
33
dictionary/.gitignore
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
33
dictionary/dictionary-api/.gitignore
vendored
Normal file
33
dictionary/dictionary-api/.gitignore
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
42
dictionary/dictionary-api/pom.xml
Normal file
42
dictionary/dictionary-api/pom.xml
Normal file
@ -0,0 +1,42 @@
|
||||
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>dictionary</artifactId>
|
||||
<groupId>cn.axzo.nanopart</groupId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<artifactId>dictionary-api</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>dictionary-api</name>
|
||||
|
||||
<properties>
|
||||
<axzo-bom.version>2.0.0-SNAPSHOT</axzo-bom.version>
|
||||
<axzo-dependencies.version>2.0.0-SNAPSHOT</axzo-dependencies.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.framework</groupId>
|
||||
<artifactId>axzo-consumer-spring-cloud-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>13.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,38 @@
|
||||
package cn.axzo.nanopart.dictionary.api;
|
||||
|
||||
import cn.axzo.framework.domain.web.result.ApiPageResult;
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.nanopart.dictionary.api.request.QueryByBatchDictTypeReq;
|
||||
import cn.axzo.nanopart.dictionary.api.request.QueryByDictTypeReq;
|
||||
import cn.axzo.nanopart.dictionary.api.response.QueryByDictTypeResp;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 字典相关 api
|
||||
*
|
||||
* @author xudawei
|
||||
* @version 1.0
|
||||
* @date 2024/04/29
|
||||
*/
|
||||
@FeignClient(name = "nanopart", url = "${axzo.service.nanopart:http://nanopart:8080}")
|
||||
public interface DictionaryApi {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@PostMapping("/api/dictionary/page")
|
||||
ApiPageResult<QueryByDictTypeResp> queryByType(@RequestBody @Valid QueryByDictTypeReq req);
|
||||
|
||||
/**
|
||||
* 通过dictType批量查询
|
||||
*/
|
||||
@PostMapping("/api/dictionary/batchQuery")
|
||||
ApiResult<Map<String, List<QueryByDictTypeResp>>> queryByBatchType(@RequestBody @Valid QueryByBatchDictTypeReq req);
|
||||
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package cn.axzo.nanopart.dictionary.api.request;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xudawei
|
||||
* @date 2024/4/29
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class QueryByBatchDictTypeReq {
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
@NotEmpty(message = "dictTypes is blank")
|
||||
private List<String> dictTypes;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package cn.axzo.nanopart.dictionary.api.request;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* @author xudawei
|
||||
* @date 2024/4/29
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class QueryByDictTypeReq {
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
@NotBlank(message = "dictType is blank")
|
||||
private String dictType;
|
||||
|
||||
/**
|
||||
* 页码
|
||||
*/
|
||||
private Integer pageNumber;
|
||||
|
||||
/**
|
||||
* 每页条数
|
||||
*/
|
||||
private Integer pageSize;
|
||||
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package cn.axzo.nanopart.dictionary.api.request;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xudawei
|
||||
* @date 2024/5/6
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class QueryDictReq {
|
||||
|
||||
/**
|
||||
* 字典类型集合
|
||||
*/
|
||||
private List<String> dictTypes;
|
||||
|
||||
/**
|
||||
* 字典key
|
||||
*/
|
||||
private String dictKey;
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
package cn.axzo.nanopart.dictionary.api.request;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @author xudawei
|
||||
* @date 2024/4/29
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class QueryPageDictReq {
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
private String dictType;
|
||||
|
||||
/**
|
||||
* 字典key
|
||||
*/
|
||||
private String dictKey;
|
||||
|
||||
/**
|
||||
* 页码
|
||||
*/
|
||||
private Integer pageNumber;
|
||||
|
||||
/**
|
||||
* 每页条数
|
||||
*/
|
||||
private Integer pageSize;
|
||||
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package cn.axzo.nanopart.dictionary.api.response;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xudawei
|
||||
* @date 2024/4/29
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class QueryByBatchDictTypeResp {
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private String dictType;
|
||||
/**
|
||||
* 集合
|
||||
*/
|
||||
private List<QueryByDictTypeResp> dataList;
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
package cn.axzo.nanopart.dictionary.api.response;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @author xudawei
|
||||
* @date 2024/4/29
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class QueryByDictTypeResp {
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private String dictType;
|
||||
|
||||
/**
|
||||
* 字典key
|
||||
*/
|
||||
private String dictKey;
|
||||
|
||||
/**
|
||||
* 值
|
||||
*/
|
||||
private String dictValue;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer orderBy;
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
package cn.axzo.nanopart.dictionary.api.response;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @author xudawei
|
||||
* @date 2024/4/29
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class QueryDictResp {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private String dictType;
|
||||
|
||||
/**
|
||||
* 字典key
|
||||
*/
|
||||
private String dictKey;
|
||||
|
||||
/**
|
||||
* 值
|
||||
*/
|
||||
private String dictValue;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer orderBy;
|
||||
|
||||
/**
|
||||
* 是否删除:0否,1是
|
||||
*/
|
||||
private String isDelete;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
spring.application.name=dictionary-api
|
||||
@ -0,0 +1,13 @@
|
||||
package cn.axzo.nanopart.dictionary.api;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class DictionaryApiApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
33
dictionary/dictionary-server/.gitignore
vendored
Normal file
33
dictionary/dictionary-server/.gitignore
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
76
dictionary/dictionary-server/pom.xml
Normal file
76
dictionary/dictionary-server/pom.xml
Normal file
@ -0,0 +1,76 @@
|
||||
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>dictionary</artifactId>
|
||||
<groupId>cn.axzo.nanopart</groupId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<groupId>cn.axzo.nanopart</groupId>
|
||||
<artifactId>dictionary-server</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>dictionary-server</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.framework</groupId>
|
||||
<artifactId>axzo-web-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.framework</groupId>
|
||||
<artifactId>axzo-spring-cloud-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.framework</groupId>
|
||||
<artifactId>axzo-consumer-spring-cloud-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.framework</groupId>
|
||||
<artifactId>axzo-processor-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<!--mybatis-plus-->
|
||||
<dependency>
|
||||
<groupId>cn.axzo.framework</groupId>
|
||||
<artifactId>axzo-mybatisplus-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<!-- swagger-yapi -->
|
||||
<dependency>
|
||||
<groupId>cn.axzo.framework</groupId>
|
||||
<artifactId>axzo-swagger-yapi-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<!-- druid -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.axzo.framework</groupId>
|
||||
<artifactId>axzo-logger-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.redisson</groupId>
|
||||
<artifactId>redisson-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.axzo.pokonyan</groupId>
|
||||
<artifactId>pokonyan</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.axzo.nanopart</groupId>
|
||||
<artifactId>dictionary-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,74 @@
|
||||
package cn.axzo.nanopart.dictionary.server.controller;
|
||||
|
||||
import cn.axzo.framework.domain.web.result.ApiPageResult;
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.nanopart.dictionary.api.DictionaryApi;
|
||||
import cn.axzo.nanopart.dictionary.api.request.QueryByBatchDictTypeReq;
|
||||
import cn.axzo.nanopart.dictionary.api.request.QueryByDictTypeReq;
|
||||
import cn.axzo.nanopart.dictionary.api.request.QueryDictReq;
|
||||
import cn.axzo.nanopart.dictionary.api.request.QueryPageDictReq;
|
||||
import cn.axzo.nanopart.dictionary.api.response.QueryByDictTypeResp;
|
||||
import cn.axzo.nanopart.dictionary.server.domain.Dictionary;
|
||||
import cn.axzo.nanopart.dictionary.server.service.DictionaryService;
|
||||
import cn.axzo.pokonyan.dao.converter.PageConverter;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.collect.Maps;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
* @author xudawei
|
||||
* @date 2024/4/29
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class DictionaryController implements DictionaryApi {
|
||||
|
||||
@Autowired
|
||||
private DictionaryService dictionaryService;
|
||||
|
||||
@Override
|
||||
public ApiPageResult<QueryByDictTypeResp> queryByType(@RequestBody @Valid QueryByDictTypeReq req) {
|
||||
Page<Dictionary> page = dictionaryService.page(BeanUtil.copyProperties(req, QueryPageDictReq.class));
|
||||
return ApiPageResult.ok(PageConverter.convert(page, record -> BeanUtil.toBean(record, QueryByDictTypeResp.class)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过dictType批量查询
|
||||
*/
|
||||
@Override
|
||||
public ApiResult<Map<String, List<QueryByDictTypeResp>>> queryByBatchType(@RequestBody @Valid QueryByBatchDictTypeReq req) {
|
||||
List<Dictionary> list = dictionaryService.query(BeanUtil.copyProperties(req, QueryDictReq.class));
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return ApiResult.ok();
|
||||
}
|
||||
Map<String, List<Dictionary>> map = list.stream().collect(Collectors.groupingBy(Dictionary::getDictType, Collectors.toList()));
|
||||
return ApiResult.ok(this.buildDictTypeMap(map));
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建QueryByDictTypeResp集合Map
|
||||
*/
|
||||
private Map<String, List<QueryByDictTypeResp>> buildDictTypeMap(Map<String, List<Dictionary>> map) {
|
||||
Map<String, List<QueryByDictTypeResp>> resultMap = Maps.newHashMap();
|
||||
if (!CollectionUtils.isEmpty(map)) {
|
||||
map.forEach((dictType, dictList) -> {
|
||||
List<QueryByDictTypeResp> respList = BeanUtil.copyToList(dictList, QueryByDictTypeResp.class);
|
||||
resultMap.put(dictType, respList);
|
||||
});
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,62 @@
|
||||
package cn.axzo.nanopart.dictionary.server.domain;
|
||||
|
||||
import cn.axzo.pokonyan.config.mybatisplus.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 应用版本信息
|
||||
*
|
||||
* @author xudawei
|
||||
* @date 2024/4/29
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName(value = "nanopart_dictionary", autoResultMap = true)
|
||||
public class Dictionary extends BaseEntity<Dictionary> {
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@TableField(value = "dict_type")
|
||||
private String dictType;
|
||||
|
||||
/**
|
||||
* 字典key
|
||||
*/
|
||||
@TableField(value = "dict_key")
|
||||
private String dictKey;
|
||||
|
||||
/**
|
||||
* 值
|
||||
*/
|
||||
@TableField(value = "dict_value")
|
||||
private String dictValue;
|
||||
|
||||
/**
|
||||
* 排序:倒序,值越大越靠前
|
||||
*/
|
||||
@TableField(value = "order_by")
|
||||
private Integer orderBy;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(value = "create_by")
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@TableField(value = "update_by")
|
||||
private Long updateBy;
|
||||
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package cn.axzo.nanopart.dictionary.server.mapper;
|
||||
|
||||
import cn.axzo.nanopart.dictionary.server.domain.Dictionary;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author chenwenjian
|
||||
* @version 1.0
|
||||
* @date 2024/4/5 11:02
|
||||
*/
|
||||
@Mapper
|
||||
public interface DictionaryDao extends BaseMapper<Dictionary> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package cn.axzo.nanopart.dictionary.server.service;
|
||||
|
||||
import cn.axzo.nanopart.dictionary.api.request.QueryDictReq;
|
||||
import cn.axzo.nanopart.dictionary.api.request.QueryPageDictReq;
|
||||
import cn.axzo.nanopart.dictionary.server.domain.Dictionary;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xudawei
|
||||
* @date 2024/4/29
|
||||
*/
|
||||
public interface DictionaryService {
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*/
|
||||
List<Dictionary> query(QueryDictReq req);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
Page<Dictionary> page(QueryPageDictReq req);
|
||||
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
package cn.axzo.nanopart.dictionary.server.service.impl;
|
||||
|
||||
import cn.axzo.nanopart.dictionary.api.request.QueryDictReq;
|
||||
import cn.axzo.nanopart.dictionary.api.request.QueryPageDictReq;
|
||||
import cn.axzo.nanopart.dictionary.server.domain.Dictionary;
|
||||
import cn.axzo.nanopart.dictionary.server.mapper.DictionaryDao;
|
||||
import cn.axzo.nanopart.dictionary.server.service.DictionaryService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.compress.utils.Lists;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author xudawei
|
||||
* @date 2024/4/29
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DictionaryServiceImpl extends ServiceImpl<DictionaryDao, Dictionary> implements DictionaryService {
|
||||
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*/
|
||||
@Override
|
||||
public List<Dictionary> query(QueryDictReq req) {
|
||||
if (StringUtils.isBlank(req.getDictKey()) && CollectionUtils.isEmpty(req.getDictTypes())) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
LambdaQueryWrapper<Dictionary> queryWrapper = buildLambdaQueryWrapper(StringUtils.EMPTY, req.getDictKey(), req.getDictTypes());
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@Override
|
||||
public Page<Dictionary> page(QueryPageDictReq req) {
|
||||
if (StringUtils.isBlank(req.getDictKey()) && StringUtils.isBlank(req.getDictType())) {
|
||||
return new Page<>(req.getPageNumber(), req.getPageSize(), 0);
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<Dictionary> pageLambdaQueryWrapper = buildLambdaQueryWrapper(req.getDictType(), req.getDictKey(), Lists.newArrayList());
|
||||
|
||||
Page<Dictionary> dictionaryPage = this.page(new Page<>(req.getPageNumber(), req.getPageSize()), pageLambdaQueryWrapper);
|
||||
if (Objects.isNull(dictionaryPage) || dictionaryPage.getTotal() == 0) {
|
||||
return new Page<>(req.getPageNumber(), req.getPageSize(), 0);
|
||||
}
|
||||
return dictionaryPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建分页查询条件
|
||||
*/
|
||||
private LambdaQueryWrapper<Dictionary> buildLambdaQueryWrapper(String dictType, String dictKey, List<String> dictTypes) {
|
||||
LambdaQueryWrapper<Dictionary> lambdaQueryWrapper = new LambdaQueryWrapper<Dictionary>();
|
||||
return lambdaQueryWrapper
|
||||
.like(StringUtils.isNotEmpty(dictType), Dictionary::getDictType, dictType)
|
||||
.in(!CollectionUtils.isEmpty(dictTypes), Dictionary::getDictType, dictTypes)
|
||||
.eq(StringUtils.isNotEmpty(dictKey), Dictionary::getDictKey, dictKey)
|
||||
.eq(Dictionary::getIsDelete, 0)
|
||||
.orderByDesc(Dictionary::getOrderBy);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
spring.application.name=dictionary-server
|
||||
@ -0,0 +1,13 @@
|
||||
package cn.axzo.nanopart.dictionary.server;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class DictionaryServerApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
62
dictionary/pom.xml
Normal file
62
dictionary/pom.xml
Normal file
@ -0,0 +1,62 @@
|
||||
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>cn.axzo.nanopart</groupId>
|
||||
<artifactId>nanopart</artifactId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<artifactId>dictionary</artifactId>
|
||||
<name>dictionary</name>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>dictionary-api</module>
|
||||
<module>dictionary-server</module>
|
||||
</modules>
|
||||
<properties>
|
||||
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.nanopart</groupId>
|
||||
<artifactId>banner-api</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>axzo</id>
|
||||
<name>axzo repository</name>
|
||||
<url>https://nexus.axzo.cn/repository/axzo/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
</project>
|
||||
@ -109,6 +109,18 @@
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.axzo.nanopart</groupId>
|
||||
<artifactId>dictionary-server</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.axzo.nanopart</groupId>
|
||||
<artifactId>dictionary-api</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.axzo.nanopart</groupId>
|
||||
<artifactId>op-api</artifactId>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user