|
@@ -0,0 +1,106 @@
|
|
|
+
|
|
|
+package com.hfln.portal.application.controller.web;
|
|
|
+
|
|
|
+
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
+import cn.hfln.framework.catchlog.CatchAndLog;
|
|
|
+import cn.hfln.framework.dto.ApiResult;
|
|
|
+import com.hfln.portal.common.dto.data.role.RoleListDTO;
|
|
|
+import com.hfln.portal.common.request.admin.AddRoleParam;
|
|
|
+import com.hfln.portal.common.request.admin.AdminAddParam;
|
|
|
+import com.hfln.portal.common.request.admin.AdminLoginParam;
|
|
|
+import com.hfln.portal.common.request.admin.AdminResetParam;
|
|
|
+import com.hfln.portal.common.response.admin.AdminLoginRes;
|
|
|
+import com.hfln.portal.common.response.user.UserTokenInfo;
|
|
|
+import com.hfln.portal.domain.customer.util.CopyUtils;
|
|
|
+import com.hfln.portal.domain.gateway.WebGateway;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.validation.Valid;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@CatchAndLog
|
|
|
+@Tag(name = "web端用户相关")
|
|
|
+@Slf4j
|
|
|
+@RequestMapping("/web/user")
|
|
|
+public class WebUserController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WebGateway webGateway;
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("/login")
|
|
|
+ @Operation(summary = "用户账户密码登录")
|
|
|
+ public ApiResult<AdminLoginRes> login(@Valid @RequestBody AdminLoginParam param) {
|
|
|
+
|
|
|
+ return ApiResult.success(webGateway.login(param));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/getTokenInfo")
|
|
|
+ @Operation(summary = "获取当前token信息(后端测试自用)")
|
|
|
+ public ApiResult<UserTokenInfo> getTokenInfo() {
|
|
|
+
|
|
|
+ return ApiResult.success(CopyUtils.copy(StpUtil.getTokenInfo(), UserTokenInfo.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/logout")
|
|
|
+ @Operation(summary = "用户退出登录")
|
|
|
+ public ApiResult<Void> logout() {
|
|
|
+
|
|
|
+ webGateway.logout();
|
|
|
+ return ApiResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/sendCode")
|
|
|
+ @Operation(summary = "用户忘记密码,发送验证码")
|
|
|
+ public ApiResult<Void> sendCode() {
|
|
|
+
|
|
|
+ webGateway.sendCode();
|
|
|
+ return ApiResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/reset")
|
|
|
+ @Operation(summary = "超管重置密码")
|
|
|
+ public ApiResult<Void> resetPassword(@Valid @RequestBody AdminResetParam param) {
|
|
|
+
|
|
|
+ webGateway.reset(param);
|
|
|
+ return ApiResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/addAccount")
|
|
|
+ @Operation(summary = "超管添加用户")
|
|
|
+ public ApiResult<Void> addAccount(@Valid @RequestBody AdminAddParam param) {
|
|
|
+
|
|
|
+ webGateway.addAccount(param);
|
|
|
+ return ApiResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/addRole")
|
|
|
+ @Operation(summary = "新增角色")
|
|
|
+ public ApiResult<Void> addRole(@RequestBody @Valid AddRoleParam params){
|
|
|
+
|
|
|
+ webGateway.addRole(params);
|
|
|
+ return ApiResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/disable")
|
|
|
+ @Operation(summary = "禁用角色")
|
|
|
+ public ApiResult<Void> disableRole(@RequestParam @Parameter(description = "角色编码") String roleCode){
|
|
|
+
|
|
|
+ webGateway.disableRole(roleCode);
|
|
|
+ return ApiResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/roleList")
|
|
|
+ @Operation(summary = "获取角色列表")
|
|
|
+ public ApiResult<List<RoleListDTO>> roleList(){
|
|
|
+ List<RoleListDTO> roleList = webGateway.roleList();
|
|
|
+ return ApiResult.success(roleList);
|
|
|
+ }
|
|
|
+}
|