31 changed files with 782 additions and 71 deletions
@ -0,0 +1,38 @@ |
|||
package com.epmet.util; |
|||
|
|||
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|||
import com.epmet.commons.tools.exception.RenException; |
|||
import com.epmet.commons.tools.security.dto.BaseTokenDto; |
|||
import com.epmet.commons.tools.utils.CpUserDetailRedis; |
|||
import com.epmet.jwt.JwtTokenUtils; |
|||
import io.jsonwebtoken.Claims; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* @Description |
|||
* @ClassName UserTokenValidateUtil |
|||
* @Auth wangc |
|||
* @Date 2020-05-21 17:47 |
|||
*/ |
|||
@Component |
|||
public class UserTokenValidateUtil { |
|||
public BaseTokenDto getBaseTokenDto(String token, JwtTokenUtils jwtTokenUtils) { |
|||
//是否过期
|
|||
Claims claims = jwtTokenUtils.getClaimByToken(token); |
|||
if (claims == null || jwtTokenUtils.isTokenExpired(claims.getExpiration())) { |
|||
throw new RenException(EpmetErrorCode.ERR401.getCode()); |
|||
} |
|||
//获取用户ID
|
|||
String app = (String) claims.get("app"); |
|||
String client = (String) claims.get("client"); |
|||
String userId = (String) claims.get("userId"); |
|||
return new BaseTokenDto(app, client, userId, token); |
|||
} |
|||
|
|||
public <T> T getLoginUserInfoByToken(String token, JwtTokenUtils jwtTokenUtils, CpUserDetailRedis cpUserDetailRedis, Class<T> clz) { |
|||
BaseTokenDto baseTokenDto = getBaseTokenDto(token, jwtTokenUtils); |
|||
//查询Redis
|
|||
return cpUserDetailRedis.get(baseTokenDto.getApp(), baseTokenDto.getClient(), baseTokenDto.getUserId(), clz); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,25 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Description |
|||
* @ClassName CommonGridIdFormDTO |
|||
* @Author wangc |
|||
* @date 2020.04.24 14:17 |
|||
*/ |
|||
@Data |
|||
public class CommonGridIdFormDTO implements Serializable { |
|||
private static final long serialVersionUID = 2496019865436084805L; |
|||
|
|||
/** |
|||
* 网格Id |
|||
* */ |
|||
@NotBlank(message = "网格Id不能为空") |
|||
private String gridId; |
|||
|
|||
|
|||
} |
@ -0,0 +1,20 @@ |
|||
package com.epmet.resi.group.dto.member.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Description |
|||
* @ClassName VotableCountResultDTO |
|||
* @Auth wangc |
|||
* @Date 2020-05-22 18:10 |
|||
*/ |
|||
@Data |
|||
public class VotableCountResultDTO implements Serializable { |
|||
private static final long serialVersionUID = -4901865119510991968L; |
|||
private String gridId; |
|||
|
|||
private Integer votableCount; |
|||
} |
@ -0,0 +1,23 @@ |
|||
package com.epmet.resi.mine.dto.from; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Description |
|||
* @ClassName MyResiUserInfoFormDTO |
|||
* @Auth wangc |
|||
* @Date 2020-05-22 17:27 |
|||
*/ |
|||
@Data |
|||
public class MyResiUserInfoFormDTO implements Serializable { |
|||
private static final long serialVersionUID = -6534841370041338474L; |
|||
@NotBlank(message = "客户Id不能为空") |
|||
private String customerId; |
|||
@NotBlank(message = "网格Id不能为空") |
|||
private String gridId; |
|||
@NotBlank(message = "用户Id不能为空") |
|||
private String userId; |
|||
} |
@ -0,0 +1,46 @@ |
|||
package com.epmet.resi.mine.dto.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @Description |
|||
* @ClassName MyResiUserInfoResultDTO |
|||
* @Auth wangc |
|||
* @Date 2020-05-22 18:26 |
|||
*/ |
|||
@Data |
|||
public class MyResiUserInfoResultDTO implements Serializable { |
|||
private static final long serialVersionUID = -1269738324822294380L; |
|||
/** |
|||
* 用户id |
|||
* */ |
|||
private String userId; |
|||
/** |
|||
* 是否已注册居民,true ,false |
|||
* */ |
|||
private Boolean registerFlag; |
|||
/** |
|||
* 微信昵称,可为空“” |
|||
* */ |
|||
private String nickName; |
|||
/** |
|||
* 注册姓名,可为空“” |
|||
* */ |
|||
private String userRealName; |
|||
/** |
|||
* 头像,可为空“” |
|||
* */ |
|||
private String userHeadPhoto; |
|||
/** |
|||
* 首次注册的网格,可为空“” |
|||
* */ |
|||
private String registerGridName; |
|||
/** |
|||
* 拥有角色名称列表,可为空[] |
|||
* */ |
|||
private List<String> roleList; |
|||
|
|||
} |
@ -0,0 +1,43 @@ |
|||
package com.epmet.modules.mine.controller; |
|||
|
|||
import com.epmet.commons.tools.annotation.LoginUser; |
|||
import com.epmet.commons.tools.security.dto.TokenDto; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.commons.tools.validator.ValidatorUtils; |
|||
import com.epmet.modules.feign.EpmetUserFeignClient; |
|||
import com.epmet.resi.mine.dto.from.MyResiUserInfoFormDTO; |
|||
import com.epmet.resi.mine.dto.result.MyResiUserInfoResultDTO; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* @Description |
|||
* @ClassName MineController |
|||
* @Auth wangc |
|||
* @Date 2020-05-22 18:33 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("mine") |
|||
public class MineController { |
|||
|
|||
@Autowired |
|||
EpmetUserFeignClient epmetUserFeignClient; |
|||
|
|||
/** |
|||
* @Description 居民端获取我的信息 |
|||
* @param myResiUserInfoFormDTO |
|||
* @return MyResiUserInfoResultDTO |
|||
* @author wangc |
|||
* @date 2020.05.22 18:37 |
|||
**/ |
|||
@PostMapping("profile") |
|||
Result<MyResiUserInfoResultDTO> getMyResiInfo(@LoginUser TokenDto tokenDto, @RequestBody MyResiUserInfoFormDTO myResiUserInfoFormDTO){ |
|||
myResiUserInfoFormDTO.setUserId(tokenDto.getUserId()); |
|||
ValidatorUtils.validateEntity(myResiUserInfoFormDTO); |
|||
return epmetUserFeignClient.resiMyselfMsg(myResiUserInfoFormDTO); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,23 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Description |
|||
* @ClassName MyResiUserInfoFormDTO |
|||
* @Auth wangc |
|||
* @Date 2020-05-22 17:27 |
|||
*/ |
|||
@Data |
|||
public class MyResiUserInfoFormDTO implements Serializable { |
|||
private static final long serialVersionUID = -6534841370041338474L; |
|||
@NotBlank(message = "客户Id不能为空") |
|||
private String customerId; |
|||
@NotBlank(message = "网格Id不能为空") |
|||
private String gridId; |
|||
@NotBlank(message = "用户Id不能为空") |
|||
private String userId; |
|||
} |
@ -0,0 +1,46 @@ |
|||
package com.epmet.dto.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @Description |
|||
* @ClassName MyResiUserInfoResultDTO |
|||
* @Auth wangc |
|||
* @Date 2020-05-22 18:26 |
|||
*/ |
|||
@Data |
|||
public class MyResiUserInfoResultDTO implements Serializable { |
|||
private static final long serialVersionUID = -1269738324822294380L; |
|||
/** |
|||
* 用户id |
|||
* */ |
|||
private String userId; |
|||
/** |
|||
* 是否已注册居民,true ,false |
|||
* */ |
|||
private Boolean registerFlag; |
|||
/** |
|||
* 微信昵称,可为空“” |
|||
* */ |
|||
private String nickName; |
|||
/** |
|||
* 注册姓名,可为空“” |
|||
* */ |
|||
private String userRealName; |
|||
/** |
|||
* 头像,可为空“” |
|||
* */ |
|||
private String userHeadPhoto; |
|||
/** |
|||
* 首次注册的网格,可为空“” |
|||
* */ |
|||
private String registerGridName; |
|||
/** |
|||
* 拥有角色名称列表,可为空[] |
|||
* */ |
|||
private List<String> roleList; |
|||
|
|||
} |
@ -0,0 +1,41 @@ |
|||
package com.epmet.dto.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Description |
|||
* @ClassName MyselfMsgResultDTO |
|||
* @Auth wangc |
|||
* @Date 2020-05-22 19:15 |
|||
*/ |
|||
@Data |
|||
public class MyselfMsgResultDTO implements Serializable { |
|||
private static final long serialVersionUID = 1862775055704168458L; |
|||
/** |
|||
* 用户id |
|||
* */ |
|||
private String userId; |
|||
/** |
|||
* 是否已注册居民 |
|||
* */ |
|||
private String resiId; |
|||
/** |
|||
* 微信昵称 |
|||
* */ |
|||
private String nickName; |
|||
/** |
|||
* 注册姓名 |
|||
* */ |
|||
private String userRealName; |
|||
/** |
|||
* 头像 |
|||
* */ |
|||
private String userHeadPhoto; |
|||
/** |
|||
* 首次注册的网格 |
|||
* */ |
|||
private String gridId; |
|||
|
|||
} |
Loading…
Reference in new issue