提交 baf6aff2 作者: han

web端登录相关接口

上级 c8c05b51
流水线 #8004 已通过 于阶段
in 2 分 21 秒
......@@ -95,5 +95,6 @@ public class UserAccountVO implements Serializable {
@ApiModelProperty(value = "用户对应的后台用户id")
private Integer backUserId;
@ApiModelProperty(value = "密码")
private String password;
}
package com.mmc.iuav.user.model.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @author: zj
* @Date: 2023/5/16 15:17
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class WebUserSucVO implements Serializable {
private static final long serialVersionUID = 7491711282161485720L;
@ApiModelProperty(value = "用户id")
private Integer userAccountId;
@ApiModelProperty(value = "token")
private String token;
@ApiModelProperty(value = "手机号")
private String phoneNum;
@ApiModelProperty(value = "昵称")
private String nickName;
}
......@@ -7,10 +7,7 @@ import com.mmc.iuav.user.dao.RoleDao;
import com.mmc.iuav.user.entity.RoleInfoDO;
import com.mmc.iuav.user.enums.UserTypeEnums;
import com.mmc.iuav.user.model.dto.LoginSuccessDTO;
import com.mmc.iuav.user.model.vo.AppUserSucVO;
import com.mmc.iuav.user.model.vo.BackUserAccountVO;
import com.mmc.iuav.user.model.vo.CompanyInfoVO;
import com.mmc.iuav.user.model.vo.UserAccountVO;
import com.mmc.iuav.user.model.vo.*;
import com.mmc.iuav.user.service.CompanyService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -52,6 +49,18 @@ public class AuthHandler {
.nickName(userAccountVO.getNickName()).userAccountId(userAccountVO.getId()).portType(UserTypeEnums.APP.getType()).build();
return appUserSucVO;
}
public WebUserSucVO addWebLoginCache(UserAccountVO userAccountVO) {
Map<String, Object> map = new HashMap<String, Object>();
map.put(JwtConstant.USER_ACCOUNT_ID, userAccountVO.getId());
map.put(JwtConstant.TOKEN_TYPE, JwtConstant.IUAV_TOKEN);
String token = JwtUtil.createJwt(map);
stringRedisTemplate.opsForValue().set(
token, JSONObject.toJSONString(userAccountVO),
JwtConstant.EXPIRATION, TimeUnit.MILLISECONDS);
WebUserSucVO webUserSucVO = WebUserSucVO.builder().token(token).phoneNum(userAccountVO.getPhoneNum())
.nickName(userAccountVO.getNickName()).userAccountId(userAccountVO.getId()).build();
return webUserSucVO;
}
public LoginSuccessDTO addPcLoginCache(BackUserAccountVO user) {
// 查询单位信息
......
......@@ -94,4 +94,11 @@ public class AuthController {
public ResultBody webRegister(@Validated(value = {Insert.class}) @RequestBody WebRegisterVO webRegisterVO) {
return authService.webRegister(webRegisterVO);
}
@ApiOperation(value = "web端账号密码登录")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = LoginSuccessDTO.class)})
@PostMapping("webLogin")
public ResultBody webLogin(
@ApiParam(value = "账号登录QO", required = true) @Validated @RequestBody LoginUserQO param) {
return authService.webLogin(param);
}
}
......@@ -35,7 +35,7 @@ public interface UserServiceDao {
* @param userAccountDO
*/
void insertUserAccount(UserAccountDO userAccountDO);
void insertUserAccount1(UserAccountDO userAccountDO);
Integer insertUserAccount1(UserAccountDO userAccountDO);
/**
* 根据用户id查询用户信息
......@@ -254,4 +254,7 @@ public interface UserServiceDao {
* 删除用户信息
*/
void deleteById(Integer id);
UserAccountDO getUserAccountInfoByPhoneNum(String phoneNum);
}
......@@ -138,6 +138,7 @@ public class UserAccountDO implements Serializable {
.briefIntroduction(this.briefIntroduction)
.coverPicture(this.coverPicture)
.districtChildId(this.districtChildId)
.password(this.password)
.build();
}
......
......@@ -59,4 +59,6 @@ public interface AuthService {
* web端用户注册
*/
ResultBody webRegister(WebRegisterVO webRegisterVO);
ResultBody webLogin(LoginUserQO param);
}
package com.mmc.iuav.user.service;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.entity.BackUserAccountDO;
import com.mmc.iuav.user.entity.UserAccountDO;
import com.mmc.iuav.user.model.dto.LoginSuccessDTO;
import com.mmc.iuav.user.model.dto.UserAccountSimpleDTO;
......@@ -25,6 +26,7 @@ public interface UserAccountService {
* @return
*/
UserAccountVO getUserAccountInfoByUnionId(String unionId);
UserAccountVO getUserAccountInfoByPhoneNum(String phoneNum);
/**
* Insert the user account
......@@ -187,4 +189,5 @@ public interface UserAccountService {
* 根据手机号查询unionId
*/
String selectUnionIdByPhone(String phone);
}
......@@ -286,6 +286,8 @@ public class AuthServiceImpl implements AuthService {
return ResultBody.error(ResultEnum.PWD_CREATE_ERROR);
}
userServiceDao.insertUserAccount1(userAccountDO);
userAccountDO.setNickName("云享飞用户_"+ userAccountDO.getId());
userServiceDao.update(userAccountDO);
}else if(userAccountDO.getPassword() == null){
//小程序登录过且绑定过手机号
try {
......@@ -300,6 +302,27 @@ public class AuthServiceImpl implements AuthService {
return ResultBody.success();
}
@Override
public ResultBody webLogin(LoginUserQO param) {
UserAccountVO user = userAccountService.getUserAccountInfoByPhoneNum(param.getAccountNo());
//查询用户信息
// BackUserAccountDO user = backUserAccountService.getUserLoginInfo(param.getAccountNo(), param.getPassWord());
if (user == null) {
return ResultBody.error(ResultEnum.LOGIN_ACCOUNT_NOT_EXIT_ERROR);
}
String loginPwd = "";
try {
loginPwd = PwdUtil.securityPwd(param.getPassWord());
} catch (NoSuchAlgorithmException e) {
return ResultBody.error(ResultEnum.PWD_CONPARED_ERROR);
}
if (!loginPwd.equals(user.getPassword())) {
return ResultBody.error(ResultEnum.LOGIN_PASSWORD_ERROR);
}
WebUserSucVO webUserSucVO = authHandler.addWebLoginCache(user);
return ResultBody.success(webUserSucVO);
}
private void extracted(Integer id) {
UserPointsVO userPointsVO = new UserPointsVO(id, NumberOfUserPoints.match(0).getMessage());
......
......@@ -101,6 +101,15 @@ public class UserAccountServiceImpl implements UserAccountService {
}
@Override
public UserAccountVO getUserAccountInfoByPhoneNum(String phoneNum) {
UserAccountDO userAccountDO = userServiceDao.getUserAccountInfoByPhoneNum(phoneNum);
if (userAccountDO != null) {
return userAccountDO.buildUserAccountVO();
}
return null;
}
@Override
public void insertUserAccount(UserAccountDO userAccountDO) {
if(userServiceDao.getUserAccountInfoByUnionId(userAccountDO.getUnionId()) == null){
userServiceDao.insertUserAccount(userAccountDO);
......@@ -587,4 +596,5 @@ public class UserAccountServiceImpl implements UserAccountService {
}
......@@ -748,5 +748,27 @@
where phone_num = #{phoneNum} and disable = 0
limit 1
</select>
<select id="getUserAccountInfoByPhoneNum" resultType="com.mmc.iuav.user.entity.UserAccountDO">
select id,
phone_num,
user_name,
nick_name,
user_img,
open_id,
union_id,
user_sex,
email,
source,
account_status,
remark,
port_type,
disable,
create_time,
update_time,
password
from user_account
where phone_num = #{phoneNum}
and disable = 0
</select>
</mapper>
......@@ -47,4 +47,5 @@ data-filter:
- /userapp/user-account/feignListAppUserAccount1
- /userapp/auth/getVerifyCode
- /userapp/auth/webRegister
- /userapp/auth/webLogin
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论