feat:
- Change Mybatis to JPA - Change groupId
This commit is contained in:
16
src/main/java/com/dlp/admin/controller/ExceptionCtrl.java
Normal file
16
src/main/java/com/dlp/admin/controller/ExceptionCtrl.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.dlp.admin.controller;
|
||||
|
||||
import com.dlp.admin.entity.exception.UsernameOrPasswordExcp;
|
||||
import com.dlp.admin.entity.resp.Resp;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
@RestControllerAdvice
|
||||
public class ExceptionCtrl {
|
||||
|
||||
@ExceptionHandler(UsernameOrPasswordExcp.class)
|
||||
public Resp<Object> handler(UsernameOrPasswordExcp e) {
|
||||
return Resp.fail(e.getCode(), e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
102
src/main/java/com/dlp/admin/controller/UserCtrl.java
Normal file
102
src/main/java/com/dlp/admin/controller/UserCtrl.java
Normal file
@@ -0,0 +1,102 @@
|
||||
package com.dlp.admin.controller;
|
||||
|
||||
import com.dlp.admin.entity.pojo.user.SysResource;
|
||||
import com.dlp.admin.entity.pojo.user.SysRole;
|
||||
import com.dlp.admin.entity.req.user.*;
|
||||
import com.dlp.admin.entity.resp.PageResp;
|
||||
import com.dlp.admin.entity.resp.Resp;
|
||||
import com.dlp.admin.entity.resp.user.GetTagResp;
|
||||
import com.dlp.admin.entity.resp.user.GetUserResp;
|
||||
import com.dlp.admin.entity.resp.user.LoginResp;
|
||||
import com.dlp.admin.repository.user.SysRoleRepo;
|
||||
import com.dlp.admin.service.UserServ;
|
||||
import com.dlp.admin.util.RedisUtil;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
||||
@AllArgsConstructor
|
||||
public class UserCtrl {
|
||||
|
||||
private final RedisUtil redisUtil;
|
||||
private final UserServ userServ;
|
||||
private final SysRoleRepo sysRoleRepo;
|
||||
|
||||
@PostMapping("/login")
|
||||
@Operation(summary = "登录接口")
|
||||
public Resp<LoginResp> login(@RequestBody LoginReq req) {
|
||||
return Resp.success(userServ.login(req));
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
@Operation(summary = "搜索用户")
|
||||
public Resp<PageResp<GetUserResp>> listUser(@RequestBody ListUserReq req) {
|
||||
return Resp.success(null);
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
@Operation(summary = "增加用户")
|
||||
public Resp<Object> addUser(@RequestBody AddUserReq req) {
|
||||
return Resp.success();
|
||||
}
|
||||
|
||||
@PostMapping("/get/{id}")
|
||||
@Operation(summary = "获取用户")
|
||||
public Resp<GetUserResp> getUser(@PathVariable("id") Long id) {
|
||||
return Resp.success(null);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@Operation(summary = "更新用户")
|
||||
public Resp<Object> updateUser(@RequestBody UpdateUserReq req) {
|
||||
return Resp.success();
|
||||
}
|
||||
|
||||
@PostMapping("/delete/{id}")
|
||||
@Operation(summary = "删除用户")
|
||||
public Resp<Object> deleteUser(@PathVariable Long id) {
|
||||
return Resp.success();
|
||||
}
|
||||
|
||||
@PostMapping("/resetPwd/{id}")
|
||||
@Operation(summary = "重置密码")
|
||||
public Resp<Object> resetPwd(@PathVariable Long id) {
|
||||
return Resp.success();
|
||||
}
|
||||
|
||||
@PostMapping("/tag/add")
|
||||
@Operation(summary = "增加用户标签")
|
||||
private Resp<Object> addUserTag(@RequestBody AddUserTagReq req) {
|
||||
return Resp.success();
|
||||
}
|
||||
|
||||
@PostMapping("/tag/delete/{id}")
|
||||
@Operation(summary = "删除用户标签")
|
||||
private Resp<Object> deleteUserTag(@PathVariable Long id) {
|
||||
return Resp.success();
|
||||
}
|
||||
|
||||
@GetMapping("/tag/list")
|
||||
@Operation(summary = "获取所有用户标签")
|
||||
private Resp<List<GetTagResp>> listUserTag() {
|
||||
return Resp.success(null);
|
||||
}
|
||||
|
||||
@GetMapping("/test")
|
||||
private Resp<Object> test() {
|
||||
SysResource resource = new SysResource();
|
||||
resource.setResource("/user/test");
|
||||
resource.setRequestMethod(RequestMethod.GET);
|
||||
List<SysResource> resources = List.of(resource);
|
||||
// return Resp.success(sysResourceMapper.batchInsert(resources));
|
||||
// return Resp.success(sysRoleMapper.selectRoleIdsByUserId(List.of(1L, 2L)));
|
||||
List<SysRole> roles = sysRoleRepo.findAll();
|
||||
roles.stream().forEach(role -> role.getResources().stream().forEach(resource1 -> System.out.println(resource1.getResource())));
|
||||
return Resp.success();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user