Commit 95536819 by zhoujinghao

app用户注册相关代码提交

1 parent fa74cfed
...@@ -2,9 +2,11 @@ package org.nafmii.controller; ...@@ -2,9 +2,11 @@ package org.nafmii.controller;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
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.Result;
import org.nafmii.service.UserService; import org.nafmii.service.UserService;
import org.nafmii.vo.AppUser;
import org.nafmii.vo.UserVO; import org.nafmii.vo.UserVO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
...@@ -41,5 +43,13 @@ public class UserController { ...@@ -41,5 +43,13 @@ public class UserController {
return register; return register;
} }
@ApiOperation( value = "app用户登陆接口(密码加验证码)",notes = "app用户登陆接口(密码加验证码)")
@PostMapping("/login")
@ResponseBody
public Result<UserVO> login (@RequestBody LoginDto loginDto){
Result<UserVO> login = userService.userLogin(loginDto);
return login;
}
} }
package org.nafmii.dto.user;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* @author:zhoujh
* @Function:TODO
* @date 2021/4/26 16:41
* @ClassName:
* @version:
* @remark:
*/
@Data
@ApiModel("app用户登陆参数对象")
public class LoginDto {
@NotNull(message = "手机号或登录账号不能为空")
@ApiModelProperty("手机号/登录账号")
private String phone;
@NotNull(message = "注册密码不能为空")
@ApiModelProperty("登陆密码")
private String loginPwd;
@NotNull(message = "验证码不能为空")
@ApiModelProperty("验证码")
private String code;
@NotNull(message = "登陆方式不能为空")
@ApiModelProperty("登陆方式0密码1验证码")
private String type;
}
...@@ -7,7 +7,6 @@ import java.util.Date; ...@@ -7,7 +7,6 @@ import java.util.Date;
public class AppUser implements Serializable { public class AppUser implements Serializable {
private Long id; private Long id;
@ApiModelProperty(value = "昵称") @ApiModelProperty(value = "昵称")
private String userName; private String userName;
......
...@@ -25,6 +25,9 @@ public enum UserEnum { ...@@ -25,6 +25,9 @@ public enum UserEnum {
*/ */
ENABLE("0","有效用户"), ENABLE("0","有效用户"),
NOTENABLE("1","无效用户"), NOTENABLE("1","无效用户"),
LOGINPHONE("1","验证码"),
LOGINPWD("0","密码"),
; ;
UserEnum(String code, String name){ UserEnum(String code, String name){
......
package org.nafmii.mapper.user; package org.nafmii.mapper.user;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
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 java.util.List; import java.util.List;
...@@ -19,6 +22,8 @@ public interface AppUserMapper { ...@@ -19,6 +22,8 @@ public interface AppUserMapper {
List<AppUser> selectByExample(AppUserExample example); List<AppUser> selectByExample(AppUserExample example);
Result<UserVO> selectByPassword(LoginDto loginDto);
AppUser selectByPrimaryKey(Long id); AppUser selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") AppUser record, @Param("example") AppUserExample example); int updateByExampleSelective(@Param("record") AppUser record, @Param("example") AppUserExample example);
......
package org.nafmii.service; package org.nafmii.service;
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.Result;
import org.nafmii.vo.AppUser;
import org.nafmii.vo.UserVO; import org.nafmii.vo.UserVO;
/** /**
...@@ -17,4 +19,6 @@ public interface UserService { ...@@ -17,4 +19,6 @@ public interface UserService {
Result<UserVO> login(); Result<UserVO> login();
//app注册接口 //app注册接口
Result register(RegisterDto registerDto); Result register(RegisterDto registerDto);
//用户登陆接口
Result<UserVO> userLogin(LoginDto loginDto);
} }
...@@ -3,8 +3,10 @@ package org.nafmii.service.impl; ...@@ -3,8 +3,10 @@ package org.nafmii.service.impl;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.nafmii.dto.user.LoginDto;
import org.nafmii.dto.user.RegisterDto; import org.nafmii.dto.user.RegisterDto;
import org.nafmii.entity.user.AppUser; import org.nafmii.entity.user.AppUser;
import org.nafmii.entity.user.AppUserExample;
import org.nafmii.enums.UserEnum; import org.nafmii.enums.UserEnum;
import org.nafmii.exception.BusinessException; import org.nafmii.exception.BusinessException;
import org.nafmii.mapper.user.AppUserMapper; import org.nafmii.mapper.user.AppUserMapper;
...@@ -45,7 +47,7 @@ public class UserServiceImpl implements UserService { ...@@ -45,7 +47,7 @@ public class UserServiceImpl implements UserService {
Result result = new Result(); Result result = new Result();
//假设验证数据通过 //假设验证数据通过
UserVO userVO = new UserVO(); UserVO userVO = new UserVO();
userVO.setPassword("zzz"); userVO.setLoginPwd("zzz");
userVO.setUserName("zzz"); userVO.setUserName("zzz");
List<UserAndRoleVo> roleList =new ArrayList<>(); List<UserAndRoleVo> roleList =new ArrayList<>();
UserAndRoleVo roleVo = new UserAndRoleVo(); UserAndRoleVo roleVo = new UserAndRoleVo();
...@@ -54,7 +56,7 @@ public class UserServiceImpl implements UserService { ...@@ -54,7 +56,7 @@ public class UserServiceImpl implements UserService {
roleList.add(roleVo); roleList.add(roleVo);
roleTwoVo.setRole("b"); roleTwoVo.setRole("b");
roleList.add(roleTwoVo); roleList.add(roleTwoVo);
userVO.setAuthorities(roleList); // userVO.setAuthorities(roleList);
StringBuilder sbf = new StringBuilder(); StringBuilder sbf = new StringBuilder();
for (UserAndRoleVo role:roleList for (UserAndRoleVo role:roleList
) { ) {
...@@ -64,7 +66,7 @@ public class UserServiceImpl implements UserService { ...@@ -64,7 +66,7 @@ public class UserServiceImpl implements UserService {
String sRole = sbf.toString(); String sRole = sbf.toString();
String substring = sRole.substring(0, sRole.lastIndexOf(",")); String substring = sRole.substring(0, sRole.lastIndexOf(","));
String token = JwtUtils.createToken(userVO.getUserName(),substring); String token = JwtUtils.createToken(userVO.getUserName(),substring);
userVO.setToken(token); // userVO.setToken(token);
result.setData(userVO); result.setData(userVO);
return result; return result;
} }
...@@ -91,7 +93,7 @@ public class UserServiceImpl implements UserService { ...@@ -91,7 +93,7 @@ public class UserServiceImpl implements UserService {
appUser.setLoginPwd(registerDto.getLoginPwd()); appUser.setLoginPwd(registerDto.getLoginPwd());
appUser.setCreateTime(new Date()); appUser.setCreateTime(new Date());
appUser.setUpdateTime(new Date()); appUser.setUpdateTime(new Date());
log.info("用户注册实体==============>"+appUser); log.info("用户注册参数==============>"+registerDto);
//将验证码放入到缓存当中(过期时间60s)test //将验证码放入到缓存当中(过期时间60s)test
// GuavaUtil.putTrackGuava(registerDto.getPhone(),registerDto.getCode()); // GuavaUtil.putTrackGuava(registerDto.getPhone(),registerDto.getCode());
//重缓存中获取(通过手机号获取) //重缓存中获取(通过手机号获取)
...@@ -110,4 +112,19 @@ public class UserServiceImpl implements UserService { ...@@ -110,4 +112,19 @@ public class UserServiceImpl implements UserService {
} }
return Result.success(null); return Result.success(null);
} }
/**
* 用户登陆接口
* @param loginDto
* @return
*/
@Override
public Result<UserVO> userLogin(LoginDto loginDto) {
AppUserExample userExample = new AppUserExample();
//首先判断登陆方式
if (loginDto.getType().equals("0")){
Result<UserVO> userVo = appUserMapper.selectByPassword(loginDto);
}
return null;
}
} }
package org.nafmii.vo; package org.nafmii.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -13,10 +16,53 @@ import java.util.List; ...@@ -13,10 +16,53 @@ import java.util.List;
* @remark: * @remark:
*/ */
@Data @Data
@ApiModel("用户返回报文")
public class UserVO { public class UserVO {
private Long id;
@ApiModelProperty(value = "昵称")
private String userName; private String userName;
private String password;
private String token;
private List<UserAndRoleVo> authorities;//角色集合
@ApiModelProperty(value = "登录密码")
private String loginPwd;
@ApiModelProperty(value = "中文姓名")
private String realName;
@ApiModelProperty(value = "手机号/登录账号")
private String phone;
@ApiModelProperty(value = "出生日期")
private String birthday;
@ApiModelProperty(value = "邮箱")
private String email;
@ApiModelProperty(value = "头像图片地址")
private String headPicture;
@ApiModelProperty(value = "国籍")
private String nationality;
@ApiModelProperty(value = "单位全称")
private String unitName;
@ApiModelProperty(value = "微信OPENT_ID")
private String openId;
@ApiModelProperty(value = "是否开启指纹登录 0 未开启 1 已开启")
private String figerprintFalg;
@ApiModelProperty(value = "是否开启人脸识别登录 0 未开启 1 已开启")
private String faceidFalg;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "更新时间")
private Date updateTime;
@ApiModelProperty(value = "是否有效标识 0 有效用户 1无效用户")
private String isEnable;
} }
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.nafmii.nafmiimbg.mapper.AppUserMapper"> <mapper namespace="org.nafmii.mapper.user.AppUserMapper">
<resultMap id="BaseResultMap" type="org.nafmii.nafmiimbg.model.AppUser"> <resultMap id="BaseResultMap" type="org.nafmii.entity.user.AppUser">
<id column="ID" jdbcType="BIGINT" property="id" /> <id column="ID" jdbcType="BIGINT" property="id" />
<result column="USER_NAME" jdbcType="VARCHAR" property="userName" /> <result column="USER_NAME" jdbcType="VARCHAR" property="userName" />
<result column="LOGIN_PWD" jdbcType="VARCHAR" property="loginPwd" /> <result column="LOGIN_PWD" jdbcType="VARCHAR" property="loginPwd" />
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
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="selectByExample" parameterType="org.nafmii.nafmiimbg.model.AppUserExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="org.nafmii.entity.user.AppUserExample" resultMap="BaseResultMap">
select select
<if test="distinct"> <if test="distinct">
distinct distinct
...@@ -105,13 +105,13 @@ ...@@ -105,13 +105,13 @@
delete from APP_USER delete from APP_USER
where ID = #{id,jdbcType=BIGINT} where ID = #{id,jdbcType=BIGINT}
</delete> </delete>
<delete id="deleteByExample" parameterType="org.nafmii.nafmiimbg.model.AppUserExample"> <delete id="deleteByExample" parameterType="org.nafmii.entity.user.AppUserExample">
delete from APP_USER delete from APP_USER
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Example_Where_Clause" /> <include refid="Example_Where_Clause" />
</if> </if>
</delete> </delete>
<insert id="insert" parameterType="org.nafmii.nafmiimbg.model.AppUser"> <insert id="insert" parameterType="org.nafmii.entity.user.AppUserExample">
insert into APP_USER (ID, USER_NAME, LOGIN_PWD, insert into APP_USER (ID, USER_NAME, LOGIN_PWD,
REAL_NAME, PHONE, BIRTHDAY, REAL_NAME, PHONE, BIRTHDAY,
EMAIL, HEAD_PICTURE, NATIONALITY, EMAIL, HEAD_PICTURE, NATIONALITY,
...@@ -125,7 +125,7 @@ ...@@ -125,7 +125,7 @@
#{faceidFalg,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{faceidFalg,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
#{isEnable,jdbcType=VARCHAR}) #{isEnable,jdbcType=VARCHAR})
</insert> </insert>
<insert id="insertSelective" parameterType="org.nafmii.nafmiimbg.model.AppUser"> <insert id="insertSelective" parameterType="org.nafmii.entity.user.AppUserExample">
insert into APP_USER insert into APP_USER
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null"> <if test="id != null">
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
</if> </if>
</trim> </trim>
</insert> </insert>
<select id="countByExample" parameterType="org.nafmii.nafmiimbg.model.AppUserExample" resultType="java.lang.Long"> <select id="countByExample" parameterType="org.nafmii.entity.user.AppUserExample" resultType="java.lang.Long">
select count(*) from APP_USER select count(*) from APP_USER
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Example_Where_Clause" /> <include refid="Example_Where_Clause" />
...@@ -312,7 +312,7 @@ ...@@ -312,7 +312,7 @@
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
</update> </update>
<update id="updateByPrimaryKeySelective" parameterType="org.nafmii.nafmiimbg.model.AppUser"> <update id="updateByPrimaryKeySelective" parameterType="org.nafmii.entity.user.AppUserExample">
update APP_USER update APP_USER
<set> <set>
<if test="userName != null"> <if test="userName != null">
...@@ -363,7 +363,7 @@ ...@@ -363,7 +363,7 @@
</set> </set>
where ID = #{id,jdbcType=BIGINT} where ID = #{id,jdbcType=BIGINT}
</update> </update>
<update id="updateByPrimaryKey" parameterType="org.nafmii.nafmiimbg.model.AppUser"> <update id="updateByPrimaryKey" parameterType="org.nafmii.entity.user.AppUserExample">
update APP_USER update APP_USER
set USER_NAME = #{userName,jdbcType=VARCHAR}, set USER_NAME = #{userName,jdbcType=VARCHAR},
LOGIN_PWD = #{loginPwd,jdbcType=VARCHAR}, LOGIN_PWD = #{loginPwd,jdbcType=VARCHAR},
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!