Commit 89d1ac8e authored by 杨阳's avatar 杨阳

打印日志

调整二维码接口参数验证 调整平台微信注册接口
parent 6b54a551
...@@ -3,6 +3,8 @@ package com.yeejoin.amos.boot.module.hygf.api.dto; ...@@ -3,6 +3,8 @@ package com.yeejoin.amos.boot.module.hygf.api.dto;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.Valid;
/** /**
* *
* @author Provence * @author Provence
...@@ -61,5 +63,5 @@ public class MobileLoginParamDto { ...@@ -61,5 +63,5 @@ public class MobileLoginParamDto {
private String verifyCode; private String verifyCode;
@ApiModelProperty("农户信息") @ApiModelProperty("农户信息")
private PeasantHouseholdDto peasantHouseholdDto; private @Valid PeasantHouseholdDto peasantHouseholdDto;
} }
...@@ -9,6 +9,9 @@ import lombok.Data; ...@@ -9,6 +9,9 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -39,13 +42,16 @@ public class PeasantHouseholdDto extends BaseDto { ...@@ -39,13 +42,16 @@ public class PeasantHouseholdDto extends BaseDto {
private String telephone; private String telephone;
@ApiModelProperty(value = "开发方名称") @ApiModelProperty(value = "开发方名称")
@NotBlank(message = "开发方名称不能为空")
private String developerName; private String developerName;
@ApiModelProperty(value = "开发方code") @ApiModelProperty(value = "开发方code")
@NotBlank(message = "开发方code不能为空")
private String developerCode; private String developerCode;
@ApiModelProperty(value = "开发方平台id") @ApiModelProperty(value = "开发方平台id")
@NotNull(message = "开发方平台id不能为空")
private Long developerId; private Long developerId;
@ApiModelProperty(value = "定金") @ApiModelProperty(value = "定金")
...@@ -90,7 +96,9 @@ public class PeasantHouseholdDto extends BaseDto { ...@@ -90,7 +96,9 @@ public class PeasantHouseholdDto extends BaseDto {
@ApiModelProperty(value = "常住详细地址") @ApiModelProperty(value = "常住详细地址")
private String permanentAddressDetail; private String permanentAddressDetail;
@ApiModelProperty(value = "开发人") @ApiModelProperty(value = "开发人")
@NotBlank(message = "开发人不能为空")
private String developer; private String developer;
@ApiModelProperty(value = "常住地址") @ApiModelProperty(value = "常住地址")
...@@ -108,20 +116,25 @@ public class PeasantHouseholdDto extends BaseDto { ...@@ -108,20 +116,25 @@ public class PeasantHouseholdDto extends BaseDto {
private List<String> permanentAddressText; private List<String> permanentAddressText;
@ApiModelProperty(value = "区域公司id") @ApiModelProperty(value = "区域公司id")
@NotNull(message = "区域公司id不能为空")
private Long regionalCompaniesSeq; private Long regionalCompaniesSeq;
@ApiModelProperty(value = "区域公司code") @ApiModelProperty(value = "区域公司code")
@NotBlank(message = "区域公司code不能为空")
private String regionalCompaniesCode; private String regionalCompaniesCode;
@ApiModelProperty(value = "区域公司名称") @ApiModelProperty(value = "区域公司名称")
@NotBlank(message = "区域公司名称不能为空")
private String regionalCompaniesName; private String regionalCompaniesName;
@ApiModelProperty(value = "身份证正面") @ApiModelProperty(value = "身份证正面")
@TableField(typeHandler = FastjsonTypeHandler.class) @TableField(typeHandler = FastjsonTypeHandler.class)
@NotEmpty(message = "身份证正面不能为空")
private List<Object> idCardFront; private List<Object> idCardFront;
@ApiModelProperty(value = "身份证反面") @ApiModelProperty(value = "身份证反面")
@TableField(typeHandler = FastjsonTypeHandler.class) @TableField(typeHandler = FastjsonTypeHandler.class)
@NotEmpty(message = "身份证反面不能为空")
private List<Object> idCardOpposite; private List<Object> idCardOpposite;
@ApiModelProperty(value = "微信唯一id") @ApiModelProperty(value = "微信唯一id")
......
...@@ -19,10 +19,10 @@ import io.swagger.annotations.Api; ...@@ -19,10 +19,10 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -105,6 +105,7 @@ public class PeasantHouseholdWxController extends BaseController { ...@@ -105,6 +105,7 @@ public class PeasantHouseholdWxController extends BaseController {
@RequestMapping (value = "/login", method = RequestMethod.POST) @RequestMapping (value = "/login", method = RequestMethod.POST)
@ApiOperation (httpMethod = "POST", value = "微信授权登陆", notes = "微信授权登陆") @ApiOperation (httpMethod = "POST", value = "微信授权登陆", notes = "微信授权登陆")
public ResponseModel<PeasantHouseholdWxDto> wxUserLogin(@ApiParam @RequestBody MobileLoginParamDto mobileLoginParam) { public ResponseModel<PeasantHouseholdWxDto> wxUserLogin(@ApiParam @RequestBody MobileLoginParamDto mobileLoginParam) {
log.info("微信授权登录入参 => {}", mobileLoginParam);
if (StringUtils.isBlank(mobileLoginParam.getAmosUserId())) { if (StringUtils.isBlank(mobileLoginParam.getAmosUserId())) {
// 扫码的userId为空, 则取默认值 // 扫码的userId为空, 则取默认值
mobileLoginParam.setAmosUserId(defaultUserId); mobileLoginParam.setAmosUserId(defaultUserId);
...@@ -116,8 +117,8 @@ public class PeasantHouseholdWxController extends BaseController { ...@@ -116,8 +117,8 @@ public class PeasantHouseholdWxController extends BaseController {
@TycloudOperation (ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation (ApiLevel = UserType.AGENCY, needAuth = false)
@RequestMapping (value = "/register", method = RequestMethod.POST) @RequestMapping (value = "/register", method = RequestMethod.POST)
@ApiOperation (httpMethod = "POST", value = "微信农户注册", notes = "微信农户注册") @ApiOperation (httpMethod = "POST", value = "微信农户注册", notes = "微信农户注册")
public ResponseModel<PeasantHouseholdDto> wxUserRegister(@ApiParam @RequestBody MobileLoginParamDto mobileLoginParam) { public ResponseModel<PeasantHouseholdDto> wxUserRegister(@Validated @ApiParam @RequestBody MobileLoginParamDto mobileLoginParam) {
// log.info("微信农户注册, 入参 => {}", JSONObject.toJSONString(mobileLoginParam)); log.info("微信农户注册, 入参 => {}", mobileLoginParam);
if (null == mobileLoginParam.getPeasantHouseholdDto()) { if (null == mobileLoginParam.getPeasantHouseholdDto()) {
throw new BadRequest("农户信息不能为空"); throw new BadRequest("农户信息不能为空");
} }
......
...@@ -249,12 +249,13 @@ public class WxServiceImpl implements IWxService { ...@@ -249,12 +249,13 @@ public class WxServiceImpl implements IWxService {
@Override @Override
public JSONObject getCode2Session(String code) { public JSONObject getCode2Session(String code) {
String url = buildOpenIdUrl(appId, secret, code); String url = buildOpenIdUrl(appId, secret, code);
log.info("微信 code2Session, code =>{}, 请求 => {}", code, url);
String resultStr = HttpUtil.sendHttpGet(url); String resultStr = HttpUtil.sendHttpGet(url);
// resultStr => {"session_key":"Mj5xbDhcZU73DtUduI1xKg==","openid":"oRraY5aYJkxkDJiG4rBaaw4MSmPA"} // resultStr => {"session_key":"Mj5xbDhcZU73DtUduI1xKg==","openid":"oRraY5aYJkxkDJiG4rBaaw4MSmPA"}
log.info("微信 Code2Session, code =>{}, 结果 => {}", code, resultStr); log.info("微信 code2Session, code =>{}, 结果 => {}", code, resultStr);
JSONObject jsonObject = JSONObject.parseObject(resultStr); JSONObject jsonObject = JSONObject.parseObject(resultStr);
if (jsonObject == null || jsonObject.getIntValue("errcode") != 0) { if (jsonObject == null || jsonObject.getIntValue("errcode") != 0) {
throw new BadRequest("微信授权失败, 请重新授权"); throw new RuntimeException("微信授权失败, 请重新授权");
} }
return jsonObject; return jsonObject;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment