123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- package com.simuwang.manage.api.system;
- import com.simuwang.base.common.support.MybatisPage;
- import com.simuwang.base.common.support.vo.OnlyIdNameVO;
- import com.simuwang.base.pojo.dto.DeleteByIdCmd;
- import com.simuwang.base.pojo.dto.GetByIdQuery;
- import com.simuwang.base.pojo.dto.UpdateStatusCmd;
- import com.simuwang.base.pojo.dto.sys.*;
- import com.simuwang.base.pojo.vo.sys.SysRoleUserVO;
- import com.simuwang.base.pojo.vo.sys.SysUserVO;
- import com.simuwang.logging.SystemLog;
- import com.simuwang.manage.service.system.SysUserService;
- import jakarta.validation.Valid;
- import org.springframework.web.bind.annotation.*;
- import java.util.List;
- /**
- * 用户管理相关接口
- */
- @SystemLog(value = "用户管理")
- @RestController
- @RequestMapping("/v1/sys/user")
- public class SysUserController {
- private final SysUserService service;
- public SysUserController(SysUserService service) {
- this.service = service;
- }
- /**
- * 分页接口
- *
- * @param query 用户列表分页请求参数
- * @return /
- */
- @SystemLog(value = "分页搜索", saveResult = true)
- @GetMapping("page")
- public MybatisPage<SysUserVO> page(UserQuery query) {
- return this.service.findPage(query);
- }
- /**
- * 多表关联的分页接口(案例,此接口暂无使用场景)
- *
- * @param query 用户列表分页请求参数
- * @return /
- */
- @GetMapping("multi-join-page")
- public MybatisPage<SysRoleUserVO> multiJoinPage(RoleUserQuery query) {
- return this.service.findMultiPage(query);
- }
- /**
- * 新增用户
- *
- * @param command 用户信息
- */
- @SystemLog(value = "新增", type = SystemLog.Type.INSERT)
- @PostMapping("save")
- public boolean save(@Valid @RequestBody UserAddCmd command) {
- this.service.insert(command);
- return true;
- }
- /**
- * 更新用户
- *
- * @param command 用户id+用户信息
- */
- @SystemLog(value = "修改", type = SystemLog.Type.UPDATE)
- @PostMapping("update")
- public boolean update(@Valid @RequestBody UserEditCmd command) {
- this.service.update(command);
- return true;
- }
- /**
- * 更新用户状态接口
- *
- * @param command 用户id+状态对象
- */
- @SystemLog(value = "更新状态", type = SystemLog.Type.UPDATE)
- @PostMapping("update-status")
- public boolean updateStatus(@Valid @RequestBody UpdateStatusCmd command) {
- this.service.updateStatus(command);
- return true;
- }
- /**
- * 根据id删除用户信息接口
- *
- * @param command 用户id对象
- */
- @SystemLog(value = "删除", type = SystemLog.Type.DELETE)
- @PostMapping("del")
- public boolean deleteById(@Valid @RequestBody DeleteByIdCmd command) {
- this.service.delete(command);
- return true;
- }
- /**
- * 用户角色绑定
- *
- * @param command 用户绑定的角色对象
- */
- @SystemLog(value = "用户角色绑定", type = SystemLog.Type.UPDATE)
- @PostMapping("bind-roles")
- public boolean bindRoles(@Valid @RequestBody UserRoleBindCmd command) {
- this.service.bindRoles(command);
- return true;
- }
- /**
- * 获取用户绑定的角色
- *
- * @param query 用户id对象
- */
- @GetMapping("list-bind-roles")
- public List<OnlyIdNameVO> listBindRoles(@Valid @RequestBody GetByIdQuery query) {
- return this.service.getUserRoles(query);
- }
- }
|