Commit 95536819 by zhoujinghao

app用户注册相关代码提交

1 parent fa74cfed
......@@ -2,9 +2,11 @@ package org.nafmii.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.nafmii.dto.user.LoginDto;
import org.nafmii.dto.user.RegisterDto;
import org.nafmii.response.Result;
import org.nafmii.service.UserService;
import org.nafmii.vo.AppUser;
import org.nafmii.vo.UserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
......@@ -41,5 +43,13 @@ public class UserController {
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;
public class AppUser implements Serializable {
private Long id;
@ApiModelProperty(value = "昵称")
private String userName;
......
......@@ -25,6 +25,9 @@ public enum UserEnum {
*/
ENABLE("0","有效用户"),
NOTENABLE("1","无效用户"),
LOGINPHONE("1","验证码"),
LOGINPWD("0","密码"),
;
UserEnum(String code, String name){
......
package org.nafmii.mapper.user;
import org.apache.ibatis.annotations.Param;
import org.nafmii.dto.user.LoginDto;
import org.nafmii.entity.user.AppUser;
import org.nafmii.entity.user.AppUserExample;
import org.nafmii.response.Result;
import org.nafmii.vo.UserVO;
import java.util.List;
......@@ -19,6 +22,8 @@ public interface AppUserMapper {
List<AppUser> selectByExample(AppUserExample example);
Result<UserVO> selectByPassword(LoginDto loginDto);
AppUser selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") AppUser record, @Param("example") AppUserExample example);
......
package org.nafmii.service;
import org.nafmii.dto.user.LoginDto;
import org.nafmii.dto.user.RegisterDto;
import org.nafmii.response.Result;
import org.nafmii.vo.AppUser;
import org.nafmii.vo.UserVO;
/**
......@@ -17,4 +19,6 @@ public interface UserService {
Result<UserVO> login();
//app注册接口
Result register(RegisterDto registerDto);
//用户登陆接口
Result<UserVO> userLogin(LoginDto loginDto);
}
......@@ -3,8 +3,10 @@ package org.nafmii.service.impl;
import lombok.extern.slf4j.Slf4j;
import org.nafmii.dto.user.LoginDto;
import org.nafmii.dto.user.RegisterDto;
import org.nafmii.entity.user.AppUser;
import org.nafmii.entity.user.AppUserExample;
import org.nafmii.enums.UserEnum;
import org.nafmii.exception.BusinessException;
import org.nafmii.mapper.user.AppUserMapper;
......@@ -45,7 +47,7 @@ public class UserServiceImpl implements UserService {
Result result = new Result();
//假设验证数据通过
UserVO userVO = new UserVO();
userVO.setPassword("zzz");
userVO.setLoginPwd("zzz");
userVO.setUserName("zzz");
List<UserAndRoleVo> roleList =new ArrayList<>();
UserAndRoleVo roleVo = new UserAndRoleVo();
......@@ -54,7 +56,7 @@ public class UserServiceImpl implements UserService {
roleList.add(roleVo);
roleTwoVo.setRole("b");
roleList.add(roleTwoVo);
userVO.setAuthorities(roleList);
// userVO.setAuthorities(roleList);
StringBuilder sbf = new StringBuilder();
for (UserAndRoleVo role:roleList
) {
......@@ -64,7 +66,7 @@ public class UserServiceImpl implements UserService {
String sRole = sbf.toString();
String substring = sRole.substring(0, sRole.lastIndexOf(","));
String token = JwtUtils.createToken(userVO.getUserName(),substring);
userVO.setToken(token);
// userVO.setToken(token);
result.setData(userVO);
return result;
}
......@@ -91,7 +93,7 @@ public class UserServiceImpl implements UserService {
appUser.setLoginPwd(registerDto.getLoginPwd());
appUser.setCreateTime(new Date());
appUser.setUpdateTime(new Date());
log.info("用户注册实体==============>"+appUser);
log.info("用户注册参数==============>"+registerDto);
//将验证码放入到缓存当中(过期时间60s)test
// GuavaUtil.putTrackGuava(registerDto.getPhone(),registerDto.getCode());
//重缓存中获取(通过手机号获取)
......@@ -110,4 +112,19 @@ public class UserServiceImpl implements UserService {
}
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;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
......@@ -13,10 +16,53 @@ import java.util.List;
* @remark:
*/
@Data
@ApiModel("用户返回报文")
public class UserVO {
private Long id;
@ApiModelProperty(value = "昵称")
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"?>
<!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">
<resultMap id="BaseResultMap" type="org.nafmii.nafmiimbg.model.AppUser">
<mapper namespace="org.nafmii.mapper.user.AppUserMapper">
<resultMap id="BaseResultMap" type="org.nafmii.entity.user.AppUser">
<id column="ID" jdbcType="BIGINT" property="id" />
<result column="USER_NAME" jdbcType="VARCHAR" property="userName" />
<result column="LOGIN_PWD" jdbcType="VARCHAR" property="loginPwd" />
......@@ -81,7 +81,7 @@
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
</sql>
<select id="selectByExample" parameterType="org.nafmii.nafmiimbg.model.AppUserExample" resultMap="BaseResultMap">
<select id="selectByExample" parameterType="org.nafmii.entity.user.AppUserExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
......@@ -105,13 +105,13 @@
delete from APP_USER
where ID = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByExample" parameterType="org.nafmii.nafmiimbg.model.AppUserExample">
<delete id="deleteByExample" parameterType="org.nafmii.entity.user.AppUserExample">
delete from APP_USER
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</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,
REAL_NAME, PHONE, BIRTHDAY,
EMAIL, HEAD_PICTURE, NATIONALITY,
......@@ -125,7 +125,7 @@
#{faceidFalg,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
#{isEnable,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="org.nafmii.nafmiimbg.model.AppUser">
<insert id="insertSelective" parameterType="org.nafmii.entity.user.AppUserExample">
insert into APP_USER
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
......@@ -228,7 +228,7 @@
</if>
</trim>
</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
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
......@@ -312,7 +312,7 @@
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="org.nafmii.nafmiimbg.model.AppUser">
<update id="updateByPrimaryKeySelective" parameterType="org.nafmii.entity.user.AppUserExample">
update APP_USER
<set>
<if test="userName != null">
......@@ -363,7 +363,7 @@
</set>
where ID = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="org.nafmii.nafmiimbg.model.AppUser">
<update id="updateByPrimaryKey" parameterType="org.nafmii.entity.user.AppUserExample">
update APP_USER
set USER_NAME = #{userName,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!