This commit is contained in:
张良(004796)
2024-03-08 14:26:20 +08:00
parent 01f5dcbb54
commit c47e71b301
3 changed files with 3 additions and 3 deletions

View File

@@ -0,0 +1,86 @@
package com.ruoyi.xq.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.xq.dto.common.sms.SystemConfigResponse;
import com.ruoyi.xq.enums.common.SystemConfigEnum;
import com.ruoyi.xq.enums.common.SystemConfigGroupEnum;
import com.ruoyi.xq.manager.SystemConfigManager;
import com.ruoyi.xq.manager.systemconfig.SystemCheckResp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/xq/systemConfig")
public class SystemConfigController {
@Autowired
private SystemConfigManager systemConfigManager;
@GetMapping("/business/all")
@SaCheckPermission("xq:businessConfig:query")
public R<List<SystemConfigResponse>> businessAll(){
List<SystemConfigResponse> responses = new ArrayList<>();
Map<String, String> allSystemConfig = systemConfigManager.getAllSystemConfig();
SystemConfigEnum[] values = SystemConfigEnum.values();
for (SystemConfigEnum value : values) {
if(value.getGroup() == SystemConfigGroupEnum.BUSINESS){
SystemConfigResponse sys = new SystemConfigResponse();
sys.setKey(value.getKey());
sys.setValue(allSystemConfig.getOrDefault(value.getKey(),value.getDefaultValue()));
sys.setDesc(value.getDesc());
responses.add(sys);
}
}
return R.ok(responses);
}
@GetMapping("/business/update")
@SaCheckPermission("xq:businessConfig:edit")
@Log(title = "修改业务设置", businessType = BusinessType.UPDATE)
public R<Void> businessUpdate(String key,String value){
SystemConfigEnum[] values = SystemConfigEnum.values();
for (SystemConfigEnum config : values) {
if (config.getGroup() == SystemConfigGroupEnum.BUSINESS && config.getKey().equals(key)) {
SystemCheckResp checkResp = systemConfigManager.setSystemConfig(config, value);
if(checkResp.isSuccess()){
return R.ok();
}
return R.fail(checkResp.getMessage());
}
}
return R.ok();
}
@GetMapping("/system/all")
@SaCheckPermission("xq:systemConfig:query")
public R<List<SystemConfigResponse>> systemAll(){
List<SystemConfigResponse> responses = new ArrayList<>();
Map<String, String> allSystemConfig = systemConfigManager.getAllSystemConfig();
SystemConfigEnum[] values = SystemConfigEnum.values();
for (SystemConfigEnum value : values) {
if(value.getGroup() == SystemConfigGroupEnum.SYSTEM){
SystemConfigResponse sys = new SystemConfigResponse();
sys.setKey(value.getKey());
sys.setValue(allSystemConfig.getOrDefault(value.getKey(),value.getDefaultValue()));
sys.setDesc(value.getDesc());
responses.add(sys);
}
}
return R.ok(responses);
}
@GetMapping("/system/update")
@SaCheckPermission("xq:systemConfig:edit")
@Log(title = "修改系统设置", businessType = BusinessType.UPDATE)
public R<Boolean> systemUpdate(String key,String value){
systemConfigManager.set(key,value);
return R.ok(true);
}
}

View File

@@ -0,0 +1,88 @@
package com.ruoyi.xq.controller.app;
import cn.dev33.satoken.annotation.SaIgnore;
import cn.hutool.core.util.PhoneUtil;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.xq.dto.app.login.LoginUser;
import com.ruoyi.xq.dto.app.login.LoginVo;
import com.ruoyi.xq.dto.app.user.ResetPasswordReq;
import com.ruoyi.xq.dto.common.sms.SmsCodeReq;
import com.ruoyi.xq.manager.CaiLoginManager;
import com.ruoyi.xq.manager.CurrentUserManager;
import com.ruoyi.xq.service.SmsVerifyService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@RestController
@RequestMapping("/api/auth")
@SaIgnore
@Tag(name = "权限相关接口,免鉴权")
@Validated
public class AuthAppController {
@Autowired
private CaiLoginManager caiLoginManager;
@Autowired
private SmsVerifyService smsVerifyService;
@Autowired
private CurrentUserManager currentUserManager;
@PostMapping("/sms/code")
@Operation(summary = "获取验证码")
@SaIgnore
@Log(title = "获取验证码", businessType = BusinessType.OTHER, isSaveDb = false)
public R<Map<String,String>> registerCode(@Validated @RequestBody SmsCodeReq code){
boolean mobile = PhoneUtil.isMobile(code.getMobile());
if(!mobile){
return R.fail(600,"请输入正确的手机格式");
}
smsVerifyService.put(code.getSmsType(),code.getMobile());
return R.ok("发送成功");
}
@PostMapping("/login")
@Operation(summary = "登陆")
@Log(title = "登陆", businessType = BusinessType.OTHER, isSaveDb = false)
public R<LoginVo> login(@Validated @RequestBody LoginUser loginBody){
LoginVo vo = new LoginVo();
String token;
if(loginBody.getLoginType() == 2){
token = caiLoginManager.login(loginBody.getUsername(), loginBody.getPassword());
}else if(loginBody.getLoginType() == 1){
token = caiLoginManager.loginSms(loginBody.getUsername(), loginBody.getCode(), loginBody.getInviteCode());
}else{
return R.fail(600,"登陆失败,参数异常");
}
vo.setToken(token);
vo.setUserInfo(currentUserManager.currentBaseInfo());
return R.ok(vo);
}
@PostMapping("/loginOut")
@Operation(summary = "登出")
@Log(title = "登出", businessType = BusinessType.OTHER, isSaveDb = false)
public R<Void> loginOut(){
caiLoginManager.logout();
return R.ok();
}
@PostMapping("/resetPassword")
@Operation(summary = "重置密码")
@Log(title = "重置密码", businessType = BusinessType.OTHER, isSaveDb = false)
public R<Void> resetPassword(@RequestBody ResetPasswordReq code){
caiLoginManager.resetPassword(code.getMobile(),code.getCode(),code.getPassword());
return R.ok();
}
}

View File

@@ -25,7 +25,7 @@ import java.util.List;
@RestController
@RequestMapping("/api/vip")
@Tag(name = "首页相关接口")
@Tag(name = "VIP相关接口")
public class VipController {
@Autowired