init
This commit is contained in:
+4
@@ -48,4 +48,8 @@ public class BizException extends RuntimeException {
|
||||
public BizException(String message, Object... args) {
|
||||
this.message = StrFormatter.format(message, args);
|
||||
}
|
||||
|
||||
public BizException(ErrorCodeInterface errorCode, Object... args) {
|
||||
this.message = StrFormatter.format(errorCode.message(), args);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -166,7 +166,7 @@ public enum ErrorCode implements ErrorCodeInterface {
|
||||
|
||||
ROLE_DATA_SCOPE_DUPLICATED_DEPT(11003, "重复的部门id", "Business.ROLE_DATA_SCOPE_DUPLICATED_DEPT"),
|
||||
|
||||
ROLE_ALREADY_ASSIGN_TO_USER(11004, "角色已分配给用户,请先取消分配,再删除角色", "Business.ROLE_ALREADY_ASSIGN_TO_USER"),
|
||||
ROLE_ALREADY_ASSIGN_TO_USER(11004, "角色:{} 已分配给用户,请先取消分配,再删除角色", "Business.ROLE_ALREADY_ASSIGN_TO_USER"),
|
||||
|
||||
ROLE_IS_NOT_AVAILABLE(11005, "角色:{} 已禁用,无法分配给用户", "Business.ROLE_IS_NOT_AVAILABLE"),
|
||||
|
||||
|
||||
+4
-2
@@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.agileboot.common.core.exception.ServiceException;
|
||||
import com.agileboot.common.core.utils.sql.SqlUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
@@ -25,7 +26,7 @@ import java.util.List;
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class PageQuery implements Serializable {
|
||||
public abstract class PageQuery<T> implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -60,7 +61,7 @@ public class PageQuery implements Serializable {
|
||||
/**
|
||||
* 构建分页对象
|
||||
*/
|
||||
public <T> Page<T> buildPage() {
|
||||
public <T> Page<T> toPage() {
|
||||
Integer pageNum = ObjectUtil.defaultIfNull(getPageNum(), DEFAULT_PAGE_NUM);
|
||||
Integer pageSize = ObjectUtil.defaultIfNull(getPageSize(), DEFAULT_PAGE_SIZE);
|
||||
if (pageNum <= 0) {
|
||||
@@ -125,4 +126,5 @@ public class PageQuery implements Serializable {
|
||||
this.pageNum = pageNum;
|
||||
}
|
||||
|
||||
public abstract LambdaQueryWrapper<T> toQueryWrapper();
|
||||
}
|
||||
|
||||
+33
-33
@@ -23,47 +23,47 @@ public class PageR<T> {
|
||||
private int code;
|
||||
private String msg;
|
||||
|
||||
public static <T> PageR<T> build() {
|
||||
PageR<T> r = new PageR<>();
|
||||
r.setCode(HttpStatus.HTTP_OK);
|
||||
r.setMsg("查询成功");
|
||||
r.setTotal(0L);
|
||||
r.setPages(0L);
|
||||
r.setCurrent(0L);
|
||||
r.setSize(0L);
|
||||
return r;
|
||||
public PageR() {
|
||||
this.code = HttpStatus.HTTP_OK;
|
||||
this.msg = "查询成功";
|
||||
this.total = 0L;
|
||||
this.current = 0L;
|
||||
this.size = 0L;
|
||||
this.pages = 0L;
|
||||
}
|
||||
|
||||
public static <T> PageR<T> build(List<T> list) {
|
||||
PageR<T> r = new PageR<>();
|
||||
r.setCode(HttpStatus.HTTP_OK);
|
||||
r.setMsg("查询成功");
|
||||
r.setRows(list);
|
||||
r.setTotal((long) list.size());
|
||||
return r;
|
||||
public PageR(List<T> list) {
|
||||
this.code = HttpStatus.HTTP_OK;
|
||||
this.rows = list;
|
||||
this.total = (long) list.size();
|
||||
this.msg = "查询成功";
|
||||
}
|
||||
|
||||
public static <T> PageR<T> build(IPage<T> page) {
|
||||
PageR<T> r = PageR.build();
|
||||
r.setRows(page.getRecords());
|
||||
r.setSize(page.getSize());
|
||||
r.setPages(page.getPages());
|
||||
r.setTotal(page.getTotal());
|
||||
r.setCurrent(page.getCurrent());
|
||||
return r;
|
||||
public PageR(IPage<T> page) {
|
||||
this.code = HttpStatus.HTTP_OK;
|
||||
this.msg = "查询成功";
|
||||
this.rows = page.getRecords();
|
||||
this.total = page.getTotal();
|
||||
this.current = page.getCurrent();
|
||||
this.size = page.getSize();
|
||||
this.pages = page.getPages();
|
||||
}
|
||||
|
||||
public static <T> PageR<T> build(IPage<?> page, List<T> list) {
|
||||
public PageR(IPage<?> page, List<T> list) {
|
||||
this.code = HttpStatus.HTTP_OK;
|
||||
this.msg = "查询成功";
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return PageR.build();
|
||||
this.total = 0L;
|
||||
this.current = 0L;
|
||||
this.size = 0L;
|
||||
this.pages = 0L;
|
||||
} else {
|
||||
this.rows = list;
|
||||
this.total = page.getTotal();
|
||||
this.current = page.getCurrent();
|
||||
this.size = page.getSize();
|
||||
this.pages = page.getPages();
|
||||
}
|
||||
PageR<T> r = PageR.build();
|
||||
r.setRows(list);
|
||||
r.setSize(page.getSize());
|
||||
r.setPages(page.getPages());
|
||||
r.setTotal(page.getTotal());
|
||||
r.setCurrent(page.getCurrent());
|
||||
return r;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ public class SaTokenExceptionHandler {
|
||||
public R<Void> handleNotLoginException(NotLoginException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',认证失败'{}',无法访问系统资源", requestURI, e.getMessage());
|
||||
return R.fail(HttpStatus.HTTP_UNAUTHORIZED, "认证失败,无法访问系统资源");
|
||||
return R.fail(HttpStatus.HTTP_UNAUTHORIZED, "2认证失败,无法访问系统资源");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,15 @@
|
||||
<groupId>com.agileboot</groupId>
|
||||
<artifactId>wol-common-mybatis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.agileboot</groupId>
|
||||
<artifactId>wol-domain</artifactId>
|
||||
</dependency>
|
||||
<!-- 获取系统信息 -->
|
||||
<dependency>
|
||||
<groupId>com.github.oshi</groupId>
|
||||
<artifactId>oshi-core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package com.agileboot.system.client.mapper;
|
||||
|
||||
import com.agileboot.system.client.pojo.entity.SysClient;
|
||||
import com.agileboot.system.client.entity.SysClient;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
public interface SysClientMapper extends BaseMapper<SysClient> {
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.agileboot.system.client.mapper.SysClientMapper">
|
||||
|
||||
</mapper>
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package com.agileboot.system.client.service;
|
||||
|
||||
import com.agileboot.system.client.pojo.vo.SysClientVO;
|
||||
import com.agileboot.system.client.vo.SysClientVO;
|
||||
|
||||
public interface ISysClientService {
|
||||
SysClientVO queryByClientId(String clientId);
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
package com.agileboot.system.client.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.agileboot.system.client.entity.SysClient;
|
||||
import com.agileboot.system.client.mapper.SysClientMapper;
|
||||
import com.agileboot.system.client.pojo.entity.SysClient;
|
||||
import com.agileboot.system.client.pojo.vo.SysClientVO;
|
||||
import com.agileboot.system.client.service.ISysClientService;
|
||||
import com.agileboot.system.client.vo.SysClientVO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
+5
-5
@@ -2,10 +2,10 @@ package com.agileboot.system.config.controller;
|
||||
|
||||
import com.agileboot.common.core.core.R;
|
||||
import com.agileboot.common.mybatis.core.page.PageR;
|
||||
import com.agileboot.system.config.pojo.dto.ConfigDTO;
|
||||
import com.agileboot.system.config.pojo.dto.ConfigQuery;
|
||||
import com.agileboot.system.config.pojo.dto.ConfigUpdate;
|
||||
import com.agileboot.system.config.dto.ConfigQuery;
|
||||
import com.agileboot.system.config.dto.ConfigUpdate;
|
||||
import com.agileboot.system.config.service.ISysConfigService;
|
||||
import com.agileboot.system.config.vo.ConfigVO;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Positive;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -34,7 +34,7 @@ public class SysConfigController {
|
||||
* 获取参数配置列表
|
||||
*/
|
||||
@GetMapping("/configs")
|
||||
public PageR<ConfigDTO> list(ConfigQuery query) {
|
||||
public PageR<ConfigVO> list(ConfigQuery query) {
|
||||
return sysConfigService.getConfigPage(query);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class SysConfigController {
|
||||
* 根据参数编号获取详细信息
|
||||
*/
|
||||
@GetMapping(value = "/config/{configId}")
|
||||
public R<ConfigDTO> getInfo(@NotNull @Positive @PathVariable Long configId) {
|
||||
public R<ConfigVO> getInfo(@NotNull @Positive @PathVariable Long configId) {
|
||||
return R.ok(sysConfigService.getConfigInfo(configId));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package com.agileboot.system.config.mapper;
|
||||
|
||||
import com.agileboot.system.config.pojo.entity.SysConfig;
|
||||
import com.agileboot.system.config.entity.SysConfig;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.agileboot.system.config.pojo.entity.SysConfig">
|
||||
<mapper namespace="com.agileboot.system.config.mapper.SysConfigMapper">
|
||||
|
||||
</mapper>
|
||||
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
package com.agileboot.system.config.pojo.dto;
|
||||
|
||||
import com.agileboot.common.mybatis.core.page.PageQuery;
|
||||
import com.agileboot.system.config.pojo.entity.SysConfig;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* 配置查询参数
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class ConfigQuery extends PageQuery {
|
||||
|
||||
// 配置名称
|
||||
private String configName;
|
||||
|
||||
// 配置key
|
||||
private String configKey;
|
||||
|
||||
// 是否允许更改配置
|
||||
private Boolean isAllowChange;
|
||||
|
||||
|
||||
public QueryWrapper<SysConfig> toQueryWrapper() {
|
||||
return new QueryWrapper<SysConfig>()
|
||||
.like(StringUtils.isNotEmpty(configName), "config_name", configName)
|
||||
.eq(StringUtils.isNotEmpty(configKey), "config_key", configKey)
|
||||
.eq(isAllowChange != null, "is_allow_change", isAllowChange)
|
||||
.orderByDesc("create_time");
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -1,9 +1,9 @@
|
||||
package com.agileboot.system.config.service;
|
||||
|
||||
import com.agileboot.common.mybatis.core.page.PageR;
|
||||
import com.agileboot.system.config.pojo.dto.ConfigDTO;
|
||||
import com.agileboot.system.config.pojo.dto.ConfigQuery;
|
||||
import com.agileboot.system.config.pojo.dto.ConfigUpdate;
|
||||
import com.agileboot.system.config.dto.ConfigQuery;
|
||||
import com.agileboot.system.config.dto.ConfigUpdate;
|
||||
import com.agileboot.system.config.vo.ConfigVO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -23,9 +23,9 @@ public interface ISysConfigService {
|
||||
*/
|
||||
String getConfigValueByKey(String key);
|
||||
|
||||
PageR<ConfigDTO> getConfigPage(ConfigQuery query);
|
||||
PageR<ConfigVO> getConfigPage(ConfigQuery query);
|
||||
|
||||
ConfigDTO getConfigInfo(Long id);
|
||||
ConfigVO getConfigInfo(Long id);
|
||||
|
||||
void updateConfig(Long id, ConfigUpdate update);
|
||||
}
|
||||
|
||||
+11
-13
@@ -2,20 +2,18 @@ package com.agileboot.system.config.service.impl;
|
||||
|
||||
import com.agileboot.common.core.exception.BizException;
|
||||
import com.agileboot.common.mybatis.core.page.PageR;
|
||||
import com.agileboot.system.config.dto.ConfigQuery;
|
||||
import com.agileboot.system.config.dto.ConfigUpdate;
|
||||
import com.agileboot.system.config.entity.SysConfig;
|
||||
import com.agileboot.system.config.mapper.SysConfigMapper;
|
||||
import com.agileboot.system.config.pojo.dto.ConfigDTO;
|
||||
import com.agileboot.system.config.pojo.dto.ConfigQuery;
|
||||
import com.agileboot.system.config.pojo.dto.ConfigUpdate;
|
||||
import com.agileboot.system.config.pojo.entity.SysConfig;
|
||||
import com.agileboot.system.config.service.ISysConfigService;
|
||||
import com.agileboot.system.config.vo.ConfigVO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 参数配置表 服务实现类
|
||||
@@ -41,15 +39,15 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageR<ConfigDTO> getConfigPage(ConfigQuery query) {
|
||||
Page<SysConfig> page = this.page(query.buildPage(), query.toQueryWrapper());
|
||||
List<ConfigDTO> records = page.getRecords().stream().map(ConfigDTO::new).collect(Collectors.toList());
|
||||
return PageR.build(page, records);
|
||||
public PageR<ConfigVO> getConfigPage(ConfigQuery query) {
|
||||
Page<SysConfig> page = this.page(query.toPage(), query.toQueryWrapper());
|
||||
IPage<ConfigVO> convert = page.convert(ConfigVO::new);
|
||||
return new PageR<>(convert);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigDTO getConfigInfo(Long id) {
|
||||
return new ConfigDTO(this.getById(id));
|
||||
public ConfigVO getConfigInfo(Long id) {
|
||||
return new ConfigVO(this.getById(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+67
-2
@@ -1,9 +1,18 @@
|
||||
package com.agileboot.system.dept.controller;
|
||||
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import com.agileboot.common.core.core.R;
|
||||
import com.agileboot.system.dept.dto.AddDeptDTO;
|
||||
import com.agileboot.system.dept.dto.DeptQuery;
|
||||
import com.agileboot.system.dept.dto.UpdateDeptDTO;
|
||||
import com.agileboot.system.dept.service.ISysDeptService;
|
||||
import com.agileboot.system.dept.vo.DeptVO;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 部门信息
|
||||
@@ -14,4 +23,60 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RequiredArgsConstructor
|
||||
public class SysDeptController {
|
||||
|
||||
private final ISysDeptService sysDeptService;
|
||||
|
||||
/**
|
||||
* 获取部门列表
|
||||
*/
|
||||
@GetMapping("/depts")
|
||||
public R<List<DeptVO>> list(DeptQuery query) {
|
||||
List<DeptVO> deptList = sysDeptService.getDeptList(query);
|
||||
return R.ok(deptList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据部门编号获取详细信息
|
||||
*/
|
||||
@GetMapping(value = "/dept/{deptId}")
|
||||
public R<DeptVO> getInfo(@PathVariable Long deptId) {
|
||||
DeptVO dept = sysDeptService.getDeptInfo(deptId);
|
||||
return R.ok(dept);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门下拉树列表
|
||||
*/
|
||||
@GetMapping("/depts/dropdown")
|
||||
public R<List<Tree<Long>>> dropdownList() {
|
||||
List<Tree<Long>> deptTree = sysDeptService.getDeptTree();
|
||||
return R.ok(deptTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增部门
|
||||
*/
|
||||
@PostMapping("/dept")
|
||||
public R<Void> add(@RequestBody AddDeptDTO addCommand) {
|
||||
sysDeptService.addDept(addCommand);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改部门
|
||||
*/
|
||||
@PutMapping("/dept/{deptId}")
|
||||
public R<Void> edit(@PathVariable("deptId") Long deptId, @RequestBody UpdateDeptDTO updateCommand) {
|
||||
updateCommand.setDeptId(deptId);
|
||||
sysDeptService.updateDept(updateCommand);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除部门
|
||||
*/
|
||||
@DeleteMapping("/dept/{deptId}")
|
||||
public R<Void> remove(@PathVariable @NotNull Long deptId) {
|
||||
sysDeptService.removeDept(deptId);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.agileboot.system.dept.mapper;
|
||||
|
||||
import com.agileboot.system.dept.entity.SysDept;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
public interface SysDeptMapper extends BaseMapper<SysDept> {
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.agileboot.system.client.pojo.entity.SysClient">
|
||||
<mapper namespace="com.agileboot.system.dept.mapper.SysDeptMapper">
|
||||
|
||||
</mapper>
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.agileboot.system.dept.service;
|
||||
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import com.agileboot.system.dept.dto.AddDeptDTO;
|
||||
import com.agileboot.system.dept.dto.DeptQuery;
|
||||
import com.agileboot.system.dept.dto.UpdateDeptDTO;
|
||||
import com.agileboot.system.dept.vo.DeptVO;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ISysDeptService {
|
||||
List<DeptVO> getDeptList(DeptQuery query);
|
||||
|
||||
DeptVO getDeptInfo(Long deptId);
|
||||
|
||||
List<Tree<Long>> getDeptTree();
|
||||
|
||||
void addDept(AddDeptDTO addCommand);
|
||||
|
||||
void updateDept(UpdateDeptDTO updateCommand);
|
||||
|
||||
void removeDept(@NotNull Long deptId);
|
||||
}
|
||||
+153
@@ -0,0 +1,153 @@
|
||||
package com.agileboot.system.dept.service.impl;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import cn.hutool.core.lang.tree.TreeUtil;
|
||||
import com.agileboot.common.core.enums.BasicEnumUtil;
|
||||
import com.agileboot.common.core.enums.common.StatusEnum;
|
||||
import com.agileboot.common.core.exception.BizException;
|
||||
import com.agileboot.common.core.exception.error.ErrorCode;
|
||||
import com.agileboot.system.dept.dto.AddDeptDTO;
|
||||
import com.agileboot.system.dept.dto.DeptQuery;
|
||||
import com.agileboot.system.dept.dto.UpdateDeptDTO;
|
||||
import com.agileboot.system.dept.entity.SysDept;
|
||||
import com.agileboot.system.dept.mapper.SysDeptMapper;
|
||||
import com.agileboot.system.dept.service.ISysDeptService;
|
||||
import com.agileboot.system.dept.vo.DeptVO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> implements ISysDeptService {
|
||||
@Override
|
||||
public List<DeptVO> getDeptList(DeptQuery query) {
|
||||
List<SysDept> list = super.list(query.toQueryWrapper());
|
||||
return list.stream().map(DeptVO::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeptVO getDeptInfo(Long deptId) {
|
||||
SysDept one = super.getById(deptId);
|
||||
return new DeptVO(one);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Tree<Long>> getDeptTree() {
|
||||
List<SysDept> list = super.list();
|
||||
return TreeUtil.build(list, 0L, (dept, tree) -> {
|
||||
tree.setId(dept.getDeptId());
|
||||
tree.setParentId(dept.getParentId());
|
||||
tree.putExtra("label", dept.getDeptName());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDept(AddDeptDTO addDTO) {
|
||||
Long parentId = addDTO.getParentId();
|
||||
SysDept entity = new SysDept();
|
||||
entity.setParentId(parentId);
|
||||
entity.setDeptName(addDTO.getDeptName());
|
||||
entity.setOrderNum(addDTO.getOrderNum());
|
||||
entity.setLeaderName(addDTO.getLeaderName());
|
||||
entity.setPhone(addDTO.getPhone());
|
||||
entity.setEmail(addDTO.getEmail());
|
||||
entity.setStatus(addDTO.getStatus());
|
||||
|
||||
LambdaQueryWrapper<SysDept> queryWrapper = Wrappers.lambdaQuery(SysDept.class)
|
||||
.eq(SysDept::getDeptName, addDTO.getDeptName())
|
||||
.eq(parentId != null, SysDept::getDeptId, parentId);
|
||||
if (super.exists(queryWrapper)) {
|
||||
throw new BizException(ErrorCode.Business.DEPT_NAME_IS_NOT_UNIQUE.message(), addDTO.getDeptName());
|
||||
}
|
||||
SysDept sysDept = generateAncestors(entity);
|
||||
super.save(sysDept);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDept(UpdateDeptDTO updateDTO) {
|
||||
Long deptId = updateDTO.getDeptId();
|
||||
Long parentId = updateDTO.getParentId();
|
||||
if (Objects.equals(parentId, deptId)) {
|
||||
throw new BizException(ErrorCode.Business.DEPT_PARENT_ID_IS_NOT_ALLOWED_SELF);
|
||||
}
|
||||
Integer status = updateDTO.getStatus();
|
||||
SysDept entity = super.getById(deptId);
|
||||
if (entity == null) {
|
||||
throw new BizException(ErrorCode.Business.COMMON_OBJECT_NOT_FOUND.message(), deptId, "部门");
|
||||
}
|
||||
entity.setParentId(parentId);
|
||||
entity.setDeptName(updateDTO.getDeptName());
|
||||
entity.setOrderNum(updateDTO.getOrderNum());
|
||||
entity.setLeaderName(updateDTO.getLeaderName());
|
||||
entity.setPhone(updateDTO.getPhone());
|
||||
entity.setEmail(updateDTO.getEmail());
|
||||
entity.setStatus(Convert.toInt(status, 0));
|
||||
|
||||
LambdaQueryWrapper<SysDept> queryWrapper = Wrappers.lambdaQuery(SysDept.class)
|
||||
.eq(SysDept::getDeptName, updateDTO.getDeptName())
|
||||
.ne(deptId != null, SysDept::getDeptId, deptId)
|
||||
.eq(parentId != null, SysDept::getDeptId, parentId);
|
||||
if (super.exists(queryWrapper)) {
|
||||
throw new BizException(ErrorCode.Business.DEPT_NAME_IS_NOT_UNIQUE.message(), updateDTO.getDeptName());
|
||||
}
|
||||
if (StatusEnum.DISABLE.getValue().equals(entity.getStatus()) && this.hasChildrenDept(deptId, true)) {
|
||||
throw new BizException(ErrorCode.Business.DEPT_STATUS_ID_IS_NOT_ALLOWED_CHANGE);
|
||||
}
|
||||
SysDept sysDept = generateAncestors(entity);
|
||||
super.updateById(sysDept);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeDept(Long deptId) {
|
||||
SysDept entity = super.getById(deptId);
|
||||
if (entity == null) {
|
||||
throw new BizException(ErrorCode.Business.COMMON_OBJECT_NOT_FOUND.message(), deptId, "部门");
|
||||
}
|
||||
if (this.hasChildrenDept(entity.getDeptId(), null)) {
|
||||
throw new BizException(ErrorCode.Business.DEPT_EXIST_CHILD_DEPT_NOT_ALLOW_DELETE);
|
||||
}
|
||||
if (this.isDeptAssignedToUsers(entity.getDeptId())) {
|
||||
throw new BizException(ErrorCode.Business.DEPT_EXIST_LINK_USER_NOT_ALLOW_DELETE);
|
||||
}
|
||||
super.removeById(deptId);
|
||||
}
|
||||
|
||||
private SysDept generateAncestors(SysDept entity) {
|
||||
Long parentId = entity.getParentId();
|
||||
if (parentId == null || parentId == 0) {
|
||||
entity.setAncestors(String.valueOf(parentId == null ? 0 : parentId));
|
||||
} else {
|
||||
SysDept parentDept = super.getById(parentId);
|
||||
// 检查 parentDept 是否为 null 或者状态为禁用
|
||||
if (parentDept == null || StatusEnum.DISABLE.equals(
|
||||
BasicEnumUtil.fromValue(StatusEnum.class, parentDept.getStatus()))) {
|
||||
throw new BizException(ErrorCode.Business.DEPT_PARENT_DEPT_NO_EXIST_OR_DISABLED);
|
||||
}
|
||||
// 处理 parentDept.getAncestors() 可能为 null 的情况
|
||||
String ancestors = parentDept.getAncestors() == null ? "" : parentDept.getAncestors();
|
||||
entity.setAncestors(ancestors + "," + parentId);
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
private boolean hasChildrenDept(Long deptId, Boolean enabled) {
|
||||
LambdaQueryWrapper<SysDept> queryWrapper = Wrappers.lambdaQuery(SysDept.class)
|
||||
.eq(enabled != null, SysDept::getStatus, 1)
|
||||
.and(o -> o.eq(SysDept::getParentId, deptId).or()
|
||||
.apply("FIND_IN_SET (" + deptId + " , ancestors)")
|
||||
);
|
||||
return super.exists(queryWrapper);
|
||||
}
|
||||
|
||||
private boolean isDeptAssignedToUsers(Long deptId) {
|
||||
LambdaQueryWrapper<SysDept> queryWrapper = Wrappers.lambdaQuery(SysDept.class)
|
||||
.eq(SysDept::getDeptId, deptId);
|
||||
return super.exists(queryWrapper);
|
||||
}
|
||||
}
|
||||
+68
-2
@@ -1,10 +1,22 @@
|
||||
package com.agileboot.system.log.controller;
|
||||
|
||||
|
||||
import com.agileboot.common.core.core.R;
|
||||
import com.agileboot.common.core.utils.poi.CustomExcelUtil;
|
||||
import com.agileboot.common.mybatis.core.page.PageR;
|
||||
import com.agileboot.system.log.dto.LoginLogQuery;
|
||||
import com.agileboot.system.log.dto.OperationLogQuery;
|
||||
import com.agileboot.system.log.service.ILogService;
|
||||
import com.agileboot.system.log.vo.LoginLogVO;
|
||||
import com.agileboot.system.log.vo.OperationLogVO;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统访问记录
|
||||
@@ -15,5 +27,59 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RequiredArgsConstructor
|
||||
public class SysLogsController {
|
||||
|
||||
private final ILogService logService;
|
||||
|
||||
/**
|
||||
* 登录日志列表
|
||||
*/
|
||||
@GetMapping("/loginLogs")
|
||||
public R<PageR<LoginLogVO>> loginInfoList(LoginLogQuery query) {
|
||||
PageR<LoginLogVO> page = logService.getLoginInfoList(query);
|
||||
return R.ok(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将登录日志导出到excel
|
||||
*/
|
||||
@GetMapping("/loginLogs/excel")
|
||||
public void loginInfosExcel(HttpServletResponse response, LoginLogQuery query) {
|
||||
PageR<LoginLogVO> page = logService.getLoginInfoList(query);
|
||||
CustomExcelUtil.writeToResponse(page.getRows(), LoginLogVO.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除登录日志
|
||||
*/
|
||||
@DeleteMapping("/loginLogs")
|
||||
public R<Void> removeLoginInfos(@RequestParam @NotNull @NotEmpty List<Long> ids) {
|
||||
logService.deleteLoginInfo(ids);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作日志列表
|
||||
*/
|
||||
@GetMapping("/operationLogs")
|
||||
public R<PageR<OperationLogVO>> operationLogs(OperationLogQuery query) {
|
||||
PageR<OperationLogVO> page = logService.getOperationLogList(query);
|
||||
return R.ok(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作日志导出
|
||||
*/
|
||||
@GetMapping("/operationLogs/excel")
|
||||
public void operationLogsExcel(HttpServletResponse response, OperationLogQuery query) {
|
||||
PageR<OperationLogVO> page = logService.getOperationLogList(query);
|
||||
CustomExcelUtil.writeToResponse(page.getRows(), OperationLogVO.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除操作日志
|
||||
*/
|
||||
@DeleteMapping("/operationLogs")
|
||||
public R<Void> removeOperationLogs(@RequestParam List<Long> operationIds) {
|
||||
logService.deleteOperationLog(operationIds);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.agileboot.system.log.mapper;
|
||||
|
||||
import com.agileboot.system.log.entity.SysLoginInfo;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统访问记录 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author valarchie
|
||||
* @since 2022-06-06
|
||||
*/
|
||||
public interface SysLoginInfoMapper extends BaseMapper<SysLoginInfo> {
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.agileboot.system.log.mapper;
|
||||
|
||||
import com.agileboot.system.log.entity.SysOperationLog;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 操作日志记录 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author valarchie
|
||||
* @since 2022-06-08
|
||||
*/
|
||||
public interface SysOperationLogMapper extends BaseMapper<SysOperationLog> {
|
||||
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.agileboot.system.log.mapper.SysLoginInfoMapper">
|
||||
|
||||
</mapper>
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.agileboot.system.log.mapper.SysOperationLogMapper">
|
||||
|
||||
</mapper>
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.agileboot.system.log.service;
|
||||
|
||||
import com.agileboot.common.mybatis.core.page.PageR;
|
||||
import com.agileboot.system.log.dto.LoginLogQuery;
|
||||
import com.agileboot.system.log.dto.OperationLogQuery;
|
||||
import com.agileboot.system.log.vo.LoginLogVO;
|
||||
import com.agileboot.system.log.vo.OperationLogVO;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ILogService {
|
||||
PageR<LoginLogVO> getLoginInfoList(LoginLogQuery query);
|
||||
|
||||
void deleteLoginInfo(@NotNull @NotEmpty List<Long> ids);
|
||||
|
||||
PageR<OperationLogVO> getOperationLogList(OperationLogQuery query);
|
||||
|
||||
void deleteOperationLog(List<Long> operationIds);
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
package com.agileboot.system.log.service.impl;
|
||||
|
||||
import com.agileboot.common.mybatis.core.page.PageR;
|
||||
import com.agileboot.system.log.dto.LoginLogQuery;
|
||||
import com.agileboot.system.log.dto.OperationLogQuery;
|
||||
import com.agileboot.system.log.entity.SysLoginInfo;
|
||||
import com.agileboot.system.log.entity.SysOperationLog;
|
||||
import com.agileboot.system.log.mapper.SysLoginInfoMapper;
|
||||
import com.agileboot.system.log.mapper.SysOperationLogMapper;
|
||||
import com.agileboot.system.log.service.ILogService;
|
||||
import com.agileboot.system.log.vo.LoginLogVO;
|
||||
import com.agileboot.system.log.vo.OperationLogVO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class LogServiceImpl implements ILogService {
|
||||
|
||||
@Resource
|
||||
private SysLoginInfoMapper sysLoginInfoMapper;
|
||||
@Resource
|
||||
private SysOperationLogMapper sysOperationLogMapper;
|
||||
|
||||
@Override
|
||||
public PageR<LoginLogVO> getLoginInfoList(LoginLogQuery query) {
|
||||
Page<SysLoginInfo> page = sysLoginInfoMapper.selectPage(query.toPage(), query.toQueryWrapper());
|
||||
IPage<LoginLogVO> pageVO = page.convert(LoginLogVO::new);
|
||||
return new PageR<>(pageVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteLoginInfo(List<Long> ids) {
|
||||
LambdaQueryWrapper<SysLoginInfo> wrapper = Wrappers.lambdaQuery(SysLoginInfo.class)
|
||||
.in(SysLoginInfo::getInfoId, ids);
|
||||
sysLoginInfoMapper.delete(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageR<OperationLogVO> getOperationLogList(OperationLogQuery query) {
|
||||
Page<SysOperationLog> page = sysOperationLogMapper.selectPage(query.toPage(), query.toQueryWrapper());
|
||||
IPage<OperationLogVO> pageVO = page.convert(OperationLogVO::new);
|
||||
return new PageR<>(pageVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteOperationLog(List<Long> operationIds) {
|
||||
sysOperationLogMapper.deleteByIds(operationIds);
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -4,7 +4,7 @@ import cn.hutool.core.lang.tree.Tree;
|
||||
import com.agileboot.common.core.core.R;
|
||||
import com.agileboot.common.satoken.pojo.LoginUser;
|
||||
import com.agileboot.common.satoken.utils.LoginHelper;
|
||||
import com.agileboot.system.menu.pojo.dto.*;
|
||||
import com.agileboot.system.menu.dto.*;
|
||||
import com.agileboot.system.menu.service.ISysMenuService;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -59,7 +59,7 @@ public class SysMenuController {
|
||||
* 内链 和 外链
|
||||
*/
|
||||
@PostMapping
|
||||
public R<Void> add(@RequestBody AddMenuCommand addCommand) {
|
||||
public R<Void> add(@RequestBody AddMenuDTO addCommand) {
|
||||
sysMenuService.addMenu(addCommand);
|
||||
return R.ok();
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class SysMenuController {
|
||||
* 修改菜单
|
||||
*/
|
||||
@PostMapping("/{menuId}")
|
||||
public R<Void> edit(@PathVariable("menuId") Long menuId, @RequestBody UpdateMenuCommand updateCommand) {
|
||||
public R<Void> edit(@PathVariable("menuId") Long menuId, @RequestBody UpdateMenuDTO updateCommand) {
|
||||
updateCommand.setMenuId(menuId);
|
||||
sysMenuService.updateMenu(updateCommand);
|
||||
return R.ok();
|
||||
@@ -77,7 +77,7 @@ public class SysMenuController {
|
||||
/**
|
||||
* 删除菜单
|
||||
*/
|
||||
@PostMapping("/{menuId}")
|
||||
@PostMapping("/del/{menuId}")
|
||||
public R<Void> remove(@PathVariable("menuId") Long menuId) {
|
||||
sysMenuService.remove(menuId);
|
||||
return R.ok();
|
||||
|
||||
+14
-14
@@ -1,6 +1,6 @@
|
||||
package com.agileboot.system.menu.mapper;
|
||||
|
||||
import com.agileboot.system.menu.pojo.entity.SysMenu;
|
||||
import com.agileboot.system.menu.entity.SysMenu;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
@@ -24,14 +24,14 @@ public interface SysMenuMapper extends BaseMapper<SysMenu> {
|
||||
* @return 菜单列表
|
||||
*/
|
||||
@Select("SELECT DISTINCT m.* "
|
||||
+ "FROM sys_menu m "
|
||||
+ " LEFT JOIN sys_role_menu rm ON m.menu_id = rm.menu_id "
|
||||
+ " LEFT JOIN sys_user u ON rm.role_id = u.role_id "
|
||||
+ "WHERE u.user_id = #{userId} "
|
||||
+ " AND m.status = 1 "
|
||||
+ " AND m.deleted = 0 "
|
||||
+ "ORDER BY m.parent_id")
|
||||
List<SysMenu> selectMenuListByUserId(@Param("userId")Long userId);
|
||||
+ "FROM sys_menu m "
|
||||
+ " LEFT JOIN sys_role_menu rm ON m.menu_id = rm.menu_id "
|
||||
+ " LEFT JOIN sys_user u ON rm.role_id = u.role_id "
|
||||
+ "WHERE u.user_id = #{userId} "
|
||||
+ " AND m.status = 1 "
|
||||
+ " AND m.deleted = 0 "
|
||||
+ "ORDER BY m.parent_id")
|
||||
List<SysMenu> selectMenuListByUserId(@Param("userId") Long userId);
|
||||
|
||||
|
||||
/**
|
||||
@@ -41,11 +41,11 @@ public interface SysMenuMapper extends BaseMapper<SysMenu> {
|
||||
* @return 选中菜单列表
|
||||
*/
|
||||
@Select("SELECT DISTINCT m.menu_id "
|
||||
+ "FROM sys_menu m "
|
||||
+ " LEFT JOIN sys_role_menu rm ON m.menu_id = rm.menu_id "
|
||||
+ "WHERE rm.role_id = #{roleId} "
|
||||
+ " AND m.deleted = 0 "
|
||||
+ "GROUP BY m.menu_id ")
|
||||
+ "FROM sys_menu m "
|
||||
+ " LEFT JOIN sys_role_menu rm ON m.menu_id = rm.menu_id "
|
||||
+ "WHERE rm.role_id = #{roleId} "
|
||||
+ " AND m.deleted = 0 "
|
||||
+ "GROUP BY m.menu_id ")
|
||||
List<Long> selectMenuIdsByRoleId(@Param("roleId") Long roleId);
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.agileboot.system.menu.pojo.entity.SysMenu">
|
||||
<mapper namespace="com.agileboot.system.menu.mapper.SysMenuMapper">
|
||||
|
||||
</mapper>
|
||||
|
||||
+5
-3
@@ -2,7 +2,7 @@ package com.agileboot.system.menu.service;
|
||||
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import com.agileboot.common.satoken.pojo.LoginUser;
|
||||
import com.agileboot.system.menu.pojo.dto.*;
|
||||
import com.agileboot.system.menu.dto.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -13,9 +13,11 @@ public interface ISysMenuService {
|
||||
|
||||
List<Tree<Long>> getDropdownList(LoginUser loginUser);
|
||||
|
||||
void addMenu(AddMenuCommand addCommand);
|
||||
void addMenu(AddMenuDTO addCommand);
|
||||
|
||||
void updateMenu(UpdateMenuCommand updateCommand);
|
||||
void updateMenu(UpdateMenuDTO updateCommand);
|
||||
|
||||
void remove(Long menuId);
|
||||
|
||||
List<Long> getMenuIdsByRoleId(Long roleId);
|
||||
}
|
||||
|
||||
+9
-4
@@ -8,9 +8,9 @@ import com.agileboot.common.core.exception.BizException;
|
||||
import com.agileboot.common.core.exception.error.ErrorCode;
|
||||
import com.agileboot.common.core.utils.jackson.JacksonUtil;
|
||||
import com.agileboot.common.satoken.pojo.LoginUser;
|
||||
import com.agileboot.system.menu.dto.*;
|
||||
import com.agileboot.system.menu.entity.SysMenu;
|
||||
import com.agileboot.system.menu.mapper.SysMenuMapper;
|
||||
import com.agileboot.system.menu.pojo.dto.*;
|
||||
import com.agileboot.system.menu.pojo.entity.SysMenu;
|
||||
import com.agileboot.system.menu.service.ISysMenuService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -62,7 +62,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMenu(AddMenuCommand addCommand) {
|
||||
public void addMenu(AddMenuDTO addCommand) {
|
||||
SysMenu entity = new SysMenu();
|
||||
BeanUtils.copyProperties(addCommand, entity, "menuId");
|
||||
String metaInfo = JacksonUtil.to(addCommand.getMeta());
|
||||
@@ -92,7 +92,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMenu(UpdateMenuCommand updateCommand) {
|
||||
public void updateMenu(UpdateMenuDTO updateCommand) {
|
||||
|
||||
}
|
||||
|
||||
@@ -109,6 +109,11 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
super.removeById(menuId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> getMenuIdsByRoleId(Long roleId) {
|
||||
return this.baseMapper.selectMenuIdsByRoleId(roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建前端所需要树结构
|
||||
*
|
||||
|
||||
+51
-2
@@ -1,8 +1,15 @@
|
||||
package com.agileboot.system.monitor.controller;
|
||||
|
||||
import com.agileboot.common.core.core.R;
|
||||
import com.agileboot.common.mybatis.core.page.PageR;
|
||||
import com.agileboot.system.monitor.service.ISysMonitorService;
|
||||
import com.agileboot.system.monitor.vo.OnlineUserVO;
|
||||
import com.agileboot.system.monitor.vo.RedisCacheInfoVO;
|
||||
import com.agileboot.system.monitor.vo.ServerInfo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 缓存监控
|
||||
@@ -12,4 +19,46 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RequiredArgsConstructor
|
||||
public class MonitorController {
|
||||
|
||||
private final ISysMonitorService sysMonitorService;
|
||||
|
||||
/**
|
||||
* Redis信息
|
||||
*/
|
||||
@GetMapping("/cacheInfo")
|
||||
public R<RedisCacheInfoVO> getRedisCacheInfo() {
|
||||
RedisCacheInfoVO redisCacheInfo = sysMonitorService.getRedisCacheInfo();
|
||||
return R.ok(redisCacheInfo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 服务器信息
|
||||
*/
|
||||
@GetMapping("/serverInfo")
|
||||
public R<ServerInfo> getServerInfo() {
|
||||
ServerInfo serverInfo = sysMonitorService.getServerInfo();
|
||||
return R.ok(serverInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取在线用户列表
|
||||
*
|
||||
* @param ipAddress ip地址
|
||||
* @param username 用户名
|
||||
* @return 分页处理后的在线用户信息
|
||||
*/
|
||||
@GetMapping("/onlineUsers")
|
||||
public R<PageR<OnlineUserVO>> onlineUsers(String ipAddress, String username) {
|
||||
List<OnlineUserVO> onlineUserList = sysMonitorService.getOnlineUserList(username, ipAddress);
|
||||
return R.ok(new PageR<>(onlineUserList));
|
||||
}
|
||||
|
||||
/**
|
||||
* 强退用户
|
||||
*/
|
||||
@DeleteMapping("/onlineUser/{tokenId}")
|
||||
public R<Void> logoutOnlineUser(@PathVariable String tokenId) {
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.agileboot.system.monitor.service;
|
||||
|
||||
import com.agileboot.system.monitor.vo.OnlineUserVO;
|
||||
import com.agileboot.system.monitor.vo.RedisCacheInfoVO;
|
||||
import com.agileboot.system.monitor.vo.ServerInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ISysMonitorService {
|
||||
RedisCacheInfoVO getRedisCacheInfo();
|
||||
|
||||
ServerInfo getServerInfo();
|
||||
|
||||
List<OnlineUserVO> getOnlineUserList(String username, String ipAddress);
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.agileboot.system.monitor.service.impl;
|
||||
|
||||
import com.agileboot.system.monitor.service.ISysMonitorService;
|
||||
import com.agileboot.system.monitor.vo.OnlineUserVO;
|
||||
import com.agileboot.system.monitor.vo.RedisCacheInfoVO;
|
||||
import com.agileboot.system.monitor.vo.ServerInfo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class SysMonitorServiceImpl implements ISysMonitorService {
|
||||
|
||||
@Override
|
||||
public RedisCacheInfoVO getRedisCacheInfo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerInfo getServerInfo() {
|
||||
return ServerInfo.fillInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OnlineUserVO> getOnlineUserList(String username, String ipAddress) {
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
+68
-2
@@ -1,9 +1,19 @@
|
||||
package com.agileboot.system.notice.controller;
|
||||
|
||||
import com.agileboot.common.core.core.R;
|
||||
import com.agileboot.common.mybatis.core.page.PageR;
|
||||
import com.agileboot.system.notice.dto.NoticeAddDTO;
|
||||
import com.agileboot.system.notice.dto.NoticeQuery;
|
||||
import com.agileboot.system.notice.dto.NoticeUpdateDTO;
|
||||
import com.agileboot.system.notice.dto.NoticeVO;
|
||||
import com.agileboot.system.notice.service.ISysNoticeService;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Positive;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 公告 信息操作处理
|
||||
@@ -14,5 +24,61 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RequiredArgsConstructor
|
||||
public class SysNoticeController {
|
||||
|
||||
private final ISysNoticeService sysNoticeService;
|
||||
|
||||
/**
|
||||
* 获取通知公告列表
|
||||
*/
|
||||
@GetMapping
|
||||
public PageR<NoticeVO> list(NoticeQuery query) {
|
||||
PageR<NoticeVO> page = sysNoticeService.getNoticeList(query);
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取通知公告列表
|
||||
* 从从库获取数据 例子 仅供参考
|
||||
*/
|
||||
@GetMapping("/database/slave")
|
||||
public R<PageR<NoticeVO>> listFromSlave(NoticeQuery query) {
|
||||
PageR<NoticeVO> page = sysNoticeService.getNoticeList(query);
|
||||
return R.ok(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据通知公告编号获取详细信息
|
||||
*/
|
||||
@GetMapping(value = "/{noticeId}")
|
||||
public R<NoticeVO> getInfo(@PathVariable @NotNull @Positive Long noticeId) {
|
||||
NoticeVO vo = sysNoticeService.getNoticeInfo(noticeId);
|
||||
return R.ok(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增通知公告
|
||||
*/
|
||||
@PostMapping
|
||||
public R<Void> add(@RequestBody NoticeAddDTO addDTO) {
|
||||
sysNoticeService.addNotice(addDTO);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改通知公告
|
||||
*/
|
||||
@PutMapping("/{noticeId}")
|
||||
public R<Void> edit(@PathVariable Long noticeId, @RequestBody NoticeUpdateDTO updateDTO) {
|
||||
updateDTO.setNoticeId(noticeId);
|
||||
sysNoticeService.updateNotice(updateDTO);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除通知公告
|
||||
*/
|
||||
@DeleteMapping
|
||||
public R<Void> remove(@RequestParam List<Integer> noticeIds) {
|
||||
sysNoticeService.deleteNotice(noticeIds);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.agileboot.system.notice.mapper;
|
||||
|
||||
import com.agileboot.system.notice.entity.SysNotice;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 菜单权限表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author valarchie
|
||||
* @since 2022-06-16
|
||||
*/
|
||||
public interface SysNoticeMapper extends BaseMapper<SysNotice> {
|
||||
|
||||
/**
|
||||
* 根据条件分页查询角色关联的用户列表
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param queryWrapper 条件选择器
|
||||
* @return 分页处理后的公告列表
|
||||
*/
|
||||
@Select("SELECT n.* "
|
||||
+ "FROM sys_notice n "
|
||||
+ "LEFT JOIN sys_user u ON n.creator_id = u.user_id"
|
||||
+ " ${ew.customSqlSegment}")
|
||||
Page<SysNotice> getNoticeList(Page<SysNotice> page, @Param(Constants.WRAPPER) Wrapper<SysNotice> queryWrapper);
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.agileboot.system.notice.mapper.SysNoticeMapper">
|
||||
|
||||
</mapper>
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.agileboot.system.notice.service;
|
||||
|
||||
import com.agileboot.common.mybatis.core.page.PageR;
|
||||
import com.agileboot.system.notice.dto.NoticeAddDTO;
|
||||
import com.agileboot.system.notice.dto.NoticeQuery;
|
||||
import com.agileboot.system.notice.dto.NoticeUpdateDTO;
|
||||
import com.agileboot.system.notice.dto.NoticeVO;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Positive;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ISysNoticeService {
|
||||
PageR<NoticeVO> getNoticeList(NoticeQuery query);
|
||||
|
||||
NoticeVO getNoticeInfo(@NotNull @Positive Long noticeId);
|
||||
|
||||
void addNotice(NoticeAddDTO addCommand);
|
||||
|
||||
void updateNotice(NoticeUpdateDTO updateCommand);
|
||||
|
||||
void deleteNotice(List<Integer> noticeIds);
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
package com.agileboot.system.notice.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.agileboot.common.core.enums.BasicEnumUtil;
|
||||
import com.agileboot.common.core.enums.common.NoticeTypeEnum;
|
||||
import com.agileboot.common.core.enums.common.StatusEnum;
|
||||
import com.agileboot.common.core.exception.BizException;
|
||||
import com.agileboot.common.core.exception.error.ErrorCode;
|
||||
import com.agileboot.common.mybatis.core.page.PageR;
|
||||
import com.agileboot.system.notice.dto.NoticeAddDTO;
|
||||
import com.agileboot.system.notice.dto.NoticeQuery;
|
||||
import com.agileboot.system.notice.dto.NoticeUpdateDTO;
|
||||
import com.agileboot.system.notice.dto.NoticeVO;
|
||||
import com.agileboot.system.notice.entity.SysNotice;
|
||||
import com.agileboot.system.notice.mapper.SysNoticeMapper;
|
||||
import com.agileboot.system.notice.service.ISysNoticeService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice> implements ISysNoticeService {
|
||||
@Override
|
||||
public PageR<NoticeVO> getNoticeList(NoticeQuery query) {
|
||||
QueryWrapper<SysNotice> queryWrapper = new QueryWrapper<SysNotice>()
|
||||
.like(StrUtil.isNotEmpty(query.getNoticeTitle()), "notice_title", query.getNoticeTitle())
|
||||
.eq(StrUtil.isNotEmpty(query.getNoticeType()), "notice_type", query.getNoticeType())
|
||||
.eq("n.deleted", 0)
|
||||
.like(StrUtil.isNotEmpty(query.getCreatorName()), "u.username", query.getCreatorName());
|
||||
Page<SysNotice> page = this.baseMapper.getNoticeList(query.toPage(), queryWrapper);
|
||||
IPage<NoticeVO> convert = page.convert(NoticeVO::new);
|
||||
return new PageR<>(convert);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NoticeVO getNoticeInfo(Long noticeId) {
|
||||
SysNotice byId = super.getById(noticeId);
|
||||
if (byId == null) {
|
||||
throw new BizException(ErrorCode.Business.COMMON_OBJECT_NOT_FOUND.message(), noticeId, "通知公告");
|
||||
}
|
||||
return new NoticeVO(byId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNotice(NoticeAddDTO addDTO) {
|
||||
BasicEnumUtil.fromValue(NoticeTypeEnum.class, addDTO.getNoticeType());
|
||||
BasicEnumUtil.fromValue(StatusEnum.class, addDTO.getStatus());
|
||||
|
||||
SysNotice sysNotice = new SysNotice();
|
||||
BeanUtil.copyProperties(addDTO, sysNotice);
|
||||
super.save(sysNotice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNotice(NoticeUpdateDTO updateDTO) {
|
||||
BasicEnumUtil.fromValue(NoticeTypeEnum.class, updateDTO.getNoticeType());
|
||||
BasicEnumUtil.fromValue(StatusEnum.class, updateDTO.getStatus());
|
||||
|
||||
Long noticeId = updateDTO.getNoticeId();
|
||||
SysNotice byId = super.getById(noticeId);
|
||||
if (byId == null) {
|
||||
throw new BizException(ErrorCode.Business.COMMON_OBJECT_NOT_FOUND, noticeId, "通知公告");
|
||||
}
|
||||
BeanUtil.copyProperties(updateDTO, byId, "noticeId");
|
||||
super.updateById(byId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteNotice(List<Integer> noticeIds) {
|
||||
super.removeBatchByIds(noticeIds);
|
||||
}
|
||||
}
|
||||
+73
-2
@@ -1,9 +1,21 @@
|
||||
package com.agileboot.system.post.controller;
|
||||
|
||||
import com.agileboot.common.core.core.R;
|
||||
import com.agileboot.common.core.utils.poi.CustomExcelUtil;
|
||||
import com.agileboot.common.mybatis.core.page.PageR;
|
||||
import com.agileboot.system.post.dto.AddPostDTO;
|
||||
import com.agileboot.system.post.dto.PostQuery;
|
||||
import com.agileboot.system.post.dto.PostVO;
|
||||
import com.agileboot.system.post.dto.UpdatePostDTO;
|
||||
import com.agileboot.system.post.service.ISysPostService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 岗位信息操作处理
|
||||
@@ -14,5 +26,64 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RequiredArgsConstructor
|
||||
public class SysPostController {
|
||||
|
||||
private final ISysPostService sysPostService;
|
||||
|
||||
/**
|
||||
* 获取岗位列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public R<PageR<PostVO>> list(PostQuery query) {
|
||||
PageR<PostVO> page = sysPostService.getPostList(query);
|
||||
return R.ok(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出查询到的所有岗位信息到excel文件
|
||||
*
|
||||
* @param response http响应
|
||||
* @param query 查询参数
|
||||
* @author Kevin Zhang
|
||||
* @date 2023-10-02
|
||||
*/
|
||||
@GetMapping("/excel")
|
||||
public void export(HttpServletResponse response, PostQuery query) {
|
||||
List<PostVO> all = sysPostService.getPostListAll(query);
|
||||
CustomExcelUtil.writeToResponse(all, PostVO.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据岗位编号获取详细信息
|
||||
*/
|
||||
@GetMapping(value = "/{postId}")
|
||||
public R<PostVO> getInfo(@PathVariable Long postId) {
|
||||
PostVO post = sysPostService.getPostInfo(postId);
|
||||
return R.ok(post);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增岗位
|
||||
*/
|
||||
@PostMapping
|
||||
public R<Void> add(@RequestBody AddPostDTO addDTO) {
|
||||
sysPostService.addPost(addDTO);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改岗位
|
||||
*/
|
||||
@PutMapping
|
||||
public R<Void> edit(@RequestBody UpdatePostDTO updateCommand) {
|
||||
sysPostService.updatePost(updateCommand);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除岗位
|
||||
*/
|
||||
@DeleteMapping
|
||||
public R<Void> remove(@RequestParam @NotNull @NotEmpty List<Long> ids) {
|
||||
sysPostService.deletePost(ids);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.agileboot.system.post.mapper;
|
||||
|
||||
import com.agileboot.system.post.entity.SysPost;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 菜单权限表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author valarchie
|
||||
* @since 2022-06-16
|
||||
*/
|
||||
public interface SysPostMapper extends BaseMapper<SysPost> {
|
||||
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.agileboot.system.post.mapper.SysPostMapper">
|
||||
|
||||
</mapper>
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.agileboot.system.post.service;
|
||||
|
||||
import com.agileboot.common.mybatis.core.page.PageR;
|
||||
import com.agileboot.system.post.dto.AddPostDTO;
|
||||
import com.agileboot.system.post.dto.PostQuery;
|
||||
import com.agileboot.system.post.dto.PostVO;
|
||||
import com.agileboot.system.post.dto.UpdatePostDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ISysPostService {
|
||||
PostVO getPostInfo(Long postId);
|
||||
|
||||
PageR<PostVO> getPostList(PostQuery query);
|
||||
|
||||
List<PostVO> getPostListAll(PostQuery query);
|
||||
|
||||
void addPost(AddPostDTO addDTO);
|
||||
|
||||
void updatePost(UpdatePostDTO updateDTO);
|
||||
|
||||
void deletePost(List<Long> ids);
|
||||
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
package com.agileboot.system.post.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.agileboot.common.core.exception.BizException;
|
||||
import com.agileboot.common.core.exception.error.ErrorCode;
|
||||
import com.agileboot.common.mybatis.core.page.PageR;
|
||||
import com.agileboot.system.post.dto.AddPostDTO;
|
||||
import com.agileboot.system.post.dto.PostQuery;
|
||||
import com.agileboot.system.post.dto.PostVO;
|
||||
import com.agileboot.system.post.dto.UpdatePostDTO;
|
||||
import com.agileboot.system.post.entity.SysPost;
|
||||
import com.agileboot.system.post.mapper.SysPostMapper;
|
||||
import com.agileboot.system.post.service.ISysPostService;
|
||||
import com.agileboot.system.user.entity.SysUser;
|
||||
import com.agileboot.system.user.mapper.SysUserMapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class SysPostServiceImpl extends ServiceImpl<SysPostMapper, SysPost> implements ISysPostService {
|
||||
|
||||
@Resource
|
||||
private SysUserMapper sysUserMapper;
|
||||
|
||||
@Override
|
||||
public PostVO getPostInfo(Long postId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageR<PostVO> getPostList(PostQuery query) {
|
||||
Page<SysPost> page = super.page(query.toPage(), query.toQueryWrapper());
|
||||
IPage<PostVO> convert = page.convert(PostVO::new);
|
||||
return new PageR<>(convert);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询满足条件的所有岗位,不分页
|
||||
*
|
||||
* @param query 查询条件
|
||||
* @return 满足查询条件的岗位列表
|
||||
* @author Kevin Zhang
|
||||
*/
|
||||
@Override
|
||||
public List<PostVO> getPostListAll(PostQuery query) {
|
||||
List<SysPost> all = super.list(query.toQueryWrapper());
|
||||
List<PostVO> records = all.stream().map(PostVO::new).collect(Collectors.toList());
|
||||
return records;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPost(AddPostDTO addDTO) {
|
||||
SysPost sysPost = new SysPost();
|
||||
BeanUtil.copyProperties(addDTO, sysPost);
|
||||
|
||||
if (this.isPostNameDuplicated(null, sysPost.getPostName())) {
|
||||
throw new BizException(ErrorCode.Business.POST_NAME_IS_NOT_UNIQUE, sysPost.getPostName());
|
||||
}
|
||||
if (this.isPostCodeDuplicated(null, sysPost.getPostCode())) {
|
||||
throw new BizException(ErrorCode.Business.POST_CODE_IS_NOT_UNIQUE, sysPost.getPostCode());
|
||||
}
|
||||
super.save(sysPost);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePost(UpdatePostDTO updateDTO) {
|
||||
Long postId = updateDTO.getPostId();
|
||||
SysPost sysPost = super.getById(postId);
|
||||
if (sysPost == null) {
|
||||
throw new BizException(ErrorCode.Business.COMMON_OBJECT_NOT_FOUND, postId, "职位");
|
||||
}
|
||||
BeanUtil.copyProperties(updateDTO, sysPost, "postId");
|
||||
if (this.isPostNameDuplicated(postId, sysPost.getPostName())) {
|
||||
throw new BizException(ErrorCode.Business.POST_NAME_IS_NOT_UNIQUE, sysPost.getPostName());
|
||||
}
|
||||
if (this.isPostCodeDuplicated(postId, sysPost.getPostCode())) {
|
||||
throw new BizException(ErrorCode.Business.POST_CODE_IS_NOT_UNIQUE, sysPost.getPostCode());
|
||||
}
|
||||
super.updateById(sysPost);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deletePost(List<Long> ids) {
|
||||
// 检测职位是否分配给用户
|
||||
LambdaQueryWrapper<SysUser> queryWrapper = Wrappers.lambdaQuery(SysUser.class)
|
||||
.in(SysUser::getPostId, ids);
|
||||
if (sysUserMapper.exists(queryWrapper)) {
|
||||
throw new BizException(ErrorCode.Business.POST_ALREADY_ASSIGNED_TO_USER_CAN_NOT_BE_DELETED);
|
||||
}
|
||||
super.removeBatchByIds(ids);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
private boolean isPostNameDuplicated(Long postId, String postName) {
|
||||
LambdaQueryWrapper<SysPost> queryWrapper = Wrappers.lambdaQuery(SysPost.class)
|
||||
.ne(postId != null, SysPost::getPostId, postId)
|
||||
.eq(SysPost::getPostName, postName);
|
||||
return baseMapper.exists(queryWrapper);
|
||||
}
|
||||
|
||||
private boolean isPostCodeDuplicated(Long postId, String postCode) {
|
||||
LambdaQueryWrapper<SysPost> queryWrapper = Wrappers.lambdaQuery(SysPost.class)
|
||||
.ne(postId != null, SysPost::getPostId, postId)
|
||||
.eq(SysPost::getPostCode, postCode);
|
||||
return baseMapper.exists(queryWrapper);
|
||||
}
|
||||
}
|
||||
+32
-34
@@ -2,11 +2,10 @@ package com.agileboot.system.role.controller;
|
||||
|
||||
import com.agileboot.common.core.core.R;
|
||||
import com.agileboot.common.core.utils.poi.CustomExcelUtil;
|
||||
import com.agileboot.common.satoken.pojo.RoleDTO;
|
||||
import com.agileboot.system.role.pojo.dto.*;
|
||||
import com.agileboot.common.mybatis.core.page.PageR;
|
||||
import com.agileboot.system.role.dto.*;
|
||||
import com.agileboot.system.role.service.ISysRoleService;
|
||||
import com.agileboot.system.user.pojo.dto.UserDTO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.agileboot.system.user.dto.UserVO;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -30,9 +29,9 @@ public class SysRoleController {
|
||||
* 角色列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public R<IPage<RoleDTO>> list(RoleQuery query) {
|
||||
IPage<RoleDTO> pageDTO = sysRoleService.getRoleList(query);
|
||||
return R.ok(pageDTO);
|
||||
public PageR<RoleVO> list(RoleQuery query) {
|
||||
PageR<RoleVO> page = sysRoleService.getRoleList(query);
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,25 +39,25 @@ public class SysRoleController {
|
||||
*/
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, RoleQuery query) {
|
||||
IPage<RoleDTO> pageDTO = sysRoleService.getRoleList(query);
|
||||
CustomExcelUtil.writeToResponse(pageDTO.getRecords(), RoleDTO.class, response);
|
||||
PageR<RoleVO> page = sysRoleService.getRoleList(query);
|
||||
CustomExcelUtil.writeToResponse(page.getRows(), RoleVO.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色编号获取详细信息
|
||||
*/
|
||||
@GetMapping(value = "/{roleId}")
|
||||
public R<RoleDTO> getInfo(@PathVariable @NotNull Long roleId) {
|
||||
RoleDTO roleInfo = sysRoleService.getRoleInfo(roleId);
|
||||
public R<RoleVO> getInfo(@PathVariable @NotNull Long roleId) {
|
||||
RoleVO roleInfo = sysRoleService.getRoleInfo(roleId);
|
||||
return R.ok(roleInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增角色
|
||||
*/
|
||||
@PostMapping
|
||||
public R<Void> add(@RequestBody AddRoleCommand addCommand) {
|
||||
sysRoleService.addRole(addCommand);
|
||||
@PostMapping("/create")
|
||||
public R<Void> add(@RequestBody AddRoleDTO addDTO) {
|
||||
sysRoleService.addRole(addDTO);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@@ -67,7 +66,7 @@ public class SysRoleController {
|
||||
*/
|
||||
@PostMapping(value = "/{roleId}")
|
||||
public R<Void> remove(@PathVariable("roleId") List<Long> roleIds) {
|
||||
sysRoleService.deleteRoleByBulk(roleIds);
|
||||
sysRoleService.deleteRole(roleIds);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@@ -75,8 +74,8 @@ public class SysRoleController {
|
||||
* 修改保存角色
|
||||
*/
|
||||
@PostMapping
|
||||
public R<Void> edit(@Validated @RequestBody UpdateRoleCommand updateCommand) {
|
||||
sysRoleService.updateRole(updateCommand);
|
||||
public R<Void> edit(@Validated @RequestBody UpdateRoleDTO updateDTO) {
|
||||
sysRoleService.updateRole(updateDTO);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@@ -85,10 +84,9 @@ public class SysRoleController {
|
||||
*/
|
||||
@PostMapping("/{roleId}/dataScope")
|
||||
public R<Void> dataScope(@PathVariable("roleId") Long roleId,
|
||||
@RequestBody UpdateDataScopeCommand command) {
|
||||
command.setRoleId(roleId);
|
||||
|
||||
sysRoleService.updateDataScope(command);
|
||||
@RequestBody UpdateDataScopeDTO updateDTO) {
|
||||
updateDTO.setRoleId(roleId);
|
||||
sysRoleService.updateDataScope(updateDTO);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@@ -97,10 +95,10 @@ public class SysRoleController {
|
||||
*/
|
||||
@PostMapping("/{roleId}/status")
|
||||
public R<Void> changeStatus(@PathVariable("roleId") Long roleId,
|
||||
@RequestBody UpdateStatusCommand command) {
|
||||
command.setRoleId(roleId);
|
||||
@RequestBody UpdateStatusDTO updateDTO) {
|
||||
updateDTO.setRoleId(roleId);
|
||||
|
||||
sysRoleService.updateStatus(command);
|
||||
sysRoleService.updateStatus(updateDTO);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@@ -109,22 +107,22 @@ public class SysRoleController {
|
||||
* 查询已分配用户角色列表
|
||||
*/
|
||||
@GetMapping("/{roleId}/allocated/list")
|
||||
public R<IPage<UserDTO>> allocatedUserList(@PathVariable("roleId") Long roleId,
|
||||
AllocatedRoleQuery query) {
|
||||
public PageR<UserVO> allocatedUserList(@PathVariable("roleId") Long roleId,
|
||||
AllocatedRoleQuery query) {
|
||||
query.setRoleId(roleId);
|
||||
IPage<UserDTO> page = sysRoleService.getAllocatedUserList(query);
|
||||
return R.ok(page);
|
||||
PageR<UserVO> page = sysRoleService.getAllocatedUserList(query);
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询未分配用户角色列表
|
||||
*/
|
||||
@GetMapping("/{roleId}/unallocated/list")
|
||||
public R<IPage<UserDTO>> unallocatedUserList(@PathVariable("roleId") Long roleId,
|
||||
UnallocatedRoleQuery query) {
|
||||
public PageR<UserVO> unallocatedUserList(@PathVariable("roleId") Long roleId,
|
||||
UnallocatedRoleQuery query) {
|
||||
query.setRoleId(roleId);
|
||||
IPage<UserDTO> page = sysRoleService.getUnallocatedUserList(query);
|
||||
return R.ok(page);
|
||||
PageR<UserVO> page = sysRoleService.getUnallocatedUserList(query);
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
@@ -133,7 +131,7 @@ public class SysRoleController {
|
||||
*/
|
||||
@PostMapping("/users/{userIds}/grant/bulk")
|
||||
public R<Void> deleteRoleOfUserByBulk(@PathVariable("userIds") List<Long> userIds) {
|
||||
sysRoleService.deleteRoleOfUserByBulk(userIds);
|
||||
sysRoleService.deleteRoleOfUserByUserIds(userIds);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@@ -143,7 +141,7 @@ public class SysRoleController {
|
||||
@PostMapping("/{roleId}/users/{userIds}/grant/bulk")
|
||||
public R<Void> addRoleForUserByBulk(@PathVariable("roleId") Long roleId,
|
||||
@PathVariable("userIds") List<Long> userIds) {
|
||||
sysRoleService.addRoleOfUserByBulk(roleId, userIds);
|
||||
sysRoleService.addRoleOfUserByByUserIds(roleId, userIds);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package com.agileboot.system.role.mapper;
|
||||
|
||||
import com.agileboot.system.role.pojo.entity.SysRole;
|
||||
import com.agileboot.system.role.entity.SysRole;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
public interface SysRoleMapper extends BaseMapper<SysRole> {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package com.agileboot.system.role.mapper;
|
||||
|
||||
import com.agileboot.system.role.pojo.entity.SysRoleMenu;
|
||||
import com.agileboot.system.role.entity.SysRoleMenu;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
public interface SysRoleMenuMapper extends BaseMapper<SysRoleMenu> {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.agileboot.system.role.pojo.entity.SysRole">
|
||||
<mapper namespace="com.agileboot.system.role.mapper.SysRoleMapper">
|
||||
|
||||
</mapper>
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.agileboot.system.role.pojo.entity.SysRoleMenu">
|
||||
<mapper namespace="com.agileboot.system.role.mapper.SysRoleMenuMapper">
|
||||
|
||||
</mapper>
|
||||
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
package com.agileboot.system.role.pojo.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@Data
|
||||
public class AllocatedRoleQuery {
|
||||
|
||||
private Long roleId;
|
||||
private String username;
|
||||
private String phoneNumber;
|
||||
|
||||
}
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
package com.agileboot.system.role.pojo.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@Data
|
||||
public class RoleQuery {
|
||||
|
||||
private String roleName;
|
||||
|
||||
private String roleKey;
|
||||
|
||||
private String status;
|
||||
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
package com.agileboot.system.role.pojo.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@Data
|
||||
public class UnallocatedRoleQuery {
|
||||
|
||||
private Long roleId;
|
||||
private String username;
|
||||
private String phoneNumber;
|
||||
|
||||
}
|
||||
+9
@@ -1,4 +1,13 @@
|
||||
package com.agileboot.system.role.service;
|
||||
|
||||
import com.agileboot.system.role.entity.SysRoleMenu;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ISysRoleMenuService {
|
||||
List<SysRoleMenu> listById(Long roleId);
|
||||
|
||||
boolean saveMenus(Long roleId, List<Long> menuIds);
|
||||
|
||||
void cleanOldMenus(List<Long> roleIds);
|
||||
}
|
||||
|
||||
+14
-15
@@ -1,33 +1,32 @@
|
||||
package com.agileboot.system.role.service;
|
||||
|
||||
import com.agileboot.common.satoken.pojo.RoleDTO;
|
||||
import com.agileboot.system.role.pojo.dto.*;
|
||||
import com.agileboot.system.user.pojo.dto.UserDTO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.agileboot.common.mybatis.core.page.PageR;
|
||||
import com.agileboot.system.role.dto.*;
|
||||
import com.agileboot.system.user.dto.UserVO;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ISysRoleService {
|
||||
IPage<RoleDTO> getRoleList(RoleQuery query);
|
||||
PageR<RoleVO> getRoleList(RoleQuery query);
|
||||
|
||||
RoleDTO getRoleInfo(@NotNull Long roleId);
|
||||
RoleVO getRoleInfo(@NotNull Long roleId);
|
||||
|
||||
void addRole(AddRoleCommand addCommand);
|
||||
void addRole(AddRoleDTO addDTO);
|
||||
|
||||
void deleteRoleByBulk(List<Long> roleIds);
|
||||
void deleteRole(List<Long> roleIds);
|
||||
|
||||
void updateRole(UpdateRoleCommand updateCommand);
|
||||
void updateRole(UpdateRoleDTO updateDTO);
|
||||
|
||||
void updateDataScope(UpdateDataScopeCommand command);
|
||||
void updateDataScope(UpdateDataScopeDTO updateDTO);
|
||||
|
||||
void updateStatus(UpdateStatusCommand command);
|
||||
void updateStatus(UpdateStatusDTO updateDTO);
|
||||
|
||||
IPage<UserDTO> getAllocatedUserList(AllocatedRoleQuery query);
|
||||
PageR<UserVO> getAllocatedUserList(AllocatedRoleQuery query);
|
||||
|
||||
IPage<UserDTO> getUnallocatedUserList(UnallocatedRoleQuery query);
|
||||
PageR<UserVO> getUnallocatedUserList(UnallocatedRoleQuery query);
|
||||
|
||||
void deleteRoleOfUserByBulk(List<Long> userIds);
|
||||
void deleteRoleOfUserByUserIds(List<Long> userIds);
|
||||
|
||||
void addRoleOfUserByBulk(Long roleId, List<Long> userIds);
|
||||
void addRoleOfUserByByUserIds(Long roleId, List<Long> userIds);
|
||||
}
|
||||
|
||||
+35
-1
@@ -1,12 +1,46 @@
|
||||
package com.agileboot.system.role.service.impl;
|
||||
|
||||
import com.agileboot.system.role.entity.SysRoleMenu;
|
||||
import com.agileboot.system.role.mapper.SysRoleMenuMapper;
|
||||
import com.agileboot.system.role.pojo.entity.SysRoleMenu;
|
||||
import com.agileboot.system.role.service.ISysRoleMenuService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRoleMenu> implements ISysRoleMenuService {
|
||||
|
||||
@Override
|
||||
public List<SysRoleMenu> listById(Long roleId) {
|
||||
LambdaQueryWrapper<SysRoleMenu> queryWrapper = Wrappers.lambdaQuery(SysRoleMenu.class).eq(SysRoleMenu::getRoleId, roleId);
|
||||
return super.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveMenus(Long roleId, List<Long> menuIds) {
|
||||
List<SysRoleMenu> list = new ArrayList<>();
|
||||
if (menuIds != null) {
|
||||
for (Long menuId : menuIds) {
|
||||
SysRoleMenu rm = new SysRoleMenu();
|
||||
rm.setRoleId(roleId);
|
||||
rm.setMenuId(menuId);
|
||||
list.add(rm);
|
||||
}
|
||||
return super.saveBatch(list);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanOldMenus(List<Long> roleIds) {
|
||||
if (roleIds == null || roleIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
LambdaQueryWrapper<SysRoleMenu> queryWrapper = Wrappers.lambdaQuery(SysRoleMenu.class).in(SysRoleMenu::getRoleId, roleIds);
|
||||
super.remove(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
+159
-20
@@ -1,72 +1,211 @@
|
||||
package com.agileboot.system.role.service.impl;
|
||||
|
||||
import com.agileboot.common.satoken.pojo.RoleDTO;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.agileboot.common.core.enums.common.StatusEnum;
|
||||
import com.agileboot.common.core.exception.BizException;
|
||||
import com.agileboot.common.core.exception.error.ErrorCode;
|
||||
import com.agileboot.common.mybatis.core.page.PageR;
|
||||
import com.agileboot.system.menu.service.ISysMenuService;
|
||||
import com.agileboot.system.role.dto.*;
|
||||
import com.agileboot.system.role.entity.SysRole;
|
||||
import com.agileboot.system.role.entity.SysRoleMenu;
|
||||
import com.agileboot.system.role.mapper.SysRoleMapper;
|
||||
import com.agileboot.system.role.pojo.dto.*;
|
||||
import com.agileboot.system.role.pojo.entity.SysRole;
|
||||
import com.agileboot.system.role.service.ISysRoleMenuService;
|
||||
import com.agileboot.system.role.service.ISysRoleService;
|
||||
import com.agileboot.system.user.pojo.dto.UserDTO;
|
||||
import com.agileboot.system.user.dto.UserVO;
|
||||
import com.agileboot.system.user.entity.SysUser;
|
||||
import com.agileboot.system.user.service.ISysUserService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements ISysRoleService {
|
||||
|
||||
private final ISysMenuService menuService;
|
||||
private final ISysRoleMenuService roleMenuService;
|
||||
private final ISysUserService userService;
|
||||
|
||||
@Override
|
||||
public IPage<RoleDTO> getRoleList(RoleQuery query) {
|
||||
public PageR<RoleVO> getRoleList(RoleQuery query) {
|
||||
Page<SysRole> page = this.page(query.toPage(), query.toQueryWrapper());
|
||||
IPage<RoleVO> convert = page.convert(RoleVO::new);
|
||||
return new PageR<>(convert);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoleVO getRoleInfo(Long roleId) {
|
||||
SysRole role = this.getById(roleId);
|
||||
RoleVO roleVO = new RoleVO(role);
|
||||
List<Long> selectedDeptList = Arrays.stream(StringUtils.split(role.getDeptIdSet(), ","))
|
||||
.filter(StringUtils::isNotEmpty).map(Long::parseLong).collect(Collectors.toList());
|
||||
roleVO.setSelectedDeptList(selectedDeptList);
|
||||
roleVO.setSelectedMenuList(menuService.getMenuIdsByRoleId(roleId));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoleDTO getRoleInfo(Long roleId) {
|
||||
return null;
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void addRole(AddRoleDTO addDTO) {
|
||||
SysRole entity = new SysRole();
|
||||
BeanUtil.copyProperties(addDTO, entity);
|
||||
if (this.isRoleNameDuplicated(null, addDTO.getRoleName())) {
|
||||
throw new BizException(ErrorCode.Business.ROLE_NAME_IS_NOT_UNIQUE, addDTO.getRoleName());
|
||||
}
|
||||
if (this.isRoleKeyDuplicated(null, addDTO.getRoleKey())) {
|
||||
throw new BizException(ErrorCode.Business.ROLE_KEY_IS_NOT_UNIQUE, addDTO.getRoleKey());
|
||||
}
|
||||
super.save(entity);
|
||||
roleMenuService.saveMenus(entity.getRoleId(), addDTO.getMenuIds());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRole(AddRoleCommand addCommand) {
|
||||
public void deleteRole(List<Long> roleIds) {
|
||||
if (roleIds == null) {
|
||||
return;
|
||||
}
|
||||
List<SysRole> list = super.list(Wrappers.lambdaQuery(SysRole.class).in(SysRole::getRoleId, roleIds));
|
||||
List<Long> collect = list.stream().map(SysRole::getRoleId).toList();
|
||||
roleIds.removeAll(collect);
|
||||
if (!roleIds.isEmpty()) {
|
||||
throw new BizException(ErrorCode.Business.COMMON_OBJECT_NOT_FOUND, roleIds.get(0), "角色");
|
||||
}
|
||||
List<SysUser> assignedUser = userService.assignedToUsersByRoleIds(collect);
|
||||
Map<Long, String> roleIdNameMap = list.stream().collect(Collectors.toMap(SysRole::getRoleId, SysRole::getRoleName));
|
||||
for (SysUser sysUser : assignedUser) {
|
||||
throw new BizException(ErrorCode.Business.ROLE_ALREADY_ASSIGN_TO_USER, roleIdNameMap.get(sysUser.getRoleId()));
|
||||
}
|
||||
|
||||
// 清空之前的角色菜单关联
|
||||
roleMenuService.cleanOldMenus(collect);
|
||||
super.removeBatchByIds(collect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRoleByBulk(List<Long> roleIds) {
|
||||
public void updateRole(UpdateRoleDTO updateDTO) {
|
||||
SysRole byId = super.getById(updateDTO.getRoleId());
|
||||
if (byId == null) {
|
||||
throw new BizException(ErrorCode.Business.COMMON_OBJECT_NOT_FOUND, updateDTO.getRoleId(), "角色");
|
||||
}
|
||||
List<SysRoleMenu> roleMenus = roleMenuService.listById(updateDTO.getRoleId());
|
||||
List<Long> menuIds = roleMenus.stream().map(SysRoleMenu::getMenuId).toList();
|
||||
|
||||
// List<Long> deptIds = StrUtil.split(byId.getDeptIdSet(), ",").stream().map(Convert::toLong).toList();
|
||||
|
||||
SysRole entity = new SysRole();
|
||||
BeanUtil.copyProperties(byId, entity);
|
||||
if (this.isRoleKeyDuplicated(entity.getRoleId(), entity.getRoleKey())) {
|
||||
throw new BizException(ErrorCode.Business.ROLE_KEY_IS_NOT_UNIQUE, entity.getRoleKey());
|
||||
}
|
||||
if (this.isRoleNameDuplicated(entity.getRoleId(), entity.getRoleName())) {
|
||||
throw new BizException(ErrorCode.Business.ROLE_NAME_IS_NOT_UNIQUE, entity.getRoleName());
|
||||
}
|
||||
roleMenuService.cleanOldMenus(List.of(entity.getRoleId()));
|
||||
roleMenuService.saveMenus(entity.getRoleId(), menuIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateRole(UpdateRoleCommand updateCommand) {
|
||||
public void updateDataScope(UpdateDataScopeDTO updateDTO) {
|
||||
SysRole byId = super.getById(updateDTO.getRoleId());
|
||||
if (byId == null) {
|
||||
throw new BizException(ErrorCode.Business.COMMON_OBJECT_NOT_FOUND, updateDTO.getRoleId(), "角色");
|
||||
}
|
||||
|
||||
byId.setDeptIdSet(this.generateDeptIdSet(updateDTO.getDeptIds()));
|
||||
byId.setDataScope(updateDTO.getDataScope());
|
||||
super.updateById(byId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDataScope(UpdateDataScopeCommand command) {
|
||||
public void updateStatus(UpdateStatusDTO updateDTO) {
|
||||
SysRole byId = super.getById(updateDTO.getRoleId());
|
||||
if (byId == null) {
|
||||
throw new BizException(ErrorCode.Business.COMMON_OBJECT_NOT_FOUND, updateDTO.getRoleId(), "角色");
|
||||
}
|
||||
|
||||
byId.setStatus(updateDTO.getStatus());
|
||||
super.updateById(byId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStatus(UpdateStatusCommand command) {
|
||||
|
||||
public PageR<UserVO> getAllocatedUserList(AllocatedRoleQuery query) {
|
||||
Page<SysUser> page = userService.getUserListByRole(query);
|
||||
IPage<UserVO> convert = page.convert(UserVO::new);
|
||||
return new PageR<>(convert);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<UserDTO> getAllocatedUserList(AllocatedRoleQuery query) {
|
||||
return null;
|
||||
public PageR<UserVO> getUnallocatedUserList(UnallocatedRoleQuery query) {
|
||||
Page<SysUser> page = userService.getUserListByRole(query);
|
||||
IPage<UserVO> convert = page.convert(UserVO::new);
|
||||
return new PageR<>(convert);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<UserDTO> getUnallocatedUserList(UnallocatedRoleQuery query) {
|
||||
return null;
|
||||
public void deleteRoleOfUserByUserIds(List<Long> userIds) {
|
||||
if (CollectionUtils.isEmpty(userIds)) {
|
||||
return;
|
||||
}
|
||||
userService.deleteBatchRoleId(userIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRoleOfUserByBulk(List<Long> userIds) {
|
||||
public void addRoleOfUserByByUserIds(Long roleId, List<Long> userIds) {
|
||||
if (CollectionUtils.isEmpty(userIds)) {
|
||||
return;
|
||||
}
|
||||
SysRole byId = super.getById(roleId);
|
||||
if (byId == null) {
|
||||
throw new BizException(ErrorCode.Business.COMMON_OBJECT_NOT_FOUND, roleId, "角色");
|
||||
}
|
||||
if (StatusEnum.DISABLE.getValue().equals(byId.getStatus())) {
|
||||
throw new BizException(ErrorCode.Business.ROLE_IS_NOT_AVAILABLE, byId.getRoleName());
|
||||
}
|
||||
|
||||
userService.updateBatchRoleId(roleId, userIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRoleOfUserByBulk(Long roleId, List<Long> userIds) {
|
||||
|
||||
//------------------------------
|
||||
private boolean isRoleNameDuplicated(Long roleId, String roleName) {
|
||||
LambdaQueryWrapper<SysRole> queryWrapper = Wrappers.lambdaQuery(SysRole.class)
|
||||
.ne(roleId != null, SysRole::getRoleId, roleId)
|
||||
.eq(SysRole::getRoleName, roleName);
|
||||
return this.baseMapper.exists(queryWrapper);
|
||||
}
|
||||
|
||||
private boolean isRoleKeyDuplicated(Long roleId, String roleKey) {
|
||||
LambdaQueryWrapper<SysRole> queryWrapper = Wrappers.lambdaQuery(SysRole.class)
|
||||
.ne(roleId != null, SysRole::getRoleId, roleId)
|
||||
.eq(SysRole::getRoleKey, roleKey);
|
||||
return this.baseMapper.exists(queryWrapper);
|
||||
}
|
||||
|
||||
private String generateDeptIdSet(List<Long> deptIds) {
|
||||
if (deptIds == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (deptIds.size() > new HashSet<>(deptIds).size()) {
|
||||
throw new BizException(ErrorCode.Business.ROLE_DATA_SCOPE_DUPLICATED_DEPT);
|
||||
}
|
||||
|
||||
return StrUtil.join(",", deptIds);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+8
-8
@@ -3,8 +3,8 @@ package com.agileboot.system.user.controller;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import com.agileboot.common.core.core.R;
|
||||
import com.agileboot.common.core.utils.poi.CustomExcelUtil;
|
||||
import com.agileboot.system.user.pojo.dto.*;
|
||||
import com.agileboot.system.user.pojo.entity.SearchUserDO;
|
||||
import com.agileboot.common.mybatis.core.page.PageR;
|
||||
import com.agileboot.system.user.dto.*;
|
||||
import com.agileboot.system.user.service.ISysUserService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
@@ -30,18 +30,18 @@ public class SysUserController {
|
||||
* 获取用户列表
|
||||
*/
|
||||
@GetMapping
|
||||
public R<IPage<UserDTO>> userList(SearchUserDO query) {
|
||||
IPage<UserDTO> page = sysUserService.getUserList(query);
|
||||
return R.ok(page);
|
||||
public PageR<UserVO> userList(SearchUserDTO dto) {
|
||||
IPage<UserVO> page = sysUserService.getUserList(dto);
|
||||
return new PageR<>(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户列表导出
|
||||
*/
|
||||
@GetMapping("/excel")
|
||||
public void exportUserByExcel(HttpServletResponse response, SearchUserDO query) {
|
||||
IPage<UserDTO> page = sysUserService.getUserList(query);
|
||||
CustomExcelUtil.writeToResponse(page.getRecords(), UserDTO.class, response);
|
||||
public void exportUserByExcel(HttpServletResponse response, SearchUserDTO dto) {
|
||||
IPage<UserVO> page = sysUserService.getUserList(dto);
|
||||
CustomExcelUtil.writeToResponse(page.getRecords(), UserVO.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+4
-1
@@ -1,8 +1,11 @@
|
||||
package com.agileboot.system.user.mapper;
|
||||
|
||||
import com.agileboot.system.user.pojo.entity.SysUser;
|
||||
import com.agileboot.system.user.entity.SysUser;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
|
||||
Page<SysUser> getUserListByRole(Page<Object> objectPage, LambdaQueryWrapper<?> queryWrapper);
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.agileboot.system.user.pojo.entity.SysUser">
|
||||
<mapper namespace="com.agileboot.system.user.mapper.SysUserMapper">
|
||||
|
||||
</mapper>
|
||||
|
||||
+16
-4
@@ -1,11 +1,13 @@
|
||||
package com.agileboot.system.user.service;
|
||||
|
||||
import com.agileboot.common.mybatis.core.page.PageQuery;
|
||||
import com.agileboot.common.satoken.pojo.LoginUser;
|
||||
import com.agileboot.system.user.pojo.dto.*;
|
||||
import com.agileboot.system.user.pojo.entity.SearchUserDO;
|
||||
import com.agileboot.system.user.pojo.entity.SysUser;
|
||||
import com.agileboot.system.user.dto.*;
|
||||
import com.agileboot.system.user.entity.SysUser;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface ISysUserService {
|
||||
@@ -13,7 +15,7 @@ public interface ISysUserService {
|
||||
|
||||
boolean registerUserInfo(SysUser sysUser);
|
||||
|
||||
IPage<UserDTO> getUserList(SearchUserDO query);
|
||||
IPage<UserVO> getUserList(SearchUserDTO dto);
|
||||
|
||||
void addUser(AddUserCommand command);
|
||||
|
||||
@@ -26,4 +28,14 @@ public interface ISysUserService {
|
||||
void changeUserStatus(ChangeStatusCommand command);
|
||||
|
||||
void deleteUsers(Set<Long> longs);
|
||||
|
||||
Page<SysUser> getUserListByRole(PageQuery<?> query);
|
||||
|
||||
boolean isAssignedToUsers(Long roleId);
|
||||
|
||||
List<SysUser> assignedToUsersByRoleIds(List<Long> collect);
|
||||
|
||||
void updateBatchRoleId(Long roleId, List<Long> userIds);
|
||||
|
||||
void deleteBatchRoleId(List<Long> userIds);
|
||||
}
|
||||
|
||||
+48
-4
@@ -4,21 +4,24 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import com.agileboot.common.core.constant.Constants;
|
||||
import com.agileboot.common.core.exception.BizException;
|
||||
import com.agileboot.common.core.exception.error.ErrorCode;
|
||||
import com.agileboot.common.mybatis.core.page.PageQuery;
|
||||
import com.agileboot.common.satoken.pojo.LoginUser;
|
||||
import com.agileboot.common.satoken.utils.LoginHelper;
|
||||
import com.agileboot.system.user.dto.*;
|
||||
import com.agileboot.system.user.entity.SysUser;
|
||||
import com.agileboot.system.user.mapper.SysUserMapper;
|
||||
import com.agileboot.system.user.pojo.dto.*;
|
||||
import com.agileboot.system.user.pojo.entity.SearchUserDO;
|
||||
import com.agileboot.system.user.pojo.entity.SysUser;
|
||||
import com.agileboot.system.user.service.ISysUserService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Service
|
||||
@@ -62,7 +65,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
// --------------------------------------
|
||||
|
||||
@Override
|
||||
public IPage<UserDTO> getUserList(SearchUserDO query) {
|
||||
public IPage<UserVO> getUserList(SearchUserDTO query) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -121,4 +124,45 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
public void deleteUsers(Set<Long> longs) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<SysUser> getUserListByRole(PageQuery<?> query) {
|
||||
return baseMapper.getUserListByRole(query.toPage(), query.toQueryWrapper());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAssignedToUsers(Long roleId) {
|
||||
return super.exists(Wrappers.lambdaQuery(SysUser.class).eq(SysUser::getRoleId, roleId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUser> assignedToUsersByRoleIds(List<Long> collect) {
|
||||
if (collect.isEmpty()) {
|
||||
return List.of();
|
||||
}
|
||||
return super.list(Wrappers.lambdaQuery(SysUser.class).in(SysUser::getRoleId, collect));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBatchRoleId(Long roleId, List<Long> userIds) {
|
||||
for (Long userId : userIds) {
|
||||
SysUser sysUser = super.getById(userId);
|
||||
if (sysUser == null) {
|
||||
throw new BizException(ErrorCode.Business.COMMON_OBJECT_NOT_FOUND, userId, "用户");
|
||||
}
|
||||
sysUser.setRoleId(roleId);
|
||||
if (sysUser.getIsAdmin() == 1) {
|
||||
throw new BizException(ErrorCode.Business.USER_ADMIN_CAN_NOT_BE_MODIFY);
|
||||
}
|
||||
super.updateById(sysUser);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteBatchRoleId(List<Long> userIds) {
|
||||
LambdaUpdateWrapper<SysUser> updateWrapper = Wrappers.lambdaUpdate(SysUser.class)
|
||||
.set(SysUser::getRoleId, null)
|
||||
.in(SysUser::getUserId, userIds);
|
||||
super.update(updateWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
<module>wol-auth</module>
|
||||
<module>agileboot-system-base</module>
|
||||
<module>wol-gateway</module>
|
||||
<module>wol-api</module>
|
||||
</modules>
|
||||
|
||||
<dependencyManagement>
|
||||
|
||||
+2
-2
@@ -5,13 +5,13 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import com.agileboot.auth.pojo.dto.LoginBody;
|
||||
import com.agileboot.auth.pojo.dto.RegisterBody;
|
||||
import com.agileboot.auth.pojo.vo.LoginVO;
|
||||
import com.agileboot.system.client.pojo.vo.SysClientVO;
|
||||
import com.agileboot.auth.service.IAuthStrategy;
|
||||
import com.agileboot.system.client.service.ISysClientService;
|
||||
import com.agileboot.auth.service.SysLoginService;
|
||||
import com.agileboot.common.core.constant.Constants;
|
||||
import com.agileboot.common.core.core.R;
|
||||
import com.agileboot.common.core.utils.ValidatorUtils;
|
||||
import com.agileboot.system.client.service.ISysClientService;
|
||||
import com.agileboot.system.client.vo.SysClientVO;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
+1
-1
@@ -3,8 +3,8 @@ package com.agileboot.auth.service;
|
||||
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.agileboot.auth.pojo.vo.LoginVO;
|
||||
import com.agileboot.system.client.pojo.vo.SysClientVO;
|
||||
import com.agileboot.common.core.exception.ServiceException;
|
||||
import com.agileboot.system.client.vo.SysClientVO;
|
||||
|
||||
/**
|
||||
* 授权策略
|
||||
|
||||
+1
-1
@@ -5,7 +5,6 @@ import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.crypto.digest.BCrypt;
|
||||
import com.agileboot.auth.pojo.dto.RegisterBody;
|
||||
import com.agileboot.system.user.pojo.entity.SysUser;
|
||||
import com.agileboot.auth.properties.CaptchaProperties;
|
||||
import com.agileboot.auth.properties.UserPasswordProperties;
|
||||
import com.agileboot.common.core.constant.Constants;
|
||||
@@ -15,6 +14,7 @@ import com.agileboot.common.core.exception.BizException;
|
||||
import com.agileboot.common.redis.utils.RedisUtils;
|
||||
import com.agileboot.common.satoken.pojo.LoginUser;
|
||||
import com.agileboot.common.satoken.utils.LoginHelper;
|
||||
import com.agileboot.system.user.entity.SysUser;
|
||||
import com.agileboot.system.user.service.ISysUserService;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ import com.agileboot.common.core.enums.LoginType;
|
||||
import com.agileboot.common.core.utils.ValidatorUtils;
|
||||
import com.agileboot.common.satoken.pojo.LoginUser;
|
||||
import com.agileboot.common.satoken.utils.LoginHelper;
|
||||
import com.agileboot.system.client.pojo.vo.SysClientVO;
|
||||
import com.agileboot.system.client.vo.SysClientVO;
|
||||
import com.agileboot.system.user.service.ISysUserService;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
<module>agileboot-system</module>
|
||||
<module>agileboot-boot-start</module>
|
||||
<module>agileboot-cloud</module>
|
||||
<module>wol-domain</module>
|
||||
<module>wol-api</module>
|
||||
<module>wol-modules</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
@@ -46,6 +48,7 @@
|
||||
<guava.version>31.0.1-jre</guava.version>
|
||||
<fastjson2.version>2.0.58</fastjson2.version>
|
||||
<satoken.version>1.44.0</satoken.version>
|
||||
<oshi.version>6.4.0</oshi.version>
|
||||
|
||||
|
||||
<!-- 插件版本 -->
|
||||
@@ -90,6 +93,11 @@
|
||||
<artifactId>wol-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.agileboot</groupId>
|
||||
<artifactId>wol-domain</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- <!– 阿里数据库连接池 –>-->
|
||||
<!-- <dependency>-->
|
||||
@@ -153,12 +161,12 @@
|
||||
<!-- <version>${pagehelper.boot.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- <!– 获取系统信息 –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.github.oshi</groupId>-->
|
||||
<!-- <artifactId>oshi-core</artifactId>-->
|
||||
<!-- <version>${oshi.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- 获取系统信息 -->
|
||||
<dependency>
|
||||
<groupId>com.github.oshi</groupId>
|
||||
<artifactId>oshi-core</artifactId>
|
||||
<version>${oshi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- io常用工具类 -->
|
||||
<dependency>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.agileboot</groupId>
|
||||
<artifactId>agileboot-system</artifactId>
|
||||
<artifactId>agileboot</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.agileboot</groupId>
|
||||
<artifactId>agileboot</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>wol-domain</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.agileboot</groupId>
|
||||
<artifactId>wol-common-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.agileboot</groupId>
|
||||
<artifactId>wol-common-mybatis</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- 获取系统信息 -->
|
||||
<dependency>
|
||||
<groupId>com.github.oshi</groupId>
|
||||
<artifactId>oshi-core</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
+1
-2
@@ -1,9 +1,8 @@
|
||||
package com.agileboot.system.client.pojo.entity;
|
||||
package com.agileboot.system.client.entity;
|
||||
|
||||
import com.agileboot.common.mybatis.core.domain.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.agileboot.system.client.pojo.vo;
|
||||
package com.agileboot.system.client.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.agileboot.system.config.dto;
|
||||
|
||||
import com.agileboot.common.mybatis.core.page.PageQuery;
|
||||
import com.agileboot.system.config.entity.SysConfig;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* 配置查询参数
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class ConfigQuery extends PageQuery<SysConfig> {
|
||||
|
||||
// 配置名称
|
||||
private String configName;
|
||||
|
||||
// 配置key
|
||||
private String configKey;
|
||||
|
||||
// 是否允许更改配置
|
||||
private Boolean isAllowChange;
|
||||
|
||||
@Override
|
||||
public LambdaQueryWrapper<SysConfig> toQueryWrapper() {
|
||||
return Wrappers.lambdaQuery(SysConfig.class)
|
||||
.like(StringUtils.isNotEmpty(configName), SysConfig::getConfigName, configName)
|
||||
.eq(StringUtils.isNotEmpty(configKey), SysConfig::getConfigKey, configKey)
|
||||
.eq(isAllowChange != null, SysConfig::getIsAllowChange, isAllowChange)
|
||||
.orderByDesc(SysConfig::getCreateTime);
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -1,8 +1,7 @@
|
||||
package com.agileboot.system.config.pojo.dto;
|
||||
package com.agileboot.system.config.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Positive;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
+1
-8
@@ -1,8 +1,7 @@
|
||||
package com.agileboot.system.config.pojo.entity;
|
||||
package com.agileboot.system.config.entity;
|
||||
|
||||
import com.agileboot.common.mybatis.core.domain.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
@@ -33,27 +32,21 @@ public class SysConfig extends BaseEntity {
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("配置名称")
|
||||
@TableField("config_name")
|
||||
private String configName;
|
||||
|
||||
@ApiModelProperty("配置键名")
|
||||
@TableField("config_key")
|
||||
private String configKey;
|
||||
|
||||
@ApiModelProperty("可选的选项")
|
||||
@TableField("config_options")
|
||||
private String configOptions;
|
||||
|
||||
@ApiModelProperty("配置值")
|
||||
@TableField("config_value")
|
||||
private String configValue;
|
||||
|
||||
@ApiModelProperty("是否允许修改")
|
||||
@TableField("is_allow_change")
|
||||
private Boolean isAllowChange;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
+4
-4
@@ -1,10 +1,10 @@
|
||||
package com.agileboot.system.config.pojo.dto;
|
||||
package com.agileboot.system.config.vo;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.agileboot.common.core.enums.BasicEnumUtil;
|
||||
import com.agileboot.common.core.enums.common.YesOrNoEnum;
|
||||
import com.agileboot.system.config.pojo.entity.SysConfig;
|
||||
import com.agileboot.system.config.entity.SysConfig;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -15,7 +15,7 @@ import java.util.List;
|
||||
* @author valarchie
|
||||
*/
|
||||
@Data
|
||||
public class ConfigDTO {
|
||||
public class ConfigVO {
|
||||
|
||||
private Long configId;
|
||||
private String configName;
|
||||
@@ -27,7 +27,7 @@ public class ConfigDTO {
|
||||
private String remark;
|
||||
private Date createTime;
|
||||
|
||||
public ConfigDTO(SysConfig entity) {
|
||||
public ConfigVO(SysConfig entity) {
|
||||
if (entity != null) {
|
||||
configId = entity.getId();
|
||||
configName = entity.getConfigName();
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.agileboot.system.dept.dto;
|
||||
|
||||
import jakarta.validation.constraints.*;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@Data
|
||||
public class AddDeptDTO {
|
||||
|
||||
/**
|
||||
* 父部门ID
|
||||
*/
|
||||
@NotNull
|
||||
@PositiveOrZero
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
@NotBlank(message = "部门名称不能为空")
|
||||
@Size(max = 30, message = "部门名称长度不能超过30个字符")
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* 显示顺序
|
||||
*/
|
||||
@NotNull(message = "显示顺序不能为空")
|
||||
private Integer orderNum;
|
||||
|
||||
/**
|
||||
* 负责人
|
||||
*/
|
||||
private String leaderName;
|
||||
|
||||
/**
|
||||
* 联系电话
|
||||
*/
|
||||
@Size(max = 11, message = "联系电话长度不能超过11个字符")
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
@Email(message = "邮箱格式不正确")
|
||||
@Size(max = 50, message = "邮箱长度不能超过50个字符")
|
||||
private String email;
|
||||
|
||||
|
||||
private Integer status;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.agileboot.system.dept.dto;
|
||||
|
||||
import com.agileboot.common.mybatis.core.page.PageQuery;
|
||||
import com.agileboot.system.dept.entity.SysDept;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class DeptQuery extends PageQuery<SysDept> {
|
||||
|
||||
private Long deptId;
|
||||
|
||||
private Long parentId;
|
||||
|
||||
@Override
|
||||
public LambdaQueryWrapper<SysDept> toQueryWrapper() {
|
||||
return Wrappers.lambdaQuery(SysDept.class)
|
||||
.eq(parentId != null, SysDept::getParentId, parentId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.agileboot.system.dept.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.PositiveOrZero;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class UpdateDeptDTO extends AddDeptDTO {
|
||||
|
||||
@NotNull
|
||||
@PositiveOrZero
|
||||
private Long deptId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.agileboot.system.dept.entity;
|
||||
|
||||
import com.agileboot.common.mybatis.core.domain.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门表
|
||||
* </p>
|
||||
*
|
||||
* @author valarchie
|
||||
* @since 2022-10-02
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("sys_dept")
|
||||
@ApiModel(value = "SysDeptEntity对象", description = "部门表")
|
||||
public class SysDept extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("部门id")
|
||||
@TableId(value = "dept_id", type = IdType.AUTO)
|
||||
private Long deptId;
|
||||
|
||||
@ApiModelProperty("父部门id")
|
||||
private Long parentId;
|
||||
|
||||
@ApiModelProperty("祖级列表")
|
||||
private String ancestors;
|
||||
|
||||
@ApiModelProperty("部门名称")
|
||||
private String deptName;
|
||||
|
||||
@ApiModelProperty("显示顺序")
|
||||
private Integer orderNum;
|
||||
|
||||
private Long leaderId;
|
||||
|
||||
@ApiModelProperty("负责人")
|
||||
private String leaderName;
|
||||
|
||||
@ApiModelProperty("联系电话")
|
||||
private String phone;
|
||||
|
||||
@ApiModelProperty("邮箱")
|
||||
private String email;
|
||||
|
||||
@ApiModelProperty("部门状态(0正常 1停用)")
|
||||
private Integer status;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.agileboot.system.dept.vo;
|
||||
|
||||
import com.agileboot.common.core.enums.BasicEnumUtil;
|
||||
import com.agileboot.common.core.enums.common.StatusEnum;
|
||||
import com.agileboot.system.dept.entity.SysDept;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@Data
|
||||
public class DeptVO {
|
||||
|
||||
public DeptVO(SysDept entity) {
|
||||
if (entity != null) {
|
||||
this.id = entity.getDeptId();
|
||||
this.parentId = entity.getParentId();
|
||||
this.deptName = entity.getDeptName();
|
||||
this.orderNum = entity.getOrderNum();
|
||||
this.leaderName = entity.getLeaderName();
|
||||
this.email = entity.getEmail();
|
||||
this.phone = entity.getPhone();
|
||||
this.status = entity.getStatus();
|
||||
this.createTime = entity.getCreateTime();
|
||||
this.statusStr = BasicEnumUtil.getDescriptionByValue(StatusEnum.class, entity.getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long parentId;
|
||||
|
||||
private String deptName;
|
||||
|
||||
private Integer orderNum;
|
||||
|
||||
private String leaderName;
|
||||
|
||||
private String phone;
|
||||
|
||||
private String email;
|
||||
|
||||
private Integer status;
|
||||
|
||||
private String statusStr;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.agileboot.system.log.dto;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.agileboot.common.mybatis.core.page.PageQuery;
|
||||
import com.agileboot.system.log.entity.SysLoginInfo;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@Data
|
||||
public class LoginLogQuery extends PageQuery<SysLoginInfo> {
|
||||
|
||||
private String ipAddress;
|
||||
private String status;
|
||||
private String username;
|
||||
|
||||
@Override
|
||||
public LambdaQueryWrapper<SysLoginInfo> toQueryWrapper() {
|
||||
return Wrappers.lambdaQuery(SysLoginInfo.class)
|
||||
.like(StrUtil.isNotEmpty(ipAddress), SysLoginInfo::getIpAddress, ipAddress)
|
||||
.eq(StrUtil.isNotEmpty(status), SysLoginInfo::getStatus, status)
|
||||
.like(StrUtil.isNotEmpty(username), SysLoginInfo::getUsername, username);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.agileboot.system.log.dto;
|
||||
|
||||
import com.agileboot.common.mybatis.core.page.PageQuery;
|
||||
import com.agileboot.system.log.entity.SysOperationLog;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@Data
|
||||
public class OperationLogQuery extends PageQuery<SysOperationLog> {
|
||||
|
||||
private String businessType;
|
||||
private String status;
|
||||
private String username;
|
||||
private String requestModule;
|
||||
|
||||
@Override
|
||||
public LambdaQueryWrapper<SysOperationLog> toQueryWrapper() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.agileboot.system.log.entity;
|
||||
|
||||
import com.agileboot.common.mybatis.core.domain.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统访问记录
|
||||
* </p>
|
||||
*
|
||||
* @author valarchie
|
||||
* @since 2022-10-02
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("sys_login_info")
|
||||
@ApiModel(value = "SysLoginInfoEntity对象", description = "系统访问记录")
|
||||
public class SysLoginInfo extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("访问ID")
|
||||
@TableId(value = "info_id", type = IdType.AUTO)
|
||||
private Long infoId;
|
||||
|
||||
@ApiModelProperty("用户账号")
|
||||
private String username;
|
||||
|
||||
@ApiModelProperty("登录IP地址")
|
||||
private String ipAddress;
|
||||
|
||||
@ApiModelProperty("登录地点")
|
||||
private String loginLocation;
|
||||
|
||||
@ApiModelProperty("浏览器类型")
|
||||
private String browser;
|
||||
|
||||
@ApiModelProperty("操作系统")
|
||||
private String operationSystem;
|
||||
|
||||
@ApiModelProperty("登录状态(1成功 0失败)")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty("提示消息")
|
||||
private String msg;
|
||||
|
||||
@ApiModelProperty("访问时间")
|
||||
private Date loginTime;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.agileboot.system.log.entity;
|
||||
|
||||
import com.agileboot.common.mybatis.core.domain.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 操作日志记录
|
||||
* </p>
|
||||
*
|
||||
* @author valarchie
|
||||
* @since 2022-10-02
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("sys_operation_log")
|
||||
@ApiModel(value = "SysOperationLogEntity对象", description = "操作日志记录")
|
||||
public class SysOperationLog extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("日志主键")
|
||||
@TableId(value = "operation_id", type = IdType.AUTO)
|
||||
private Long operationId;
|
||||
|
||||
@ApiModelProperty("业务类型(0其它 1新增 2修改 3删除)")
|
||||
private Integer businessType;
|
||||
|
||||
@ApiModelProperty("请求方式")
|
||||
private Integer requestMethod;
|
||||
|
||||
@ApiModelProperty("请求模块")
|
||||
private String requestModule;
|
||||
|
||||
@ApiModelProperty("请求URL")
|
||||
private String requestUrl;
|
||||
|
||||
@ApiModelProperty("调用方法")
|
||||
private String calledMethod;
|
||||
|
||||
@ApiModelProperty("操作类别(0其它 1后台用户 2手机端用户)")
|
||||
private Integer operatorType;
|
||||
|
||||
@ApiModelProperty("用户ID")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("操作人员")
|
||||
private String username;
|
||||
|
||||
@ApiModelProperty("操作人员ip")
|
||||
private String operatorIp;
|
||||
|
||||
@ApiModelProperty("操作地点")
|
||||
private String operatorLocation;
|
||||
|
||||
@ApiModelProperty("部门ID")
|
||||
private Long deptId;
|
||||
|
||||
@ApiModelProperty("部门名称")
|
||||
private String deptName;
|
||||
|
||||
@ApiModelProperty("请求参数")
|
||||
private String operationParam;
|
||||
|
||||
@ApiModelProperty("返回参数")
|
||||
private String operationResult;
|
||||
|
||||
@ApiModelProperty("操作状态(1正常 0异常)")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty("错误消息")
|
||||
private String errorStack;
|
||||
|
||||
@ApiModelProperty("操作时间")
|
||||
private Date operationTime;
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.agileboot.system.log.vo;
|
||||
|
||||
import com.agileboot.common.core.annotation.ExcelColumn;
|
||||
import com.agileboot.common.core.annotation.ExcelSheet;
|
||||
import com.agileboot.common.core.enums.BasicEnumUtil;
|
||||
import com.agileboot.common.core.enums.common.LoginStatusEnum;
|
||||
import com.agileboot.system.log.entity.SysLoginInfo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@Data
|
||||
@ExcelSheet(name = "登录日志")
|
||||
public class LoginLogVO {
|
||||
|
||||
public LoginLogVO(SysLoginInfo entity) {
|
||||
if (entity != null) {
|
||||
logId = entity.getInfoId() + "";
|
||||
username = entity.getUsername();
|
||||
ipAddress = entity.getIpAddress();
|
||||
loginLocation = entity.getLoginLocation();
|
||||
operationSystem = entity.getOperationSystem();
|
||||
browser = entity.getBrowser();
|
||||
status = entity.getStatus();
|
||||
statusStr = BasicEnumUtil.getDescriptionByValue(LoginStatusEnum.class, entity.getStatus());
|
||||
msg = entity.getMsg();
|
||||
loginTime = entity.getLoginTime();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ExcelColumn(name = "ID")
|
||||
private String logId;
|
||||
|
||||
@ExcelColumn(name = "用户名")
|
||||
private String username;
|
||||
|
||||
@ExcelColumn(name = "ip地址")
|
||||
private String ipAddress;
|
||||
|
||||
@ExcelColumn(name = "登录地点")
|
||||
private String loginLocation;
|
||||
|
||||
@ExcelColumn(name = "操作系统")
|
||||
private String operationSystem;
|
||||
|
||||
@ExcelColumn(name = "浏览器")
|
||||
private String browser;
|
||||
|
||||
private Integer status;
|
||||
|
||||
@ExcelColumn(name = "状态")
|
||||
private String statusStr;
|
||||
|
||||
@ExcelColumn(name = "描述")
|
||||
private String msg;
|
||||
|
||||
@ExcelColumn(name = "登录时间")
|
||||
private Date loginTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package com.agileboot.system.log.vo;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.agileboot.common.core.annotation.ExcelColumn;
|
||||
import com.agileboot.common.core.annotation.ExcelSheet;
|
||||
import com.agileboot.common.core.enums.BasicEnumUtil;
|
||||
import com.agileboot.common.core.enums.common.BusinessTypeEnum;
|
||||
import com.agileboot.common.core.enums.common.OperationStatusEnum;
|
||||
import com.agileboot.common.core.enums.common.OperatorTypeEnum;
|
||||
import com.agileboot.common.core.enums.common.RequestMethodEnum;
|
||||
import com.agileboot.system.log.entity.SysOperationLog;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@Data
|
||||
@ExcelSheet(name = "操作日志")
|
||||
public class OperationLogVO {
|
||||
|
||||
public OperationLogVO(SysOperationLog entity) {
|
||||
if (entity != null) {
|
||||
BeanUtil.copyProperties(entity, this);
|
||||
this.requestMethod = BasicEnumUtil.getDescriptionByValue(RequestMethodEnum.class,
|
||||
entity.getRequestMethod());
|
||||
this.statusStr = BasicEnumUtil.getDescriptionByValue(OperationStatusEnum.class, entity.getStatus());
|
||||
businessTypeStr = BasicEnumUtil.getDescriptionByValue(BusinessTypeEnum.class, entity.getBusinessType());
|
||||
operatorTypeStr = BasicEnumUtil.getDescriptionByValue(OperatorTypeEnum.class, entity.getOperatorType());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ExcelColumn(name = "ID")
|
||||
private Long operationId;
|
||||
|
||||
private Integer businessType;
|
||||
|
||||
@ExcelColumn(name = "操作类型")
|
||||
private String businessTypeStr;
|
||||
|
||||
@ExcelColumn(name = "操作类型")
|
||||
private String requestMethod;
|
||||
|
||||
@ExcelColumn(name = "操作类型")
|
||||
private String requestModule;
|
||||
|
||||
@ExcelColumn(name = "操作类型")
|
||||
private String requestUrl;
|
||||
|
||||
@ExcelColumn(name = "操作类型")
|
||||
private String calledMethod;
|
||||
|
||||
private Integer operatorType;
|
||||
|
||||
@ExcelColumn(name = "操作人类型")
|
||||
private String operatorTypeStr;
|
||||
|
||||
@ExcelColumn(name = "用户ID")
|
||||
private Long userId;
|
||||
|
||||
@ExcelColumn(name = "用户名")
|
||||
private String username;
|
||||
|
||||
@ExcelColumn(name = "ip地址")
|
||||
private String operatorIp;
|
||||
|
||||
@ExcelColumn(name = "ip地点")
|
||||
private String operatorLocation;
|
||||
|
||||
@ExcelColumn(name = "部门ID")
|
||||
private Long deptId;
|
||||
|
||||
@ExcelColumn(name = "部门")
|
||||
private String deptName;
|
||||
|
||||
@ExcelColumn(name = "操作参数")
|
||||
private String operationParam;
|
||||
|
||||
@ExcelColumn(name = "操作结果")
|
||||
private String operationResult;
|
||||
|
||||
private Integer status;
|
||||
|
||||
@ExcelColumn(name = "状态")
|
||||
private String statusStr;
|
||||
|
||||
@ExcelColumn(name = "错误堆栈")
|
||||
private String errorStack;
|
||||
|
||||
@ExcelColumn(name = "操作时间")
|
||||
private Date operationTime;
|
||||
|
||||
}
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package com.agileboot.system.menu.pojo.dto;
|
||||
package com.agileboot.system.menu.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
@@ -9,7 +9,7 @@ import lombok.Data;
|
||||
* @author valarchie
|
||||
*/
|
||||
@Data
|
||||
public class AddMenuCommand {
|
||||
public class AddMenuDTO {
|
||||
|
||||
private Long parentId;
|
||||
@NotBlank(message = "菜单名称不能为空")
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.agileboot.system.menu.pojo.dto;
|
||||
package com.agileboot.system.menu.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
+2
-3
@@ -1,11 +1,11 @@
|
||||
package com.agileboot.system.menu.pojo.dto;
|
||||
package com.agileboot.system.menu.dto;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.agileboot.common.core.enums.BasicEnumUtil;
|
||||
import com.agileboot.common.core.enums.common.MenuTypeEnum;
|
||||
import com.agileboot.common.core.enums.common.StatusEnum;
|
||||
import com.agileboot.common.core.utils.jackson.JacksonUtil;
|
||||
import com.agileboot.system.menu.pojo.entity.SysMenu;
|
||||
import com.agileboot.system.menu.entity.SysMenu;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@@ -73,5 +73,4 @@ public class MenuDTO {
|
||||
private String icon;
|
||||
|
||||
|
||||
|
||||
}
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package com.agileboot.system.menu.pojo.dto;
|
||||
package com.agileboot.system.menu.dto;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.agileboot.common.core.utils.jackson.JacksonUtil;
|
||||
import com.agileboot.system.menu.pojo.entity.SysMenu;
|
||||
import com.agileboot.system.menu.entity.SysMenu;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package com.agileboot.system.menu.pojo.dto;
|
||||
package com.agileboot.system.menu.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -7,7 +7,7 @@ import lombok.Data;
|
||||
*/
|
||||
@Data
|
||||
public class MenuQuery {
|
||||
// 直接交给前端筛选
|
||||
// 直接交给前端筛选
|
||||
// private String menuName;
|
||||
// private Boolean isVisible;
|
||||
// private Integer status;
|
||||
+7
-6
@@ -1,4 +1,4 @@
|
||||
package com.agileboot.system.menu.pojo.dto;
|
||||
package com.agileboot.system.menu.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
@@ -10,6 +10,7 @@ import java.util.List;
|
||||
/**
|
||||
* 路由显示信息
|
||||
* 必须加上@JsonInclude(Include.NON_NULL)的注解 否则传null值给Vue动态路由渲染时会出错
|
||||
*
|
||||
* @author valarchie
|
||||
*/
|
||||
@Data
|
||||
@@ -31,14 +32,14 @@ public class MetaDTO {
|
||||
// 需要内嵌的iframe链接地址
|
||||
private String frameSrc;
|
||||
/**
|
||||
* 是否是内部页面 使用frameSrc来嵌入页面时,当isFrameSrcInternal=true的时候, 前端需要做特殊处理
|
||||
* 比如链接是 /druid/login.html
|
||||
* 前端需要处理成 http://localhost:8080/druid/login.html
|
||||
*/
|
||||
* 是否是内部页面 使用frameSrc来嵌入页面时,当isFrameSrcInternal=true的时候, 前端需要做特殊处理
|
||||
* 比如链接是 /druid/login.html
|
||||
* 前端需要处理成 http://localhost:8080/druid/login.html
|
||||
*/
|
||||
private Boolean isFrameSrcInternal;
|
||||
|
||||
/**
|
||||
* 菜单排序,值越高排的越后(只针对顶级路由)
|
||||
* 菜单排序,值越高排的越后(只针对顶级路由)
|
||||
*/
|
||||
private Integer rank;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.agileboot.system.menu.pojo.dto;
|
||||
package com.agileboot.system.menu.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package com.agileboot.system.menu.pojo.dto;
|
||||
package com.agileboot.system.menu.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
@@ -9,7 +9,7 @@ import lombok.EqualsAndHashCode;
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class UpdateMenuCommand extends AddMenuCommand {
|
||||
public class UpdateMenuDTO extends AddMenuDTO {
|
||||
|
||||
@NotNull
|
||||
private Long menuId;
|
||||
+1
-12
@@ -1,8 +1,7 @@
|
||||
package com.agileboot.system.menu.pojo.entity;
|
||||
package com.agileboot.system.menu.entity;
|
||||
|
||||
import com.agileboot.common.mybatis.core.domain.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
@@ -35,43 +34,33 @@ public class SysMenu extends BaseEntity {
|
||||
private Long menuId;
|
||||
|
||||
@ApiModelProperty("菜单名称")
|
||||
@TableField("menu_name")
|
||||
private String menuName;
|
||||
|
||||
@ApiModelProperty("菜单的类型(1为普通菜单2为目录3为iFrame4为外部网站)")
|
||||
@TableField("menu_type")
|
||||
private Integer menuType;
|
||||
|
||||
@ApiModelProperty("路由名称(需保持和前端对应的vue文件中的name保持一致defineOptions方法中设置的name)")
|
||||
@TableField("router_name")
|
||||
private String routerName;
|
||||
|
||||
@ApiModelProperty("父菜单ID")
|
||||
@TableField("parent_id")
|
||||
private Long parentId;
|
||||
|
||||
@ApiModelProperty("组件路径(对应前端项目view文件夹中的路径)")
|
||||
@TableField("path")
|
||||
private String path;
|
||||
|
||||
@ApiModelProperty("是否按钮")
|
||||
@TableField("is_button")
|
||||
private Boolean isButton;
|
||||
|
||||
@ApiModelProperty("权限标识")
|
||||
@TableField("permission")
|
||||
private String permission;
|
||||
|
||||
@ApiModelProperty("路由元信息(前端根据这个信息进行逻辑处理)")
|
||||
@TableField("meta_info")
|
||||
private String metaInfo;
|
||||
|
||||
@ApiModelProperty("菜单状态(1启用 0停用)")
|
||||
@TableField("`status`")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user