|
|
@@ -4,6 +4,7 @@ import com.izouma.nineth.enums.OperationType;
|
|
|
import com.izouma.nineth.exception.BusinessException;
|
|
|
import com.izouma.nineth.service.CacheService;
|
|
|
import com.izouma.nineth.service.CollectionService;
|
|
|
+import com.izouma.nineth.service.MintActivityService;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
@@ -27,6 +28,8 @@ public class CacheController {
|
|
|
|
|
|
private final CollectionService collectionService;
|
|
|
|
|
|
+ private final MintActivityService mintActivityService;
|
|
|
+
|
|
|
@RequestMapping("/clear")
|
|
|
@PreAuthorize("hasRole('ADMIN')")
|
|
|
public void clear(String name, String stringParam, Long longParam) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
|
|
|
@@ -78,4 +81,31 @@ public class CacheController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @PostMapping(value = "/mint/operating/{mintActivityId}/{mintNum}/{mintOperationType}")
|
|
|
+ public void operatingMintStock(@PathVariable Long mintActivityId, @PathVariable int mintNum, @PathVariable OperationType mintOperationType){
|
|
|
+ if (Objects.isNull(mintActivityId)) {
|
|
|
+ throw new BusinessException("mintActivityId参数错误");
|
|
|
+ }
|
|
|
+ if (0 >= mintNum) {
|
|
|
+ throw new BusinessException("num参数错误");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(mintOperationType)) {
|
|
|
+ throw new BusinessException("操作类型不可为空");
|
|
|
+ }
|
|
|
+ switch (mintOperationType) {
|
|
|
+ case INCREASE_STOCK:
|
|
|
+ log.info(String.format("mintActivityId:[%S] 加库存:[%S]", mintActivityId, mintNum));
|
|
|
+ mintActivityService.increaseStock(mintActivityId, mintNum);
|
|
|
+ break;
|
|
|
+ case DECREASE_STOCK:
|
|
|
+ log.info(String.format("mintActivityId:[%S] 减库存:[%S]", mintActivityId, mintNum));
|
|
|
+ mintActivityService.decreaseStock(mintActivityId, mintNum);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ String err = String.format("暂不支持的操作类型:[%S]", mintOperationType);
|
|
|
+ log.info(err);
|
|
|
+ throw new BusinessException(err);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|