feat: 组织架构相关接口提交
This commit is contained in:
@ -0,0 +1,20 @@
|
|||||||
|
package day.gitlab.dolphin.common.core.util;
|
||||||
|
|
||||||
|
public class Pair<T, E> {
|
||||||
|
|
||||||
|
private final T t;
|
||||||
|
private final E e;
|
||||||
|
|
||||||
|
public Pair(T t, E e) {
|
||||||
|
this.t = t;
|
||||||
|
this.e = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T getFirst() {
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
public E getLast() {
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
package day.gitlab.dolphin.common.mybatis.util;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import day.gitlab.dolphin.common.web.entity.PageRequest;
|
||||||
|
import day.gitlab.dolphin.common.web.entity.PageResponse;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public class Mappers {
|
||||||
|
|
||||||
|
public static <T, E> Page<E> page(PageRequest<T> pageRequest,
|
||||||
|
BaseMapper<E> mapper,
|
||||||
|
Function<T, LambdaQueryWrapper<E>> function) {
|
||||||
|
Page<E> reqPage = toPage(pageRequest);
|
||||||
|
LambdaQueryWrapper<E> wrapper = function.apply(pageRequest.getQuery());
|
||||||
|
|
||||||
|
Page<E> resPage = mapper.selectPage(reqPage, wrapper);
|
||||||
|
Long count = mapper.selectCount(wrapper);
|
||||||
|
resPage.setTotal(count);
|
||||||
|
|
||||||
|
return resPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, E> Page<E> toPage(PageRequest<T> pageRequest) {
|
||||||
|
return new Page<>(pageRequest.getPageIndex(), pageRequest.getPageSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, E> PageResponse<E> mapPage(Page<T> page, Function<T, E> mapper) {
|
||||||
|
List<E> records = page.getRecords().stream().map(mapper).toList();
|
||||||
|
|
||||||
|
return new PageResponse<>(page.getCurrent(), page.getSize(), page.getTotal(), records);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,39 +0,0 @@
|
|||||||
package day.gitlab.dolphin.common.mybatis.util;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import day.gitlab.dolphin.common.web.entity.PageRequest;
|
|
||||||
import day.gitlab.dolphin.common.web.entity.PageResponse;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.function.BiFunction;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public class Pages {
|
|
||||||
|
|
||||||
public static <T, E> Page<E> paginate(PageRequest<T> pageRequest, BaseMapper<E> mapper, BiFunction<T, LambdaQueryWrapper<E>, LambdaQueryWrapper<E>> biFunction) {
|
|
||||||
Page<E> page = new Page<>(pageRequest.getPageIndex(), pageRequest.getPageSize());
|
|
||||||
LambdaQueryWrapper<E> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper = biFunction.apply(pageRequest.getQuery(), wrapper);
|
|
||||||
|
|
||||||
Page<E> ePage = mapper.selectPage(page, wrapper);
|
|
||||||
Long t = mapper.selectCount(wrapper);
|
|
||||||
page.setTotal(t);
|
|
||||||
return ePage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T, E> PageResponse<E> toPageResponse(Page<T> page, Function<T, E> mapFunction) {
|
|
||||||
PageResponse<E> pageResponse = new PageResponse<>();
|
|
||||||
pageResponse.setPageIndex(page.getCurrent());
|
|
||||||
pageResponse.setPageSize(page.getSize());
|
|
||||||
pageResponse.setTotal(page.getTotal());
|
|
||||||
|
|
||||||
if (page.getRecords() != null) {
|
|
||||||
pageResponse.setRecords(page.getRecords().stream().map(mapFunction).filter(Objects::nonNull).toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
return pageResponse;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package day.gitlab.dolphin.common.mybatis.entity;
|
package day.gitlab.dolphin.common.mybatis.util;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator;
|
import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator;
|
||||||
import day.gitlab.dolphin.common.core.util.UUIDv7;
|
import day.gitlab.dolphin.common.core.util.UUIDv7;
|
||||||
@ -1,8 +1,10 @@
|
|||||||
package day.gitlab.dolphin.module.core.service.impl;
|
package day.gitlab.dolphin.module.core.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import day.gitlab.dolphin.common.core.util.Strings;
|
import day.gitlab.dolphin.common.core.util.Strings;
|
||||||
import day.gitlab.dolphin.common.mybatis.util.Pages;
|
import day.gitlab.dolphin.common.mybatis.util.Mappers;
|
||||||
import day.gitlab.dolphin.common.web.entity.PageRequest;
|
import day.gitlab.dolphin.common.web.entity.PageRequest;
|
||||||
import day.gitlab.dolphin.common.web.entity.PageResponse;
|
import day.gitlab.dolphin.common.web.entity.PageResponse;
|
||||||
import day.gitlab.dolphin.module.core.controller.dto.DictionaryDTO;
|
import day.gitlab.dolphin.module.core.controller.dto.DictionaryDTO;
|
||||||
@ -28,7 +30,8 @@ public class DictionaryServiceImpl implements DictionaryService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResponse<DictionaryVO> paginate(PageRequest<DictionaryDTO> pageRequest) {
|
public PageResponse<DictionaryVO> paginate(PageRequest<DictionaryDTO> pageRequest) {
|
||||||
Page<Dictionary> paginate = Pages.paginate(pageRequest, dictionaryMapper, (dto, wrapper) -> {
|
Page<Dictionary> page = Mappers.page(pageRequest, dictionaryMapper, (dto) -> {
|
||||||
|
LambdaQueryWrapper<Dictionary> wrapper = Wrappers.lambdaQuery();
|
||||||
if (Strings.isNotBlank(dto.getName())) {
|
if (Strings.isNotBlank(dto.getName())) {
|
||||||
wrapper.like(Dictionary::getName, dto.getName());
|
wrapper.like(Dictionary::getName, dto.getName());
|
||||||
}
|
}
|
||||||
@ -38,11 +41,10 @@ public class DictionaryServiceImpl implements DictionaryService {
|
|||||||
if (Strings.isNotBlank(dto.getType())) {
|
if (Strings.isNotBlank(dto.getType())) {
|
||||||
wrapper.eq(Dictionary::getType, dto.getType());
|
wrapper.eq(Dictionary::getType, dto.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
return wrapper;
|
return wrapper;
|
||||||
});
|
});
|
||||||
|
|
||||||
return Pages.toPageResponse(paginate, (record) -> {
|
return Mappers.mapPage(page, (record) -> {
|
||||||
DictionaryVO dictionaryVO = new DictionaryVO();
|
DictionaryVO dictionaryVO = new DictionaryVO();
|
||||||
BeanUtils.copyProperties(record, dictionaryVO);
|
BeanUtils.copyProperties(record, dictionaryVO);
|
||||||
return dictionaryVO;
|
return dictionaryVO;
|
||||||
|
|||||||
@ -0,0 +1,46 @@
|
|||||||
|
package day.gitlab.dolphin.module.rbac.controller;
|
||||||
|
|
||||||
|
import day.gitlab.dolphin.common.web.entity.ApiResponse;
|
||||||
|
import day.gitlab.dolphin.common.web.entity.PageRequest;
|
||||||
|
import day.gitlab.dolphin.common.web.entity.PageResponse;
|
||||||
|
import day.gitlab.dolphin.module.rbac.controller.dto.DepartmentDTO;
|
||||||
|
import day.gitlab.dolphin.module.rbac.controller.vo.DepartmentVO;
|
||||||
|
import day.gitlab.dolphin.module.rbac.service.DepartmentService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping("/department")
|
||||||
|
public class DepartmentController {
|
||||||
|
|
||||||
|
private final DepartmentService departmentService;
|
||||||
|
|
||||||
|
@PostMapping("/paginate")
|
||||||
|
public ApiResponse<PageResponse<DepartmentVO>> paginate(@RequestBody PageRequest<DepartmentDTO> pageRequest) {
|
||||||
|
return ApiResponse.success(departmentService.paginate(pageRequest));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/update")
|
||||||
|
public ApiResponse<Boolean> update(@RequestBody DepartmentDTO record) {
|
||||||
|
return ApiResponse.success(departmentService.update(record));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/delete")
|
||||||
|
public ApiResponse<Boolean> delete(@RequestBody DepartmentDTO record) {
|
||||||
|
return ApiResponse.success(departmentService.delete(record.getId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/deleteBatch")
|
||||||
|
public ApiResponse<Integer> deleteBatch(@RequestBody DepartmentDTO record) {
|
||||||
|
return ApiResponse.success(departmentService.deleteBatch(record.getIds()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/insert")
|
||||||
|
public ApiResponse<Boolean> insert(@RequestBody DepartmentDTO record) {
|
||||||
|
return ApiResponse.success(departmentService.insert(record));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -23,6 +23,7 @@ public class RegionController {
|
|||||||
public ApiResponse<PageResponse<RegionVO>> paginate(@RequestBody PageRequest<RegionDTO> pageRequest) {
|
public ApiResponse<PageResponse<RegionVO>> paginate(@RequestBody PageRequest<RegionDTO> pageRequest) {
|
||||||
return ApiResponse.success(regionService.paginate(pageRequest));
|
return ApiResponse.success(regionService.paginate(pageRequest));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/update")
|
@PostMapping("/update")
|
||||||
public ApiResponse<Boolean> update(@RequestBody RegionDTO record) {
|
public ApiResponse<Boolean> update(@RequestBody RegionDTO record) {
|
||||||
return ApiResponse.success(regionService.update(record));
|
return ApiResponse.success(regionService.update(record));
|
||||||
@ -42,5 +43,4 @@ public class RegionController {
|
|||||||
public ApiResponse<Boolean> insert(@RequestBody RegionDTO record) {
|
public ApiResponse<Boolean> insert(@RequestBody RegionDTO record) {
|
||||||
return ApiResponse.success(regionService.insert(record));
|
return ApiResponse.success(regionService.insert(record));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,46 @@
|
|||||||
|
package day.gitlab.dolphin.module.rbac.controller;
|
||||||
|
|
||||||
|
import day.gitlab.dolphin.common.web.entity.ApiResponse;
|
||||||
|
import day.gitlab.dolphin.common.web.entity.PageRequest;
|
||||||
|
import day.gitlab.dolphin.common.web.entity.PageResponse;
|
||||||
|
import day.gitlab.dolphin.module.rbac.controller.dto.RoleDTO;
|
||||||
|
import day.gitlab.dolphin.module.rbac.controller.vo.RoleVO;
|
||||||
|
import day.gitlab.dolphin.module.rbac.service.RoleService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping("/role")
|
||||||
|
public class RoleController {
|
||||||
|
|
||||||
|
private final RoleService roleService;
|
||||||
|
|
||||||
|
@PostMapping("/role")
|
||||||
|
public ApiResponse<PageResponse<RoleVO>> paginate(@RequestBody PageRequest<RoleDTO> pageRequest) {
|
||||||
|
return ApiResponse.success(roleService.paginate(pageRequest));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/update")
|
||||||
|
public ApiResponse<Boolean> update(@RequestBody RoleDTO record) {
|
||||||
|
return ApiResponse.success(roleService.update(record));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/delete")
|
||||||
|
public ApiResponse<Boolean> delete(@RequestBody RoleDTO record) {
|
||||||
|
return ApiResponse.success(roleService.delete(record.getId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/deleteBatch")
|
||||||
|
public ApiResponse<Integer> deleteBatch(@RequestBody RoleDTO record) {
|
||||||
|
return ApiResponse.success(roleService.deleteBatch(record.getIds()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/insert")
|
||||||
|
public ApiResponse<Boolean> insert(@RequestBody RoleDTO record) {
|
||||||
|
return ApiResponse.success(roleService.insert(record));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
package day.gitlab.dolphin.module.rbac.controller;
|
||||||
|
|
||||||
|
import day.gitlab.dolphin.common.web.entity.ApiResponse;
|
||||||
|
import day.gitlab.dolphin.common.web.entity.PageRequest;
|
||||||
|
import day.gitlab.dolphin.common.web.entity.PageResponse;
|
||||||
|
import day.gitlab.dolphin.module.rbac.controller.dto.UserDTO;
|
||||||
|
import day.gitlab.dolphin.module.rbac.controller.vo.UserVO;
|
||||||
|
import day.gitlab.dolphin.module.rbac.service.UserService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping("/user")
|
||||||
|
public class UserController {
|
||||||
|
|
||||||
|
private final UserService userService;
|
||||||
|
|
||||||
|
@PostMapping("/paginate")
|
||||||
|
public ApiResponse<PageResponse<UserVO>> paginate(@RequestBody PageRequest<UserDTO> pageRequest) {
|
||||||
|
return ApiResponse.success(userService.paginate(pageRequest));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/update")
|
||||||
|
public ApiResponse<Boolean> update(@RequestBody UserDTO record) {
|
||||||
|
return ApiResponse.success(userService.update(record));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/delete")
|
||||||
|
public ApiResponse<Boolean> delete(@RequestBody UserDTO record) {
|
||||||
|
return ApiResponse.success(userService.delete(record.getId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/deleteBatch")
|
||||||
|
public ApiResponse<Integer> deleteBatch(@RequestBody UserDTO record) {
|
||||||
|
return ApiResponse.success(userService.deleteBatch(record.getIds()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/insert")
|
||||||
|
public ApiResponse<Boolean> insert(@RequestBody UserDTO record) {
|
||||||
|
return ApiResponse.success(userService.insert(record));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
package day.gitlab.dolphin.module.rbac.controller.dto;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class DepartmentDTO {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String regionId;
|
||||||
|
|
||||||
|
private String parentId;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
private List<String> ids;
|
||||||
|
}
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
package day.gitlab.dolphin.module.rbac.controller.dto;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class RoleDTO {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
private List<String> ids;
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
package day.gitlab.dolphin.module.rbac.controller.dto;
|
||||||
|
|
||||||
|
import day.gitlab.dolphin.module.rbac.enums.UserEnabled;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class UserDTO {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
private String nickname;
|
||||||
|
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
private String enabled;
|
||||||
|
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
private List<String> ids;
|
||||||
|
}
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
package day.gitlab.dolphin.module.rbac.controller.vo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class DepartmentVO {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String regionId;
|
||||||
|
|
||||||
|
private String parentId;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
private List<DepartmentVO> children;
|
||||||
|
}
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
package day.gitlab.dolphin.module.rbac.controller.vo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class RoleVO {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
private Date updateTime;
|
||||||
|
}
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
package day.gitlab.dolphin.module.rbac.controller.vo;
|
||||||
|
|
||||||
|
import day.gitlab.dolphin.module.rbac.enums.UserEnabled;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class UserVO {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
private String nickname;
|
||||||
|
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
private UserEnabled enabled;
|
||||||
|
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
private Date updateTime;
|
||||||
|
}
|
||||||
@ -12,4 +12,13 @@ public enum UserEnabled implements IEnum<String> {
|
|||||||
DISABLED("0");
|
DISABLED("0");
|
||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
|
|
||||||
|
public static UserEnabled fromValue(String value) {
|
||||||
|
for (UserEnabled status : values()) {
|
||||||
|
if (status.value.equals(value)) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("Unknown value: " + value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,24 @@
|
|||||||
package day.gitlab.dolphin.module.rbac.service;
|
package day.gitlab.dolphin.module.rbac.service;
|
||||||
|
|
||||||
|
import day.gitlab.dolphin.common.web.entity.PageRequest;
|
||||||
|
import day.gitlab.dolphin.common.web.entity.PageResponse;
|
||||||
|
import day.gitlab.dolphin.module.rbac.controller.dto.DepartmentDTO;
|
||||||
|
import day.gitlab.dolphin.module.rbac.controller.vo.DepartmentVO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 针对表【sys_rbac_department(部门表)】的数据库操作Service
|
* 针对表【sys_rbac_department(部门表)】的数据库操作Service
|
||||||
*/
|
*/
|
||||||
public interface DepartmentService {
|
public interface DepartmentService {
|
||||||
|
|
||||||
|
PageResponse<DepartmentVO> paginate(PageRequest<DepartmentDTO> pageRequest);
|
||||||
|
|
||||||
|
boolean update(DepartmentDTO record);
|
||||||
|
|
||||||
|
boolean delete(String id);
|
||||||
|
|
||||||
|
int deleteBatch(List<String> ids);
|
||||||
|
|
||||||
|
boolean insert(DepartmentDTO record);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,24 @@
|
|||||||
package day.gitlab.dolphin.module.rbac.service;
|
package day.gitlab.dolphin.module.rbac.service;
|
||||||
|
|
||||||
|
import day.gitlab.dolphin.common.web.entity.PageRequest;
|
||||||
|
import day.gitlab.dolphin.common.web.entity.PageResponse;
|
||||||
|
import day.gitlab.dolphin.module.rbac.controller.dto.RoleDTO;
|
||||||
|
import day.gitlab.dolphin.module.rbac.controller.vo.RoleVO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 针对表【sys_rbac_role(角色表)】的数据库操作Service
|
* 针对表【sys_rbac_role(角色表)】的数据库操作Service
|
||||||
*/
|
*/
|
||||||
public interface RoleService {
|
public interface RoleService {
|
||||||
|
|
||||||
|
PageResponse<RoleVO> paginate(PageRequest<RoleDTO> pageRequest);
|
||||||
|
|
||||||
|
boolean update(RoleDTO record);
|
||||||
|
|
||||||
|
boolean delete(String id);
|
||||||
|
|
||||||
|
int deleteBatch(List<String> ids);
|
||||||
|
|
||||||
|
boolean insert(RoleDTO record);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,24 @@
|
|||||||
package day.gitlab.dolphin.module.rbac.service;
|
package day.gitlab.dolphin.module.rbac.service;
|
||||||
|
|
||||||
|
import day.gitlab.dolphin.common.web.entity.PageRequest;
|
||||||
|
import day.gitlab.dolphin.common.web.entity.PageResponse;
|
||||||
|
import day.gitlab.dolphin.module.rbac.controller.dto.UserDTO;
|
||||||
|
import day.gitlab.dolphin.module.rbac.controller.vo.UserVO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 针对表【sys_rbac_user(用户表)】的数据库操作Service
|
* 针对表【sys_rbac_user(用户表)】的数据库操作Service
|
||||||
*/
|
*/
|
||||||
public interface UserService {
|
public interface UserService {
|
||||||
|
|
||||||
|
PageResponse<UserVO> paginate(PageRequest<UserDTO> pageRequest);
|
||||||
|
|
||||||
|
boolean update(UserDTO record);
|
||||||
|
|
||||||
|
boolean delete(String id);
|
||||||
|
|
||||||
|
int deleteBatch(List<String> ids);
|
||||||
|
|
||||||
|
boolean insert(UserDTO record);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,146 @@
|
|||||||
package day.gitlab.dolphin.module.rbac.service.impl;
|
package day.gitlab.dolphin.module.rbac.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import day.gitlab.dolphin.common.core.util.Strings;
|
||||||
|
import day.gitlab.dolphin.common.mybatis.util.Mappers;
|
||||||
|
import day.gitlab.dolphin.common.web.entity.PageRequest;
|
||||||
|
import day.gitlab.dolphin.common.web.entity.PageResponse;
|
||||||
|
import day.gitlab.dolphin.module.rbac.controller.dto.DepartmentDTO;
|
||||||
|
import day.gitlab.dolphin.module.rbac.controller.vo.DepartmentVO;
|
||||||
|
import day.gitlab.dolphin.module.rbac.entity.Department;
|
||||||
|
import day.gitlab.dolphin.module.rbac.mapper.DepartmentMapper;
|
||||||
import day.gitlab.dolphin.module.rbac.service.DepartmentService;
|
import day.gitlab.dolphin.module.rbac.service.DepartmentService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 针对表【sys_rbac_department(部门表)】的数据库操作Service实现
|
* 针对表【sys_rbac_department(部门表)】的数据库操作Service实现
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class DepartmentServiceImpl implements DepartmentService {
|
public class DepartmentServiceImpl implements DepartmentService {
|
||||||
|
|
||||||
|
private final DepartmentMapper departmentMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResponse<DepartmentVO> paginate(PageRequest<DepartmentDTO> pageRequest) {
|
||||||
|
Page<Department> resPage = Mappers.page(pageRequest, departmentMapper, dto -> {
|
||||||
|
LambdaQueryWrapper<Department> wrapper = Wrappers.lambdaQuery();
|
||||||
|
if (Strings.isNotBlank(dto.getRegionId())) {
|
||||||
|
wrapper.eq(Department::getRegionId, dto.getRegionId());
|
||||||
|
}
|
||||||
|
if (Strings.isNotBlank(dto.getName())) {
|
||||||
|
wrapper.like(Department::getName, dto.getName());
|
||||||
|
}
|
||||||
|
if (Strings.isNotBlank(dto.getCode())) {
|
||||||
|
wrapper.eq(Department::getCode, dto.getCode());
|
||||||
|
}
|
||||||
|
wrapper.isNull(Department::getParentId);
|
||||||
|
return wrapper;
|
||||||
|
});
|
||||||
|
|
||||||
|
PageResponse<DepartmentVO> pageResponse = Mappers.mapPage(resPage, (record) -> {
|
||||||
|
DepartmentVO departmentVO = new DepartmentVO();
|
||||||
|
BeanUtils.copyProperties(record, departmentVO);
|
||||||
|
return departmentVO;
|
||||||
|
});
|
||||||
|
|
||||||
|
LambdaQueryWrapper<Department> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
DepartmentDTO dto = pageRequest.getQuery();
|
||||||
|
if (Strings.isNotBlank(dto.getRegionId())) {
|
||||||
|
wrapper.eq(Department::getRegionId, dto.getRegionId());
|
||||||
|
}
|
||||||
|
if (Strings.isNotBlank(dto.getName())) {
|
||||||
|
wrapper.like(Department::getName, dto.getName());
|
||||||
|
}
|
||||||
|
if (Strings.isNotBlank(dto.getCode())) {
|
||||||
|
wrapper.eq(Department::getCode, dto.getCode());
|
||||||
|
}
|
||||||
|
List<Department> departments = departmentMapper.selectList(wrapper);
|
||||||
|
pageResponse.getRecords().forEach(record -> {
|
||||||
|
list2tree(record, departments);
|
||||||
|
});
|
||||||
|
pageResponse.setTotal((long) departments.size());
|
||||||
|
return pageResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean update(DepartmentDTO record) {
|
||||||
|
Department department = departmentMapper.selectById(record.getId());
|
||||||
|
if (department != null) {
|
||||||
|
department.setRegionId(record.getRegionId());
|
||||||
|
department.setParentId(record.getParentId());
|
||||||
|
department.setName(record.getName());
|
||||||
|
department.setCode(record.getCode());
|
||||||
|
department.setSort(record.getSort());
|
||||||
|
department.setDescription(record.getDescription());
|
||||||
|
department.setUpdateTime(Timestamp.from(Instant.now()));
|
||||||
|
return departmentMapper.updateById(department) == 1;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean delete(String id) {
|
||||||
|
Department department = departmentMapper.selectById(id);
|
||||||
|
if (department != null) {
|
||||||
|
return departmentMapper.deleteById(department.getId()) == 1;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int deleteBatch(List<String> ids) {
|
||||||
|
return departmentMapper.deleteByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean insert(DepartmentDTO record) {
|
||||||
|
Department department = new Department();
|
||||||
|
BeanUtils.copyProperties(record, department);
|
||||||
|
department.setId(null);
|
||||||
|
department.setCreateTime(Timestamp.from(Instant.now()));
|
||||||
|
department.setUpdateTime(Timestamp.from(Instant.now()));
|
||||||
|
return departmentMapper.insert(department) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<DepartmentVO> list2tree(List<Department> records) {
|
||||||
|
List<DepartmentVO> root = records.stream()
|
||||||
|
.filter(rec -> Strings.isBlank(rec.getParentId()))
|
||||||
|
.map(rec -> {
|
||||||
|
DepartmentVO vo = new DepartmentVO();
|
||||||
|
BeanUtils.copyProperties(rec, vo);
|
||||||
|
return vo;
|
||||||
|
})
|
||||||
|
.toList();
|
||||||
|
for (DepartmentVO parent : root) {
|
||||||
|
list2tree(parent, records);
|
||||||
|
}
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void list2tree(DepartmentVO parent, List<Department> records) {
|
||||||
|
List<DepartmentVO> children = records.stream()
|
||||||
|
.filter(rec -> parent.getId().equals(rec.getParentId()))
|
||||||
|
.map(rec -> {
|
||||||
|
DepartmentVO vo = new DepartmentVO();
|
||||||
|
BeanUtils.copyProperties(rec, vo);
|
||||||
|
return vo;
|
||||||
|
})
|
||||||
|
.toList();
|
||||||
|
parent.setChildren(children);
|
||||||
|
|
||||||
|
for (DepartmentVO child : children) {
|
||||||
|
list2tree(child, records);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
package day.gitlab.dolphin.module.rbac.service.impl;
|
package day.gitlab.dolphin.module.rbac.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import day.gitlab.dolphin.common.core.util.Strings;
|
import day.gitlab.dolphin.common.core.util.Strings;
|
||||||
import day.gitlab.dolphin.common.mybatis.util.Pages;
|
import day.gitlab.dolphin.common.mybatis.util.Mappers;
|
||||||
import day.gitlab.dolphin.common.web.entity.PageRequest;
|
import day.gitlab.dolphin.common.web.entity.PageRequest;
|
||||||
import day.gitlab.dolphin.common.web.entity.PageResponse;
|
import day.gitlab.dolphin.common.web.entity.PageResponse;
|
||||||
import day.gitlab.dolphin.module.rbac.controller.dto.RegionDTO;
|
import day.gitlab.dolphin.module.rbac.controller.dto.RegionDTO;
|
||||||
@ -30,7 +31,8 @@ public class RegionServiceImpl implements RegionService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResponse<RegionVO> paginate(PageRequest<RegionDTO> pageRequest) {
|
public PageResponse<RegionVO> paginate(PageRequest<RegionDTO> pageRequest) {
|
||||||
Page<Region> paginate = Pages.paginate(pageRequest, regionMapper, (dto, wrapper) -> {
|
Page<Region> resPage = Mappers.page(pageRequest, regionMapper, dto -> {
|
||||||
|
LambdaQueryWrapper<Region> wrapper = Wrappers.lambdaQuery();
|
||||||
if (Strings.isNotBlank(dto.getName())) {
|
if (Strings.isNotBlank(dto.getName())) {
|
||||||
wrapper.like(Region::getName, dto.getName());
|
wrapper.like(Region::getName, dto.getName());
|
||||||
}
|
}
|
||||||
@ -41,7 +43,7 @@ public class RegionServiceImpl implements RegionService {
|
|||||||
return wrapper;
|
return wrapper;
|
||||||
});
|
});
|
||||||
|
|
||||||
PageResponse<RegionVO> pageResponse = Pages.toPageResponse(paginate, (record) -> {
|
PageResponse<RegionVO> pageResponse = Mappers.mapPage(resPage, (record) -> {
|
||||||
RegionVO dictionaryVO = new RegionVO();
|
RegionVO dictionaryVO = new RegionVO();
|
||||||
BeanUtils.copyProperties(record, dictionaryVO);
|
BeanUtils.copyProperties(record, dictionaryVO);
|
||||||
return dictionaryVO;
|
return dictionaryVO;
|
||||||
|
|||||||
@ -1,14 +1,91 @@
|
|||||||
package day.gitlab.dolphin.module.rbac.service.impl;
|
package day.gitlab.dolphin.module.rbac.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import day.gitlab.dolphin.common.core.util.Strings;
|
||||||
|
import day.gitlab.dolphin.common.mybatis.util.Mappers;
|
||||||
|
import day.gitlab.dolphin.common.web.entity.PageRequest;
|
||||||
|
import day.gitlab.dolphin.common.web.entity.PageResponse;
|
||||||
|
import day.gitlab.dolphin.module.rbac.controller.dto.RoleDTO;
|
||||||
|
import day.gitlab.dolphin.module.rbac.controller.vo.RoleVO;
|
||||||
|
import day.gitlab.dolphin.module.rbac.entity.Role;
|
||||||
|
import day.gitlab.dolphin.module.rbac.mapper.RoleMapper;
|
||||||
import day.gitlab.dolphin.module.rbac.service.RoleService;
|
import day.gitlab.dolphin.module.rbac.service.RoleService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 针对表【sys_rbac_role(角色表)】的数据库操作Service实现
|
* 针对表【sys_rbac_role(角色表)】的数据库操作Service实现
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class RoleServiceImpl implements RoleService {
|
public class RoleServiceImpl implements RoleService {
|
||||||
|
|
||||||
|
private final RoleMapper roleMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResponse<RoleVO> paginate(PageRequest<RoleDTO> pageRequest) {
|
||||||
|
Page<Role> resPage = Mappers.page(pageRequest, roleMapper, dto -> {
|
||||||
|
LambdaQueryWrapper<Role> wrapper = Wrappers.lambdaQuery();
|
||||||
|
if (Strings.isNotBlank(dto.getName())) {
|
||||||
|
wrapper.like(Role::getName, dto.getName());
|
||||||
|
}
|
||||||
|
if (Strings.isNotBlank(dto.getCode())) {
|
||||||
|
wrapper.eq(Role::getCode, dto.getCode());
|
||||||
|
}
|
||||||
|
return wrapper;
|
||||||
|
});
|
||||||
|
|
||||||
|
return Mappers.mapPage(resPage, (record) -> {
|
||||||
|
RoleVO RoleVO = new RoleVO();
|
||||||
|
BeanUtils.copyProperties(record, RoleVO);
|
||||||
|
return RoleVO;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean update(RoleDTO record) {
|
||||||
|
Role role = roleMapper.selectById(record.getId());
|
||||||
|
if (role != null) {
|
||||||
|
role.setName(record.getName());
|
||||||
|
role.setCode(record.getCode());
|
||||||
|
role.setSort(record.getSort());
|
||||||
|
role.setDescription(record.getDescription());
|
||||||
|
role.setUpdateTime(Timestamp.from(Instant.now()));
|
||||||
|
return roleMapper.updateById(role) == 1;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean delete(String id) {
|
||||||
|
Role role = roleMapper.selectById(id);
|
||||||
|
if (role != null) {
|
||||||
|
return roleMapper.deleteById(role.getId()) == 1;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int deleteBatch(List<String> ids) {
|
||||||
|
return roleMapper.deleteByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean insert(RoleDTO record) {
|
||||||
|
Role role = new Role();
|
||||||
|
BeanUtils.copyProperties(record, role);
|
||||||
|
role.setId(null);
|
||||||
|
role.setCreateTime(Timestamp.from(Instant.now()));
|
||||||
|
role.setUpdateTime(Timestamp.from(Instant.now()));
|
||||||
|
return roleMapper.insert(role) == 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,14 +1,92 @@
|
|||||||
package day.gitlab.dolphin.module.rbac.service.impl;
|
package day.gitlab.dolphin.module.rbac.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import day.gitlab.dolphin.common.core.util.Strings;
|
||||||
|
import day.gitlab.dolphin.common.mybatis.util.Mappers;
|
||||||
|
import day.gitlab.dolphin.common.web.entity.PageRequest;
|
||||||
|
import day.gitlab.dolphin.common.web.entity.PageResponse;
|
||||||
|
import day.gitlab.dolphin.module.rbac.controller.dto.UserDTO;
|
||||||
|
import day.gitlab.dolphin.module.rbac.controller.vo.UserVO;
|
||||||
|
import day.gitlab.dolphin.module.rbac.entity.User;
|
||||||
|
import day.gitlab.dolphin.module.rbac.enums.UserEnabled;
|
||||||
|
import day.gitlab.dolphin.module.rbac.mapper.UserMapper;
|
||||||
import day.gitlab.dolphin.module.rbac.service.UserService;
|
import day.gitlab.dolphin.module.rbac.service.UserService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 针对表【sys_rbac_user(用户表)】的数据库操作Service实现
|
* 针对表【sys_rbac_user(用户表)】的数据库操作Service实现
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class UserServiceImpl implements UserService {
|
public class UserServiceImpl implements UserService {
|
||||||
|
|
||||||
|
private final UserMapper userMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResponse<UserVO> paginate(PageRequest<UserDTO> pageRequest) {
|
||||||
|
Page<User> resPage = Mappers.page(pageRequest, userMapper, dto -> {
|
||||||
|
LambdaQueryWrapper<User> wrapper = Wrappers.lambdaQuery();
|
||||||
|
if (Strings.isNotBlank(dto.getUsername())) {
|
||||||
|
wrapper.like(User::getUsername, dto.getUsername());
|
||||||
|
}
|
||||||
|
if (Strings.isNotBlank(dto.getNickname())) {
|
||||||
|
wrapper.eq(User::getNickname, dto.getNickname());
|
||||||
|
}
|
||||||
|
return wrapper;
|
||||||
|
});
|
||||||
|
|
||||||
|
return Mappers.mapPage(resPage, (record) -> {
|
||||||
|
UserVO userVO = new UserVO();
|
||||||
|
BeanUtils.copyProperties(record, userVO);
|
||||||
|
return userVO;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean update(UserDTO record) {
|
||||||
|
User user = userMapper.selectById(record.getId());
|
||||||
|
if (user != null) {
|
||||||
|
user.setUsername(record.getUsername());
|
||||||
|
user.setNickname(record.getNickname());
|
||||||
|
user.setEnabled(UserEnabled.fromValue(record.getEnabled()));
|
||||||
|
user.setDescription(record.getDescription());
|
||||||
|
user.setUpdateTime(Timestamp.from(Instant.now()));
|
||||||
|
return userMapper.updateById(user) == 1;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean delete(String id) {
|
||||||
|
User user = userMapper.selectById(id);
|
||||||
|
if (user != null) {
|
||||||
|
return userMapper.deleteById(user.getId()) == 1;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int deleteBatch(List<String> ids) {
|
||||||
|
return userMapper.deleteByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean insert(UserDTO record) {
|
||||||
|
User user = new User();
|
||||||
|
BeanUtils.copyProperties(record, user);
|
||||||
|
user.setId(null);
|
||||||
|
user.setCreateTime(Timestamp.from(Instant.now()));
|
||||||
|
user.setUpdateTime(Timestamp.from(Instant.now()));
|
||||||
|
return userMapper.insert(user) == 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
1
pom.xml
1
pom.xml
@ -93,6 +93,7 @@
|
|||||||
</annotationProcessorPaths>
|
</annotationProcessorPaths>
|
||||||
<source>${java.version}</source>
|
<source>${java.version}</source>
|
||||||
<target>${java.version}</target>
|
<target>${java.version}</target>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
|||||||
Reference in New Issue
Block a user