|
|
@@ -39,6 +39,22 @@ public class CouponController {
|
|
|
return JSON.toJSONString(responseResult);
|
|
|
}
|
|
|
|
|
|
+ // 查找对应的商品
|
|
|
+ CouponBean dbCouponBean = null;
|
|
|
+ try {
|
|
|
+ dbCouponBean = couponRepository.findCouponById(couponBean.id);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 找不到对应商品,说明是新增
|
|
|
+ if (dbCouponBean == null) {
|
|
|
+ couponBean.createTimeMillis = System.currentTimeMillis();
|
|
|
+ }
|
|
|
+
|
|
|
+ couponBean.updateTimeMillis = System.currentTimeMillis();
|
|
|
+ couponBean.isLocal = false;
|
|
|
+
|
|
|
try {
|
|
|
couponRepository.save(couponBean);
|
|
|
} catch (Exception e) {
|
|
|
@@ -103,7 +119,7 @@ public class CouponController {
|
|
|
// 自带的分页查询
|
|
|
List<CouponBean> couponBeanList;
|
|
|
try {
|
|
|
- Sort sort = new Sort(Sort.Direction.DESC,"id");
|
|
|
+ Sort sort = new Sort(Sort.Direction.DESC,"updateTimeMillis");
|
|
|
couponBeanList = couponRepository.findAll(new PageRequest(pageNum, pageSize, sort)).getContent();
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|