Commit aabd74f8 authored by 33's avatar 33

Api版权接口

parent 4f0360ab
...@@ -25,7 +25,22 @@ public enum ResultCode implements IErrorCode { ...@@ -25,7 +25,22 @@ public enum ResultCode implements IErrorCode {
PAY_FAILED(422, "支付失败"), PAY_FAILED(422, "支付失败"),
REFUND_FAILED(422, "退款失败"), REFUND_FAILED(422, "退款失败"),
signature_wrong(440, "签名错误"), app_key_wrong(440, "app_key错误"),
biz_id_wrong(440, "biz_id错误"),
signature_wrong(440, "signature错误"),
publish_state_wrong(440, "发表状态错误"),
first_publish_date_wrong(440, "首次发表日期错误"),
first_publish_city_wrong(440, "首次发表城市错误"),
first_publish_province_wrong(440, "首次发表省份错误"),
sign_type_wrong(440, "署名类型错误"),
owner_type_wrong(440, "著作权人类型错误"),
is_effective_wrong(440, "证件是否长期有效错误"),
effective_end_date_wrong(440, "证件有效终止时间错误"),
id_type_wrong(440, "证件类型错误"),
positive_photo_wrong(440, "正面照片错误"),
back_photo_wrong(440, "反面照片错误"),
personal_photo_wrong(440, "手持身份证照片错误"),
certificates_photo_wrong(440, "证件照片错误"),
; ;
......
...@@ -16,7 +16,7 @@ import java.util.Date; ...@@ -16,7 +16,7 @@ import java.util.Date;
@Data @Data
public class CopyrightOwnerOO { public class CopyrightOwnerOO {
@NotNull(message = "著作权人类型不能为空") @NotNull(message = "著作权人类型不能为空")
@ApiModelProperty(value = "类别 0-自然人 1-法人") @ApiModelProperty(value = "著作权人类型 0-自然人 1-法人")
private Integer type; private Integer type;
@NotBlank(message = "著作权人不能为空") @NotBlank(message = "著作权人不能为空")
...@@ -28,7 +28,7 @@ public class CopyrightOwnerOO { ...@@ -28,7 +28,7 @@ public class CopyrightOwnerOO {
private String idNumber; private String idNumber;
@NotNull(message = "证件是否长期有效不能为空") @NotNull(message = "证件是否长期有效不能为空")
@ApiModelProperty(value = "是否长期有效 0-否 1-是") @ApiModelProperty(value = "证件是否长期有效 0-否 1-是")
private Integer isEffective; private Integer isEffective;
@DateTimeFormat(pattern = "yyyy-MM-dd") @DateTimeFormat(pattern = "yyyy-MM-dd")
......
...@@ -190,6 +190,7 @@ public class CopyrightApiServiceImpl extends ServiceImpl<CopyrightApiMapper, Cop ...@@ -190,6 +190,7 @@ public class CopyrightApiServiceImpl extends ServiceImpl<CopyrightApiMapper, Cop
} }
@Override @Override
@Transactional(rollbackFor = Exception.class)
public void pass(Integer id) { public void pass(Integer id) {
RLock lock = redisson.getLock("copyright:api:apply:" + id); RLock lock = redisson.getLock("copyright:api:apply:" + id);
boolean tryLock; boolean tryLock;
......
...@@ -44,12 +44,12 @@ public class CopyrightApiController { ...@@ -44,12 +44,12 @@ public class CopyrightApiController {
String appKey = baseOO.getAppKey(); String appKey = baseOO.getAppKey();
OpenKeyDO openKeyDO = openKeyService.getByAppKey(appKey); OpenKeyDO openKeyDO = openKeyService.getByAppKey(appKey);
if (openKeyDO == null) { if (openKeyDO == null) {
throw GlobalException.newException(ResultCode.VALIDATE_FAILED); throw GlobalException.newException(ResultCode.app_key_wrong);
} }
String bizId = baseOO.getBizId(); String bizId = baseOO.getBizId();
if (StringUtils.isBlank(bizId)) { if (StringUtils.isBlank(bizId)) {
throw GlobalException.newException(ResultCode.VALIDATE_FAILED); throw GlobalException.newException(ResultCode.biz_id_wrong);
} }
String signature = baseOO.getSignature(); String signature = baseOO.getSignature();
...@@ -66,21 +66,30 @@ public class CopyrightApiController { ...@@ -66,21 +66,30 @@ public class CopyrightApiController {
} }
Integer publishState = copyrightOO.getPublishState(); Integer publishState = copyrightOO.getPublishState();
if (publishState == null || publishState != 0 && publishState != 1) { if (publishState != 0 && publishState != 1) {
throw GlobalException.newException(ResultCode.VALIDATE_FAILED); throw GlobalException.newException(ResultCode.publish_state_wrong);
} }
// 如果发表状态是已发表的话,需要传入首次发表日期和省市 // 如果发表状态是已发表的话,需要传入首次发表日期和省市
if (SystemConstant.BOOLEAN_DATA_TRUE.equals(publishState) && if (SystemConstant.BOOLEAN_DATA_TRUE.equals(publishState)) {
(copyrightOO.getFirstPublishDate() == null || Date firstPublishDate = copyrightOO.getFirstPublishDate();
StringUtils.isAnyBlank(copyrightOO.getFirstPublishCity(), copyrightOO.getFirstPublishProvince()))) { if (firstPublishDate == null) {
throw GlobalException.newException(ResultCode.VALIDATE_FAILED); throw GlobalException.newException(ResultCode.first_publish_date_wrong);
}
String firstPublishCity = copyrightOO.getFirstPublishCity();
if (StringUtils.isBlank(firstPublishCity)) {
throw GlobalException.newException(ResultCode.first_publish_city_wrong);
}
String firstPublishProvince = copyrightOO.getFirstPublishProvince();
if (StringUtils.isBlank(firstPublishProvince)) {
throw GlobalException.newException(ResultCode.first_publish_province_wrong);
}
} }
List<CopyrightAuthorOO> authors = copyrightOO.getAuthors(); List<CopyrightAuthorOO> authors = copyrightOO.getAuthors();
for (CopyrightAuthorOO author : authors) { for (CopyrightAuthorOO author : authors) {
String signType = author.getSignType(); String signType = author.getSignType();
if (!"本名".equals(signType) && !"别名".equals(signType) && !"匿名".equals(signType)) { if (!"本名".equals(signType) && !"别名".equals(signType) && !"匿名".equals(signType)) {
throw GlobalException.newException(ResultCode.VALIDATE_FAILED); throw GlobalException.newException(ResultCode.sign_type_wrong);
} }
} }
...@@ -88,33 +97,39 @@ public class CopyrightApiController { ...@@ -88,33 +97,39 @@ public class CopyrightApiController {
for (CopyrightOwnerOO owner : owners) { for (CopyrightOwnerOO owner : owners) {
Integer type = owner.getType(); Integer type = owner.getType();
if (type != 0 && type != 1) { if (type != 0 && type != 1) {
throw GlobalException.newException(ResultCode.VALIDATE_FAILED); throw GlobalException.newException(ResultCode.owner_type_wrong);
} }
Integer isEffective = owner.getIsEffective(); Integer isEffective = owner.getIsEffective();
if (isEffective != 0 && isEffective != 1) { if (isEffective != 0 && isEffective != 1) {
throw GlobalException.newException(ResultCode.VALIDATE_FAILED); throw GlobalException.newException(ResultCode.is_effective_wrong);
} }
if (isEffective == 0) { if (isEffective == 0) {
Date endDate = owner.getEffectiveEndDate(); Date endDate = owner.getEffectiveEndDate();
if (endDate == null) { if (endDate == null) {
throw GlobalException.newException(ResultCode.VALIDATE_FAILED); throw GlobalException.newException(ResultCode.effective_end_date_wrong);
} }
} }
Integer idType = owner.getIdType(); Integer idType = owner.getIdType();
if (idType < 0 || idType > 7) { if (idType < 0 || idType > 7) {
throw GlobalException.newException(ResultCode.VALIDATE_FAILED); throw GlobalException.newException(ResultCode.id_type_wrong);
} }
if (idType == 0) { if (idType == 0) {
String positivePhoto = owner.getPositivePhoto(); String positivePhoto = owner.getPositivePhoto();
if (StringUtils.isBlank(positivePhoto)) {
throw GlobalException.newException(ResultCode.positive_photo_wrong);
}
String backPhoto = owner.getBackPhoto(); String backPhoto = owner.getBackPhoto();
if (StringUtils.isBlank(backPhoto)) {
throw GlobalException.newException(ResultCode.back_photo_wrong);
}
String personalPhoto = owner.getPersonalPhoto(); String personalPhoto = owner.getPersonalPhoto();
if (StringUtils.isAnyBlank(positivePhoto, backPhoto, personalPhoto)) { if (StringUtils.isBlank(personalPhoto)) {
throw GlobalException.newException(ResultCode.VALIDATE_FAILED); throw GlobalException.newException(ResultCode.personal_photo_wrong);
} }
} else { } else {
String certificatesPhoto = owner.getCertificatesPhoto(); String certificatesPhoto = owner.getCertificatesPhoto();
if (StringUtils.isBlank(certificatesPhoto)) { if (StringUtils.isBlank(certificatesPhoto)) {
throw GlobalException.newException(ResultCode.VALIDATE_FAILED); throw GlobalException.newException(ResultCode.certificates_photo_wrong);
} }
} }
} }
......
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