mirror of
https://gitee.com/lakernote/easy-admin.git
synced 2026-09-03 05:33:47 +08:00
bug fix and code refactor
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@@ -22,9 +22,9 @@
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
/.idea/
|
||||
# Compiled class file
|
||||
/target/
|
||||
# Log file
|
||||
/logs/
|
||||
/file/
|
||||
/oss-file/
|
||||
|
||||
# oss files
|
||||
/storage/
|
||||
|
||||
@@ -10,5 +10,5 @@ lombok.tostring.callsuper=CALL
|
||||
# SKIP: 不调用父类的方法,只考虑当前类中的属性。
|
||||
# WARN: 生成代码时会发出警告,提醒开发者是否需要调用父类的方法。
|
||||
lombok.equalsandhashcode.callsuper=CALL
|
||||
# 生成的setter方法不再是void, 而是返回this, 方便链式调用
|
||||
lombok.accessors.chain=true
|
||||
# 生成的setter方法不再是void, 而是返回this, 方便链式调用,这个选项视情况而定,感觉不好用
|
||||
lombok.accessors.chain=false
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.laker.admin.framework.lock;
|
||||
|
||||
import com.laker.admin.framework.lock.api.ILock;
|
||||
import com.laker.admin.framework.lock.impl.jdbc.MysqlILock;
|
||||
import com.laker.admin.framework.lock.impl.jdbc.MysqlLock;
|
||||
import com.laker.admin.framework.lock.impl.redis.RedisILock;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
@@ -22,7 +22,7 @@ public class EasyLockConfig {
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnProperty(name = "lock.type", havingValue = "mysql", matchIfMissing = true)
|
||||
public ILock mysqlLock(JdbcTemplate jdbcTemplate, TaskScheduler taskScheduler) {
|
||||
return new MysqlILock(jdbcTemplate, taskScheduler);
|
||||
return new MysqlLock(jdbcTemplate, taskScheduler);
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.time.Duration;
|
||||
* @author laker
|
||||
*/
|
||||
@Slf4j
|
||||
public class MysqlILock extends AbstractSimpleILock {
|
||||
public class MysqlLock extends AbstractSimpleILock {
|
||||
|
||||
/**
|
||||
* 原始sql 需要配合DuplicateKeyException使用,不优雅:INSERT INTO distribute_lock (lock_key, token, expire, thread_id) VALUES (?, ?, ?, ?);
|
||||
@@ -26,7 +26,7 @@ public class MysqlILock extends AbstractSimpleILock {
|
||||
public static final String REFRESH_FORMATTED_QUERY = "UPDATE distribute_lock SET expire = ? WHERE lock_key = ? AND token = ?;";
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
|
||||
public MysqlILock(JdbcTemplate jdbcTemplate, TaskScheduler taskScheduler) {
|
||||
public MysqlLock(JdbcTemplate jdbcTemplate, TaskScheduler taskScheduler) {
|
||||
super(taskScheduler);
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSON;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||
import com.laker.admin.framework.aop.metrics.Metrics;
|
||||
@@ -34,9 +35,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import static org.snaker.engine.access.QueryFilter.DESC;
|
||||
|
||||
@@ -53,36 +52,37 @@ public class SnakerflowFacetsController {
|
||||
@Autowired
|
||||
private ISysUserService sysUserService;
|
||||
|
||||
// ---------流程相关 ---------
|
||||
// ---------流程相关 --------- //
|
||||
|
||||
|
||||
/**
|
||||
* 获取流程定义
|
||||
*/
|
||||
@GetMapping("/getXml")
|
||||
public Response processEdit(String id) {
|
||||
public Response<String> getProcessXml(String id) {
|
||||
Process process = snakerEngineFacets.getEngine().process().getProcessById(id);
|
||||
if (process.getDBContent() != null) {
|
||||
return Response.ok(new String(process.getDBContent(), StandardCharsets.UTF_8));
|
||||
}
|
||||
return Response.error("500", "xml异常");
|
||||
return Optional.ofNullable(process.getDBContent())
|
||||
.map(content -> Response.ok(new String(content, StandardCharsets.UTF_8)))
|
||||
.orElse(Response.error500("xml异常"));
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/process/modelJson")
|
||||
@ApiOperation(value = "根据流程定义名称获取流程定义json", tags = "流程引擎-流程")
|
||||
@Metrics
|
||||
public String getProcess(@RequestParam(required = false) String processId) {
|
||||
public String getProcessJson(@RequestParam(required = false) String processId) {
|
||||
if (StrUtil.isBlank(processId)) {
|
||||
return "";
|
||||
return StrUtil.EMPTY;
|
||||
}
|
||||
Process process = snakerEngineFacets.getEngine().process().getProcessById(processId);
|
||||
AssertHelper.notNull(process);
|
||||
ProcessModel processModel = process.getModel();
|
||||
if (processModel != null) {
|
||||
return SnakerHelper.getModelJson(processModel);
|
||||
if (Objects.isNull(process)) {
|
||||
return StrUtil.EMPTY;
|
||||
}
|
||||
return null;
|
||||
ProcessModel processModel = process.getModel();
|
||||
if (Objects.isNull(processModel)) {
|
||||
return StrUtil.EMPTY;
|
||||
}
|
||||
return SnakerHelper.getModelJson(processModel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,14 +90,13 @@ public class SnakerflowFacetsController {
|
||||
*/
|
||||
@ApiOperation(value = "根据给定的参数列表args分页查询process", tags = "流程引擎-流程")
|
||||
@RequestMapping(value = "/process/list", method = RequestMethod.GET)
|
||||
public Response processList(Page<Process> page, String displayName) {
|
||||
public Response<JSON> getProcessList(Page<Process> page, String displayName) {
|
||||
QueryFilter filter = new QueryFilter();
|
||||
if (StringHelper.isNotEmpty(displayName)) {
|
||||
filter.setDisplayName(displayName);
|
||||
}
|
||||
filter.orderBy("create_Time").order(DESC);
|
||||
snakerEngineFacets.getEngine().process().getProcesss(page, filter);
|
||||
|
||||
return PageResponse.ok(JSONUtil.parse(page.getResult()), page.getTotalCount());
|
||||
}
|
||||
|
||||
@@ -105,13 +104,12 @@ public class SnakerflowFacetsController {
|
||||
* 根据流程定义ID,删除流程定义
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "根据流程定义ID,删除流程定义", tags = "流程引擎-流程")
|
||||
@RequestMapping(value = "/process/delete/{id}", method = RequestMethod.GET)
|
||||
@Metrics
|
||||
@SaCheckPermission("flow.delete")
|
||||
public Response processDelete(@PathVariable("id") String id) {
|
||||
public Response<Void> processDelete(@PathVariable("id") String id) {
|
||||
snakerEngineFacets.getEngine().process().undeploy(id);
|
||||
return Response.ok();
|
||||
}
|
||||
@@ -120,13 +118,13 @@ public class SnakerflowFacetsController {
|
||||
* 保存流程定义[web流程设计器]
|
||||
*
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "保存流程定义[web流程设计器]", tags = "流程引擎-流程")
|
||||
@RequestMapping(value = "/process/deployXml", method = RequestMethod.POST)
|
||||
@SaCheckPermission("flow.update")
|
||||
@RepeatSubmitLimit(businessKey = "savemodel", businessParam = "#model")
|
||||
public boolean processDeploy(String model, String id, @RequestParam(required = false, defaultValue = "false") boolean xmlHearder) {
|
||||
public boolean saveProcessXml(String model, String id,
|
||||
@RequestParam(required = false, defaultValue = "false") boolean xmlHearder) {
|
||||
InputStream input = null;
|
||||
try {
|
||||
String xml = "";
|
||||
@@ -141,14 +139,13 @@ public class SnakerflowFacetsController {
|
||||
snakerEngineFacets.getEngine().process().deploy(input);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("", e);
|
||||
return false;
|
||||
} finally {
|
||||
if (input != null) {
|
||||
try {
|
||||
input.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -158,14 +155,14 @@ public class SnakerflowFacetsController {
|
||||
@ApiOperation(value = "流程定义+流程状态", tags = "流程引擎-流程")
|
||||
@RequestMapping(value = "/process/json", method = RequestMethod.GET)
|
||||
@Metrics
|
||||
public Object json(String processId, String orderId) {
|
||||
public Object getProcessJson(String processId, String orderId) {
|
||||
if (StrUtil.isBlank(processId)) {
|
||||
processId = snakerEngineFacets.getEngine().query().getHistOrder(orderId).getProcessId();
|
||||
}
|
||||
Process process = snakerEngineFacets.getEngine().process().getProcessById(processId);
|
||||
AssertHelper.notNull(process);
|
||||
ProcessModel model = process.getModel();
|
||||
Map<String, String> jsonMap = new HashMap<String, String>();
|
||||
Map<String, String> jsonMap = new HashMap<>();
|
||||
if (model != null) {
|
||||
jsonMap.put("process", SnakerHelper.getModelJson(model));
|
||||
}
|
||||
@@ -178,16 +175,15 @@ public class SnakerflowFacetsController {
|
||||
return jsonMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* --------- 任务相关 ---------
|
||||
*/
|
||||
// --------- 任务相关 --------- //
|
||||
|
||||
|
||||
/**
|
||||
* 根据当前用户查询待办任务列表
|
||||
*/
|
||||
@GetMapping("/task/todoList")
|
||||
@ApiOperation(value = "根据当前用户查询待办任务列表", tags = "流程引擎-任务")
|
||||
public PageResponse userTaskTodoList() {
|
||||
public PageResponse<List<WorkItem>> getUserTaskTodoList() {
|
||||
Page<WorkItem> page = new Page<>(30);
|
||||
snakerEngineFacets.getEngine().query().getWorkItems(page,
|
||||
new QueryFilter().setOperator(StpUtil.getLoginIdAsString()));
|
||||
@@ -199,7 +195,7 @@ public class SnakerflowFacetsController {
|
||||
*/
|
||||
@GetMapping("/task/doneList")
|
||||
@ApiOperation(value = "根据当前用户查询已办任务列表", tags = "流程引擎-任务")
|
||||
public PageResponse userTaskdoneList() {
|
||||
public PageResponse<List<WorkItem>> getUserTaskDoneList() {
|
||||
Page<WorkItem> page = new Page<>(30);
|
||||
snakerEngineFacets.getEngine().query().getHistoryWorkItems(page,
|
||||
new QueryFilter().setOperator(StpUtil.getLoginIdAsString()));
|
||||
@@ -207,8 +203,8 @@ public class SnakerflowFacetsController {
|
||||
}
|
||||
|
||||
@GetMapping("/task/actor/add")
|
||||
@ApiOperation(value = "根据流程实例id和任务名称,增加任务参与者", tags = "流程引擎-任务")
|
||||
public Response addTaskActor(String orderId, String taskName, String operator) {
|
||||
@ApiOperation(value = "根据流程实例id和任务名称,动态增加任务参与者", tags = "流程引擎-任务")
|
||||
public Response<Void> addTaskActor(String orderId, String taskName, String operator) {
|
||||
List<Task> tasks = snakerEngineFacets.getEngine().query().getActiveTasks(new QueryFilter().setOrderId(orderId));
|
||||
for (Task task : tasks) {
|
||||
if (task.getTaskName().equalsIgnoreCase(taskName) && StringUtils.isNotEmpty(operator)) {
|
||||
@@ -220,11 +216,11 @@ public class SnakerflowFacetsController {
|
||||
|
||||
@GetMapping("/task/tip")
|
||||
@ApiOperation(value = "根据流程实例id和任务名称,查找当前任务的到达时间和待执行人", tags = "流程引擎-任务")
|
||||
public Response taskTip(String orderId, String taskName) {
|
||||
public Response<Map<String, String>> taskTip(String orderId, String taskName) {
|
||||
List<Task> tasks = snakerEngineFacets.getEngine().query().getActiveTasks(new QueryFilter().setOrderId(orderId));
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String createTime = "";
|
||||
String finishTime = "";
|
||||
String createTime = StrUtil.EMPTY;
|
||||
String finishTime = StrUtil.EMPTY;
|
||||
boolean find = false;
|
||||
for (Task task : tasks) {
|
||||
if (task.getTaskName().equalsIgnoreCase(taskName)) {
|
||||
@@ -256,7 +252,7 @@ public class SnakerflowFacetsController {
|
||||
if (builder.length() > 0) {
|
||||
builder.deleteCharAt(builder.length() - 1);
|
||||
}
|
||||
Map<String, String> data = new HashMap<String, String>();
|
||||
Map<String, String> data = new HashMap<>();
|
||||
data.put("actors", builder.toString());
|
||||
data.put("createTime", createTime);
|
||||
data.put("finishTime", finishTime);
|
||||
@@ -270,7 +266,7 @@ public class SnakerflowFacetsController {
|
||||
@ApiOperation(value = "\t 【审批任务】驳回,根据任务主键ID,操作人ID,参数列表执行任务,并且根据nodeName跳转到任意节点\n" +
|
||||
"\t 1、nodeName为null时,则跳转至上一步处理\n" +
|
||||
"\t 2、nodeName不为null时,则任意跳转,即动态创建转移", tags = "流程引擎-任务")
|
||||
public Response activeTaskReject(String taskId, String nodeName, String reason) {
|
||||
public Response<Void> activeTaskReject(String taskId, String nodeName, String reason) {
|
||||
Dict rejectReason = Dict.create()
|
||||
// 拒绝原因,建议单独搞个 审核表 审核的comment file单独存储
|
||||
.set("rejectReason", reason);
|
||||
@@ -279,14 +275,14 @@ public class SnakerflowFacetsController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 活动任务的驳回-驳回到发起人
|
||||
* 活动任务的驳回-驳回到发起人节点
|
||||
*/
|
||||
@GetMapping("/task/rejectToCreate")
|
||||
@ApiOperation(value = "任务的驳回-驳回到发起人", tags = "流程引擎-任务")
|
||||
public Response activeTaskReject(String taskId) {
|
||||
@ApiOperation(value = "任务的驳回-驳回到发起人节点", tags = "流程引擎-任务")
|
||||
public Response<Void> doRejectToCreate(String taskId) {
|
||||
List<WorkItem> workItems = snakerEngineFacets.getEngine().query().getWorkItems(null, new QueryFilter().setTaskId(taskId));
|
||||
if (CollUtil.isEmpty(workItems)) {
|
||||
Response.error("500", "不存在任务喽");
|
||||
Response.error500("不存在的任务喽");
|
||||
}
|
||||
WorkItem workItem = workItems.get(0);
|
||||
Process process = snakerEngineFacets.getEngine().process().getProcessById(workItem.getProcessId());
|
||||
@@ -299,7 +295,7 @@ public class SnakerflowFacetsController {
|
||||
|
||||
@RequestMapping(value = "/task/approval", method = RequestMethod.GET)
|
||||
@ApiOperation(value = "【审批任务】同意", tags = "流程引擎-任务")
|
||||
public Response doApproval(String taskId, String reason) {
|
||||
public Response<Void> doApproval(String taskId, String reason) {
|
||||
snakerEngineFacets.execute(taskId, StpUtil.getLoginIdAsString(), null);
|
||||
return Response.ok();
|
||||
}
|
||||
@@ -313,22 +309,21 @@ public class SnakerflowFacetsController {
|
||||
*/
|
||||
@GetMapping("/task/undo")
|
||||
@ApiOperation(value = "根据任务主键id、操作人撤回任务", tags = "流程引擎-任务")
|
||||
public Response historyTaskUndo(String taskId) {
|
||||
public Response<Void> historyTaskUndo(String taskId) {
|
||||
snakerEngineFacets.getEngine().task().withdrawTask(taskId, StpUtil.getLoginIdAsString());
|
||||
return Response.ok();
|
||||
}
|
||||
|
||||
@GetMapping("/task/transferMajor")
|
||||
@ApiOperation(value = "转办", tags = "流程引擎-任务")
|
||||
public Response transferMajor(String taskId, String nextOperator) {
|
||||
public Response<Void> transferMajor(String taskId, String nextOperator) {
|
||||
snakerEngineFacets.transferMajor(taskId, StpUtil.getLoginIdAsString(), nextOperator.split(","));
|
||||
return Response.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ------------------ 流程
|
||||
*/
|
||||
// ------------------ 流程实例管理 ------------------ //
|
||||
|
||||
/**
|
||||
* 流程实例管理
|
||||
*/
|
||||
|
||||
@@ -46,9 +46,7 @@ public class IndexController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情参考:https://gitee.com/whvse/EasyCaptcha
|
||||
*
|
||||
* @return
|
||||
* 详情参考:<a href="https://gitee.com/whvse/EasyCaptcha">...</a>
|
||||
*/
|
||||
@GetMapping("/captcha")
|
||||
@ResponseBody
|
||||
@@ -74,7 +72,7 @@ public class IndexController {
|
||||
|
||||
/**
|
||||
* 缩略图
|
||||
* http://localhost:8080/thumbnail?url=http://localhost:8080/admin/admin/images/wx.jpg
|
||||
* <a href="http://localhost:8080/thumbnail?url=http://localhost:8080/admin/admin/images/wx.jpg">...</a>
|
||||
*/
|
||||
@GetMapping("/thumbnail")
|
||||
public void thumbnail(String url, HttpServletResponse response,
|
||||
|
||||
@@ -63,17 +63,17 @@ public class LoginController {
|
||||
String code = iEasyCache.get(loginDto.getUid());
|
||||
iEasyCache.remove(loginDto.getUid());
|
||||
if (!StrUtil.equalsIgnoreCase(code, loginDto.getCaptchaCode())) {
|
||||
return Response.error("500", "验证码不正确或已失效");
|
||||
return Response.error500("验证码不正确或已失效");
|
||||
}
|
||||
// 单机版:在map中创建了会话,token id等映射关系 // 写入cookie
|
||||
SysUser sysUser = sysUserService.getOne(Wrappers.<SysUser>lambdaQuery()
|
||||
.eq(SysUser::getUserName, loginDto.getUsername())
|
||||
.eq(SysUser::getPassword, SecureUtil.sha256(loginDto.getPassword())));
|
||||
if (sysUser == null) {
|
||||
return Response.error("5001", "用户名或密码不正确");
|
||||
return Response.error500("用户名或密码不正确");
|
||||
}
|
||||
if (sysUser.getEnable() == 0) {
|
||||
return Response.error("5001", "用户:" + loginDto.getUsername() + "已被禁用");
|
||||
return Response.error500("用户已被禁用");
|
||||
}
|
||||
StpUtil.login(sysUser.getUserId());
|
||||
// 获取用户的数据权限
|
||||
|
||||
@@ -40,14 +40,13 @@ public class NginxController {
|
||||
|
||||
@GetMapping
|
||||
public Response get(@RequestParam(required = false) String path) {
|
||||
NgxConfig conf = null;
|
||||
NgxConfig conf;
|
||||
try {
|
||||
if (StrUtil.isBlank(path)) {
|
||||
path = easyConfig.getNginx().getConfPath();
|
||||
}
|
||||
conf = NgxConfig.read(path);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return Response.error("500", "路径错误:" + path);
|
||||
}
|
||||
String content = new NgxDumper(conf).dump();
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.laker.admin.module.sys.controller;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||
@@ -39,11 +38,11 @@ public class SysDeptController {
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation(value = "分页查询")
|
||||
public Response pageAll(@RequestParam(required = false, defaultValue = "1") long current,
|
||||
@RequestParam(required = false, defaultValue = "10") long size) {
|
||||
Page roadPage = new Page<>(current, size);
|
||||
LambdaQueryWrapper<SysDept> queryWrapper = new QueryWrapper().lambda();
|
||||
Page pageList = sysDeptService.page(roadPage, queryWrapper);
|
||||
public Response<Page<SysDept>> pageAll(@RequestParam(required = false, defaultValue = "1") long current,
|
||||
@RequestParam(required = false, defaultValue = "10") long size) {
|
||||
Page<SysDept> roadPage = new Page<>(current, size);
|
||||
LambdaQueryWrapper<SysDept> queryWrapper = new LambdaQueryWrapper<>();
|
||||
Page<SysDept> pageList = sysDeptService.page(roadPage, queryWrapper);
|
||||
return Response.ok(pageList);
|
||||
}
|
||||
|
||||
@@ -75,15 +74,16 @@ public class SysDeptController {
|
||||
return Response.ok(sysDeptService.removeByIds(CollUtil.toList(ids)));
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "获取组织列表不分页")
|
||||
@GetMapping("/data")
|
||||
public ResultTable data(SysDept param) {
|
||||
public ResultTable data() {
|
||||
List<SysDept> data = sysDeptService.list(Wrappers.<SysDept>lambdaQuery()
|
||||
.eq(SysDept::getStatus, true)
|
||||
.orderByAsc(SysDept::getSort));
|
||||
return ResultTable.dataTable(data);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取组织树")
|
||||
@GetMapping("/tree")
|
||||
public ResultTree tree() {
|
||||
List<SysDept> data = sysDeptService.list(Wrappers.<SysDept>lambdaQuery()
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.laker.admin.module.sys.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||
@@ -37,18 +36,18 @@ public class SysMenuController {
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation(value = "系统菜单表分页查询")
|
||||
public Response pageAll(@RequestParam(required = false, defaultValue = "1") long current,
|
||||
@RequestParam(required = false, defaultValue = "10") long size) {
|
||||
Page roadPage = new Page<>(current, size);
|
||||
LambdaQueryWrapper<SysPower> queryWrapper = new QueryWrapper().lambda();
|
||||
Page pageList = sysMenuService.page(roadPage, queryWrapper);
|
||||
public Response<Page<SysPower>> pageAll(@RequestParam(required = false, defaultValue = "1") long current,
|
||||
@RequestParam(required = false, defaultValue = "10") long size) {
|
||||
Page<SysPower> roadPage = new Page<>(current, size);
|
||||
LambdaQueryWrapper<SysPower> queryWrapper = new LambdaQueryWrapper<>();
|
||||
Page<SysPower> pageList = sysMenuService.page(roadPage, queryWrapper);
|
||||
return Response.ok(pageList);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation(value = "系统菜单表分页查询")
|
||||
public Response list() {
|
||||
public Response<List<SysPower>> list() {
|
||||
List<SysPower> list = sysMenuService.list(Wrappers.<SysPower>lambdaQuery().orderByAsc(SysPower::getSort));
|
||||
return Response.ok(list);
|
||||
}
|
||||
@@ -56,13 +55,13 @@ public class SysMenuController {
|
||||
@PostMapping
|
||||
@ApiOperation(value = "新增或者更新系统菜单表")
|
||||
@SaCheckPermission("menu.update")
|
||||
public Response saveOrUpdate(@RequestBody SysPower param) {
|
||||
public Response<Boolean> saveOrUpdate(@RequestBody SysPower param) {
|
||||
return Response.ok(sysMenuService.saveOrUpdate(param));
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
@ApiOperation(value = "根据id查询系统菜单表")
|
||||
public Response get(@PathVariable Long id) {
|
||||
public Response<SysPower> get(@PathVariable Long id) {
|
||||
return Response.ok(sysMenuService.getById(id));
|
||||
}
|
||||
|
||||
@@ -75,8 +74,8 @@ public class SysMenuController {
|
||||
|
||||
|
||||
@GetMapping("/selectTree")
|
||||
@ApiOperation(value = "菜单树")
|
||||
public Response selectTree() {
|
||||
@ApiOperation(value = "菜单列表树")
|
||||
public Response<List<MenuVo>> selectTree() {
|
||||
List<MenuVo> menuVos = sysMenuService.menu();
|
||||
return Response.ok(menuVos);
|
||||
}
|
||||
@@ -84,7 +83,7 @@ public class SysMenuController {
|
||||
@DeleteMapping("/{id}")
|
||||
@ApiOperation(value = "根据id删除系统菜单表")
|
||||
@SaCheckPermission("menu.delete")
|
||||
public Response delete(@PathVariable Long id) {
|
||||
public Response<Boolean> delete(@PathVariable Long id) {
|
||||
return Response.ok(sysMenuService.removeById(id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.laker.admin.module.sys.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||
@@ -45,13 +44,13 @@ public class SysRoleController {
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation(value = "分页查询")
|
||||
public PageResponse pageAll(@RequestParam(required = false, defaultValue = "1") long current,
|
||||
@RequestParam(required = false, defaultValue = "10") long size,
|
||||
Integer roleType) { // 1是菜单接口角色,2为数据角色
|
||||
Page roadPage = new Page<>(current, size);
|
||||
LambdaQueryWrapper<SysRole> queryWrapper = new QueryWrapper().lambda();
|
||||
public PageResponse<List<SysRole>> pageAll(@RequestParam(required = false, defaultValue = "1") long current,
|
||||
@RequestParam(required = false, defaultValue = "10") long size,
|
||||
Integer roleType) { // 1是菜单接口角色,2为数据角色
|
||||
Page<SysRole> roadPage = new Page<>(current, size);
|
||||
LambdaQueryWrapper<SysRole> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(roleType != null, SysRole::getRoleType, roleType);
|
||||
Page pageList = sysRoleService.page(roadPage, queryWrapper);
|
||||
Page<SysRole> pageList = sysRoleService.page(roadPage, queryWrapper);
|
||||
return PageResponse.ok(pageList.getRecords(), pageList.getTotal());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.laker.admin.module.sys.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.annotation.SaCheckRole;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@@ -78,9 +79,9 @@ public class SysUserController {
|
||||
|
||||
@GetMapping("/pageComplexAll")
|
||||
@ApiOperation(value = "复杂分页查询示例")
|
||||
public PageResponse<List<SysUser>> pageComplexAll(PageVO page, UserDto userDto) {
|
||||
Page<SysUser> roadPage = page.toPage();
|
||||
Page<SysUser> pageList = sysUserService.page(roadPage, userDto.queryWrapper());
|
||||
public PageResponse<List<SysUser>> pageComplexAll(PageVO page, UserDto userDto) {
|
||||
Page<SysUser> roadPage = page.toPage();
|
||||
Page<SysUser> pageList = sysUserService.page(roadPage, userDto.queryWrapper());
|
||||
return PageResponse.ok(pageList.getRecords(), pageList.getTotal());
|
||||
}
|
||||
|
||||
@@ -106,13 +107,13 @@ public class SysUserController {
|
||||
public Response saveOrUpdate(@RequestBody SysUser param) {
|
||||
|
||||
if (param.getUserId() == null && param.getDeptId() == null) {
|
||||
return Response.error("500", "请选择部门");
|
||||
return Response.error500("请选择部门");
|
||||
}
|
||||
|
||||
if (param.getUserId() == null) {
|
||||
// 只有超级管理员才能创建用户
|
||||
if (StpUtil.getLoginIdAsLong() != 1L) {
|
||||
return Response.error("403", "只有超级管理员才能创建用户!");
|
||||
return Response.error403("只有超级管理员才能创建用户!");
|
||||
}
|
||||
String password = param.getPassword();
|
||||
param.setPassword(SecureUtil.sha256(password));
|
||||
@@ -137,7 +138,7 @@ public class SysUserController {
|
||||
return Response.ok(sysUserService.updateById(param));
|
||||
}
|
||||
|
||||
public boolean saveUserRole(Long userId, List<String> roleIds) {
|
||||
private boolean saveUserRole(Long userId, List<String> roleIds) {
|
||||
sysUserRoleService.remove(Wrappers.<SysUserRole>lambdaQuery().eq(SysUserRole::getUserId, userId));
|
||||
List<SysUserRole> sysUserRoles = new ArrayList<>();
|
||||
roleIds.forEach(roleId -> {
|
||||
@@ -173,8 +174,9 @@ public class SysUserController {
|
||||
}
|
||||
|
||||
@PutMapping("/resetPwd/{userId}")
|
||||
@ApiOperation(value = "更新用户密码")
|
||||
@ApiOperation(value = "重置用户密码")
|
||||
@SaCheckPermission("user.reset.pwd")
|
||||
@SaCheckRole("admin")
|
||||
public Response resetPwd(@PathVariable Long userId) {
|
||||
SysUser user = new SysUser();
|
||||
user.setUserId(userId);
|
||||
|
||||
Reference in New Issue
Block a user