feat: 数据字典相关接口提交
This commit is contained in:
@ -17,6 +17,10 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-validation</artifactId>
|
||||||
|
</dependency>
|
||||||
<!-- jjwt -->
|
<!-- jjwt -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.jsonwebtoken</groupId>
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
|||||||
@ -0,0 +1,25 @@
|
|||||||
|
package day.gitlab.dolphin.common.core.entity;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.Min;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class PageRequest {
|
||||||
|
|
||||||
|
/** 当前分页,默认1 */
|
||||||
|
@Min(1)
|
||||||
|
@NotNull
|
||||||
|
private Long pageNumber = 1L;
|
||||||
|
|
||||||
|
/** 分页条数,默认10 */
|
||||||
|
@Min(1)
|
||||||
|
@NotNull
|
||||||
|
private Long pageSize = 10L;
|
||||||
|
}
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
package day.gitlab.dolphin.common.core.entity;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class PageResponse<T> {
|
||||||
|
|
||||||
|
/** 总记录数 */
|
||||||
|
private Long total = 0L;
|
||||||
|
|
||||||
|
/** 当前分页,默认1 */
|
||||||
|
private Long pageNumber = 1L;
|
||||||
|
|
||||||
|
/** 分页条数,默认10 */
|
||||||
|
private Long pageSize = 10L;
|
||||||
|
|
||||||
|
/** 记录 */
|
||||||
|
private List<T> records;
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
package day.gitlab.dolphin.common.core.entity;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class QueryPageRequest<T> extends PageRequest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询参数
|
||||||
|
*/
|
||||||
|
private T query;
|
||||||
|
}
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
package day.gitlab.dolphin.common.mybatis;
|
||||||
|
|
||||||
|
import com.mybatisflex.core.BaseMapper;
|
||||||
|
import com.mybatisflex.core.paginate.Page;
|
||||||
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
|
import day.gitlab.dolphin.common.core.entity.PageResponse;
|
||||||
|
import day.gitlab.dolphin.common.core.entity.QueryPageRequest;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public class Pages {
|
||||||
|
|
||||||
|
public static <T, E> Page<E> paginate(BaseMapper<E> mapper, QueryPageRequest<T> pageRequest, BiFunction<T, QueryWrapper, QueryWrapper> biFunction) {
|
||||||
|
Page<E> page = new Page<>(pageRequest.getPageNumber(), pageRequest.getPageSize());
|
||||||
|
QueryWrapper wrapper = new QueryWrapper();
|
||||||
|
wrapper = biFunction.apply(pageRequest.getQuery(), wrapper);
|
||||||
|
|
||||||
|
return mapper.paginate(page, wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, E> PageResponse<E> toPageResponse(Page<T> page, Function<T, E> mapFunction) {
|
||||||
|
PageResponse<E> pageResponse = new PageResponse<>();
|
||||||
|
pageResponse.setPageNumber(page.getPageNumber());
|
||||||
|
pageResponse.setPageSize(page.getPageSize());
|
||||||
|
pageResponse.setTotal(page.getTotalRow());
|
||||||
|
|
||||||
|
if (page.getRecords() != null) {
|
||||||
|
pageResponse.setRecords(page.getRecords().stream().map(mapFunction).filter(Objects::nonNull).toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
return pageResponse;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -9,6 +9,6 @@ public class UUIDv7KeyGenerator implements IKeyGenerator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object generate(Object entity, String keyColumn) {
|
public Object generate(Object entity, String keyColumn) {
|
||||||
return UUIDv7.randomUUID().timestamp();
|
return UUIDv7.randomUUID().toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,5 +17,6 @@ spring:
|
|||||||
port: 10001
|
port: 10001
|
||||||
database: 0
|
database: 0
|
||||||
password: 123456
|
password: 123456
|
||||||
|
jackson:
|
||||||
|
date-format: yyyy-MM-dd HH:mm:ss
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,12 @@
|
|||||||
00000000=success
|
00000000=success
|
||||||
99999999=failure
|
99999999=failure
|
||||||
|
|
||||||
00010001=Unauthorized
|
00010001=Unauthorized
|
||||||
00010002=Token invalid
|
00010002=Token invalid
|
||||||
00010003=Token expired
|
00010003=Token expired
|
||||||
00010004=Refresh Token expired
|
00010004=Refresh Token expired
|
||||||
00010005=Forbidden
|
00010005=Forbidden
|
||||||
00010101=Username or password is incorrect
|
00010101=Username or password is incorrect
|
||||||
00010102=User is not enabled
|
00010102=User is not enabled
|
||||||
|
|
||||||
|
00020101=Fields required:[{0}]
|
||||||
@ -3,6 +3,7 @@
|
|||||||
99999999=失败
|
99999999=失败
|
||||||
|
|
||||||
# 00 系统
|
# 00 系统
|
||||||
|
|
||||||
# 0001 系统->认证授权
|
# 0001 系统->认证授权
|
||||||
00010001=未授权
|
00010001=未授权
|
||||||
00010002=令牌无效
|
00010002=令牌无效
|
||||||
@ -12,3 +13,6 @@
|
|||||||
# 000101 系统->认证授权->登录
|
# 000101 系统->认证授权->登录
|
||||||
00010101=用户名或密码错误
|
00010101=用户名或密码错误
|
||||||
00010102=用户已被禁用
|
00010102=用户已被禁用
|
||||||
|
|
||||||
|
# 0002 核心模块
|
||||||
|
00020101=字段不能为空:[{0}]
|
||||||
|
|||||||
@ -0,0 +1,6 @@
|
|||||||
|
package day.gitlab.dolphin.core.constants;
|
||||||
|
|
||||||
|
public class Exceptions {
|
||||||
|
|
||||||
|
public static final String FIELD_REQUIRED = "00020101";
|
||||||
|
}
|
||||||
@ -1,18 +1,15 @@
|
|||||||
package day.gitlab.dolphin.core.controller;
|
package day.gitlab.dolphin.core.controller;
|
||||||
|
|
||||||
import com.mybatisflex.core.paginate.Page;
|
import day.gitlab.dolphin.common.core.entity.PageResponse;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import day.gitlab.dolphin.common.core.entity.QueryPageRequest;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import day.gitlab.dolphin.common.core.entity.Result;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import day.gitlab.dolphin.common.security.annotation.AuthorityCheck;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import day.gitlab.dolphin.common.security.annotation.AuthorityType;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
import day.gitlab.dolphin.core.entity.dto.DictionaryDTO;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import day.gitlab.dolphin.core.entity.vo.DictionaryVO;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import day.gitlab.dolphin.core.entity.Dictionary;
|
|
||||||
import day.gitlab.dolphin.core.service.DictionaryService;
|
import day.gitlab.dolphin.core.service.DictionaryService;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典 控制层。
|
* 字典 控制层。
|
||||||
@ -24,72 +21,45 @@ import java.util.List;
|
|||||||
@RequestMapping("/dictionary")
|
@RequestMapping("/dictionary")
|
||||||
public class DictionaryController {
|
public class DictionaryController {
|
||||||
|
|
||||||
@Autowired
|
@Resource
|
||||||
private DictionaryService dictionaryService;
|
private DictionaryService dictionaryService;
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存字典。
|
|
||||||
*
|
|
||||||
* @param dictionary 字典
|
|
||||||
* @return {@code true} 保存成功,{@code false} 保存失败
|
|
||||||
*/
|
|
||||||
@PostMapping("save")
|
|
||||||
public boolean save(@RequestBody Dictionary dictionary) {
|
|
||||||
return dictionaryService.save(dictionary);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键删除字典。
|
|
||||||
*
|
|
||||||
* @param id 主键
|
|
||||||
* @return {@code true} 删除成功,{@code false} 删除失败
|
|
||||||
*/
|
|
||||||
@DeleteMapping("remove/{id}")
|
|
||||||
public boolean remove(@PathVariable String id) {
|
|
||||||
return dictionaryService.removeById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键更新字典。
|
|
||||||
*
|
|
||||||
* @param dictionary 字典
|
|
||||||
* @return {@code true} 更新成功,{@code false} 更新失败
|
|
||||||
*/
|
|
||||||
@PutMapping("update")
|
|
||||||
public boolean update(@RequestBody Dictionary dictionary) {
|
|
||||||
return dictionaryService.updateById(dictionary);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询所有字典。
|
|
||||||
*
|
|
||||||
* @return 所有数据
|
|
||||||
*/
|
|
||||||
@GetMapping("list")
|
|
||||||
public List<Dictionary> list() {
|
|
||||||
return dictionaryService.list();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键获取字典。
|
|
||||||
*
|
|
||||||
* @param id 字典主键
|
|
||||||
* @return 字典详情
|
|
||||||
*/
|
|
||||||
@GetMapping("getInfo/{id}")
|
|
||||||
public Dictionary getInfo(@PathVariable String id) {
|
|
||||||
return dictionaryService.getById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询字典。
|
* 分页查询字典。
|
||||||
*
|
*
|
||||||
* @param page 分页对象
|
* @param pageRequest 分页请求参数
|
||||||
* @return 分页对象
|
* @return 分页对象
|
||||||
*/
|
*/
|
||||||
@GetMapping("page")
|
@GetMapping("paginate")
|
||||||
public Page<Dictionary> page(Page<Dictionary> page) {
|
public Result<PageResponse<DictionaryVO>> page(@RequestBody QueryPageRequest<DictionaryDTO> pageRequest) {
|
||||||
return dictionaryService.page(page);
|
return Result.success(dictionaryService.page(pageRequest));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("add")
|
||||||
|
@AuthorityCheck(type = AuthorityType.OR, value = {"ROLE00001"})
|
||||||
|
public Result<Void> add(@RequestBody DictionaryDTO dictionaryDTO) {
|
||||||
|
dictionaryService.add(dictionaryDTO);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("edit")
|
||||||
|
@AuthorityCheck(type = AuthorityType.OR, value = {"ROLE00001"})
|
||||||
|
public Result<Void> edit(@RequestBody DictionaryDTO dictionaryDTO) {
|
||||||
|
dictionaryService.edit(dictionaryDTO);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("delete")
|
||||||
|
@AuthorityCheck(type = AuthorityType.OR, value = {"ROLE00001"})
|
||||||
|
public Result<Void> delete(@RequestBody DictionaryDTO dictionaryDTO) {
|
||||||
|
dictionaryService.delete(dictionaryDTO.getId());
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("deleteBatch")
|
||||||
|
@AuthorityCheck(type = AuthorityType.OR, value = {"ROLE00001"})
|
||||||
|
public Result<Void> deleteBatch(@RequestBody DictionaryDTO dictionaryDTO) {
|
||||||
|
dictionaryService.deleteBatch(dictionaryDTO.getIds());
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +1,7 @@
|
|||||||
package day.gitlab.dolphin.core.controller;
|
package day.gitlab.dolphin.core.controller;
|
||||||
|
|
||||||
import com.mybatisflex.core.paginate.Page;
|
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import day.gitlab.dolphin.core.entity.DictionaryItem;
|
|
||||||
import day.gitlab.dolphin.core.service.DictionaryItemService;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典项 控制层。
|
* 字典项 控制层。
|
||||||
@ -23,73 +12,4 @@ import java.util.List;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/dictionaryItem")
|
@RequestMapping("/dictionaryItem")
|
||||||
public class DictionaryItemController {
|
public class DictionaryItemController {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private DictionaryItemService dictionaryItemService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存字典项。
|
|
||||||
*
|
|
||||||
* @param dictionaryItem 字典项
|
|
||||||
* @return {@code true} 保存成功,{@code false} 保存失败
|
|
||||||
*/
|
|
||||||
@PostMapping("save")
|
|
||||||
public boolean save(@RequestBody DictionaryItem dictionaryItem) {
|
|
||||||
return dictionaryItemService.save(dictionaryItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键删除字典项。
|
|
||||||
*
|
|
||||||
* @param id 主键
|
|
||||||
* @return {@code true} 删除成功,{@code false} 删除失败
|
|
||||||
*/
|
|
||||||
@DeleteMapping("remove/{id}")
|
|
||||||
public boolean remove(@PathVariable String id) {
|
|
||||||
return dictionaryItemService.removeById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键更新字典项。
|
|
||||||
*
|
|
||||||
* @param dictionaryItem 字典项
|
|
||||||
* @return {@code true} 更新成功,{@code false} 更新失败
|
|
||||||
*/
|
|
||||||
@PutMapping("update")
|
|
||||||
public boolean update(@RequestBody DictionaryItem dictionaryItem) {
|
|
||||||
return dictionaryItemService.updateById(dictionaryItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询所有字典项。
|
|
||||||
*
|
|
||||||
* @return 所有数据
|
|
||||||
*/
|
|
||||||
@GetMapping("list")
|
|
||||||
public List<DictionaryItem> list() {
|
|
||||||
return dictionaryItemService.list();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键获取字典项。
|
|
||||||
*
|
|
||||||
* @param id 字典项主键
|
|
||||||
* @return 字典项详情
|
|
||||||
*/
|
|
||||||
@GetMapping("getInfo/{id}")
|
|
||||||
public DictionaryItem getInfo(@PathVariable String id) {
|
|
||||||
return dictionaryItemService.getById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页查询字典项。
|
|
||||||
*
|
|
||||||
* @param page 分页对象
|
|
||||||
* @return 分页对象
|
|
||||||
*/
|
|
||||||
@GetMapping("page")
|
|
||||||
public Page<DictionaryItem> page(Page<DictionaryItem> page) {
|
|
||||||
return dictionaryItemService.page(page);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package day.gitlab.dolphin.core.entity;
|
package day.gitlab.dolphin.core.entity;
|
||||||
|
|
||||||
import com.mybatisflex.annotation.Id;
|
import com.mybatisflex.annotation.Id;
|
||||||
|
import com.mybatisflex.annotation.KeyType;
|
||||||
import com.mybatisflex.annotation.Table;
|
import com.mybatisflex.annotation.Table;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
|||||||
@ -0,0 +1,27 @@
|
|||||||
|
package day.gitlab.dolphin.core.entity.dto;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class DictionaryDTO {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
private List<String> ids;
|
||||||
|
}
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
package day.gitlab.dolphin.core.entity.dto;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.Min;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class DictionarySearchParamsDTO {
|
||||||
|
|
||||||
|
@Min(1)
|
||||||
|
@NotNull
|
||||||
|
private Long current;
|
||||||
|
|
||||||
|
@Min(1)
|
||||||
|
@NotNull
|
||||||
|
private Long size;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
package day.gitlab.dolphin.core.entity.vo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class DictionaryVO {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
private Timestamp createTime;
|
||||||
|
|
||||||
|
private Timestamp updateTime;
|
||||||
|
}
|
||||||
@ -1,8 +1,14 @@
|
|||||||
package day.gitlab.dolphin.core.mapper;
|
package day.gitlab.dolphin.core.mapper;
|
||||||
|
|
||||||
|
import com.mybatisflex.core.paginate.Page;
|
||||||
|
import day.gitlab.dolphin.common.core.entity.QueryPageRequest;
|
||||||
|
import day.gitlab.dolphin.common.mybatis.Pages;
|
||||||
|
import day.gitlab.dolphin.core.entity.dto.DictionaryDTO;
|
||||||
|
import day.gitlab.dolphin.core.entity.table.DictionaryTableDef;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import com.mybatisflex.core.BaseMapper;
|
import com.mybatisflex.core.BaseMapper;
|
||||||
import day.gitlab.dolphin.core.entity.Dictionary;
|
import day.gitlab.dolphin.core.entity.Dictionary;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典 映射层。
|
* 字典 映射层。
|
||||||
@ -13,4 +19,19 @@ import day.gitlab.dolphin.core.entity.Dictionary;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface DictionaryMapper extends BaseMapper<Dictionary> {
|
public interface DictionaryMapper extends BaseMapper<Dictionary> {
|
||||||
|
|
||||||
|
default Page<Dictionary> page(QueryPageRequest<DictionaryDTO> pageRequest) {
|
||||||
|
return Pages.paginate(this, pageRequest, (dict, wrapper) -> {
|
||||||
|
if (StringUtils.hasText(dict.getName())) {
|
||||||
|
wrapper.and(DictionaryTableDef.DICTIONARY.NAME.like(dict.getName()));
|
||||||
|
}
|
||||||
|
if (StringUtils.hasText(dict.getCode())) {
|
||||||
|
wrapper.and(DictionaryTableDef.DICTIONARY.CODE.like(dict.getCode()));
|
||||||
|
}
|
||||||
|
if (StringUtils.hasText(dict.getType())) {
|
||||||
|
wrapper.and(DictionaryTableDef.DICTIONARY.TYPE.eq(dict.getType()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return wrapper;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,11 @@
|
|||||||
package day.gitlab.dolphin.core.service;
|
package day.gitlab.dolphin.core.service;
|
||||||
|
|
||||||
import com.mybatisflex.core.service.IService;
|
|
||||||
import day.gitlab.dolphin.core.entity.DictionaryItem;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典项 服务层。
|
* 字典项 服务层。
|
||||||
*
|
*
|
||||||
* @author jiangyc
|
* @author jiangyc
|
||||||
* @since 2025-11-28
|
* @since 2025-11-28
|
||||||
*/
|
*/
|
||||||
public interface DictionaryItemService extends IService<DictionaryItem> {
|
public interface DictionaryItemService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,11 @@
|
|||||||
package day.gitlab.dolphin.core.service;
|
package day.gitlab.dolphin.core.service;
|
||||||
|
|
||||||
import com.mybatisflex.core.service.IService;
|
import day.gitlab.dolphin.common.core.entity.PageResponse;
|
||||||
import day.gitlab.dolphin.core.entity.Dictionary;
|
import day.gitlab.dolphin.common.core.entity.QueryPageRequest;
|
||||||
|
import day.gitlab.dolphin.core.entity.dto.DictionaryDTO;
|
||||||
|
import day.gitlab.dolphin.core.entity.vo.DictionaryVO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典 服务层。
|
* 字典 服务层。
|
||||||
@ -9,6 +13,15 @@ import day.gitlab.dolphin.core.entity.Dictionary;
|
|||||||
* @author jiangyc
|
* @author jiangyc
|
||||||
* @since 2025-11-28
|
* @since 2025-11-28
|
||||||
*/
|
*/
|
||||||
public interface DictionaryService extends IService<Dictionary> {
|
public interface DictionaryService {
|
||||||
|
|
||||||
|
PageResponse<DictionaryVO> page(QueryPageRequest<DictionaryDTO> pageRequest);
|
||||||
|
|
||||||
|
void add(DictionaryDTO dictionaryDTO);
|
||||||
|
|
||||||
|
void edit(DictionaryDTO dictionaryDTO);
|
||||||
|
|
||||||
|
void delete(String id);
|
||||||
|
|
||||||
|
void deleteBatch(List<String> ids);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,5 @@
|
|||||||
package day.gitlab.dolphin.core.service.impl;
|
package day.gitlab.dolphin.core.service.impl;
|
||||||
|
|
||||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
|
||||||
import day.gitlab.dolphin.core.entity.DictionaryItem;
|
|
||||||
import day.gitlab.dolphin.core.mapper.DictionaryItemMapper;
|
|
||||||
import day.gitlab.dolphin.core.service.DictionaryItemService;
|
import day.gitlab.dolphin.core.service.DictionaryItemService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -13,6 +10,6 @@ import org.springframework.stereotype.Service;
|
|||||||
* @since 2025-11-28
|
* @since 2025-11-28
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class DictionaryItemServiceImpl extends ServiceImpl<DictionaryItemMapper, DictionaryItem> implements DictionaryItemService{
|
public class DictionaryItemServiceImpl implements DictionaryItemService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,24 @@
|
|||||||
package day.gitlab.dolphin.core.service.impl;
|
package day.gitlab.dolphin.core.service.impl;
|
||||||
|
|
||||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
import com.mybatisflex.core.paginate.Page;
|
||||||
|
import day.gitlab.dolphin.common.core.entity.PageResponse;
|
||||||
|
import day.gitlab.dolphin.common.core.entity.QueryPageRequest;
|
||||||
|
import day.gitlab.dolphin.common.core.i18n.MessagesHelper;
|
||||||
|
import day.gitlab.dolphin.common.mybatis.Pages;
|
||||||
|
import day.gitlab.dolphin.core.constants.Exceptions;
|
||||||
import day.gitlab.dolphin.core.entity.Dictionary;
|
import day.gitlab.dolphin.core.entity.Dictionary;
|
||||||
|
import day.gitlab.dolphin.core.entity.dto.DictionaryDTO;
|
||||||
|
import day.gitlab.dolphin.core.entity.vo.DictionaryVO;
|
||||||
import day.gitlab.dolphin.core.mapper.DictionaryMapper;
|
import day.gitlab.dolphin.core.mapper.DictionaryMapper;
|
||||||
import day.gitlab.dolphin.core.service.DictionaryService;
|
import day.gitlab.dolphin.core.service.DictionaryService;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典 服务层实现。
|
* 字典 服务层实现。
|
||||||
@ -13,6 +27,86 @@ import org.springframework.stereotype.Service;
|
|||||||
* @since 2025-11-28
|
* @since 2025-11-28
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class DictionaryServiceImpl extends ServiceImpl<DictionaryMapper, Dictionary> implements DictionaryService{
|
public class DictionaryServiceImpl implements DictionaryService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DictionaryMapper dictionaryMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MessagesHelper messagesHelper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResponse<DictionaryVO> page(QueryPageRequest<DictionaryDTO> pageRequest) {
|
||||||
|
Page<Dictionary> page = dictionaryMapper.page(pageRequest);
|
||||||
|
|
||||||
|
return Pages.toPageResponse(page, (rec) -> {
|
||||||
|
DictionaryVO vo = new DictionaryVO();
|
||||||
|
vo.setId(rec.getId());
|
||||||
|
vo.setName(rec.getName());
|
||||||
|
vo.setCode(rec.getCode());
|
||||||
|
vo.setType(rec.getType());
|
||||||
|
vo.setDescription(rec.getDescription());
|
||||||
|
vo.setCreateTime(rec.getCreateTime());
|
||||||
|
vo.setUpdateTime(rec.getUpdateTime());
|
||||||
|
return vo;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void add(DictionaryDTO dictionaryDTO) {
|
||||||
|
validate(dictionaryDTO);
|
||||||
|
|
||||||
|
Dictionary dict = Dictionary.builder()
|
||||||
|
.name(dictionaryDTO.getName())
|
||||||
|
.code(dictionaryDTO.getCode())
|
||||||
|
.type(dictionaryDTO.getType())
|
||||||
|
.description(dictionaryDTO.getDescription())
|
||||||
|
.createTime(Timestamp.from(Instant.now()))
|
||||||
|
.updateTime(Timestamp.from(Instant.now()))
|
||||||
|
.build();
|
||||||
|
dictionaryMapper.insert(dict);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void edit(DictionaryDTO dictionaryDTO) {
|
||||||
|
validate(dictionaryDTO);
|
||||||
|
|
||||||
|
Dictionary dict = Dictionary.builder()
|
||||||
|
.id(dictionaryDTO.getId())
|
||||||
|
.name(dictionaryDTO.getName())
|
||||||
|
.code(dictionaryDTO.getCode())
|
||||||
|
.type(dictionaryDTO.getType())
|
||||||
|
.description(dictionaryDTO.getDescription())
|
||||||
|
.updateTime(Timestamp.from(Instant.now()))
|
||||||
|
.build();
|
||||||
|
dictionaryMapper.update(dict);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(String id) {
|
||||||
|
dictionaryMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteBatch(List<String> ids) {
|
||||||
|
dictionaryMapper.deleteBatchByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validate(DictionaryDTO dictionaryDTO) {
|
||||||
|
List<String> fields = new ArrayList<>();
|
||||||
|
|
||||||
|
if (!StringUtils.hasText(dictionaryDTO.getName())) {
|
||||||
|
fields.add("name");
|
||||||
|
}
|
||||||
|
if (!StringUtils.hasText(dictionaryDTO.getCode())) {
|
||||||
|
fields.add("code");
|
||||||
|
}
|
||||||
|
if (!StringUtils.hasText(dictionaryDTO.getType())) {
|
||||||
|
fields.add("type");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fields.isEmpty()) {
|
||||||
|
throw messagesHelper.newBusinessException(Exceptions.FIELD_REQUIRED, String.join(",", fields));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +1,7 @@
|
|||||||
package day.gitlab.dolphin.rbac.controller;
|
package day.gitlab.dolphin.rbac.controller;
|
||||||
|
|
||||||
import com.mybatisflex.core.paginate.Page;
|
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import day.gitlab.dolphin.rbac.entity.Department;
|
|
||||||
import day.gitlab.dolphin.rbac.service.DepartmentService;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门表 控制层。
|
* 部门表 控制层。
|
||||||
@ -23,73 +12,4 @@ import java.util.List;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/department")
|
@RequestMapping("/department")
|
||||||
public class DepartmentController {
|
public class DepartmentController {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private DepartmentService departmentService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存部门表。
|
|
||||||
*
|
|
||||||
* @param department 部门表
|
|
||||||
* @return {@code true} 保存成功,{@code false} 保存失败
|
|
||||||
*/
|
|
||||||
@PostMapping("save")
|
|
||||||
public boolean save(@RequestBody Department department) {
|
|
||||||
return departmentService.save(department);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键删除部门表。
|
|
||||||
*
|
|
||||||
* @param id 主键
|
|
||||||
* @return {@code true} 删除成功,{@code false} 删除失败
|
|
||||||
*/
|
|
||||||
@DeleteMapping("remove/{id}")
|
|
||||||
public boolean remove(@PathVariable String id) {
|
|
||||||
return departmentService.removeById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键更新部门表。
|
|
||||||
*
|
|
||||||
* @param department 部门表
|
|
||||||
* @return {@code true} 更新成功,{@code false} 更新失败
|
|
||||||
*/
|
|
||||||
@PutMapping("update")
|
|
||||||
public boolean update(@RequestBody Department department) {
|
|
||||||
return departmentService.updateById(department);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询所有部门表。
|
|
||||||
*
|
|
||||||
* @return 所有数据
|
|
||||||
*/
|
|
||||||
@GetMapping("list")
|
|
||||||
public List<Department> list() {
|
|
||||||
return departmentService.list();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键获取部门表。
|
|
||||||
*
|
|
||||||
* @param id 部门表主键
|
|
||||||
* @return 部门表详情
|
|
||||||
*/
|
|
||||||
@GetMapping("getInfo/{id}")
|
|
||||||
public Department getInfo(@PathVariable String id) {
|
|
||||||
return departmentService.getById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页查询部门表。
|
|
||||||
*
|
|
||||||
* @param page 分页对象
|
|
||||||
* @return 分页对象
|
|
||||||
*/
|
|
||||||
@GetMapping("page")
|
|
||||||
public Page<Department> page(Page<Department> page) {
|
|
||||||
return departmentService.page(page);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,73 +23,4 @@ import java.util.List;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/region")
|
@RequestMapping("/region")
|
||||||
public class RegionController {
|
public class RegionController {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RegionService regionService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存区划项。
|
|
||||||
*
|
|
||||||
* @param region 区划项
|
|
||||||
* @return {@code true} 保存成功,{@code false} 保存失败
|
|
||||||
*/
|
|
||||||
@PostMapping("save")
|
|
||||||
public boolean save(@RequestBody Region region) {
|
|
||||||
return regionService.save(region);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键删除区划项。
|
|
||||||
*
|
|
||||||
* @param id 主键
|
|
||||||
* @return {@code true} 删除成功,{@code false} 删除失败
|
|
||||||
*/
|
|
||||||
@DeleteMapping("remove/{id}")
|
|
||||||
public boolean remove(@PathVariable String id) {
|
|
||||||
return regionService.removeById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键更新区划项。
|
|
||||||
*
|
|
||||||
* @param region 区划项
|
|
||||||
* @return {@code true} 更新成功,{@code false} 更新失败
|
|
||||||
*/
|
|
||||||
@PutMapping("update")
|
|
||||||
public boolean update(@RequestBody Region region) {
|
|
||||||
return regionService.updateById(region);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询所有区划项。
|
|
||||||
*
|
|
||||||
* @return 所有数据
|
|
||||||
*/
|
|
||||||
@GetMapping("list")
|
|
||||||
public List<Region> list() {
|
|
||||||
return regionService.list();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键获取区划项。
|
|
||||||
*
|
|
||||||
* @param id 区划项主键
|
|
||||||
* @return 区划项详情
|
|
||||||
*/
|
|
||||||
@GetMapping("getInfo/{id}")
|
|
||||||
public Region getInfo(@PathVariable String id) {
|
|
||||||
return regionService.getById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页查询区划项。
|
|
||||||
*
|
|
||||||
* @param page 分页对象
|
|
||||||
* @return 分页对象
|
|
||||||
*/
|
|
||||||
@GetMapping("page")
|
|
||||||
public Page<Region> page(Page<Region> page) {
|
|
||||||
return regionService.page(page);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +1,7 @@
|
|||||||
package day.gitlab.dolphin.rbac.controller;
|
package day.gitlab.dolphin.rbac.controller;
|
||||||
|
|
||||||
import com.mybatisflex.core.paginate.Page;
|
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import day.gitlab.dolphin.rbac.entity.Role;
|
|
||||||
import day.gitlab.dolphin.rbac.service.RoleService;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色表 控制层。
|
* 角色表 控制层。
|
||||||
@ -23,73 +12,4 @@ import java.util.List;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/role")
|
@RequestMapping("/role")
|
||||||
public class RoleController {
|
public class RoleController {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RoleService roleService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存角色表。
|
|
||||||
*
|
|
||||||
* @param role 角色表
|
|
||||||
* @return {@code true} 保存成功,{@code false} 保存失败
|
|
||||||
*/
|
|
||||||
@PostMapping("save")
|
|
||||||
public boolean save(@RequestBody Role role) {
|
|
||||||
return roleService.save(role);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键删除角色表。
|
|
||||||
*
|
|
||||||
* @param id 主键
|
|
||||||
* @return {@code true} 删除成功,{@code false} 删除失败
|
|
||||||
*/
|
|
||||||
@DeleteMapping("remove/{id}")
|
|
||||||
public boolean remove(@PathVariable String id) {
|
|
||||||
return roleService.removeById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键更新角色表。
|
|
||||||
*
|
|
||||||
* @param role 角色表
|
|
||||||
* @return {@code true} 更新成功,{@code false} 更新失败
|
|
||||||
*/
|
|
||||||
@PutMapping("update")
|
|
||||||
public boolean update(@RequestBody Role role) {
|
|
||||||
return roleService.updateById(role);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询所有角色表。
|
|
||||||
*
|
|
||||||
* @return 所有数据
|
|
||||||
*/
|
|
||||||
@GetMapping("list")
|
|
||||||
public List<Role> list() {
|
|
||||||
return roleService.list();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键获取角色表。
|
|
||||||
*
|
|
||||||
* @param id 角色表主键
|
|
||||||
* @return 角色表详情
|
|
||||||
*/
|
|
||||||
@GetMapping("getInfo/{id}")
|
|
||||||
public Role getInfo(@PathVariable String id) {
|
|
||||||
return roleService.getById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页查询角色表。
|
|
||||||
*
|
|
||||||
* @param page 分页对象
|
|
||||||
* @return 分页对象
|
|
||||||
*/
|
|
||||||
@GetMapping("page")
|
|
||||||
public Page<Role> page(Page<Role> page) {
|
|
||||||
return roleService.page(page);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +1,7 @@
|
|||||||
package day.gitlab.dolphin.rbac.controller;
|
package day.gitlab.dolphin.rbac.controller;
|
||||||
|
|
||||||
import com.mybatisflex.core.paginate.Page;
|
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import day.gitlab.dolphin.rbac.entity.User;
|
|
||||||
import day.gitlab.dolphin.rbac.service.UserService;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户表 控制层。
|
* 用户表 控制层。
|
||||||
@ -23,73 +12,4 @@ import java.util.List;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/user")
|
@RequestMapping("/user")
|
||||||
public class UserController {
|
public class UserController {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UserService userService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存用户表。
|
|
||||||
*
|
|
||||||
* @param user 用户表
|
|
||||||
* @return {@code true} 保存成功,{@code false} 保存失败
|
|
||||||
*/
|
|
||||||
@PostMapping("save")
|
|
||||||
public boolean save(@RequestBody User user) {
|
|
||||||
return userService.save(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键删除用户表。
|
|
||||||
*
|
|
||||||
* @param id 主键
|
|
||||||
* @return {@code true} 删除成功,{@code false} 删除失败
|
|
||||||
*/
|
|
||||||
@DeleteMapping("remove/{id}")
|
|
||||||
public boolean remove(@PathVariable String id) {
|
|
||||||
return userService.removeById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键更新用户表。
|
|
||||||
*
|
|
||||||
* @param user 用户表
|
|
||||||
* @return {@code true} 更新成功,{@code false} 更新失败
|
|
||||||
*/
|
|
||||||
@PutMapping("update")
|
|
||||||
public boolean update(@RequestBody User user) {
|
|
||||||
return userService.updateById(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询所有用户表。
|
|
||||||
*
|
|
||||||
* @return 所有数据
|
|
||||||
*/
|
|
||||||
@GetMapping("list")
|
|
||||||
public List<User> list() {
|
|
||||||
return userService.list();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键获取用户表。
|
|
||||||
*
|
|
||||||
* @param id 用户表主键
|
|
||||||
* @return 用户表详情
|
|
||||||
*/
|
|
||||||
@GetMapping("getInfo/{id}")
|
|
||||||
public User getInfo(@PathVariable String id) {
|
|
||||||
return userService.getById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页查询用户表。
|
|
||||||
*
|
|
||||||
* @param page 分页对象
|
|
||||||
* @return 分页对象
|
|
||||||
*/
|
|
||||||
@GetMapping("page")
|
|
||||||
public Page<User> page(Page<User> page) {
|
|
||||||
return userService.page(page);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,11 @@
|
|||||||
package day.gitlab.dolphin.rbac.service;
|
package day.gitlab.dolphin.rbac.service;
|
||||||
|
|
||||||
import com.mybatisflex.core.service.IService;
|
|
||||||
import day.gitlab.dolphin.rbac.entity.Department;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门表 服务层。
|
* 部门表 服务层。
|
||||||
*
|
*
|
||||||
* @author jiangyc
|
* @author jiangyc
|
||||||
* @since 2025-11-28
|
* @since 2025-11-28
|
||||||
*/
|
*/
|
||||||
public interface DepartmentService extends IService<Department> {
|
public interface DepartmentService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,11 @@
|
|||||||
package day.gitlab.dolphin.rbac.service;
|
package day.gitlab.dolphin.rbac.service;
|
||||||
|
|
||||||
import com.mybatisflex.core.service.IService;
|
|
||||||
import day.gitlab.dolphin.rbac.entity.Region;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 区划项 服务层。
|
* 区划项 服务层。
|
||||||
*
|
*
|
||||||
* @author jiangyc
|
* @author jiangyc
|
||||||
* @since 2025-11-28
|
* @since 2025-11-28
|
||||||
*/
|
*/
|
||||||
public interface RegionService extends IService<Region> {
|
public interface RegionService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,11 @@
|
|||||||
package day.gitlab.dolphin.rbac.service;
|
package day.gitlab.dolphin.rbac.service;
|
||||||
|
|
||||||
import com.mybatisflex.core.service.IService;
|
|
||||||
import day.gitlab.dolphin.rbac.entity.Role;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色表 服务层。
|
* 角色表 服务层。
|
||||||
*
|
*
|
||||||
* @author jiangyc
|
* @author jiangyc
|
||||||
* @since 2025-11-28
|
* @since 2025-11-28
|
||||||
*/
|
*/
|
||||||
public interface RoleService extends IService<Role> {
|
public interface RoleService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,11 @@
|
|||||||
package day.gitlab.dolphin.rbac.service;
|
package day.gitlab.dolphin.rbac.service;
|
||||||
|
|
||||||
import com.mybatisflex.core.service.IService;
|
|
||||||
import day.gitlab.dolphin.rbac.entity.User;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户表 服务层。
|
* 用户表 服务层。
|
||||||
*
|
*
|
||||||
* @author jiangyc
|
* @author jiangyc
|
||||||
* @since 2025-11-28
|
* @since 2025-11-28
|
||||||
*/
|
*/
|
||||||
public interface UserService extends IService<User> {
|
public interface UserService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,5 @@
|
|||||||
package day.gitlab.dolphin.rbac.service.impl;
|
package day.gitlab.dolphin.rbac.service.impl;
|
||||||
|
|
||||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
|
||||||
import day.gitlab.dolphin.rbac.entity.Department;
|
|
||||||
import day.gitlab.dolphin.rbac.mapper.DepartmentMapper;
|
|
||||||
import day.gitlab.dolphin.rbac.service.DepartmentService;
|
import day.gitlab.dolphin.rbac.service.DepartmentService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -13,6 +10,6 @@ import org.springframework.stereotype.Service;
|
|||||||
* @since 2025-11-28
|
* @since 2025-11-28
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Department> implements DepartmentService{
|
public class DepartmentServiceImpl implements DepartmentService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,5 @@
|
|||||||
package day.gitlab.dolphin.rbac.service.impl;
|
package day.gitlab.dolphin.rbac.service.impl;
|
||||||
|
|
||||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
|
||||||
import day.gitlab.dolphin.rbac.entity.Region;
|
|
||||||
import day.gitlab.dolphin.rbac.mapper.RegionMapper;
|
|
||||||
import day.gitlab.dolphin.rbac.service.RegionService;
|
import day.gitlab.dolphin.rbac.service.RegionService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -13,6 +10,6 @@ import org.springframework.stereotype.Service;
|
|||||||
* @since 2025-11-28
|
* @since 2025-11-28
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> implements RegionService{
|
public class RegionServiceImpl implements RegionService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,5 @@
|
|||||||
package day.gitlab.dolphin.rbac.service.impl;
|
package day.gitlab.dolphin.rbac.service.impl;
|
||||||
|
|
||||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
|
||||||
import day.gitlab.dolphin.rbac.entity.Role;
|
|
||||||
import day.gitlab.dolphin.rbac.mapper.RoleMapper;
|
|
||||||
import day.gitlab.dolphin.rbac.service.RoleService;
|
import day.gitlab.dolphin.rbac.service.RoleService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -13,6 +10,6 @@ import org.springframework.stereotype.Service;
|
|||||||
* @since 2025-11-28
|
* @since 2025-11-28
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService{
|
public class RoleServiceImpl implements RoleService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,5 @@
|
|||||||
package day.gitlab.dolphin.rbac.service.impl;
|
package day.gitlab.dolphin.rbac.service.impl;
|
||||||
|
|
||||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
|
||||||
import day.gitlab.dolphin.rbac.entity.User;
|
|
||||||
import day.gitlab.dolphin.rbac.mapper.UserMapper;
|
|
||||||
import day.gitlab.dolphin.rbac.service.UserService;
|
import day.gitlab.dolphin.rbac.service.UserService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -13,6 +10,6 @@ import org.springframework.stereotype.Service;
|
|||||||
* @since 2025-11-28
|
* @since 2025-11-28
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService{
|
public class UserServiceImpl implements UserService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user