Search in sources :

Example 1 with SeckillExecutionDTO

use of com.goodskill.api.dto.SeckillExecutionDTO in project goodsKill by techa03.

the class SeckillController method execute.

@PostMapping(value = "/{seckillId}/{md5}/execution", produces = { "application/json;charset=UTF-8" })
@ResponseBody
public Result<SeckillExecutionDTO> execute(@PathVariable("seckillId") Long seckillId, @PathVariable("md5") String md5, @CookieValue(value = "killPhone", required = false) String phone) {
    Result<SeckillExecutionDTO> result;
    if (phone == null) {
        result = Result.fail("未注册");
        return result;
    }
    try {
        SeckillExecutionDTO execution = seckillService.executeSeckill(seckillId, phone, md5);
        result = Result.ok(execution);
    } catch (RepeatKillException e) {
        logger.info(e.getMessage(), e);
        SeckillExecutionDTO execution = new SeckillExecutionDTO(seckillId, SeckillStatEnum.REPEAT_KILL.getStateInfo());
        result = Result.fail(execution, null);
    } catch (SeckillCloseException e) {
        logger.info(e.getMessage(), e);
        SeckillExecutionDTO execution = new SeckillExecutionDTO(seckillId, SeckillStatEnum.END.getStateInfo());
        result = Result.fail(execution, null);
    } catch (Exception e) {
        logger.info(e.getMessage(), e);
        SeckillExecutionDTO execution = new SeckillExecutionDTO(seckillId, SeckillStatEnum.INNER_ERROR.getStateInfo());
        result = Result.fail(execution, null);
    }
    return result;
}
Also used : SeckillCloseException(com.goodskill.common.exception.SeckillCloseException) RepeatKillException(com.goodskill.common.exception.RepeatKillException) RepeatKillException(com.goodskill.common.exception.RepeatKillException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) SeckillCloseException(com.goodskill.common.exception.SeckillCloseException) SeckillExecutionDTO(com.goodskill.api.dto.SeckillExecutionDTO)

Aggregations

SeckillExecutionDTO (com.goodskill.api.dto.SeckillExecutionDTO)1 RepeatKillException (com.goodskill.common.exception.RepeatKillException)1 SeckillCloseException (com.goodskill.common.exception.SeckillCloseException)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1