26 changed files with 999 additions and 348 deletions
@ -0,0 +1,51 @@ |
|||
package com.epmet.controller; |
|||
|
|||
import com.epmet.common.token.annotation.Login; |
|||
import com.epmet.common.token.dto.form.LoginByPassWordFormDTO; |
|||
import com.epmet.common.token.dto.form.LoginByWxCodeFormDTO; |
|||
import com.epmet.common.token.dto.result.UserTokenResultDTO; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.commons.tools.validator.ValidatorUtils; |
|||
import com.epmet.service.LoginService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
/** |
|||
* @Description 通用登陆接口 |
|||
* @Author yinzuomei |
|||
* @Date 2020/3/14 13:58 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("login") |
|||
public class LoginController { |
|||
@Autowired |
|||
private LoginService loginService; |
|||
|
|||
/** |
|||
* @param formDTO |
|||
* @return com.epmet.commons.tools.utils.Result<java.lang.String> |
|||
* @Author yinzuomei |
|||
* @Description 微信小程序登录 |
|||
* @Date 2020/3/14 14:35 |
|||
**/ |
|||
@PostMapping("loginbywxcode") |
|||
public Result<UserTokenResultDTO> loginByWxCode(@RequestBody LoginByWxCodeFormDTO formDTO) { |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(formDTO); |
|||
return loginService.loginByWxCode(formDTO); |
|||
} |
|||
|
|||
/** |
|||
* @param formDTO |
|||
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.UserTokenResultDTO> |
|||
* @Author yinzuomei |
|||
* @Description 手机号+密码登录接口 |
|||
* @Date 2020/3/14 19:46 |
|||
**/ |
|||
@PostMapping("loginbypassword") |
|||
public Result<UserTokenResultDTO> loginByPassword(@RequestBody LoginByPassWordFormDTO formDTO) { |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(formDTO); |
|||
return loginService.loginByPassword(formDTO); |
|||
} |
|||
} |
@ -0,0 +1,41 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.dao; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.entity.CustomerUserEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
/** |
|||
* 客户用户信息表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2020-03-14 |
|||
*/ |
|||
@Mapper |
|||
public interface CustomerUserDao extends BaseDao<CustomerUserEntity> { |
|||
|
|||
/** |
|||
* @param openId |
|||
* @return userId |
|||
* @Author yinzuomei |
|||
* @Description 根据openId查询居民用户信息 |
|||
* @Date 2020/3/14 20:45 |
|||
**/ |
|||
String selectByWxOpenId(String openId); |
|||
} |
@ -0,0 +1,91 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
|
|||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 客户用户信息表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2020-03-14 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("customer_user") |
|||
public class CustomerUserEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 客户Id CUSTOMER.id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 微信openId |
|||
*/ |
|||
private String wxOpenId; |
|||
|
|||
/** |
|||
* 手机号 |
|||
*/ |
|||
private String mobile; |
|||
|
|||
/** |
|||
* 昵称 |
|||
*/ |
|||
private String nickname; |
|||
|
|||
/** |
|||
* 性别:0.男 1.女 字典表(key:sex) |
|||
*/ |
|||
private Integer sex; |
|||
|
|||
/** |
|||
* 头像 |
|||
*/ |
|||
private String headImgUrl; |
|||
|
|||
/** |
|||
* 国家 |
|||
*/ |
|||
private String country; |
|||
|
|||
/** |
|||
* 省份 |
|||
*/ |
|||
private String province; |
|||
|
|||
/** |
|||
* 城市 |
|||
*/ |
|||
private String city; |
|||
|
|||
/** |
|||
* 语言 |
|||
*/ |
|||
private String language; |
|||
|
|||
} |
@ -0,0 +1,41 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.epmet.jwt; |
|||
|
|||
import org.springframework.boot.context.properties.ConfigurationProperties; |
|||
import org.springframework.context.annotation.Configuration; |
|||
|
|||
/** |
|||
* Jwt |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 |
|||
*/ |
|||
@Configuration |
|||
@ConfigurationProperties(prefix = "jwt.token") |
|||
public class JwtTokenProperties { |
|||
private String secret; |
|||
private int expire; |
|||
|
|||
public String getSecret() { |
|||
return secret; |
|||
} |
|||
|
|||
public void setSecret(String secret) { |
|||
this.secret = secret; |
|||
} |
|||
|
|||
public int getExpire() { |
|||
return expire; |
|||
} |
|||
|
|||
public void setExpire(int expire) { |
|||
this.expire = expire; |
|||
} |
|||
} |
@ -0,0 +1,105 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* <p> |
|||
* https://www.renren.io
|
|||
* <p> |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.epmet.jwt; |
|||
|
|||
import io.jsonwebtoken.Claims; |
|||
import io.jsonwebtoken.Jwts; |
|||
import io.jsonwebtoken.SignatureAlgorithm; |
|||
import org.apache.commons.codec.binary.Base64; |
|||
import org.joda.time.DateTime; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.Calendar; |
|||
import java.util.Date; |
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* Jwt工具类 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 |
|||
*/ |
|||
@Component |
|||
public class JwtTokenUtils { |
|||
private static final Logger logger = LoggerFactory.getLogger(JwtTokenUtils.class); |
|||
|
|||
@Autowired |
|||
private JwtTokenProperties jwtProperties; |
|||
|
|||
/** |
|||
* 生成jwt token 弃用 |
|||
*/ |
|||
@Deprecated |
|||
public String generateToken(String userId) { |
|||
return Jwts.builder() |
|||
.setHeaderParam("typ", "JWT") |
|||
.setSubject(userId) |
|||
.setIssuedAt(new Date()) |
|||
.setExpiration(DateTime.now().plusSeconds(jwtProperties.getExpire()).toDate()) |
|||
.signWith(SignatureAlgorithm.HS512, jwtProperties.getSecret()) |
|||
.compact(); |
|||
} |
|||
|
|||
public Claims getClaimByToken(String token) { |
|||
try { |
|||
return Jwts.parser() |
|||
.setSigningKey(jwtProperties.getSecret()) |
|||
.parseClaimsJws(token) |
|||
.getBody(); |
|||
} catch (Exception e) { |
|||
logger.debug("validate is token error, token = " + token, e); |
|||
return null; |
|||
} |
|||
} |
|||
public String createToken(Map<String, Object> map) { |
|||
return Jwts.builder() |
|||
.setHeaderParam("typ", "JWT") |
|||
.setClaims(map) |
|||
.setIssuedAt(new Date()) |
|||
.setExpiration(DateTime.now().plusSeconds(jwtProperties.getExpire()).toDate()) |
|||
.signWith(SignatureAlgorithm.HS512, jwtProperties.getSecret()) |
|||
.compact(); |
|||
} |
|||
|
|||
/** |
|||
* token是否过期 |
|||
* |
|||
* @return true:过期 |
|||
*/ |
|||
public boolean isTokenExpired(Date expiration) { |
|||
return expiration.before(new Date()); |
|||
} |
|||
|
|||
public static void main(String[] args) { |
|||
Map<String, Object> map=new HashMap<>(); |
|||
map.put("app","gov"); |
|||
map.put("client","wxmp"); |
|||
map.put("userId","100526ABC"); |
|||
String tokenStr=Jwts.builder() |
|||
.setHeaderParam("typ", "JWT") |
|||
.setClaims(map) |
|||
.setIssuedAt(new Date()) |
|||
.setExpiration(DateTime.now().plusSeconds(604800).toDate()) |
|||
.signWith(SignatureAlgorithm.HS512, "7016867071f0ebf1c46f123eaaf4b9d6[elink.epmet]") |
|||
.compact(); |
|||
System.out.println(tokenStr); |
|||
Claims claims= Jwts.parser() |
|||
.setSigningKey("7016867071f0ebf1c46f123eaaf4b9d6[elink.epmet]") |
|||
.parseClaimsJws(tokenStr) |
|||
.getBody(); |
|||
System.out.println("app="+ claims.get("app")); |
|||
System.out.println("client="+ claims.get("client")); |
|||
System.out.println("userId="+ claims.get("userId")); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,31 @@ |
|||
package com.epmet.service; |
|||
|
|||
import com.epmet.common.token.dto.form.LoginByPassWordFormDTO; |
|||
import com.epmet.common.token.dto.form.LoginByWxCodeFormDTO; |
|||
import com.epmet.common.token.dto.result.UserTokenResultDTO; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
|
|||
/** |
|||
* @Description |
|||
* @Author yinzuomei |
|||
* @Date 2020/3/14 20:21 |
|||
*/ |
|||
public interface LoginService { |
|||
/** |
|||
* @param formDTO |
|||
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.UserTokenResultDTO> |
|||
* @Author yinzuomei |
|||
* @Description 微信小程序登录 |
|||
* @Date 2020/3/14 19:34 |
|||
**/ |
|||
Result<UserTokenResultDTO> loginByWxCode(LoginByWxCodeFormDTO formDTO); |
|||
|
|||
/** |
|||
* @param formDTO |
|||
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.UserTokenResultDTO> |
|||
* @Author yinzuomei |
|||
* @Description 手机号+密码登录接口 |
|||
* @Date 2020/3/14 19:54 |
|||
**/ |
|||
Result<UserTokenResultDTO> loginByPassword(LoginByPassWordFormDTO formDTO); |
|||
} |
@ -0,0 +1,193 @@ |
|||
package com.epmet.service.impl; |
|||
|
|||
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; |
|||
import cn.binarywang.wx.miniapp.bean.WxMaUserInfo; |
|||
import com.epmet.common.token.constant.LoginConstant; |
|||
import com.epmet.common.token.dto.TokenDto; |
|||
import com.epmet.common.token.dto.form.LoginByPassWordFormDTO; |
|||
import com.epmet.common.token.dto.form.LoginByWxCodeFormDTO; |
|||
import com.epmet.common.token.dto.result.UserTokenResultDTO; |
|||
import com.epmet.common.token.util.CpUserDetailRedis; |
|||
import com.epmet.commons.tools.exception.RenException; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.dao.CustomerUserDao; |
|||
import com.epmet.entity.CustomerUserEntity; |
|||
import com.epmet.jwt.JwtTokenProperties; |
|||
import com.epmet.jwt.JwtTokenUtils; |
|||
import com.epmet.service.LoginService; |
|||
import com.epmet.utils.WxMaServiceUtils; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import me.chanjar.weixin.common.error.WxErrorException; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @Description |
|||
* @Author yinzuomei |
|||
* @Date 2020/3/14 20:31 |
|||
*/ |
|||
@Slf4j |
|||
@Service |
|||
public class LoginServiceImpl implements LoginService { |
|||
private static final Logger logger = LoggerFactory.getLogger(AuthServiceImpl.class); |
|||
|
|||
@Autowired |
|||
private CustomerUserDao customerUserDao; |
|||
|
|||
@Autowired |
|||
private WxMaServiceUtils wxMaServiceUtils; |
|||
|
|||
@Autowired |
|||
private JwtTokenUtils jwtTokenUtils; |
|||
|
|||
@Autowired |
|||
private JwtTokenProperties jwtTokenProperties; |
|||
|
|||
@Autowired |
|||
private CpUserDetailRedis cpUserDetailRedis; |
|||
|
|||
/** |
|||
* 微信小程序登录 |
|||
* |
|||
* @param formDTO |
|||
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.UserTokenResultDTO> |
|||
* @author yinzuomei |
|||
* @since 2020/3/14 19:34 |
|||
*/ |
|||
@Override |
|||
public Result<UserTokenResultDTO> loginByWxCode(LoginByWxCodeFormDTO formDTO) { |
|||
//1、根据wxCode获取微信信息
|
|||
WxMaJscode2SessionResult wxMaJscode2SessionResult = this.getWxMaUser(formDTO); |
|||
logger.info("openId=[" + wxMaJscode2SessionResult.getOpenid() + "]unionId=[" + wxMaJscode2SessionResult.getUnionid() + "]"); |
|||
//2、根据openId查询数据库,没有则直接插入一条记录
|
|||
String userId = this.getUserId(formDTO, wxMaJscode2SessionResult); |
|||
if (StringUtils.isNotBlank(userId)) { |
|||
//3、封装token且存到redis
|
|||
UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO(); |
|||
userTokenResultDTO.setToken(this.packagingUserToken(formDTO, userId, wxMaJscode2SessionResult)); |
|||
return new Result<UserTokenResultDTO>().ok(userTokenResultDTO); |
|||
} |
|||
return new Result<UserTokenResultDTO>().error("登录失败"); |
|||
} |
|||
|
|||
/** |
|||
* 解析微信code获取小程序用户信息 |
|||
* |
|||
* @param formDTO |
|||
* @return cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult |
|||
* @author yinzuomei |
|||
* @date 2020/3/14 20:16 |
|||
*/ |
|||
private WxMaJscode2SessionResult getWxMaUser(LoginByWxCodeFormDTO formDTO) { |
|||
WxMaJscode2SessionResult wxMaJscode2SessionResult = null; |
|||
try { |
|||
if (LoginConstant.APP_GOV.equals(formDTO.getApp())) { |
|||
wxMaJscode2SessionResult = wxMaServiceUtils.govWxMaService().jsCode2SessionInfo(formDTO.getWxCode()); |
|||
} else if (LoginConstant.APP_OPER.equals(formDTO.getApp())) { |
|||
wxMaJscode2SessionResult = wxMaServiceUtils.operWxMaService().jsCode2SessionInfo(formDTO.getWxCode()); |
|||
} else if (LoginConstant.APP_RESI.equals(formDTO.getApp())) { |
|||
wxMaJscode2SessionResult = wxMaServiceUtils.resiWxMaService().jsCode2SessionInfo(formDTO.getWxCode()); |
|||
} |
|||
} catch (WxErrorException e) { |
|||
log.error("->[getMaOpenId]::error[{}]", "解析微信code失败"); |
|||
} |
|||
if (null == wxMaJscode2SessionResult) { |
|||
throw new RenException("解析微信用户信息失败"); |
|||
} else if (StringUtils.isBlank(wxMaJscode2SessionResult.getOpenid())) { |
|||
throw new RenException("获取微信openid失败"); |
|||
} |
|||
return wxMaJscode2SessionResult; |
|||
} |
|||
|
|||
/** |
|||
* 根据openId查询用户id |
|||
* |
|||
* @param formDTO |
|||
* @param wxMaJscode2SessionResult |
|||
* @return java.lang.String |
|||
* @author yinzuomei |
|||
* @since 2020/3/14 19:34 |
|||
*/ |
|||
private String getUserId(LoginByWxCodeFormDTO formDTO, WxMaJscode2SessionResult wxMaJscode2SessionResult) { |
|||
String userId = ""; |
|||
if (LoginConstant.APP_GOV.equals(formDTO.getApp())) { |
|||
//查询customer_staff待完善
|
|||
} else if (LoginConstant.APP_OPER.equals(formDTO.getApp())) { |
|||
//查询oper_staff待完善
|
|||
} else if (LoginConstant.APP_RESI.equals(formDTO.getApp())) { |
|||
//查询customer_user
|
|||
userId = customerUserDao.selectByWxOpenId(wxMaJscode2SessionResult.getOpenid()); |
|||
if (StringUtils.isBlank(userId)) { |
|||
WxMaUserInfo wxMaUserInfo = wxMaServiceUtils.resiWxMaService().getUserService() |
|||
.getUserInfo(wxMaJscode2SessionResult.getSessionKey(), |
|||
formDTO.getEncryptedData(), |
|||
formDTO.getIv()); |
|||
CustomerUserEntity customerUserEntity = new CustomerUserEntity(); |
|||
customerUserEntity.setCity(wxMaUserInfo.getCity()); |
|||
customerUserEntity.setWxOpenId(wxMaUserInfo.getOpenId()); |
|||
customerUserEntity.setNickname(wxMaUserInfo.getNickName()); |
|||
customerUserEntity.setCountry(wxMaUserInfo.getCountry()); |
|||
customerUserEntity.setHeadImgUrl(wxMaUserInfo.getAvatarUrl()); |
|||
customerUserEntity.setCountry(wxMaUserInfo.getCountry()); |
|||
customerUserEntity.setProvince(wxMaUserInfo.getProvince()); |
|||
customerUserEntity.setSex(Integer.valueOf(wxMaUserInfo.getGender())); |
|||
customerUserDao.insert(customerUserEntity); |
|||
userId = customerUserEntity.getId(); |
|||
} |
|||
} |
|||
return userId; |
|||
} |
|||
|
|||
/** |
|||
* 封装用户token值 |
|||
* |
|||
* @param formDTO |
|||
* @param userId |
|||
* @param wxMaJscode2SessionResult |
|||
* @return java.lang.String |
|||
* @author yinzuomei |
|||
* @since 2020/3/14 19:34 |
|||
*/ |
|||
private String packagingUserToken(LoginByWxCodeFormDTO formDTO, |
|||
String userId, |
|||
WxMaJscode2SessionResult wxMaJscode2SessionResult) { |
|||
// 生成token
|
|||
Map<String, Object> map = new HashMap<>(); |
|||
map.put("app", formDTO.getApp()); |
|||
map.put("client", formDTO.getClient()); |
|||
map.put("userId", userId); |
|||
String token = jwtTokenUtils.createToken(map); |
|||
int expire = jwtTokenProperties.getExpire(); |
|||
TokenDto tokenDto = new TokenDto(); |
|||
tokenDto.setApp(formDTO.getApp()); |
|||
tokenDto.setClient(formDTO.getClient()); |
|||
tokenDto.setUserId(userId); |
|||
tokenDto.setOpenId(wxMaJscode2SessionResult.getOpenid()); |
|||
tokenDto.setSessionKey(wxMaJscode2SessionResult.getSessionKey()); |
|||
tokenDto.setUnionId(wxMaJscode2SessionResult.getUnionid()); |
|||
cpUserDetailRedis.set(tokenDto, expire); |
|||
return token; |
|||
} |
|||
|
|||
/** |
|||
* 手机号+密码登录接口 |
|||
* |
|||
* @param formDTO |
|||
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.UserTokenResultDTO> |
|||
* @author yinzuomei |
|||
* @since 2020/3/14 19:34 |
|||
*/ |
|||
@Override |
|||
public Result<UserTokenResultDTO> loginByPassword(LoginByPassWordFormDTO formDTO) { |
|||
//1、账号是否存在
|
|||
//2、密码是否正确
|
|||
//3、生成token返回,且将TokenDto存到redis
|
|||
return null; |
|||
} |
|||
} |
@ -0,0 +1,15 @@ |
|||
<?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="com.epmet.dao.CustomerUserDao"> |
|||
<!-- 根据openId查询居民用户信息 --> |
|||
<select id="selectByWxOpenId" parameterType="java.lang.String" resultType="java.lang.String"> |
|||
SELECT |
|||
cu.id |
|||
FROM |
|||
customer_user cu |
|||
WHERE |
|||
cu.DEL_FLAG = '0' |
|||
AND cu.WX_OPEN_ID = #{openId} |
|||
</select> |
|||
</mapper> |
@ -0,0 +1,33 @@ |
|||
package com.epmet.common.token.constant; |
|||
|
|||
/** |
|||
* @Description app、client |
|||
* @Author yinzuomei |
|||
* @Date 2020/3/14 20:12 |
|||
*/ |
|||
public interface LoginConstant { |
|||
/** |
|||
* 政府端 |
|||
*/ |
|||
String APP_GOV = "gov"; |
|||
|
|||
/** |
|||
* 居民端 |
|||
*/ |
|||
String APP_RESI = "resi"; |
|||
|
|||
/** |
|||
* 运营端 |
|||
*/ |
|||
String APP_OPER = "oper"; |
|||
|
|||
/** |
|||
* web |
|||
*/ |
|||
String CLIENT_WEB = "web"; |
|||
|
|||
/** |
|||
* 微信小程序 |
|||
*/ |
|||
String CLIENT_WXMP = "wxmp"; |
|||
} |
@ -1,32 +0,0 @@ |
|||
package com.epmet.common.token.dto; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* |
|||
* 用户所有角色权限信息 |
|||
* |
|||
* @Author:liuchuang |
|||
* @Date:2019/11/19 23:48 |
|||
*/ |
|||
@Data |
|||
public class DeptDataScopeDTO implements Serializable { |
|||
private static final long serialVersionUID = -6319876948812713836L; |
|||
|
|||
/** |
|||
* 部门ID |
|||
*/ |
|||
private Long deptId; |
|||
|
|||
/** |
|||
* 部门名称 |
|||
*/ |
|||
private String deptName; |
|||
|
|||
/** |
|||
* 部门类型 |
|||
*/ |
|||
private String typeKey; |
|||
} |
@ -1,52 +1,49 @@ |
|||
package com.elink.esua.epdc.common.token.dto; |
|||
package com.epmet.common.token.dto; |
|||
|
|||
import com.google.gson.annotations.SerializedName; |
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 用户token |
|||
* |
|||
* @author rongchao |
|||
* @Date 18-10-31 |
|||
* @author yinzuomei |
|||
* @Date 2020-03-14 |
|||
*/ |
|||
@Data |
|||
public class TokenDto implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 用户ID |
|||
*/ |
|||
private String userId; |
|||
|
|||
/** |
|||
* 昵称 |
|||
*/ |
|||
private String nickname; |
|||
|
|||
/** |
|||
* 用户头像 |
|||
*/ |
|||
private String faceImg; |
|||
|
|||
/** |
|||
* 手机号 |
|||
*/ |
|||
private String mobile; |
|||
|
|||
/** |
|||
* 真实姓名 |
|||
*/ |
|||
private String realName; |
|||
|
|||
/** |
|||
* 网格ID |
|||
*/ |
|||
private Long gridId; |
|||
|
|||
/** |
|||
* 党员标识 0:否、1:是 |
|||
*/ |
|||
private String partyFlag; |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 政府端:gov、居民端:resi、运营端:oper |
|||
*/ |
|||
private String app; |
|||
|
|||
/** |
|||
* PC端:web、微信小程序:wxmp |
|||
*/ |
|||
private String client; |
|||
|
|||
/** |
|||
* 用户ID |
|||
*/ |
|||
private String userId; |
|||
|
|||
/** |
|||
* sessionKey |
|||
*/ |
|||
private String sessionKey; |
|||
|
|||
/** |
|||
* openId |
|||
*/ |
|||
private String openId; |
|||
|
|||
/** |
|||
* unionId |
|||
*/ |
|||
private String unionId; |
|||
} |
|||
|
@ -1,48 +0,0 @@ |
|||
package com.epmet.common.token.dto; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* |
|||
* 工作端用户授权信息 |
|||
* |
|||
* @Author:liuchuang |
|||
* @Date:2019/11/19 20:17 |
|||
*/ |
|||
@Data |
|||
public class WorkUserAuthorizationDTO implements Serializable { |
|||
private static final long serialVersionUID = -4230190448906007120L; |
|||
|
|||
/** |
|||
* 令牌 |
|||
*/ |
|||
private String token; |
|||
|
|||
/** |
|||
* 过期时长,单位秒 |
|||
*/ |
|||
private Integer expire; |
|||
|
|||
/** |
|||
* 部门名称 |
|||
*/ |
|||
private String deptName; |
|||
|
|||
/** |
|||
* 用户标签key |
|||
*/ |
|||
private String userTagKey; |
|||
|
|||
/** |
|||
* 注册状态 0-未注册,1-已注册 |
|||
*/ |
|||
private String registerState; |
|||
|
|||
/** |
|||
* 用户所有角色权限信息 |
|||
*/ |
|||
private List<DeptDataScopeDTO> deptDataScopeList; |
|||
} |
@ -1,29 +0,0 @@ |
|||
package com.epmet.common.token.dto; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* |
|||
* 工作端用户登录信息 |
|||
* |
|||
* @Author:liuchuang |
|||
* @Date:2019/11/19 20:19 |
|||
*/ |
|||
@Data |
|||
public class WorkUserLoginDTO implements Serializable { |
|||
private static final long serialVersionUID = 1905641243346550379L; |
|||
|
|||
@NotBlank(message="用户名不能为空") |
|||
private String username; |
|||
|
|||
@NotBlank(message="密码不能为空") |
|||
private String password; |
|||
|
|||
@NotBlank(message="微信code不能为空") |
|||
private String wxCode; |
|||
|
|||
private String openId; |
|||
} |
@ -1,25 +0,0 @@ |
|||
package com.epmet.common.token.dto; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import javax.validation.constraints.NotNull; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* |
|||
* 工作端获取token Form DTO |
|||
* |
|||
* @Author:liuchuang |
|||
* @Date:2019/11/19 20:35 |
|||
*/ |
|||
@Data |
|||
public class WorkUserTokenFormDTO implements Serializable { |
|||
private static final long serialVersionUID = -2239027109939769097L; |
|||
|
|||
@NotNull(message = "用户ID不能为空") |
|||
private Long id; |
|||
|
|||
@NotBlank(message = "用户名不能为空") |
|||
private String username; |
|||
} |
@ -0,0 +1,29 @@ |
|||
package com.epmet.common.token.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Description 手机号+密码登录接口入参 |
|||
* @Author yinzuomei |
|||
* @Date 2020/3/14 19:46 |
|||
*/ |
|||
@Data |
|||
public class LoginByPassWordFormDTO extends LoginCommonFormDTO implements Serializable { |
|||
private static final long serialVersionUID = -7507437651048051183L; |
|||
|
|||
/** |
|||
* 手机号 |
|||
*/ |
|||
@NotBlank(message = "手机号不能为空") |
|||
private String phone; |
|||
|
|||
/** |
|||
* 密码 |
|||
*/ |
|||
@NotBlank(message = "密码不能为空") |
|||
private String password; |
|||
|
|||
} |
@ -0,0 +1,34 @@ |
|||
package com.epmet.common.token.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Description 微信小程序登录接口入参 |
|||
* @Author yinzuomei |
|||
* @Date 2020/3/14 14:39 |
|||
*/ |
|||
@Data |
|||
public class LoginByWxCodeFormDTO extends LoginCommonFormDTO implements Serializable { |
|||
private static final long serialVersionUID = 7950477424010655108L; |
|||
|
|||
/** |
|||
* 微信code |
|||
*/ |
|||
@NotBlank(message = "wxCode不能为空") |
|||
private String wxCode; |
|||
|
|||
/** |
|||
* 用户信息 |
|||
*/ |
|||
@NotBlank(message = "用户信息不能为空") |
|||
private String encryptedData; |
|||
|
|||
/** |
|||
* 加密算法的初始向量 |
|||
*/ |
|||
@NotBlank(message = "初始向量不能为空") |
|||
private String iv; |
|||
} |
@ -0,0 +1,28 @@ |
|||
package com.epmet.common.token.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Description 登录接口通用入参 |
|||
* @Author yinzuomei |
|||
* @Date 2020/3/14 19:47 |
|||
*/ |
|||
@Data |
|||
public class LoginCommonFormDTO implements Serializable { |
|||
private static final long serialVersionUID = -5582224784914714820L; |
|||
|
|||
/** |
|||
* 政府端:gov、居民端:resi、运营端:oper |
|||
*/ |
|||
@NotBlank(message = "app不能为空(政府端:gov、居民端:resi、运营端:oper)") |
|||
private String app; |
|||
|
|||
/** |
|||
* PC端:web、微信小程序:wxmp |
|||
*/ |
|||
@NotBlank(message = "client不能为空(PC端:web、微信小程序:wxmp)") |
|||
private String client; |
|||
} |
@ -0,0 +1,20 @@ |
|||
package com.epmet.common.token.dto.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Description 登录接口返参DTO |
|||
* @Author yinzuomei |
|||
* @Date 2020/3/14 15:10 |
|||
*/ |
|||
@Data |
|||
public class UserTokenResultDTO implements Serializable { |
|||
private static final long serialVersionUID = 5214475907074876716L; |
|||
|
|||
/** |
|||
* 令牌 |
|||
*/ |
|||
private String token; |
|||
} |
Loading…
Reference in new issue