商城登录接口
This commit is contained in:
parent
5b0e807b29
commit
201f7d4f5c
|
|
@ -131,8 +131,7 @@ public class TokenController {
|
||||||
@PostMapping("loginByMall")
|
@PostMapping("loginByMall")
|
||||||
public R<?> loginByMall(@RequestBody LoginUser loginUser) {
|
public R<?> loginByMall(@RequestBody LoginUser loginUser) {
|
||||||
// 用户注册
|
// 用户注册
|
||||||
sysLoginService.loginByMall(loginUser);
|
return R.ok(sysLoginService.loginByMall(loginUser));
|
||||||
return R.ok(null,"登录成功");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("微服务平台认证接口")
|
@ApiOperation("微服务平台认证接口")
|
||||||
|
|
|
||||||
|
|
@ -12,14 +12,18 @@ import com.bonus.sgzb.common.core.text.Convert;
|
||||||
import com.bonus.sgzb.common.core.utils.StringUtils;
|
import com.bonus.sgzb.common.core.utils.StringUtils;
|
||||||
import com.bonus.sgzb.common.core.utils.ip.IpUtils;
|
import com.bonus.sgzb.common.core.utils.ip.IpUtils;
|
||||||
import com.bonus.sgzb.common.redis.service.RedisService;
|
import com.bonus.sgzb.common.redis.service.RedisService;
|
||||||
|
import com.bonus.sgzb.common.security.service.TokenService;
|
||||||
import com.bonus.sgzb.common.security.utils.SecurityUtils;
|
import com.bonus.sgzb.common.security.utils.SecurityUtils;
|
||||||
import com.bonus.sgzb.system.api.RemoteUserService;
|
import com.bonus.sgzb.system.api.RemoteUserService;
|
||||||
import com.bonus.sgzb.system.api.domain.SysUser;
|
import com.bonus.sgzb.system.api.domain.SysUser;
|
||||||
import com.bonus.sgzb.system.api.model.LoginUser;
|
import com.bonus.sgzb.system.api.model.LoginUser;
|
||||||
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录校验方法
|
* 登录校验方法
|
||||||
|
|
@ -40,6 +44,10 @@ public class SysLoginService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TokenService tokenService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户名密码登录
|
* 用户名密码登录
|
||||||
*/
|
*/
|
||||||
|
|
@ -232,7 +240,22 @@ public class SysLoginService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void loginByMall(LoginUser loginUser) {
|
public Map loginByMall(LoginUser loginUser) {
|
||||||
|
String username = loginUser.getUsername();
|
||||||
|
HashMap hashMap = new HashMap();
|
||||||
|
String token = loginUser.getToken();
|
||||||
|
// 表示商城登录该系统的标识
|
||||||
|
if (StringUtils.isNotBlank(token)) {
|
||||||
|
R<LoginUser> userInfo = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
|
||||||
|
if (ObjectUtils.isNotEmpty(userInfo.getData())) {
|
||||||
|
return tokenService.createToken(userInfo.getData());
|
||||||
|
} else {
|
||||||
|
hashMap.put("login_user", "该用户未注册");
|
||||||
|
return hashMap;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
hashMap.put("login_user", "token为空");
|
||||||
|
return hashMap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue