秒杀时间段优化,hutool升级到5.2.5,swagger contact修改去掉idea启动的warn及其其他警告

This commit is contained in:
hupeng
2020-04-06 12:09:51 +08:00
parent d0a8cd1c7a
commit 2fa92da5c9
16 changed files with 48 additions and 11 deletions

View File

@ -37,7 +37,7 @@
<swagger.version>2.9.2</swagger.version> <swagger.version>2.9.2</swagger.version>
<fastjson.version>1.2.54</fastjson.version> <fastjson.version>1.2.54</fastjson.version>
<druid.version>1.1.10</druid.version> <druid.version>1.1.10</druid.version>
<hutool.version>4.6.0</hutool.version> <hutool.version>5.2.5</hutool.version>
<commons-pool2.version>2.5.0</commons-pool2.version> <commons-pool2.version>2.5.0</commons-pool2.version>
<mapstruct.version>1.2.0.Final</mapstruct.version> <mapstruct.version>1.2.0.Final</mapstruct.version>
</properties> </properties>

View File

@ -19,4 +19,7 @@ ADD COLUMN `give_price` decimal(8, 2) NULL DEFAULT 0 COMMENT '赠送金额' AFTE
ALTER TABLE `yx_system_attachment` ALTER TABLE `yx_system_attachment`
ADD COLUMN `uid` int(0) UNSIGNED NULL DEFAULT 0 COMMENT '用户id' AFTER `module_type`, ADD COLUMN `uid` int(0) UNSIGNED NULL DEFAULT 0 COMMENT '用户id' AFTER `module_type`,
ADD COLUMN `invite_code` varchar(50) NULL DEFAULT '' COMMENT '邀请码' AFTER `uid` ADD COLUMN `invite_code` varchar(50) NULL DEFAULT '' COMMENT '邀请码' AFTER `uid`
ALTER TABLE `yx_store_seckill`
ADD COLUMN `time_id` int(10) UNSIGNED NULL DEFAULT 0 COMMENT '时间段id' AFTER `start_time_date`

View File

@ -12,6 +12,7 @@ import java.util.List;
@ApiModel("分页") @ApiModel("分页")
@SuppressWarnings("unchecked")
public class Paging<T> implements Serializable { public class Paging<T> implements Serializable {
private static final long serialVersionUID = -1683800405530086022L; private static final long serialVersionUID = -1683800405530086022L;

View File

@ -43,7 +43,7 @@ public interface YxStoreSeckillService extends BaseService<YxStoreSeckill> {
* @param limit * @param limit
* @return * @return
*/ */
List<YxStoreSeckillQueryVo> getList(int page, int limit, int startTime,int endTime); List<YxStoreSeckillQueryVo> getList(int page, int limit, int time);
/** /**
* 根据ID获取查询对象 * 根据ID获取查询对象
* @param id * @param id

View File

@ -54,6 +54,7 @@ public class YxStoreSeckillServiceImpl extends BaseServiceImpl<YxStoreSeckillMap
private final YxStoreProductReplyService replyService; private final YxStoreProductReplyService replyService;
/** /**
* 退回库存减少销量 * 退回库存减少销量
* @param num * @param num
@ -104,6 +105,7 @@ public class YxStoreSeckillServiceImpl extends BaseServiceImpl<YxStoreSeckillMap
.replyCount(replyService.productReplyCount(yxStoreSeckillQueryVo.getProductId())) .replyCount(replyService.productReplyCount(yxStoreSeckillQueryVo.getProductId()))
.build(); .build();
return storeSeckillDTO; return storeSeckillDTO;
} }
@ -116,11 +118,13 @@ public class YxStoreSeckillServiceImpl extends BaseServiceImpl<YxStoreSeckillMap
* @return * @return
*/ */
@Override @Override
public List<YxStoreSeckillQueryVo> getList(int page, int limit,int startTime,int endTime) { public List<YxStoreSeckillQueryVo> getList(int page, int limit, int time) {
int nowTime = OrderUtil.getSecondTimestampTwo();
Page<YxStoreSeckill> pageModel = new Page<>(page, limit); Page<YxStoreSeckill> pageModel = new Page<>(page, limit);
QueryWrapper<YxStoreSeckill> wrapper = new QueryWrapper<>(); QueryWrapper<YxStoreSeckill> wrapper = new QueryWrapper<>();
wrapper.eq("is_del",0).eq("status",1) wrapper.eq("is_del",0).eq("status",1)
.le("start_time",startTime).ge("stop_time",endTime).orderByDesc("sort"); .eq("time_id",time)
.le("start_time",nowTime).ge("stop_time",nowTime).orderByDesc("sort");
List<YxStoreSeckillQueryVo> yxStoreSeckillQueryVos = storeSeckillMap List<YxStoreSeckillQueryVo> yxStoreSeckillQueryVos = storeSeckillMap
.toDto(yxStoreSeckillMapper.selectPage(pageModel,wrapper).getRecords()); .toDto(yxStoreSeckillMapper.selectPage(pageModel,wrapper).getRecords());
yxStoreSeckillQueryVos.forEach(item->{ yxStoreSeckillQueryVos.forEach(item->{

View File

@ -22,8 +22,10 @@ import co.yixiang.enums.AppFromEnum;
import co.yixiang.modules.activity.entity.YxStorePink; import co.yixiang.modules.activity.entity.YxStorePink;
import co.yixiang.modules.activity.service.YxStoreCombinationService; import co.yixiang.modules.activity.service.YxStoreCombinationService;
import co.yixiang.modules.activity.service.YxStorePinkService; import co.yixiang.modules.activity.service.YxStorePinkService;
import co.yixiang.modules.activity.web.dto.StoreCombinationDTO;
import co.yixiang.modules.activity.web.param.YxStoreCombinationQueryParam; import co.yixiang.modules.activity.web.param.YxStoreCombinationQueryParam;
import co.yixiang.modules.activity.web.vo.YxStoreCombinationQueryVo; import co.yixiang.modules.activity.web.vo.YxStoreCombinationQueryVo;
import co.yixiang.modules.shop.service.YxStoreProductRelationService;
import co.yixiang.modules.shop.service.YxSystemConfigService; import co.yixiang.modules.shop.service.YxSystemConfigService;
import co.yixiang.modules.user.entity.YxSystemAttachment; import co.yixiang.modules.user.entity.YxSystemAttachment;
import co.yixiang.modules.user.service.YxSystemAttachmentService; import co.yixiang.modules.user.service.YxSystemAttachmentService;
@ -67,6 +69,7 @@ public class StoreCombinationController extends BaseController {
private final YxSystemConfigService systemConfigService; private final YxSystemConfigService systemConfigService;
private final YxUserService yxUserService; private final YxUserService yxUserService;
private final YxSystemAttachmentService systemAttachmentService; private final YxSystemAttachmentService systemAttachmentService;
private final YxStoreProductRelationService relationService;
@Value("${file.path}") @Value("${file.path}")
private String path; private String path;
@ -92,7 +95,10 @@ public class StoreCombinationController extends BaseController {
public ApiResult<Object> detail(@PathVariable Integer id){ public ApiResult<Object> detail(@PathVariable Integer id){
if(ObjectUtil.isNull(id)) return ApiResult.fail("参数有误"); if(ObjectUtil.isNull(id)) return ApiResult.fail("参数有误");
int uid = SecurityUtils.getUserId().intValue(); int uid = SecurityUtils.getUserId().intValue();
return ApiResult.ok(storeCombinationService.getDetail(id,uid)); StoreCombinationDTO storeCombinationDTO = storeCombinationService.getDetail(id,uid);
storeCombinationDTO.setUserCollect(relationService
.isProductRelation(storeCombinationDTO.getStoreInfo().getProductId(),"product",uid,"collect"));
return ApiResult.ok(storeCombinationDTO);
} }
/** /**

View File

@ -18,11 +18,14 @@ import co.yixiang.constant.ShopConstants;
import co.yixiang.modules.activity.service.YxStoreSeckillService; import co.yixiang.modules.activity.service.YxStoreSeckillService;
import co.yixiang.modules.activity.web.dto.SeckillConfigDTO; import co.yixiang.modules.activity.web.dto.SeckillConfigDTO;
import co.yixiang.modules.activity.web.dto.SeckillTimeDTO; import co.yixiang.modules.activity.web.dto.SeckillTimeDTO;
import co.yixiang.modules.activity.web.dto.StoreSeckillDTO;
import co.yixiang.modules.activity.web.param.YxStoreSeckillQueryParam; import co.yixiang.modules.activity.web.param.YxStoreSeckillQueryParam;
import co.yixiang.modules.activity.web.vo.YxStoreSeckillQueryVo; import co.yixiang.modules.activity.web.vo.YxStoreSeckillQueryVo;
import co.yixiang.modules.shop.entity.YxSystemGroupData; import co.yixiang.modules.shop.entity.YxSystemGroupData;
import co.yixiang.modules.shop.service.YxStoreProductRelationService;
import co.yixiang.modules.shop.service.YxSystemGroupDataService; import co.yixiang.modules.shop.service.YxSystemGroupDataService;
import co.yixiang.utils.OrderUtil; import co.yixiang.utils.OrderUtil;
import co.yixiang.utils.SecurityUtils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@ -56,6 +59,7 @@ public class StoreSeckillController extends BaseController {
private final YxStoreSeckillService yxStoreSeckillService; private final YxStoreSeckillService yxStoreSeckillService;
private final YxSystemGroupDataService yxSystemGroupDataService; private final YxSystemGroupDataService yxSystemGroupDataService;
private final YxStoreProductRelationService relationService;
/** /**
* 秒杀产品列表 * 秒杀产品列表
@ -66,6 +70,7 @@ public class StoreSeckillController extends BaseController {
public ApiResult<Object> getYxStoreSeckillPageList(@PathVariable String time, public ApiResult<Object> getYxStoreSeckillPageList(@PathVariable String time,
YxStoreSeckillQueryParam queryParam) throws Exception { YxStoreSeckillQueryParam queryParam) throws Exception {
if (StrUtil.isBlank(time)) return ApiResult.fail("参数错误"); if (StrUtil.isBlank(time)) return ApiResult.fail("参数错误");
/** 此处代码已经废弃
YxSystemGroupData systemGroupData = yxSystemGroupDataService YxSystemGroupData systemGroupData = yxSystemGroupDataService
.findData(Integer.valueOf(time)); .findData(Integer.valueOf(time));
if (ObjectUtil.isNull(systemGroupData)) return ApiResult.fail("参数错误"); if (ObjectUtil.isNull(systemGroupData)) return ApiResult.fail("参数错误");
@ -73,10 +78,9 @@ public class StoreSeckillController extends BaseController {
JSONObject jsonObject = JSONObject.parseObject(systemGroupData.getValue()); JSONObject jsonObject = JSONObject.parseObject(systemGroupData.getValue());
int startTime = today + (jsonObject.getInteger("time") * 3600); int startTime = today + (jsonObject.getInteger("time") * 3600);
int endTime = today + ((jsonObject.getInteger("time") + jsonObject.getInteger("continued")) * 3600); int endTime = today + ((jsonObject.getInteger("time") + jsonObject.getInteger("continued")) * 3600);
**/
return ApiResult.ok(yxStoreSeckillService.getList(queryParam.getPage().intValue(), return ApiResult.ok(yxStoreSeckillService.getList(queryParam.getPage().intValue(),
queryParam.getLimit().intValue(), startTime, endTime)); queryParam.getLimit().intValue(), Integer.valueOf(time)));
} }
@ -87,7 +91,11 @@ public class StoreSeckillController extends BaseController {
@GetMapping("/seckill/detail/{id}") @GetMapping("/seckill/detail/{id}")
@ApiOperation(value = "秒杀产品详情", notes = "秒杀产品详情", response = YxStoreSeckillQueryVo.class) @ApiOperation(value = "秒杀产品详情", notes = "秒杀产品详情", response = YxStoreSeckillQueryVo.class)
public ApiResult<Object> getYxStoreSeckill(@PathVariable Integer id) throws Exception { public ApiResult<Object> getYxStoreSeckill(@PathVariable Integer id) throws Exception {
return ApiResult.ok(yxStoreSeckillService.getDetail(id)); int uid = SecurityUtils.getUserId().intValue();
StoreSeckillDTO storeSeckillDTO = yxStoreSeckillService.getDetail(id);
storeSeckillDTO.setUserCollect(relationService
.isProductRelation(storeSeckillDTO.getStoreInfo().getProductId(),"product",uid,"collect"));
return ApiResult.ok(storeSeckillDTO);
} }

View File

@ -34,6 +34,8 @@ public class StoreCombinationDTO implements Serializable {
private String replyChance; private String replyChance;
private YxStoreCombinationQueryVo storeInfo; private YxStoreCombinationQueryVo storeInfo;
private Boolean userCollect = false;
} }

View File

@ -26,6 +26,9 @@ public class StoreSeckillDTO implements Serializable {
private YxStoreSeckillQueryVo storeInfo; private YxStoreSeckillQueryVo storeInfo;
@Builder.Default
private Boolean userCollect = false;
} }

View File

@ -18,6 +18,7 @@ import springfox.documentation.schema.AlternateTypeRule;
import springfox.documentation.schema.AlternateTypeRuleConvention; import springfox.documentation.schema.AlternateTypeRuleConvention;
import springfox.documentation.schema.ModelRef; import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.ApiInfo; import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.Parameter; import springfox.documentation.service.Parameter;
import springfox.documentation.spi.DocumentationType; import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.spring.web.plugins.Docket;
@ -84,7 +85,7 @@ public class SwaggerConfig {
.termsOfServiceUrl(serverUrl) .termsOfServiceUrl(serverUrl)
.description(title) .description(title)
.version(version) .version(version)
.contact("610796224@qq.com") .contact(new Contact("hupeng","https://www.yixiang.co","guchengwuyue@163.com"))
.build(); .build();
} }

View File

@ -21,6 +21,7 @@ import static org.springframework.http.HttpStatus.*;
*/ */
@Slf4j @Slf4j
@RestControllerAdvice @RestControllerAdvice
@SuppressWarnings("unchecked")
public class GlobalExceptionHandler { public class GlobalExceptionHandler {
/** /**

View File

@ -21,6 +21,7 @@ import java.io.IOException;
@RestController @RestController
@RequestMapping("/api/logs") @RequestMapping("/api/logs")
@Api(tags = "监控:日志管理") @Api(tags = "监控:日志管理")
@SuppressWarnings("unchecked")
public class LogController { public class LogController {
private final LogService logService; private final LogService logService;

View File

@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
@Api(tags = "商城:微信菜單") @Api(tags = "商城:微信菜單")
@RestController @RestController
@RequestMapping("api") @RequestMapping("api")
@SuppressWarnings("unchecked")
public class WechatMenuController { public class WechatMenuController {
private final YxCacheService yxCacheService; private final YxCacheService yxCacheService;

View File

@ -148,6 +148,9 @@ public class YxStoreSeckill implements Serializable {
@Column(name = "is_show",nullable = false) @Column(name = "is_show",nullable = false)
private Integer isShow; private Integer isShow;
@NotNull(message = "请选择开始时间")
private Integer timeId;
public void copy(YxStoreSeckill source){ public void copy(YxStoreSeckill source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
} }

View File

@ -94,4 +94,6 @@ public class YxStoreSeckillDTO implements Serializable {
private Date endTimeDate; private Date endTimeDate;
private String statusStr; private String statusStr;
private Integer timeId;
} }

View File

@ -32,6 +32,7 @@ import java.util.Map;
@Api(tags = "上传统一管理") @Api(tags = "上传统一管理")
@RestController @RestController
@RequestMapping("/api/upload") @RequestMapping("/api/upload")
@SuppressWarnings("unchecked")
public class UploadController { public class UploadController {
@Value("${file.localUrl}") @Value("${file.localUrl}")