17 changed files with 1123 additions and 211 deletions
@ -0,0 +1,167 @@ |
|||
package com.elink.esua.epdc.commons.tools.utils; |
|||
|
|||
import org.apache.commons.lang3.StringUtils; |
|||
|
|||
import java.text.ParseException; |
|||
import java.text.SimpleDateFormat; |
|||
import java.time.LocalDate; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 身份证号工具 |
|||
* |
|||
* @author yujintao |
|||
* @email yujintao@elink-cn.com |
|||
* @date 2019/9/7 13:11 |
|||
*/ |
|||
public class IdentityNoUtils { |
|||
|
|||
/** |
|||
* 15位身份证号 |
|||
*/ |
|||
private static final Integer FIFTEEN_ID_CARD = 15; |
|||
/** |
|||
* 18位身份证号 |
|||
*/ |
|||
private static final Integer EIGHTEEN_ID_CARD = 18; |
|||
|
|||
/** |
|||
* 根据身份证号获取性别 |
|||
* 0女;1男 |
|||
* |
|||
* @param IDCard |
|||
* @return |
|||
*/ |
|||
public static Integer getSex(String IDCard) { |
|||
if (StringUtils.isNotBlank(IDCard)) { |
|||
if (IDCard.length() == FIFTEEN_ID_CARD) { |
|||
if (Integer.parseInt(IDCard.substring(14, 15)) % 2 == 0) { |
|||
return 0; |
|||
} else { |
|||
return 1; |
|||
} |
|||
} else if (IDCard.length() == EIGHTEEN_ID_CARD) { |
|||
if (Integer.parseInt(IDCard.substring(16).substring(0, 1)) % 2 == 0) { |
|||
return 0; |
|||
} else { |
|||
return 1; |
|||
} |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
/** |
|||
* 根据身份证号获取年龄 |
|||
* |
|||
* @param IDCard |
|||
* @return |
|||
*/ |
|||
public static Integer getAge(String IDCard) { |
|||
int age; |
|||
LocalDate now = LocalDate.now(); |
|||
int nowYear = now.getYear(); |
|||
int nowMonth = now.getMonthValue(); |
|||
int cardYear = 0; |
|||
int cardMonth = 0; |
|||
if (StringUtils.isNotBlank(IDCard) && isValid(IDCard)) { |
|||
if (IDCard.length() == FIFTEEN_ID_CARD) { |
|||
// 身份证上的年份(15位身份证为1980年前的)
|
|||
String uyear = "19" + IDCard.substring(6, 8); |
|||
cardYear = Integer.parseInt(uyear); |
|||
// 身份证上的月份
|
|||
String uyue = IDCard.substring(8, 10); |
|||
cardMonth = Integer.parseInt(uyue); |
|||
} else if (IDCard.length() == EIGHTEEN_ID_CARD) { |
|||
// 身份证上的年份
|
|||
String year = IDCard.substring(6).substring(0, 4); |
|||
cardYear = Integer.parseInt(year); |
|||
// 身份证上的月份
|
|||
String yue = IDCard.substring(10).substring(0, 2); |
|||
cardMonth = Integer.parseInt(yue); |
|||
} |
|||
} |
|||
// 当前月份大于用户出身的月份表示已过生日
|
|||
if (cardMonth <= nowMonth) { |
|||
age = nowYear - cardYear + 1; |
|||
// 当前用户还没过生
|
|||
} else { |
|||
age = nowYear - cardYear; |
|||
} |
|||
return age; |
|||
} |
|||
|
|||
/** |
|||
* 获取出生日期 yyyy-MM-dd |
|||
* |
|||
* @param IDCard |
|||
* @return |
|||
*/ |
|||
public static String getBirthday(String IDCard) { |
|||
String year = ""; |
|||
String month = ""; |
|||
String day = ""; |
|||
if (StringUtils.isNotBlank(IDCard)) { |
|||
//15位身份证号
|
|||
if (IDCard.length() == FIFTEEN_ID_CARD) { |
|||
// 身份证上的年份(15位身份证为1980年前的)
|
|||
year = "19" + IDCard.substring(6, 8); |
|||
//身份证上的月份
|
|||
month = IDCard.substring(8, 10); |
|||
//身份证上的日期
|
|||
day = IDCard.substring(10, 12); |
|||
//18位身份证号
|
|||
} else if (IDCard.length() == EIGHTEEN_ID_CARD) { |
|||
// 身份证上的年份
|
|||
year = IDCard.substring(6).substring(0, 4); |
|||
// 身份证上的月份
|
|||
month = IDCard.substring(10).substring(0, 2); |
|||
//身份证上的日期
|
|||
day = IDCard.substring(12).substring(0, 2); |
|||
} |
|||
} |
|||
return year + "-" + month + "-" + day; |
|||
} |
|||
|
|||
/** |
|||
* 身份证验证是否有效 |
|||
* |
|||
* @param id 号码内容 |
|||
* @return boolean |
|||
* @author |
|||
* @date |
|||
*/ |
|||
public static boolean isValid(String id) { |
|||
Boolean validResult = true; |
|||
//校验长度只能为15或18
|
|||
int len = id.length(); |
|||
if (len != FIFTEEN_ID_CARD && len != EIGHTEEN_ID_CARD) { |
|||
validResult = false; |
|||
} |
|||
//校验生日
|
|||
if (!validDate(id)) { |
|||
validResult = false; |
|||
} |
|||
return validResult; |
|||
} |
|||
|
|||
/** |
|||
* 校验生日 |
|||
* |
|||
* @param id |
|||
* @return |
|||
*/ |
|||
private static boolean validDate(String id) { |
|||
try { |
|||
String birth = id.length() == 15 ? "19" + id.substring(6, 12) : id.substring(6, 14); |
|||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); |
|||
Date birthDate = sdf.parse(birth); |
|||
if (!birth.equals(sdf.format(birthDate))) { |
|||
return false; |
|||
} |
|||
} catch (ParseException e) { |
|||
return false; |
|||
} |
|||
return true; |
|||
} |
|||
} |
@ -0,0 +1,32 @@ |
|||
package com.elink.esua.epdc.controller; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; |
|||
import com.elink.esua.epdc.dto.epdc.form.EpdcUserRegistFormDTO; |
|||
import com.elink.esua.epdc.service.AppUserService; |
|||
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; |
|||
|
|||
/** |
|||
* 用户模块 |
|||
* |
|||
* @author yujintao |
|||
* @email yujintao@elink-cn.com |
|||
* @date 2019/9/6 19:30 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("app-user") |
|||
public class ApiAppUserController { |
|||
|
|||
@Autowired |
|||
private AppUserService appUserService; |
|||
|
|||
@PostMapping("user/regist") |
|||
public Result userRegist(@RequestBody EpdcUserRegistFormDTO formDto){ |
|||
ValidatorUtils.validateEntity(formDto); |
|||
return appUserService.userRegist(formDto); |
|||
} |
|||
} |
@ -0,0 +1,31 @@ |
|||
package com.elink.esua.epdc.feign; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.CompleteDeptDTO; |
|||
import com.elink.esua.epdc.feign.fallback.AdminFeignClientFallback; |
|||
import org.springframework.cloud.openfeign.FeignClient; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
|
|||
/** |
|||
* 管理端接口 |
|||
* |
|||
* @author yujintao |
|||
* @email yujintao@elink-cn.com |
|||
* @date 2019/9/7 9:27 |
|||
*/ |
|||
@FeignClient(name = ServiceConstant.EPDC_ADMIN_SERVER, fallback = AdminFeignClientFallback.class) |
|||
public interface AdminFeignClient { |
|||
|
|||
/** |
|||
* 根据网格ID获取所有上级机构名称和ID |
|||
* |
|||
* @param gridId |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.CompleteDeptDTO> |
|||
* @author yujintao |
|||
* @date 2019/9/7 09:31 |
|||
*/ |
|||
@GetMapping("sys/dept/getCompleteDept/{gridId}") |
|||
Result<CompleteDeptDTO> getCompleteDept(@PathVariable("gridId") Long gridId); |
|||
} |
@ -0,0 +1,46 @@ |
|||
package com.elink.esua.epdc.feign; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.UserDTO; |
|||
import com.elink.esua.epdc.feign.fallback.UserFeignClientFallback; |
|||
import org.springframework.cloud.openfeign.FeignClient; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
|
|||
/** |
|||
* appuser端接口 |
|||
* |
|||
* @author yujintao |
|||
* @email yujintao@elink-cn.com |
|||
* @date 2019/9/7 9:27 |
|||
*/ |
|||
@FeignClient(name = ServiceConstant.EPDC_USER_SERVER, fallback = UserFeignClientFallback.class) |
|||
public interface UserFeignClient { |
|||
|
|||
/** |
|||
* 获取用户信息 |
|||
* |
|||
* @param openId |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.UserDTO> |
|||
* @author yujintao |
|||
* @date 2019/9/7 11:04 |
|||
*/ |
|||
@GetMapping("app-user/epdc-app/user/getByOpenId/{openId}") |
|||
Result<UserDTO> getUserInfoByOpenId(@PathVariable("openId") String openId); |
|||
|
|||
/** |
|||
* 用户注册 |
|||
* |
|||
* @param userDto |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
* @author yujintao |
|||
* @date 2019/9/7 14:26 |
|||
*/ |
|||
@PostMapping(value = "app-user/epdc-app/user/regist", consumes = MediaType.APPLICATION_JSON_VALUE) |
|||
Result userRegist(@RequestBody UserDTO userDto); |
|||
|
|||
} |
@ -0,0 +1,22 @@ |
|||
package com.elink.esua.epdc.feign.fallback; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; |
|||
import com.elink.esua.epdc.commons.tools.utils.ModuleUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.CompleteDeptDTO; |
|||
import com.elink.esua.epdc.feign.AdminFeignClient; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* @author yujintao |
|||
* @email yujintao@elink-cn.com |
|||
* @date 2019/9/7 9:30 |
|||
*/ |
|||
@Component |
|||
public class AdminFeignClientFallback implements AdminFeignClient { |
|||
|
|||
@Override |
|||
public Result<CompleteDeptDTO> getCompleteDept(Long gridId) { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPDC_ADMIN_SERVER, "getCompleteDept", gridId); |
|||
} |
|||
} |
@ -0,0 +1,27 @@ |
|||
package com.elink.esua.epdc.feign.fallback; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; |
|||
import com.elink.esua.epdc.commons.tools.utils.ModuleUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.UserDTO; |
|||
import com.elink.esua.epdc.feign.UserFeignClient; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* @author yujintao |
|||
* @email yujintao@elink-cn.com |
|||
* @date 2019/9/7 9:30 |
|||
*/ |
|||
@Component |
|||
public class UserFeignClientFallback implements UserFeignClient { |
|||
|
|||
@Override |
|||
public Result<UserDTO> getUserInfoByOpenId(String openId) { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPDC_USER_SERVER, "getUserInfoByOpenId", openId); |
|||
} |
|||
|
|||
@Override |
|||
public Result userRegist(UserDTO userDto) { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPDC_USER_SERVER, "userRegist", userDto); |
|||
} |
|||
} |
@ -0,0 +1,36 @@ |
|||
package com.elink.esua.epdc.redis; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.redis.RedisKeys; |
|||
import com.elink.esua.epdc.commons.tools.redis.RedisUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* @author yujintao |
|||
* @email yujintao@elink-cn.com |
|||
* @date 2019/9/7 10:26 |
|||
*/ |
|||
@Component |
|||
public class AppUserRedis { |
|||
|
|||
@Autowired |
|||
private RedisUtils redisUtils; |
|||
|
|||
/** |
|||
* 获取短信验证码 |
|||
* |
|||
* @param phone 手机号 |
|||
* @return java.lang.String |
|||
* @author yujintao |
|||
* @date 2019/9/7 10:29 |
|||
*/ |
|||
public String getSmsCode(String phone) { |
|||
String key = RedisKeys.getPhoneSmsCodeKey(phone); |
|||
Object smsCode = redisUtils.get(key); |
|||
if (null != smsCode) { |
|||
return (String) smsCode; |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,22 @@ |
|||
package com.elink.esua.epdc.service; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.epdc.form.EpdcUserRegistFormDTO; |
|||
|
|||
/** |
|||
* @author yujintao |
|||
* @email yujintao@elink-cn.com |
|||
* @date 2019/9/7 9:50 |
|||
*/ |
|||
public interface AppUserService { |
|||
|
|||
/** |
|||
* 移动端用户注册 |
|||
* |
|||
* @param formDto |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
* @author yujintao |
|||
* @date 2019/9/7 09:54 |
|||
*/ |
|||
Result userRegist(EpdcUserRegistFormDTO formDto); |
|||
} |
@ -0,0 +1,163 @@ |
|||
package com.elink.esua.epdc.service.impl; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.constant.NumConstant; |
|||
import com.elink.esua.epdc.commons.tools.enums.YesOrNoEnum; |
|||
import com.elink.esua.epdc.commons.tools.exception.RenException; |
|||
import com.elink.esua.epdc.commons.tools.utils.*; |
|||
import com.elink.esua.epdc.dto.CompleteDeptDTO; |
|||
import com.elink.esua.epdc.dto.UserDTO; |
|||
import com.elink.esua.epdc.dto.epdc.form.EpdcUserRegistFormDTO; |
|||
import com.elink.esua.epdc.enums.AppUserAuditStateEnum; |
|||
import com.elink.esua.epdc.enums.AppUserRegisterSourceEnum; |
|||
import com.elink.esua.epdc.enums.AppUserRegisterWayEnum; |
|||
import com.elink.esua.epdc.feign.AdminFeignClient; |
|||
import com.elink.esua.epdc.feign.UserFeignClient; |
|||
import com.elink.esua.epdc.redis.AppUserRedis; |
|||
import com.elink.esua.epdc.service.AppUserService; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import me.chanjar.weixin.common.error.WxErrorException; |
|||
import me.chanjar.weixin.mp.api.WxMpService; |
|||
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken; |
|||
import me.chanjar.weixin.mp.bean.result.WxMpUser; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import java.util.Date; |
|||
|
|||
|
|||
/** |
|||
* @author yujintao |
|||
* @email yujintao@elink-cn.com |
|||
* @date 2019/9/7 9:50 |
|||
*/ |
|||
@Slf4j |
|||
@Service |
|||
public class AppUserServiceImpl implements AppUserService { |
|||
|
|||
@Autowired |
|||
private AppUserRedis appUserRedis; |
|||
|
|||
@Autowired |
|||
private WxMpService wxMpService; |
|||
|
|||
@Autowired |
|||
private AdminFeignClient adminFeignClient; |
|||
|
|||
@Autowired |
|||
private UserFeignClient userFeignClient; |
|||
|
|||
|
|||
@Override |
|||
public Result userRegist(EpdcUserRegistFormDTO formDto) { |
|||
|
|||
// 校验手机验证码
|
|||
String mobile = formDto.getMobile(); |
|||
String smsCode = appUserRedis.getSmsCode(mobile); |
|||
if (StringUtils.isBlank(smsCode) || !smsCode.equals(formDto.getSmsCode())) { |
|||
return new Result().error("手机验证码错误"); |
|||
} |
|||
|
|||
// 解析微信用户信息
|
|||
WxMpUser wxMpUser = this.getWxMpUser(formDto.getWxCode()); |
|||
|
|||
// 查询当前微信是否已注册用户
|
|||
Result<UserDTO> userInfoResult = userFeignClient.getUserInfoByOpenId(wxMpUser.getOpenId()); |
|||
if (!userInfoResult.success()) { |
|||
return new Result().error("查询用户信息失败"); |
|||
} |
|||
UserDTO userDto = userInfoResult.getData(); |
|||
if (null != userDto) { |
|||
if (AppUserAuditStateEnum.UNDER_AUDIT.value().equals(userDto.getState())) { |
|||
return new Result().error("用户尚在审核中,请耐心等待"); |
|||
} |
|||
return new Result().error("此微信号已注册用户,请前往登录"); |
|||
} |
|||
|
|||
// 获取网格机构详情
|
|||
String gridId = formDto.getGridId(); |
|||
Result<CompleteDeptDTO> adminDeptResult = adminFeignClient.getCompleteDept(Long.parseLong(gridId)); |
|||
if (!adminDeptResult.success() || null == adminDeptResult.getData()) { |
|||
return new Result().error("查询网格信息失败"); |
|||
} |
|||
CompleteDeptDTO completeDept = adminDeptResult.getData(); |
|||
|
|||
userDto = this.packUserDto(formDto, wxMpUser, completeDept); |
|||
HttpServletRequest request = HttpContextUtils.getHttpServletRequest(); |
|||
userDto.setLastLoginIp(IpUtils.getIpAddr(request)); |
|||
|
|||
return userFeignClient.userRegist(userDto); |
|||
} |
|||
|
|||
/** |
|||
* 组装用户对象 |
|||
* |
|||
* @param formDto 前端表单提交 |
|||
* @param wxMpUser 用户微信信息 |
|||
* @param completeDept 用户机构信息 |
|||
* @return com.elink.esua.epdc.dto.UserDTO |
|||
* @author yujintao |
|||
* @date 2019/9/7 14:13 |
|||
*/ |
|||
private UserDTO packUserDto(EpdcUserRegistFormDTO formDto, WxMpUser wxMpUser, CompleteDeptDTO completeDept) { |
|||
UserDTO user = ConvertUtils.sourceToTarget(formDto, UserDTO.class); |
|||
|
|||
PhoneDto phoneDto = PhoneUtil.getPhoneDto(formDto.getMobile()); |
|||
if (phoneDto != null) { |
|||
user.setMobileProvince(phoneDto.getProvinceName()); |
|||
user.setMobileCity(phoneDto.getCityName()); |
|||
user.setMobileCarrier(phoneDto.getCarrier()); |
|||
} |
|||
user.setSex(String.valueOf(IdentityNoUtils.getSex(formDto.getIdentityNo()))); |
|||
user.setBirthday(DateUtils.parse(IdentityNoUtils.getBirthday(formDto.getIdentityNo()), DateUtils.DATE_PATTERN)); |
|||
user.setNickname( |
|||
formDto.getRoad().concat("-").concat(formDto.getRealName().substring(NumConstant.ZERO, NumConstant.ONE)) |
|||
.concat(NumConstant.ZERO_STR.equals(user.getSex()) ? "女士" : "先生") |
|||
); |
|||
|
|||
user.setStreet(completeDept.getStreet()); |
|||
user.setStreetId(completeDept.getStreetId()); |
|||
user.setCommunity(completeDept.getCommunity()); |
|||
user.setCommunityId(completeDept.getCommunityId()); |
|||
user.setGrid(completeDept.getGrid()); |
|||
user.setGridId(completeDept.getGridId()); |
|||
|
|||
String address = formDto.getRoad() |
|||
.concat(StringUtils.isNotBlank(formDto.getVillageName()) ? formDto.getVillageName() : "") |
|||
.concat(StringUtils.isNotBlank(formDto.getBuildingCode()) ? formDto.getBuildingCode().concat("号楼") : "") |
|||
.concat(StringUtils.isNotBlank(formDto.getUnitCode()) ? formDto.getUnitCode().concat("单元") : ""); |
|||
|
|||
user.setAddress(address); |
|||
user.setWxOpenId(wxMpUser.getOpenId()); |
|||
user.setFaceImg(wxMpUser.getHeadImgUrl()); |
|||
user.setRegisterTime(new Date()); |
|||
user.setState(AppUserAuditStateEnum.UNDER_AUDIT.value()); |
|||
user.setPartyFlag(YesOrNoEnum.NO.value()); |
|||
user.setRegisterWay(AppUserRegisterWayEnum.WX.value()); |
|||
user.setRegisterSource(AppUserRegisterSourceEnum.WP.value()); |
|||
return user; |
|||
} |
|||
|
|||
/** |
|||
* 解析微信code获取微信用户信息 |
|||
* |
|||
* @param wxCode |
|||
* @return me.chanjar.weixin.mp.bean.result.WxMpUser |
|||
* @author yujintao |
|||
* @date 2019/9/7 14:11 |
|||
*/ |
|||
private WxMpUser getWxMpUser(String wxCode) { |
|||
WxMpUser wxMpUser = null; |
|||
try { |
|||
WxMpOAuth2AccessToken wxMpOAuth2AccessToken = wxMpService.oauth2getAccessToken(wxCode); |
|||
wxMpUser = wxMpService.oauth2getUserInfo(wxMpOAuth2AccessToken, null); |
|||
} catch (WxErrorException e) { |
|||
throw new RenException("解析微信code失败"); |
|||
} |
|||
if (null == wxMpUser || StringUtils.isBlank(wxMpUser.getOpenId())) { |
|||
throw new RenException("解析微信用户信息失败"); |
|||
} |
|||
return wxMpUser; |
|||
} |
|||
} |
@ -0,0 +1,70 @@ |
|||
package com.elink.esua.epdc.dto.epdc.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 移动端用户注册 |
|||
* |
|||
* @author yujintao |
|||
* @email yujintao@elink-cn.com |
|||
* @date 2019/9/6 20:37 |
|||
*/ |
|||
@Data |
|||
public class EpdcUserRegistFormDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = -6563961367676230567L; |
|||
|
|||
/** |
|||
* 身份证号码 |
|||
*/ |
|||
@NotBlank(message = "身份证号码不能为空") |
|||
private String identityNo; |
|||
/** |
|||
* 手机号 |
|||
*/ |
|||
@NotBlank(message = "手机号不能为空") |
|||
private String mobile; |
|||
/** |
|||
* 短信验证码 |
|||
*/ |
|||
@NotBlank(message = "短信验证码不能为空") |
|||
private String smsCode; |
|||
/** |
|||
* 真实姓名 |
|||
*/ |
|||
@NotBlank(message = "真实姓名不能为空") |
|||
private String realName; |
|||
/** |
|||
* 网格Id |
|||
*/ |
|||
@NotBlank(message = "网格Id不能为空") |
|||
private String gridId; |
|||
/** |
|||
* 所在道路 |
|||
*/ |
|||
@NotBlank(message = "所在道路不能为空") |
|||
private String road; |
|||
/** |
|||
* 小区名 |
|||
*/ |
|||
@NotBlank(message = "小区名不能为空") |
|||
private String villageName; |
|||
/** |
|||
* 楼栋号 |
|||
*/ |
|||
@NotBlank(message = "楼栋号不能为空") |
|||
private String buildingCode; |
|||
/** |
|||
* 单元号 |
|||
*/ |
|||
@NotBlank(message = "单元号不能为空") |
|||
private String unitCode; |
|||
/** |
|||
* 微信code |
|||
*/ |
|||
@NotBlank(message = "微信code不能为空") |
|||
private String wxCode; |
|||
} |
@ -0,0 +1,49 @@ |
|||
package com.elink.esua.epdc.controller; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.constant.Constant; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.UserDTO; |
|||
import com.elink.esua.epdc.service.UserService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
/** |
|||
* 对移动端开放 |
|||
* |
|||
* @author yujintao |
|||
* @email yujintao@elink-cn.com |
|||
* @date 2019/9/6 20:31 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping(Constant.EPDC_APP + "user") |
|||
public class EpdcAppUserController { |
|||
|
|||
@Autowired |
|||
private UserService userService; |
|||
|
|||
/** |
|||
* 根据用户openId获取用户信息(只查询已注册或审核中的用户) |
|||
* |
|||
* @param openId |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.UserDTO> |
|||
* @author yujintao |
|||
* @date 2019/9/7 10:51 |
|||
*/ |
|||
@GetMapping("getByOpenId/{openId}") |
|||
public Result<UserDTO> getUserInfoByOpenId(@PathVariable("openId") String openId) { |
|||
return userService.getUserInfoByOpenId(openId); |
|||
} |
|||
|
|||
/** |
|||
* 移动端用户注册 |
|||
* |
|||
* @param userDto |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
* @author yujintao |
|||
* @date 2019/9/7 14:20 |
|||
*/ |
|||
@PostMapping("regist") |
|||
public Result userRegist(@RequestBody UserDTO userDto) { |
|||
return userService.userRegist(userDto); |
|||
} |
|||
} |
Loading…
Reference in new issue