完善c端登录
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
package com.ruoyi.web.controller.client;
|
||||
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.ShopUser;
|
||||
import com.ruoyi.common.core.domain.entity.ShopUserResq;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.framework.web.service.SysLoginService;
|
||||
import com.ruoyi.system.service.AliConfigService;
|
||||
import com.ruoyi.system.service.ShopUserService;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.SwaggerDefinition;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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;
|
||||
|
||||
@RequestMapping("/client")
|
||||
@RestController
|
||||
public class ShopUserController {
|
||||
|
||||
@Autowired
|
||||
private SysLoginService loginService;
|
||||
@Autowired
|
||||
private AliConfigService aliConfigService;
|
||||
@Autowired
|
||||
private ShopUserService shopUserService;
|
||||
|
||||
|
||||
/**
|
||||
* 获取验证码
|
||||
*/
|
||||
@PostMapping("/getCode")
|
||||
public AjaxResult getCode(@RequestBody ShopUser shopUser){
|
||||
String result = aliConfigService.sendMsg(shopUser);
|
||||
if (result != null){
|
||||
return AjaxResult.success();
|
||||
}
|
||||
return AjaxResult.error("发送验证码失败");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 登录方法
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/shopLogin")
|
||||
public AjaxResult shopLogin(@RequestBody ShopUserResq userResq)
|
||||
{
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ShopUser shopUser = shopUserService.login(userResq);
|
||||
if (shopUser.getMsg() != null){
|
||||
return AjaxResult.error(shopUser.getMsg());
|
||||
}else {
|
||||
// 生成令牌
|
||||
String token = loginService.shopUserLogin(shopUser.getUsername(), shopUser.getPassword());
|
||||
ajax.put("userinfo", shopUser);
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
return ajax;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -49,21 +49,6 @@ public class SysLoginController
|
||||
@Autowired
|
||||
private ISysConfigService configService;
|
||||
|
||||
/**
|
||||
* 登录方法
|
||||
*
|
||||
* @param shopUser 登录信息
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/shopLogin")
|
||||
public AjaxResult shopLogin(@RequestBody ShopUser shopUser)
|
||||
{
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
// 生成令牌
|
||||
String token = loginService.shopUserLogin(shopUser.getUsername(), shopUser.getPassword());
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录方法
|
||||
|
||||
Reference in New Issue
Block a user