You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.9 KiB
59 lines
1.9 KiB
2 months ago
|
package com.water.watersys.controller;
|
||
|
|
||
|
import cn.dev33.satoken.stp.StpUtil;
|
||
|
import com.water.watersys.components.Result;
|
||
|
import com.water.watersys.model.dto.ChangePassword;
|
||
|
import com.water.watersys.model.vo.UserOv;
|
||
|
import com.water.watersys.service.UserSysService;
|
||
|
import io.swagger.v3.oas.annotations.Operation;
|
||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||
|
import jakarta.annotation.Resource;
|
||
|
import org.springframework.web.bind.annotation.*;
|
||
|
|
||
|
@RestController
|
||
|
@CrossOrigin
|
||
|
@Tag(name = "用户", description = "用户")
|
||
|
public class UserController {
|
||
|
@Resource
|
||
|
private UserSysService userSysService;
|
||
|
|
||
|
|
||
|
@Operation(summary = "获取用户信息", description = "获取用户信息")
|
||
|
@GetMapping("/user")
|
||
|
public Result<UserOv> user() {
|
||
|
Object loginId = StpUtil.getLoginId();
|
||
|
UserOv userOv = userSysService.getUser((String) loginId);
|
||
|
if (userOv != null) {
|
||
|
return Result.success(userOv);
|
||
|
}else {
|
||
|
return Result.notFoundFail();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Operation(summary = "修改用户密码", description = "修改用户密码")
|
||
|
@PutMapping("/changePassword")
|
||
|
public Result<String> changePassword(@RequestBody ChangePassword changePassword) {
|
||
|
String loginId = (String) StpUtil.getLoginId();
|
||
|
Integer id = userSysService.changePassword(changePassword,loginId);
|
||
|
if (id != 0) {
|
||
|
return Result.success();
|
||
|
}else {
|
||
|
return Result.createFail("密码验证失败");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Operation(summary = "修改用户状态", description = "修改用户状态")
|
||
|
@PutMapping("/changeUserStatus")
|
||
|
public Result<String> changeUserStatus(Integer status) {
|
||
|
String loginId = (String) StpUtil.getLoginId();
|
||
|
Integer id = userSysService.changeUserStatus(status,loginId);
|
||
|
if (id != 0) {
|
||
|
return Result.success();
|
||
|
}else {
|
||
|
return Result.createFail();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|