记得上下班打卡 | git大法好,push需谨慎

Commit c07ef2f7 authored by 张国柄's avatar 张国柄

+参数校验:用户中心相关

parent 62806cc1
package com.liquidnet.service.adam.dto;
import com.liquidnet.commons.lang.constant.LnsRegex;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
@ApiModel(value = "AdamAddressesParam", description = "添加/编辑收获地址入参")
@Data
public class AdamAddressesParam implements java.io.Serializable {
private static final long serialVersionUID = -2626425843975309892L;
@ApiModelProperty(position = 10, required = false, value = "收获地址ID,编辑时必传[64]")
private String addressesId;
@ApiModelProperty(position = 11, required = true, value = "入场人名称[50]", example = "Swagger")
@ApiModelProperty(position = 11, required = true, value = "姓名[50]", example = "Swagger")
@Size(min = 1, max = 30, message = "姓名长度限制1~30位字符")
private String name;
@ApiModelProperty(position = 12, required = true, value = "手机号[11]", example = "13111111111")
@Pattern(regexp = "\\d{11}", message = "手机号格式有误")
private String phone;
@ApiModelProperty(position = 13, required = true, value = "省份[30]", example = "北京")
@Pattern(regexp = LnsRegex.Valid.CHINESE_PCD, message = "省份必须为2~30位汉字")
private String province;
@ApiModelProperty(position = 14, required = true, value = "城市[30]", example = "北京城区")
@NotNull(message = "城市不能为空")
@Pattern(regexp = LnsRegex.Valid.CHINESE_PCD, message = "城市必须为2~30位汉字")
private String city;
@ApiModelProperty(position = 15, required = true, value = "区县[30]", example = "朝阳区")
@Pattern(regexp = LnsRegex.Valid.CHINESE_PCD, message = "区县必须为2~30位汉字")
private String county;
@ApiModelProperty(position = 16, required = true, value = "详细地址[100]", example = "广渠路1号创1958园区")
@Size(max = 100, message = "详细地址长度最长100位")
private String address;
}
package com.liquidnet.service.adam.dto;
import com.liquidnet.commons.lang.constant.LnsRegex;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
@ApiModel(value = "AdamEntersParam", description = "添加/编辑入场人入参")
@Data
public class AdamEntersParam implements java.io.Serializable {
private static final long serialVersionUID = 8628253022063935727L;
@ApiModelProperty(position = 10, required = false, value = "入场人ID,编辑时必传[50]")
private String entersId;
@ApiModelProperty(position = 11, required = true, value = "入场人名称[50]", example = "Swagger")
@ApiModelProperty(position = 11, required = true, value = "入场人姓名[50]", example = "Swagger")
@Pattern(regexp = LnsRegex.Valid.CHINESE_HANZI, message = "姓名必须为2~20位汉字")
private String name;
@ApiModelProperty(position = 12, required = true, value = "入场人手机号[11]", example = "13100000000")
@Pattern(regexp = "\\d{11}", message = "手机号格式有误")
private String mobile;
@ApiModelProperty(position = 13, required = true, value = "证件类型:1-大陆身份证,2-港澳通行证,3-台胞证,4-护照,5-军官证", allowableValues = "1,2,3,4,5")
@Pattern(regexp = "\\b(1,2,3,4,5)\\b", message = "证件类型无效")
private Integer type;
@ApiModelProperty(position = 14, required = true, value = "入场人证件号[11]", example = "110101110001010111")
@Pattern(regexp = LnsRegex.Valid.CHINESE_ID_CARD, message = "身份证号格式有误")
private String idCard;
}
......@@ -3,7 +3,11 @@ package com.liquidnet.service.adam.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.io.Serializable;
@ApiModel(value = "AdamThirdPartParam", description = "第三方账号登录注册入参")
......@@ -13,10 +17,13 @@ public class AdamThirdPartParam implements Serializable {
@ApiModelProperty(position = 11, required = true, value = "第三方OPENID[64]")
private String openId;
@ApiModelProperty(position = 12, required = true, value = "昵称[64]", example = "Swagger")
@Size(min = 2, max = 64, message = "昵称字符长度限制2~64位")
private String nickname;
@ApiModelProperty(position = 13, required = true, value = "头像[255]", example = "http://pic.zhengzai.tv/default/avatar.png")
@Size(max = 255, message = "头像字符长度大于255位")
private String avatar;
@ApiModelProperty(position = 14, required = true, value = "平台类型[255]", allowableValues = "WEIBO,WECHAT,QQ")
@Pattern(regexp = "\\b(WEIBO,WECHAT,QQ)\\b", message = "平台类型无效")
private String platform;
@ApiModelProperty(position = 15, required = false, value = "手机号[新账号时必传]", example = "13111111111")
private String mobile;
......
package com.liquidnet.service.adam.dto;
import com.liquidnet.commons.lang.constant.LnsRegex;
import com.liquidnet.service.adam.dto.vo.AdamTagParentVo;
import com.liquidnet.service.adam.dto.vo.AdamTagVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.util.List;
@ApiModel(value = "AdamUserInfoParam", description = "个人资料编辑参数")
......@@ -13,19 +18,27 @@ import java.util.List;
public class AdamUserInfoParam implements java.io.Serializable {
private static final long serialVersionUID = -1084524066864012398L;
@ApiModelProperty(position = 11, required = true, value = "头像[255]", example = "http://pic.zhengzai.tv/default/avatar.png")
@Size(max = 255, message = "头像字符长度大于255位")
private String avatar;
@ApiModelProperty(position = 12, required = true, value = "背景[255]", example = "https://img.zhengzai.tv/files/2021/01/13/5ffeab3584b7d.png")
@Size(max = 255, message = "背景字符长度大于255位")
private String background;
@ApiModelProperty(position = 13, required = true, value = "昵称[32]", example = "Swagger")
@Size(min = 2, max = 64, message = "昵称字符长度限制2~64位")
private String nickname;
@ApiModelProperty(position = 14, required = true, value = "性别[32]", example = "{\"val\":\"MS00\",\"desc\":\"其他性别\"}")
@NotNull(message = "性别标签不能为空")
private AdamTagVo sex;
@ApiModelProperty(position = 15, required = true, value = "生日[YYYY-MM-DD]", example = "2021-05-17")
@Pattern(regexp = LnsRegex.Valid.DATETIME_YMD, message = "时间格式有误")
private String birthday;
@ApiModelProperty(position = 16, required = true, value = "常住地/区域[100]", example = "北京 北京市 朝阳区")
@NotBlank(message = "常住地/区域不能为空")
private String area;
@ApiModelProperty(position = 17, required = true, value = "签名[255]", example = "...................")
@Size(max = 255, message = "签名过长")
private String signature;
@ApiModelProperty(position = 18, required = true, value = "标签[500]", example = "[{\"val\":\"MMS01\",\"desc\":\"民歌\",\"tagVos\":[{\"val\":\"MMS0101\",\"desc\":\"A\"},{\"val\":\"MMS0102\",\"desc\":\"B\"}]},{\"val\":\"MMS02\",\"desc\":\"house\",\"tagVos\":[{\"val\":\"MMS0201\",\"desc\":\"C\"}]}]")
@NotNull(message = "风格标签不能为空")
private List<AdamTagParentVo> tagMe;
}
......@@ -3,6 +3,7 @@ package com.liquidnet.service.adam.dto.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
@ApiModel(value = "AdamTagVo", description = "标签库")
......
......@@ -62,4 +62,12 @@ public interface IAdamRdmService {
void delUserMemberVoByUid(String uid);
AdamMemberSimpleVo getMemberSimpleVo();
boolean setTagsForSex(List<AdamTagVo> voList);
List<AdamTagVo> getTagsForSex();
boolean setTagsForMusic(List<AdamTagParentVo> voList);
List<AdamTagParentVo> getTagsForMusic();
}
......@@ -2,6 +2,25 @@ package com.liquidnet.commons.lang.constant;
public class LnsRegex {
public static class Valid {
/**
* yyyy-MM-dd HH:mm:ss
*/
public static final String DATETIME_FULL = "^(((((0[48]|[2468][048]|[3579][26])00))|(([0-9]{2})(0[48]|[2468][048]|[13579][26])))[-|.|/| ]0?2[-|.|/| ]29|(((?!0{1,4})[0-9]{1,4})[-|.|/| ](((0[13-9]|1[0-2]|[13-9])[-|.|/| ](29|30))|((0[13578]|(10|12)|[13578])[-|.|/| ]31)|((0(?:[1-9])|1(?:[0-2])|[1-9])[-|.|/| ](0(?:[1-9])|1[0-9]|2[0-8]|[1-9])))))( ((0?[0-9])|(1[0-9]|2[0-3])):(([1-5][0-9])|(0?[0-9])):(([1-5][0-9])|(0?[0-9])))?$";
/**
* yyyy-MM-dd
*/
public static final String DATETIME_YMD = "^(((((0[48]|[2468][048]|[3579][26])00))|(([0-9]{2})(0[48]|[2468][048]|[13579][26])))[-|.|/| ]0?2[-|.|/| ]29|(((?!0{1,4})[0-9]{1,4})[-|.|/| ](((0[13-9]|1[0-2]|[13-9])[-|.|/| ](29|30))|((0[13578]|(10|12)|[13578])[-|.|/| ]31)|((0(?:[1-9])|1(?:[0-2])|[1-9])[-|.|/| ](0(?:[1-9])|1[0-9]|2[0-8]|[1-9])))))$";
/**
* 汉字-姓名(2~20位)
*/
public static final String CHINESE_HANZI = "^[\\u4e00-\\u9fa5]{2,20}$";
/**
* 汉字-省|市|区(2~30位)
*/
public static final String CHINESE_PCD = "^[\\u4e00-\\u9fa5]{2,30}$";
/**
* 身份证号(15位||18位)
*/
public static final String CHINESE_ID_CARD = "(^\\d{15}$)|(^\\d{18}$)|(^\\d{17}(\\d|X|x)$)";
}
}
......@@ -11,12 +11,15 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.WebRequest;
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
/**
......@@ -34,12 +37,24 @@ public class RestControllerAdviceHandler {
@ExceptionHandler(value = Exception.class)
@ResponseBody
public ResponseEntity serviceExceptionHandler(Exception rex, WebRequest request) {
public ResponseEntity<Error> serviceExceptionHandler(Exception rex, WebRequest request) {
logger.error("serviceExceptionHandler request:{},param:{}", request.getContextPath(), JSON.toJSONString(request.getParameterMap()));
if (rex instanceof ConstraintViolationException) {
ConstraintViolationException ygex = ((ConstraintViolationException) rex);
String message = ygex.getMessage().split("\\.")[1];
logger.error("LiquidnetServiceException errorCode:{} error : {}", ErrorCode.HTTP_PARAM_ERROR.getCode(), ygex.getMessage());
String message = ((ConstraintViolation) ygex.getConstraintViolations().toArray()[0]).getMessage();
logger.error("ConstraintViolationException code:{},msg:{}", ErrorCode.HTTP_PARAM_ERROR.getCode(), message);
return new ResponseEntity<Error>(new Error(ErrorCode.HTTP_PARAM_ERROR.getCode(), message), HttpStatus.OK);
}
if (rex instanceof MissingServletRequestParameterException) {
MissingServletRequestParameterException ygex = ((MissingServletRequestParameterException) rex);
String message = ygex.getMessage();
logger.error("ConstraintViolationException code:{},msg:{}", ErrorCode.HTTP_PARAM_ERROR.getCode(), message);
return new ResponseEntity<Error>(new Error(ErrorCode.HTTP_PARAM_ERROR.getCode(), message), HttpStatus.OK);
}
if (rex instanceof MethodArgumentNotValidException) {
MethodArgumentNotValidException ygex = ((MethodArgumentNotValidException) rex);
String message = ygex.getBindingResult().getFieldErrors().get(0).getDefaultMessage();
logger.error("ConstraintViolationException code:{},msg:{}", ErrorCode.HTTP_PARAM_ERROR.getCode(), message);
return new ResponseEntity<Error>(new Error(ErrorCode.HTTP_PARAM_ERROR.getCode(), message), HttpStatus.OK);
}
if (rex instanceof LiquidnetFeignException) {
......@@ -47,7 +62,7 @@ public class RestControllerAdviceHandler {
String errorCode = ygex.errorCode().getCode();
String message = ygex.getMessage();
message = message == null ? ygex.errorCode().getMessage() : message;
logger.error("LiquidnetServiceException errorCode:{} error : {}", errorCode, ygex.getMessage());
logger.error("LiquidnetFeignException code:{},msg:{}", errorCode, ygex.getMessage());
return new ResponseEntity<Error>(new Error(errorCode, message), HttpStatus.OK);
}
if (rex instanceof LiquidnetServiceException) {
......@@ -55,10 +70,10 @@ public class RestControllerAdviceHandler {
String errorCode = ygex.errorCode().getCode();
String message = ygex.getMessage();
message = message == null ? ygex.errorCode().getMessage() : message;
logger.error("LiquidnetServiceException errorCode:{} error : {}", errorCode, ygex.getMessage());
logger.error("LiquidnetServiceException code:{},msg:{}", errorCode, ygex.getMessage());
return new ResponseEntity<Error>(new Error(errorCode, message), HttpStatus.OK);
} else {
logger.error("serviceExceptionHandler:{}", rex);
logger.error("serviceExceptionHandler unknown exception", rex);
return new ResponseEntity<Error>(new Error(ErrorCode.HTTP_SYSTEM_ERROR.getCode(), ErrorCode.HTTP_SYSTEM_ERROR.getMessage()), HttpStatus.OK);
}
}
......
......@@ -14,7 +14,7 @@ liquidnet:
pattern-file: '%d{yyyy-MM-dd HH:mm:ss.SSS} [ %-5level] %thread [%logger{96}:%line] - %msg%n'
pattern-console: '%d{yyyy-MM-dd HH:mm:ss.SSS} [ %-5level] %thread [%logger{96}:%line] - %msg%n'
pattern-rolling-file-name: ${liquidnet.logfile.path}/${liquidnet.logfile.name}-%d{yyyy-MM-dd}.%i.log
level-root: info
level: debug
rabbitmq:
connection-timeout: 5000
mysql:
......
......@@ -14,7 +14,7 @@ liquidnet:
pattern-file: '%d{yyyy-MM-dd HH:mm:ss.SSS} [ %-5level] %thread [%logger{96}:%line] - %msg%n'
pattern-console: '%d{yyyy-MM-dd HH:mm:ss.SSS} [ %-5level] %thread [%logger{96}:%line] - %msg%n'
pattern-rolling-file-name: ${liquidnet.logfile.path}/${liquidnet.logfile.name}-%d{yyyy-MM-dd}.%i.log
level-root: info
level: debug
rabbitmq:
connection-timeout: 3000
mysql:
......
......@@ -29,8 +29,7 @@ logging:
level:
root: info
#以下是为指定包设置日志级别
com:
liquidnet: info
com.liquidnet: ${liquidnet.logfile.level}
# -----------------------------------------------------------
eureka:
# client:
......
......@@ -18,6 +18,8 @@ public class AdamRedisConst {
public static final String INFO_ENTERS = INFO.concat("enters:");
public static final String INFO_ADDRESSES = INFO.concat("addresses:");
public static final String INFO_TAGS_SEX = INFO.concat("tags:sex");
public static final String INFO_TAGS_MUSIC = INFO.concat("tags:sex");
public static final String INFO_MEMBER_SIMPLE = INFO.concat("member_simple");
public static final String INFO_MEMBERS = ADAM.concat(":list:members");
......
......@@ -17,8 +17,11 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
......@@ -34,6 +37,7 @@ import java.util.List;
@ApiSupport(order = 10050)
@Api(tags = "收获地址")
@Slf4j
@Validated
@RestController
@RequestMapping("addr")
public class AdamAddressesController {
......@@ -45,8 +49,7 @@ public class AdamAddressesController {
@ApiOperationSupport(order = 1)
@ApiOperation(value = "添加收获地址")
@PostMapping("add")
public ResponseDto<Object> add(@RequestBody AdamAddressesParam parameter) {
// TODO: 2021/4/28 数据校验
public ResponseDto<Object> add(@RequestBody @Valid AdamAddressesParam parameter) {
String currentUid = CurrentUtil.getCurrentUid();
AdamAddresses adamAddresses = new AdamAddresses();
......@@ -78,7 +81,7 @@ public class AdamAddressesController {
@ApiOperationSupport(order = 3)
@ApiOperation(value = "设置默认收货地址")
@PostMapping("def/{addrId}")
public ResponseDto<Object> def(@PathVariable String addrId) {
public ResponseDto<Object> def(@NotBlank(message = "收货地址ID不能为空") @PathVariable String addrId) {
String currentUid = CurrentUtil.getCurrentUid();
AdamAddresses addresses = adamRdmService.getAddressesByUidAddressesId(currentUid, addrId);
......@@ -92,8 +95,10 @@ public class AdamAddressesController {
@ApiOperationSupport(order = 4)
@ApiOperation(value = "编辑收获地址")
@PostMapping("edit")
public ResponseDto<Object> edit(@RequestBody AdamAddressesParam parameter) {
// TODO: 2021/4/28 校验
public ResponseDto<Object> edit(@RequestBody @Valid AdamAddressesParam parameter) {
if (StringUtils.isBlank(parameter.getAddressesId())) {
return ResponseDto.failure(ErrorMapping.get("10016"));
}
String currentUid = CurrentUtil.getCurrentUid();
AdamAddresses updateInfo = new AdamAddresses();
......@@ -110,7 +115,7 @@ public class AdamAddressesController {
@ApiOperationSupport(order = 5)
@ApiOperation(value = "删除收获地址")
@PostMapping("del/{addrId}")
public ResponseDto<Object> del(@PathVariable String addrId) {
public ResponseDto<Object> del(@NotBlank(message = "收货地址ID不能为空") @PathVariable String addrId) {
String currentUid = CurrentUtil.getCurrentUid();
......@@ -124,10 +129,8 @@ public class AdamAddressesController {
@ApiOperationSupport(order = 6)
@ApiOperation(value = "收货地址详情")
@PostMapping("query/{id}")
public ResponseDto<AdamAddressesVo> query(@PathVariable(name = "id") String addrId,
@RequestParam(name = "uid", required = false) String uid) {
// TODO: 2021/4/28 校验
public ResponseDto<AdamAddressesVo> query(@NotBlank(message = "收货地址ID不能为空") @PathVariable(name = "id") String addrId,
@NotBlank(message = "用户ID不能为空") @RequestParam(required = false) String uid) {
AdamAddresses addresses = adamRdmService.getAddressesByUidAddressesId(StringUtils.isBlank(uid) ? CurrentUtil.getCurrentUid() : uid, addrId);
return null == addresses ? ResponseDto.failure(ErrorMapping.get(10105)) : ResponseDto.success(AdamAddressesVo.getNew().copy(addresses));
......
......@@ -16,6 +16,10 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
/**
* <p>
* 收藏 前端控制器
......@@ -35,9 +39,15 @@ public class AdamCollectionController {
@ApiOperationSupport(order = 1)
@ApiOperation(value = "添加收藏")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "type", value = "收藏类型[TICKET,VIDEO]", allowableValues = "TICKET,VIDEO"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "contentId", value = "内容ID[1,64]"),
})
@PostMapping("add")
public ResponseDto<Object> add(@RequestParam String type, @RequestParam String contentId) {
// TODO: 2021/4/28 数据校验
public ResponseDto<Object> add(@Pattern(regexp = "\\b(TICKET,VIDEO)\\b", message = "收藏类型无效")
@RequestParam String type,
@Size(min = 1, max = 64, message = "内容ID长度限制为1~64位字符")
@RequestParam String contentId) {
String currentUid = CurrentUtil.getCurrentUid();
AdamCollectBaseVo existVo = adamCollectionService.query(currentUid, type, contentId);
......@@ -55,13 +65,13 @@ public class AdamCollectionController {
@ApiOperationSupport(order = 2)
@ApiOperation(value = "删除收藏")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "type", value = "收藏类型", allowableValues = "TICKET,VIDEO,SITE,ARTIST,BAND,BRAND,STYLE,GOODS,MUSIC,SONG"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "type", value = "收藏类型", allowableValues = "TICKET,VIDEO"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "contentIds", value = "内容ID[多个ID用','分隔]"),
})
@PostMapping("del")
public ResponseDto<Object> del(@RequestParam String type, @RequestParam String contentIds) {
// TODO: 2021/4/28 数据校验
public ResponseDto<Object> del(@Pattern(regexp = "\\b(TICKET,VIDEO)\\b", message = "收藏类型无效")
@RequestParam String type,
@NotBlank(message = "内容Id不能为空") @RequestParam String contentIds) {
adamCollectionService.del(CurrentUtil.getCurrentUid(), type, contentIds.split(","));
return ResponseDto.success();
......@@ -70,16 +80,15 @@ public class AdamCollectionController {
@ApiOperationSupport(order = 3)
@ApiOperation(value = "收藏列表")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "type", value = "收藏类型", allowableValues = "TICKET,VIDEO,SITE,ARTIST,BAND,BRAND,STYLE,GOODS,MUSIC,SONG"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "type", value = "收藏类型", allowableValues = "TICKET,VIDEO"),
@ApiImplicitParam(type = "form", required = false, dataType = "Integer", name = "pageNo", value = "页码", example = "1"),
@ApiImplicitParam(type = "form", required = false, dataType = "Integer", name = "pageSize", value = "页展示条数", example = "5"),
})
@PostMapping("list")
public ResponseDto<PageInfo<AdamCollectVo>> list(@RequestParam String type,
public ResponseDto<PageInfo<AdamCollectVo>> list(@Pattern(regexp = "\\b(TICKET,VIDEO)\\b", message = "收藏类型无效")
@RequestParam String type,
@RequestParam(defaultValue = "1", required = false) int pageNo,
@RequestParam(defaultValue = "5", required = false) int pageSize) {
// TODO: 2021/4/28 数据校验
pageNo = pageNo > 0 ? pageNo : 1;
pageSize = pageSize <= 0 || pageSize > 10 ? 5 : pageSize;
......@@ -89,15 +98,13 @@ public class AdamCollectionController {
// @ApiOperationSupport(order = 4)
// @ApiOperation(value = "获取特定内容的收藏用户列表 -> 返回结构待定")
// @ApiImplicitParams({
// @ApiImplicitParam(type = "form", required = true, dataType = "String", name = "type", value = "收藏类型", allowableValues = "TICKET,VIDEO,SITE,ARTIST,BAND,BRAND,STYLE,GOODS,MUSIC,SONG"),
// @ApiImplicitParam(type = "form", required = true, dataType = "String", name = "type", value = "收藏类型", allowableValues = "TICKET,VIDEO"),
// @ApiImplicitParam(type = "form", required = true, dataType = "String", name = "contentId", value = "内容ID[64]"),
// })
// @PostMapping("list/user")
// public ResponseDto<Object> listUser(@RequestParam String type, @RequestParam String contentId) {
// // TODO: 2021/4/28 数据校验、身份认证、获取登录UID
// String uid = "1";
//
// // TODO: 2021/5/10
//
//
// return ResponseDto.success();
......@@ -106,12 +113,14 @@ public class AdamCollectionController {
@ApiOperationSupport(order = 5)
@ApiOperation(value = "获取收藏状态")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "type", value = "收藏类型", allowableValues = "TICKET,VIDEO,SITE,ARTIST,BAND,BRAND,STYLE,GOODS,MUSIC,SONG"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "type", value = "收藏类型", allowableValues = "TICKET,VIDEO"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "contentId", value = "内容ID[64]"),
})
@GetMapping("state")
public ResponseDto<Boolean> state(@RequestParam String type, @RequestParam String contentId) {
// TODO: 2021/4/28 数据校验
public ResponseDto<Boolean> state(@Pattern(regexp = "\\b(TICKET,VIDEO)\\b", message = "收藏类型无效")
@RequestParam String type,
@Size(min = 1, max = 64, message = "内容ID长度限制为1~64位字符")
@RequestParam String contentId) {
return ResponseDto.success(adamCollectionService.queryState(CurrentUtil.getCurrentUid(), type, contentId));
}
}
......@@ -17,6 +17,10 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
/**
* <p>
* 收藏 前端控制器
......@@ -36,9 +40,15 @@ public class AdamDisposedController {
@ApiOperationSupport(order = 1)
@ApiOperation(value = "添加想去")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "type", value = "想去类型[TICKET,VIDEO]", allowableValues = "TICKET,VIDEO"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "contentId", value = "内容ID[1,64]"),
})
@PostMapping("add")
public ResponseDto<Object> add(@RequestParam String type, @RequestParam String contentId) {
// TODO: 2021/4/28 数据校验
public ResponseDto<Object> add(@Pattern(regexp = "\\b(TICKET,VIDEO)\\b", message = "想去类型无效")
@RequestParam String type,
@Size(min = 1, max = 64, message = "内容ID长度限制为1~64位字符")
@RequestParam String contentId) {
String currentUid = CurrentUtil.getCurrentUid();
AdamDisposedBaseVo existVo = adamDisposedService.query(currentUid, type, contentId);
......@@ -57,13 +67,13 @@ public class AdamDisposedController {
@ApiOperationSupport(order = 2)
@ApiOperation(value = "删除想去")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "type", value = "收藏类型", allowableValues = "TICKET"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "type", value = "收藏类型", allowableValues = "TICKET,VIDEO"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "contentIds", value = "内容ID[多个ID用','分隔]"),
})
@PostMapping("del")
public ResponseDto<Object> del(@RequestParam String type, @RequestParam String contentIds) {
// TODO: 2021/4/28 数据校验
public ResponseDto<Object> del(@Pattern(regexp = "\\b(TICKET,VIDEO)\\b", message = "想去类型无效")
@RequestParam String type,
@NotBlank(message = "内容Id不能为空") @RequestParam String contentIds) {
adamDisposedService.del(CurrentUtil.getCurrentUid(), type, contentIds.split(","));
return ResponseDto.success();
......@@ -72,16 +82,15 @@ public class AdamDisposedController {
@ApiOperationSupport(order = 3)
@ApiOperation(value = "想去列表")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "type", value = "收藏类型", allowableValues = "TICKET"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "type", value = "收藏类型", allowableValues = "TICKET,VIDEO"),
@ApiImplicitParam(type = "form", required = false, dataType = "Integer", name = "pageNo", value = "页码", example = "1"),
@ApiImplicitParam(type = "form", required = false, dataType = "Integer", name = "pageSize", value = "页展示条数", example = "5"),
})
@PostMapping("list")
public ResponseDto<PageInfo<AdamDisposedVo>> list(@RequestParam String type,
public ResponseDto<PageInfo<AdamDisposedVo>> list(@Pattern(regexp = "\\b(TICKET,VIDEO)\\b", message = "想去类型无效")
@RequestParam String type,
@RequestParam(defaultValue = "1", required = false) int pageNo,
@RequestParam(defaultValue = "5", required = false) int pageSize) {
// TODO: 2021/4/28 数据校验
pageNo = pageNo > 0 ? pageNo : 1;
pageSize = pageSize <= 0 || pageSize > 10 ? 10 : pageSize;
......@@ -91,17 +100,18 @@ public class AdamDisposedController {
@ApiOperationSupport(order = 4)
@ApiOperation(value = "想去用户列表")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "type", value = "收藏类型", allowableValues = "TICKET"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "contentId", value = "内容ID[64]"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "type", value = "收藏类型", allowableValues = "TICKET,VIDEO"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "contentId", value = "内容ID[1,64]"),
@ApiImplicitParam(type = "form", required = false, dataType = "Integer", name = "pageNo", value = "页码", example = "1"),
@ApiImplicitParam(type = "form", required = false, dataType = "Integer", name = "pageSize", value = "页展示条数", example = "10"),
})
@PostMapping("list/user")
public ResponseDto<PageInfo<AdamDisposedUserVo>> listUser(@RequestParam String type, @RequestParam String contentId,
public ResponseDto<PageInfo<AdamDisposedUserVo>> listUser(@Pattern(regexp = "\\b(TICKET,VIDEO)\\b", message = "想去类型无效")
@RequestParam String type,
@Size(min = 1, max = 64, message = "内容ID长度限制为1~64位字符")
@RequestParam String contentId,
@RequestParam(defaultValue = "1", required = false) int pageNo,
@RequestParam(defaultValue = "10", required = false) int pageSize) {
// TODO: 2021/4/28 数据校验
pageNo = pageNo > 0 ? pageNo : 1;
pageSize = pageSize <= 0 || pageSize > 20 ? 20 : pageSize;
......@@ -115,8 +125,10 @@ public class AdamDisposedController {
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "contentId", value = "内容ID[64]"),
})
@GetMapping("state")
public ResponseDto<Boolean> state(@RequestParam String type, @RequestParam String contentId) {
// TODO: 2021/4/28 数据校验
public ResponseDto<Boolean> state(@Pattern(regexp = "\\b(TICKET,VIDEO)\\b", message = "想去类型无效")
@RequestParam String type,
@Size(min = 1, max = 64, message = "内容ID长度限制为1~64位字符")
@RequestParam String contentId) {
return ResponseDto.success(adamDisposedService.queryState(CurrentUtil.getCurrentUid(), type, contentId));
}
}
......@@ -17,8 +17,11 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
......@@ -34,6 +37,7 @@ import java.util.List;
@ApiSupport(order = 10040)
@Api(tags = "入场人")
@Slf4j
@Validated
@RestController
@RequestMapping("enters")
public class AdamEntersController {
......@@ -45,11 +49,9 @@ public class AdamEntersController {
@ApiOperationSupport(order = 1)
@ApiOperation(value = "添加入场人")
@PostMapping("add")
public ResponseDto<String> add(@RequestBody AdamEntersParam parameter) {
// TODO: 2021/4/28 数据校验
public ResponseDto<String> add(@RequestBody @Valid AdamEntersParam parameter) {
String currentUid = CurrentUtil.getCurrentUid();
AdamEnters addInfo = new AdamEnters();
BeanUtils.copyProperties(parameter, addInfo);
addInfo.setUid(currentUid);
......@@ -79,7 +81,7 @@ public class AdamEntersController {
@ApiOperationSupport(order = 3)
@ApiOperation(value = "设置默认入场人")
@PostMapping("def/{entersId}")
public ResponseDto<Object> def(@PathVariable String entersId) {
public ResponseDto<Object> def(@NotBlank(message = "入场人ID不能为空") @PathVariable String entersId) {
String currentUid = CurrentUtil.getCurrentUid();
AdamEnters enters = adamRdmService.getEntersByUidEntersId(currentUid, entersId);
if (null == enters) return ResponseDto.failure(ErrorMapping.get("10105"));
......@@ -93,8 +95,10 @@ public class AdamEntersController {
@ApiOperationSupport(order = 4)
@ApiOperation(value = "编辑入场人")
@PostMapping("edit")
public ResponseDto<Object> edit(@RequestBody AdamEntersParam parameter) {
// TODO: 2021/4/28 校验
public ResponseDto<Object> edit(@RequestBody @Valid AdamEntersParam parameter) {
if (StringUtils.isBlank(parameter.getEntersId())) {
return ResponseDto.failure(ErrorMapping.get("10015"));
}
String currentUid = CurrentUtil.getCurrentUid();
AdamEnters enters = adamRdmService.getEntersByUidEntersId(currentUid, parameter.getEntersId());
......@@ -114,11 +118,11 @@ public class AdamEntersController {
@ApiOperationSupport(order = 5)
@ApiOperation(value = "删除入场人")
@PostMapping("del/{entersId}")
public ResponseDto<Object> del(@PathVariable String entersId) {
public ResponseDto<Object> del(@NotBlank(message = "入场人ID不能为空") @PathVariable String entersId) {
String currentUid = CurrentUtil.getCurrentUid();
AdamEnters enters = adamRdmService.getEntersByUidEntersId(currentUid, entersId);
if (null == enters) return ResponseDto.failure(ErrorMapping.get(10105));
if (null == enters) return ResponseDto.failure(ErrorMapping.get("10105"));
adamEntersService.remove(currentUid, entersId);
return ResponseDto.success();
......@@ -127,10 +131,8 @@ public class AdamEntersController {
@ApiOperationSupport(order = 6)
@ApiOperation(value = "入场人详情")
@PostMapping("query/{id}")
public ResponseDto<AdamEntersVo> query(@PathVariable(name = "id") String entersId,
@RequestParam(name = "uid", required = false) String uid) {
// TODO: 2021/4/28 校验
public ResponseDto<AdamEntersVo> query(@NotBlank(message = "入场人ID不能为空") @PathVariable(name = "id") String entersId,
@NotBlank(message = "用户ID不能为空") @RequestParam(required = false) String uid) {
AdamEnters info = adamRdmService.getEntersByUidEntersId(StringUtils.isBlank(uid) ? CurrentUtil.getCurrentUid() : uid, entersId);
return null == info ? ResponseDto.failure(ErrorMapping.get(10105)) : ResponseDto.success(AdamEntersVo.getNew().copy(info));
......
......@@ -27,8 +27,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.util.DigestUtils;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.HashMap;
......@@ -38,6 +42,7 @@ import java.util.Objects;
@ApiSupport(order = 10010)
@Api(tags = "用户登录")
@Slf4j
@Validated
@RestController
@RequestMapping("")
public class AdamLoginController {
......@@ -83,8 +88,8 @@ public class AdamLoginController {
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "mobile", value = "手机号"),
})
@GetMapping(value = {"send"})
public ResponseDto<Object> sendSms(@RequestParam String mobile) {
log.info("send to mobile:{}", mobile);
public ResponseDto<Object> sendSms(@Pattern(regexp = "\\d{11}", message = "手机号格式有误") @RequestParam String mobile) {
log.debug("send to mobile:{}", mobile);
LinkedMultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("mobile", mobile);
......@@ -112,9 +117,11 @@ public class AdamLoginController {
@ApiImplicitParam(type = "body", required = true, dataType = "String", name = "code", value = "验证码"),
})
@PostMapping(value = {"login/sms"})
public ResponseDto<AdamLoginInfoVo> loginBySms(@RequestParam String mobile, @RequestParam String code) {
// TODO: 2021/5/12 参数检验
log.info("mobile:{},code:{}", mobile, code);
public ResponseDto<AdamLoginInfoVo> loginBySms(@Pattern(regexp = "\\d{11}", message = "手机号格式有误")
@RequestParam String mobile,
@Pattern(regexp = "\\d{6}", message = "验证码格式有误")
@RequestParam String code) {
log.debug("mobile:{},code:{}", mobile, code);
if (!this.checkSmsCode(mobile, code)) return ResponseDto.failure(ErrorMapping.get("10002"));
......@@ -123,10 +130,10 @@ public class AdamLoginController {
StringUtils.isEmpty(uid) ? adamUserService.register(mobile) : adamRdmService.getUserInfoVoByUid(uid);
AdamLoginInfoVo loginInfoVo = AdamLoginInfoVo.getNew();
// if (userInfoVo.getIsComplete() == 1) {
loginInfoVo.setRealNameInfo(adamRdmService.getRealInfoVoByUid(userInfoVo.getUid()));
loginInfoVo.setThirdPartInfo(adamRdmService.getThirdPartVoListByUid(userInfoVo.getUid()));
loginInfoVo.setUserMemberVo(adamRdmService.getUserMemberVoByUid(userInfoVo.getUid()));
loginInfoVo.setMemberSimpleVo(adamRdmService.getMemberSimpleVo());
loginInfoVo.setRealNameInfo(adamRdmService.getRealInfoVoByUid(userInfoVo.getUid()));
loginInfoVo.setThirdPartInfo(adamRdmService.getThirdPartVoListByUid(userInfoVo.getUid()));
loginInfoVo.setUserMemberVo(adamRdmService.getUserMemberVoByUid(userInfoVo.getUid()));
loginInfoVo.setMemberSimpleVo(adamRdmService.getMemberSimpleVo());
// }
loginInfoVo.setUserInfo(userInfoVo);
loginInfoVo.setToken(this.ssoProcess(userInfoVo));
......@@ -139,9 +146,8 @@ public class AdamLoginController {
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "accessToken", value = "访问令牌"),
})
@PostMapping(value = {"login/mobile"})
public ResponseDto<AdamLoginInfoVo> loginByMobile(@RequestParam String accessToken) {
// TODO: 2021/5/10
log.info("login by mobile access token:{}", accessToken);
public ResponseDto<AdamLoginInfoVo> loginByMobile(@NotBlank(message = "访问令牌不能为空") @RequestParam String accessToken) {
log.debug("login by mobile access token:{}", accessToken);
String mobile = this.getMobile(accessToken);
if (StringUtils.isEmpty(mobile)) return ResponseDto.failure(ErrorMapping.get("10005"));
......@@ -151,10 +157,10 @@ public class AdamLoginController {
StringUtils.isEmpty(uid) ? adamUserService.register(mobile) : adamRdmService.getUserInfoVoByUid(uid);
AdamLoginInfoVo loginInfoVo = AdamLoginInfoVo.getNew();
// if (loginInfoVo.getUserInfo().getIsComplete() == 1) {
loginInfoVo.setRealNameInfo(adamRdmService.getRealInfoVoByUid(userInfoVo.getUid()));
loginInfoVo.setThirdPartInfo(adamRdmService.getThirdPartVoListByUid(userInfoVo.getUid()));
loginInfoVo.setUserMemberVo(adamRdmService.getUserMemberVoByUid(userInfoVo.getUid()));
loginInfoVo.setMemberSimpleVo(adamRdmService.getMemberSimpleVo());
loginInfoVo.setRealNameInfo(adamRdmService.getRealInfoVoByUid(userInfoVo.getUid()));
loginInfoVo.setThirdPartInfo(adamRdmService.getThirdPartVoListByUid(userInfoVo.getUid()));
loginInfoVo.setUserMemberVo(adamRdmService.getUserMemberVoByUid(userInfoVo.getUid()));
loginInfoVo.setMemberSimpleVo(adamRdmService.getMemberSimpleVo());
// }
loginInfoVo.setUserInfo(userInfoVo);
loginInfoVo.setToken(this.ssoProcess(userInfoVo));
......@@ -164,9 +170,12 @@ public class AdamLoginController {
@ApiOperationSupport(order = 5)
@ApiOperation(value = "第三方账号登录")
@PostMapping(value = {"login/tpa"})
public ResponseDto<AdamLoginInfoVo> loginByTpa(@RequestBody AdamThirdPartParam parameter) {
// TODO: 2021/5/10
log.info("login by tpa:{}", JsonUtils.toJson(parameter));
public ResponseDto<AdamLoginInfoVo> loginByTpa(@RequestBody @Valid AdamThirdPartParam parameter) {
log.debug("login by tpa:{}", JsonUtils.toJson(parameter));
if (StringUtils.isBlank(parameter.getOpenId())) {
return ResponseDto.failure(ErrorMapping.get("10009"));
}
AdamLoginInfoVo loginInfoVo = AdamLoginInfoVo.getNew();
if (StringUtils.isEmpty(parameter.getMobile())) {
......
......@@ -2,6 +2,7 @@ package com.liquidnet.service.adam.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.liquidnet.commons.lang.constant.LnsRegex;
import com.liquidnet.commons.lang.util.CurrentUtil;
import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.commons.lang.util.HttpUtil;
......@@ -20,14 +21,20 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.util.CollectionUtils;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.util.*;
@ApiSupport(order = 10020)
@Api(tags = "用户中心")
@Slf4j
@Validated
@RestController
@RequestMapping("user")
public class AdamUserController {
......@@ -47,12 +54,17 @@ public class AdamUserController {
@ApiOperationSupport(order = 1)
@ApiOperation(value = "个人资料编辑")
@PostMapping(value = {"edit"})
public ResponseDto<AdamUserInfoVo> edit(@RequestBody AdamUserInfoParam parameter) {
// TODO: 2021/5/10
log.info("parameter:{}", JsonUtils.toJson(parameter));
String currentUid = CurrentUtil.getCurrentUid();
public ResponseDto<AdamUserInfoVo> edit(@RequestBody @Valid AdamUserInfoParam parameter) {
log.debug("parameter:{}", JsonUtils.toJson(parameter));
AdamUserInfoVo editUserInfoVo = adamRdmService.getUserInfoVoByUid(currentUid);
if (!this.getTagsForSex().getData().contains(parameter.getSex())) {
return ResponseDto.failure(ErrorMapping.get("10011"));
}
if (!this.getTagsForMusic().getData().contains(parameter.getTagMe())) {
return ResponseDto.failure(ErrorMapping.get("10012"));
}
AdamUserInfoVo editUserInfoVo = adamRdmService.getUserInfoVoByUid(CurrentUtil.getCurrentUid());
editUserInfoVo.setAvatar(parameter.getAvatar());
editUserInfoVo.setBackground(parameter.getBackground());
editUserInfoVo.setNickname(parameter.getNickname());
......@@ -72,40 +84,50 @@ public class AdamUserController {
@ApiOperationSupport(order = 2)
@ApiOperation(value = "音乐风格")
@GetMapping(value = {"tag/ms"})
public ResponseDto<List<AdamTagParentVo>> getMsTag() {
List<AdamTagParentVo> tagMsVoList = new ArrayList<>();
tagMsVoList.add(AdamTagParentVo.getNew().setVal("MMS01").setDesc("民歌").setTagVos(Arrays.asList(
AdamTagVo.getNew().setVal("MMS0101").setDesc("A"),
AdamTagVo.getNew().setVal("MMS0102").setDesc("B")
)));
tagMsVoList.add(AdamTagParentVo.getNew().setVal("MMS02").setDesc("house").setTagVos(Arrays.asList(
AdamTagVo.getNew().setVal("MMS0201").setDesc("C"),
AdamTagVo.getNew().setVal("MMS0202").setDesc("D")
)));
tagMsVoList.add(AdamTagParentVo.getNew().setVal("MMS03").setDesc("R&B").setTagVos(Arrays.asList(
AdamTagVo.getNew().setVal("MMS0301").setDesc("E"),
AdamTagVo.getNew().setVal("MMS0302").setDesc("F")
)));
return ResponseDto.success(tagMsVoList);
public ResponseDto<List<AdamTagParentVo>> getTagsForMusic() {
List<AdamTagParentVo> tagsForMusic = adamRdmService.getTagsForMusic();
if (CollectionUtils.isEmpty(tagsForMusic)) {
tagsForMusic = new ArrayList<>();
tagsForMusic.add(AdamTagParentVo.getNew().setVal("MMS01").setDesc("民歌").setTagVos(Arrays.asList(
AdamTagVo.getNew().setVal("MMS0101").setDesc("A"),
AdamTagVo.getNew().setVal("MMS0102").setDesc("B")
)));
tagsForMusic.add(AdamTagParentVo.getNew().setVal("MMS02").setDesc("house").setTagVos(Arrays.asList(
AdamTagVo.getNew().setVal("MMS0201").setDesc("C"),
AdamTagVo.getNew().setVal("MMS0202").setDesc("D")
)));
tagsForMusic.add(AdamTagParentVo.getNew().setVal("MMS03").setDesc("R&B").setTagVos(Arrays.asList(
AdamTagVo.getNew().setVal("MMS0301").setDesc("E"),
AdamTagVo.getNew().setVal("MMS0302").setDesc("F")
)));
adamRdmService.setTagsForMusic(tagsForMusic);
}
return ResponseDto.success(tagsForMusic);
}
@ApiOperationSupport(order = 3)
@ApiOperation(value = "性别列表")
@GetMapping(value = {"tag/sex"})
public ResponseDto<List<AdamTagVo>> getSexTag() {
List<AdamTagVo> tagSexVoList = new ArrayList<>();
tagSexVoList.add(AdamTagVo.getNew().setVal("MS00").setDesc("其他性别"));
tagSexVoList.add(AdamTagVo.getNew().setVal("MS01").setDesc("男性"));
tagSexVoList.add(AdamTagVo.getNew().setVal("MS02").setDesc("女性"));
tagSexVoList.add(AdamTagVo.getNew().setVal("MS03").setDesc("跨性别女性"));
tagSexVoList.add(AdamTagVo.getNew().setVal("MS04").setDesc("跨性别男性"));
tagSexVoList.add(AdamTagVo.getNew().setVal("MS05").setDesc("双性别者"));
tagSexVoList.add(AdamTagVo.getNew().setVal("MS06").setDesc("性别模糊"));
tagSexVoList.add(AdamTagVo.getNew().setVal("MS07").setDesc("性别流动"));
tagSexVoList.add(AdamTagVo.getNew().setVal("MS08").setDesc("无性别者"));
tagSexVoList.add(AdamTagVo.getNew().setVal("MS09").setDesc("不确定性别"));
tagSexVoList.add(AdamTagVo.getNew().setVal("MS10").setDesc("不在乎性别"));
return ResponseDto.success(tagSexVoList);
public ResponseDto<List<AdamTagVo>> getTagsForSex() {
List<AdamTagVo> tagsForSex = adamRdmService.getTagsForSex();
if (CollectionUtils.isEmpty(tagsForSex)) {
tagsForSex = new ArrayList<>();
tagsForSex.add(AdamTagVo.getNew().setVal("MS00").setDesc("其他性别"));
tagsForSex.add(AdamTagVo.getNew().setVal("MS01").setDesc("男性"));
tagsForSex.add(AdamTagVo.getNew().setVal("MS02").setDesc("女性"));
tagsForSex.add(AdamTagVo.getNew().setVal("MS03").setDesc("跨性别女性"));
tagsForSex.add(AdamTagVo.getNew().setVal("MS04").setDesc("跨性别男性"));
tagsForSex.add(AdamTagVo.getNew().setVal("MS05").setDesc("双性别者"));
tagsForSex.add(AdamTagVo.getNew().setVal("MS06").setDesc("性别模糊"));
tagsForSex.add(AdamTagVo.getNew().setVal("MS07").setDesc("性别流动"));
tagsForSex.add(AdamTagVo.getNew().setVal("MS08").setDesc("无性别者"));
tagsForSex.add(AdamTagVo.getNew().setVal("MS09").setDesc("不确定性别"));
tagsForSex.add(AdamTagVo.getNew().setVal("MS10").setDesc("不在乎性别"));
adamRdmService.setTagsForSex(tagsForSex);
}
return ResponseDto.success(tagsForSex);
}
@ApiOperationSupport(order = 4)
......@@ -115,9 +137,11 @@ public class AdamUserController {
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "code", value = "验证码"),
})
@PostMapping(value = {"edit/mobile"})
public ResponseDto<Object> editMobile(@RequestParam String mobile, @RequestParam String code) {
// TODO: 2021/5/10
log.info("mobile:{},code:{}", mobile, code);
public ResponseDto<Object> editMobile(@Pattern(regexp = "\\d{11}", message = "手机号格式有误")
@RequestParam String mobile,
@Pattern(regexp = "\\d{6}", message = "验证码格式有误")
@RequestParam String code) {
log.debug("mobile:{},code:{}", mobile, code);
if (!this.checkSmsCode(mobile, code)) return ResponseDto.failure(ErrorMapping.get("10002"));
......@@ -135,9 +159,11 @@ public class AdamUserController {
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "idCard", value = "证件号"),
})
@PostMapping(value = {"identity"})
public ResponseDto<AdamRealInfoVo> identity(@RequestParam String name, @RequestParam String idCard) {
// TODO: 2021/5/10
log.info("name:{},idCard:{}", name, idCard);
public ResponseDto<AdamRealInfoVo> identity(@Pattern(regexp = LnsRegex.Valid.CHINESE_HANZI, message = "姓名必须为2~20位汉字")
@RequestParam String name,
@Pattern(regexp = LnsRegex.Valid.CHINESE_ID_CARD, message = "身份证号格式有误")
@RequestParam String idCard) {
log.debug("name:{},idCard:{}", name, idCard);
AdamRealInfoVo infoVo = adamUserService.identity(CurrentUtil.getCurrentUid(), name, idCard);
......@@ -155,7 +181,6 @@ public class AdamUserController {
// public ResponseDto<Object> editPwd(@RequestParam String mobile, @RequestParam String password, @RequestParam String code) {
// log.info("mobile:{},password:{},code:{}", mobile, password, code);
//
// // TODO: 2021/5/10
//
//
// return ResponseDto.success();
......@@ -164,9 +189,13 @@ public class AdamUserController {
@ApiOperationSupport(order = 7)
@ApiOperation(value = "绑定第三方账号")
@PostMapping(value = {"tpa/bind"})
public ResponseDto<List<AdamThirdPartInfoVo>> bindTpa(@RequestBody AdamThirdPartParam parameter) {
// TODO: 2021/5/10
log.info("login by tpa:{}", JsonUtils.toJson(parameter));
public ResponseDto<List<AdamThirdPartInfoVo>> bindTpa(@RequestBody @Valid AdamThirdPartParam parameter) {
log.debug("login by tpa:{}", JsonUtils.toJson(parameter));
if (StringUtils.isBlank(parameter.getOpenId())) {
return ResponseDto.failure(ErrorMapping.get("10009"));
}
String currentUid = CurrentUtil.getCurrentUid();
String existUid = adamRdmService.getUidByPlatformOpenId(parameter.getPlatform(), parameter.getOpenId());
......@@ -197,10 +226,10 @@ public class AdamUserController {
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "platform", value = "平台类型", allowableValues = "WEIBO,WECHAT,QQ"),
})
@PostMapping(value = {"tpa/unbind/{platform}"})
public ResponseDto<List<AdamThirdPartInfoVo>> unbindTpa(@PathVariable String platform) {
// TODO: 2021/5/10
public ResponseDto<List<AdamThirdPartInfoVo>> unbindTpa(@Pattern(regexp = "\\b(WEIBO,WECHAT,QQ)\\b", message = "平台类型无效")
@PathVariable String platform) {
String currentUid = CurrentUtil.getCurrentUid();
log.info("unbind tpa.platform:{},uid:{}", platform, currentUid);
log.debug("unbind tpa.platform:{},uid:{}", platform, currentUid);
adamUserService.unBindTpa(currentUid, platform);
......
......@@ -227,4 +227,24 @@ public class AdamRdmServiceImpl implements IAdamRdmService {
}
return simpleVo;
}
@Override
public boolean setTagsForSex(List<AdamTagVo> voList) {
return redisUtil.set(AdamRedisConst.INFO_TAGS_SEX, voList);
}
@Override
public List<AdamTagVo> getTagsForSex() {
return (List<AdamTagVo>) redisUtil.get(AdamRedisConst.INFO_TAGS_SEX);
}
@Override
public boolean setTagsForMusic(List<AdamTagParentVo> voList) {
return redisUtil.set(AdamRedisConst.INFO_TAGS_MUSIC, voList);
}
@Override
public List<AdamTagParentVo> getTagsForMusic() {
return (List<AdamTagParentVo>) redisUtil.get(AdamRedisConst.INFO_TAGS_MUSIC);
}
}
......@@ -6,6 +6,14 @@
10006=第三方账号未注册
10007=第三方账号已绑定其它账号
10008=已绑定同类型第三方账号
10009=OPENID不能为空
10010=
10011=性别标签无效
10012=音乐风格标签无效
10013=
10014=
10015=入场人ID不能为空
10016=收货地址ID不能为空
10101=姓名或身份证件号无效
......
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