Commit 1c3ef6d9 by zhoujinghao

app用户登陆接口

1 parent 409961c8
...@@ -45,8 +45,8 @@ public class UserController { ...@@ -45,8 +45,8 @@ public class UserController {
@ApiOperation( value = "app用户登陆接口(密码加验证码)",notes = "app用户登陆接口(密码加验证码)") @ApiOperation( value = "app用户登陆接口(密码加验证码)",notes = "app用户登陆接口(密码加验证码)")
@PostMapping("/login") @PostMapping("/login")
@ResponseBody @ResponseBody
public Result<UserVO> login (@RequestBody LoginDto loginDto){ public ApiResponse<UserVO> login (@RequestBody LoginDto loginDto){
Result<UserVO> login = userService.userLogin(loginDto); ApiResponse<UserVO> login = userService.userLogin(loginDto);
return login; return login;
} }
......
...@@ -5,7 +5,6 @@ import org.apache.ibatis.annotations.Param; ...@@ -5,7 +5,6 @@ import org.apache.ibatis.annotations.Param;
import org.nafmii.dto.user.LoginDto; import org.nafmii.dto.user.LoginDto;
import org.nafmii.entity.user.AppUser; import org.nafmii.entity.user.AppUser;
import org.nafmii.entity.user.AppUserExample; import org.nafmii.entity.user.AppUserExample;
import org.nafmii.response.Result;
import org.nafmii.vo.UserVO; import org.nafmii.vo.UserVO;
import java.util.List; import java.util.List;
...@@ -23,7 +22,9 @@ public interface AppUserMapper { ...@@ -23,7 +22,9 @@ public interface AppUserMapper {
List<AppUser> selectByExample(AppUserExample example); List<AppUser> selectByExample(AppUserExample example);
Result<UserVO> selectByPassword(LoginDto loginDto); List<UserVO> selectByPassword(LoginDto loginDto);
List<UserVO> selectByPhone(@Param("phone") String phone);
AppUser selectByPrimaryKey(Long id); AppUser selectByPrimaryKey(Long id);
......
...@@ -2,8 +2,7 @@ package org.nafmii.service; ...@@ -2,8 +2,7 @@ package org.nafmii.service;
import org.nafmii.dto.user.LoginDto; import org.nafmii.dto.user.LoginDto;
import org.nafmii.dto.user.RegisterDto; import org.nafmii.dto.user.RegisterDto;
import org.nafmii.response.Result; import org.nafmii.response.ApiResponse;
import org.nafmii.vo.AppUser;
import org.nafmii.vo.UserVO; import org.nafmii.vo.UserVO;
/** /**
...@@ -16,9 +15,9 @@ import org.nafmii.vo.UserVO; ...@@ -16,9 +15,9 @@ import org.nafmii.vo.UserVO;
*/ */
public interface UserService { public interface UserService {
//模拟用户登陆接口 //模拟用户登陆接口
Result<UserVO> login(); ApiResponse<UserVO> login();
//app注册接口 //app注册接口
Result register(RegisterDto registerDto); ApiResponse register(RegisterDto registerDto);
//用户登陆接口 //用户登陆接口
Result<UserVO> userLogin(LoginDto loginDto); ApiResponse<UserVO> userLogin(LoginDto loginDto);
} }
...@@ -120,12 +120,32 @@ public class UserServiceImpl implements UserService { ...@@ -120,12 +120,32 @@ public class UserServiceImpl implements UserService {
* @return * @return
*/ */
@Override @Override
public Result<UserVO> userLogin(LoginDto loginDto) { public ApiResponse<UserVO> userLogin(LoginDto loginDto) {
AppUserExample userExample = new AppUserExample(); List<UserVO> userVo = new ArrayList<>();
//首先判断登陆方式 //首先判断登陆方式
if (loginDto.getType().equals("0")){ if (loginDto.getType().equals("0")){
Result<UserVO> userVo = appUserMapper.selectByPassword(loginDto); //密码登陆
userVo = appUserMapper.selectByPassword(loginDto);
if (userVo.isEmpty()){
throw new BusinessException("请先注册");
} }
return null; }else{
//验证码登陆
String code = (String) GuavaUtil.getTrackGuava(loginDto.getPhone());
log.info("冲缓存中获取的验证码===============》{}",code);
if (null == code){
throw new BusinessException("验证码已过期");
}
if (!code.equals(loginDto.getCode())){
throw new BusinessException("验证码错误请重新输入");
}
userVo = appUserMapper.selectByPhone(loginDto.getPhone());
if (userVo.isEmpty()){
throw new BusinessException("请先注册");
}
}
ApiResponse apiResponse =new ApiResponse();
apiResponse.setData(userVo);
return apiResponse;
} }
} }
...@@ -81,6 +81,27 @@ ...@@ -81,6 +81,27 @@
ID, USER_NAME, LOGIN_PWD, REAL_NAME, PHONE, BIRTHDAY, EMAIL, HEAD_PICTURE, NATIONALITY, ID, USER_NAME, LOGIN_PWD, REAL_NAME, PHONE, BIRTHDAY, EMAIL, HEAD_PICTURE, NATIONALITY,
UNIT_NAME, OPEN_ID, FIGERPRINT_FALG, FACEID_FALG, CREATE_TIME, UPDATE_TIME, IS_ENABLE UNIT_NAME, OPEN_ID, FIGERPRINT_FALG, FACEID_FALG, CREATE_TIME, UPDATE_TIME, IS_ENABLE
</sql> </sql>
<select id="selectByPassword" parameterType="org.nafmii.dto.user.LoginDto" resultType="org.nafmii.vo.UserVO">
select ID as id,
USER_NAME as userName, LOGIN_PWD as loginPwd, REAL_NAME as realName, PHONE as phone, BIRTHDAY as birthday, EMAIL as email, HEAD_PICTURE as headPicture, NATIONALITY as nationality,
UNIT_NAME as unitName, OPEN_ID as openId, FIGERPRINT_FALG as figerprintFalg, FACEID_FALG as faceidFalg, CREATE_TIME as createTime, UPDATE_TIME as updateTime, IS_ENABLE as isEnable
from APP_USER where IS_ENABLE = 0
<if test="phone !=null">
and PHONE !=#{phone}
</if>
<if test="loginPwd !=null">
and LOGIN_PWD !=#{loginPwd}
</if>
</select>
<select id="selectByPhone" parameterType="map" resultType="org.nafmii.vo.UserVO">
select ID as id,
USER_NAME as userName, LOGIN_PWD as loginPwd, REAL_NAME as realName, PHONE as phone, BIRTHDAY as birthday, EMAIL as email, HEAD_PICTURE as headPicture, NATIONALITY as nationality,
UNIT_NAME as unitName, OPEN_ID as openId, FIGERPRINT_FALG as figerprintFalg, FACEID_FALG as faceidFalg, CREATE_TIME as createTime, UPDATE_TIME as updateTime, IS_ENABLE as isEnable
from APP_USER where IS_ENABLE = 0
<if test="phone !=null">
and PHONE !=#{phone}
</if>
</select>
<select id="selectByExample" parameterType="org.nafmii.entity.user.AppUserExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="org.nafmii.entity.user.AppUserExample" resultMap="BaseResultMap">
select select
<if test="distinct"> <if test="distinct">
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!