This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
4,211 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
kkmall-common/src/main/java/name/lkk/common/enume/OrderStatusEnum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package name.lkk.common.enume; | ||
|
||
public enum OrderStatusEnum { | ||
CREATE_NEW(0,"待付款"), | ||
PAYED(1,"已付款"), | ||
SENDED(2,"已发货"), | ||
RECIEVED(3,"已完成"), | ||
CANCLED(4,"已取消"), | ||
SERVICING(5,"售后中"), | ||
SERVICED(6,"售后完成"); | ||
private Integer code; | ||
private String msg; | ||
|
||
OrderStatusEnum(Integer code, String msg) { | ||
this.code = code; | ||
this.msg = msg; | ||
} | ||
|
||
public Integer getCode() { | ||
return code; | ||
} | ||
|
||
public String getMsg() { | ||
return msg; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
kkmall-common/src/main/java/name/lkk/common/exception/BizCodeEnum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package name.lkk.common.exception; | ||
|
||
/** | ||
* <p>Title: BizCodeEnum</p> | ||
* Description: | ||
* 错误码和错误信息定义类 | ||
* 1. 错误码定义规则为5为数字 | ||
* 2. 前两位表示业务场景,最后三位表示错误码。例如:100001。10:通用 001:系统未知异常 | ||
* 3. 维护错误码后需要维护错误描述,将他们定义为枚举形式 | ||
* 错误码列表: | ||
* 10: 通用 | ||
* 001:参数格式校验 | ||
* 002: 短信验证码频率太高 | ||
* 11: 商品 | ||
* 12: 订单 | ||
* 13: 购物车 | ||
* 14: 物流 | ||
* 15: 用户 | ||
* 21: 库存 | ||
*/ | ||
public enum BizCodeEnum { | ||
UNKNOW_EXCEPTION(10000, "系统未知异常"), | ||
VAILD_EXCEPTION(10001, "参数格式校验失败"), | ||
SMS_CODE_EXCEPTION(10002, "验证码获取频率太高,稍后再试"), | ||
TO_MANY_REQUEST(10003, "请求流量过大"), | ||
SMS_SEND_CODE_EXCEPTION(10403, "短信发送失败"), | ||
USER_EXIST_EXCEPTION(15001, "用户已经存在"), | ||
PHONE_EXIST_EXCEPTION(15002, "手机号已经存在"), | ||
LOGINACTT_PASSWORD_ERROR(15003, "账号或密码错误"), | ||
SOCIALUSER_LOGIN_ERROR(15004, "社交账号登录失败"), | ||
NOT_STOCK_EXCEPTION(21000, "商品库存不足"), | ||
PRODUCT_UP_EXCEPTION(11000,"商品上架异常"); | ||
|
||
private int code; | ||
|
||
private String msg; | ||
|
||
BizCodeEnum(int code, String msg) { | ||
this.code = code; | ||
this.msg = msg; | ||
} | ||
|
||
public int getCode() { | ||
return code; | ||
} | ||
|
||
public String getMsg() { | ||
return msg; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
kkmall-common/src/main/java/name/lkk/common/exception/NotStockException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package name.lkk.common.exception; | ||
|
||
/** | ||
* <p>Title: NotStockException</p> | ||
* Description: | ||
* date:2020/7/2 11:43 | ||
*/ | ||
public class NotStockException extends RuntimeException{ | ||
|
||
private Long skuId; | ||
|
||
public NotStockException(String msg) { | ||
super(msg + "号商品没有足够的库存了"); | ||
} | ||
|
||
public Long getSkuId() { | ||
return skuId; | ||
} | ||
|
||
public void setSkuId(Long skuId) { | ||
this.skuId = skuId; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
kkmall-common/src/main/java/name/lkk/common/valid/AddGroup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package name.lkk.common.valid; | ||
|
||
/** | ||
* 新增分组 | ||
*/ | ||
public interface AddGroup { | ||
} |
30 changes: 30 additions & 0 deletions
30
kkmall-common/src/main/java/name/lkk/common/valid/ListValue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package name.lkk.common.valid; | ||
|
||
import javax.validation.Constraint; | ||
import javax.validation.Payload; | ||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
import static java.lang.annotation.ElementType.*; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
/** | ||
* <p>Title: ListValue</p> | ||
* Description:JSR303自定义注解 必须有前三个方法 | ||
* date:2020/6/1 23:25 | ||
*/ | ||
@Documented | ||
// 指定校验器 这里可以指定多个不同的校验器 | ||
@Constraint(validatedBy = { ListValueConstraintValidator.class }) | ||
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE }) | ||
@Retention(RUNTIME) | ||
public @interface ListValue { | ||
String message() default "{com.firenay.common.valid.ListValue.message}"; | ||
|
||
Class<?>[] groups() default { }; | ||
|
||
Class<? extends Payload>[] payload() default { }; | ||
|
||
int[] vals() default { }; | ||
} |
40 changes: 40 additions & 0 deletions
40
kkmall-common/src/main/java/name/lkk/common/valid/ListValueConstraintValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package name.lkk.common.valid; | ||
|
||
import javax.validation.ConstraintValidator; | ||
import javax.validation.ConstraintValidatorContext; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
/** | ||
* <p>Title: ListValueConstraintValidator</p> | ||
* Description:校验器:规定ListValue这个注解 用于校验 Integer 类型的数据 | ||
* POSTman :{"name":"aaa","logo":"https://github.com/1046762075","sort":0,"firstLetter":"d","showStatus":0} | ||
* date:2020/6/1 23:33 | ||
*/ | ||
public class ListValueConstraintValidator implements ConstraintValidator<ListValue,Integer> { | ||
|
||
/** | ||
* set 里面就是使用注解时规定的值, 例如: @ListValue(vals = {0,1}) set= {0,1} | ||
*/ | ||
private Set<Integer> set = new HashSet<>(); | ||
|
||
//初始化方法 | ||
@Override | ||
public void initialize(ListValue constraintAnnotation) { | ||
|
||
int[] vals = constraintAnnotation.vals(); | ||
for (int val : vals) { | ||
set.add(val); | ||
} | ||
} | ||
|
||
/** | ||
* 判断是否校验成功 | ||
* @param value 需要校验的值 | ||
* 判断这个值再set里面没 | ||
*/ | ||
@Override | ||
public boolean isValid(Integer value, ConstraintValidatorContext context) { | ||
return set.contains(value); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
kkmall-common/src/main/java/name/lkk/common/valid/UpdateGroup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package name.lkk.common.valid; | ||
|
||
/** | ||
* 修改分组 | ||
*/ | ||
public interface UpdateGroup { | ||
} |
4 changes: 4 additions & 0 deletions
4
kkmall-common/src/main/java/name/lkk/common/valid/UpdateStatusGroup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package name.lkk.common.valid; | ||
|
||
public interface UpdateStatusGroup { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
com.firenay.common.valid.ListValue.message=\u5FC5\u987B\u63D0\u4EA4\u6307\u5B9A\u7684\u503C [0,1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.