diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/PushLimitController.java b/mallinkAdmin/src/main/java/com/iformall/controller/PushLimitController.java index 0e76203cc..9f240d19a 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/PushLimitController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/PushLimitController.java @@ -35,7 +35,7 @@ public class PushLimitController extends BaseController { @ApiOperation("根据id更新接口") @PostMapping("update") public ResultData update(@RequestBody PushLimit pushLimit) { - pushLimit.setMsgAmount(null); + pushLimit.setTenantId(getTenantId()); pushLimitService.saveOrUpdate(pushLimit); return new ResultData(); } @@ -56,4 +56,13 @@ public class PushLimitController extends BaseController { } + @ApiOperation("默认数据接口") + @GetMapping("/getDefaultData") + public ResultData getDefaultData() { + + PushLimit pushLimit=pushLimitService.getDefaultData(getTenantId()); + return new ResultData(pushLimit); + } + + } diff --git a/mallinkService/src/main/java/com/iformall/service/PushLimitService.java b/mallinkService/src/main/java/com/iformall/service/PushLimitService.java index 63ed79add..70c97b716 100644 --- a/mallinkService/src/main/java/com/iformall/service/PushLimitService.java +++ b/mallinkService/src/main/java/com/iformall/service/PushLimitService.java @@ -26,8 +26,8 @@ public interface PushLimitService { /** * 保存或更新实体 * - * @param record - */ + * @param record + */ void saveOrUpdate(PushLimit record); /** @@ -36,12 +36,7 @@ public interface PushLimitService { * @param id */ void deleteById(Long id); - - - - - - - + + PushLimit getDefaultData(String tenantId); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/PushLimitServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/PushLimitServiceImpl.java index 33a13993d..57e92dd94 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/PushLimitServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/PushLimitServiceImpl.java @@ -9,6 +9,8 @@ import com.iformall.service.PushLimitService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; + @Service public class PushLimitServiceImpl implements PushLimitService { @@ -28,26 +30,50 @@ public class PushLimitServiceImpl implements PushLimitService { @Override public void saveOrUpdate(PushLimit record) { - if (record.getId() == null) { - //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); + PushLimit params=new PushLimit(); + params.setTenantId(record.getTenantId()); + List list = pushLimitMapper.findList(params); + if(list.size()>0){ + pushLimitMapper.updateByPrimaryKeySelective(record); + }else{ final IdWorker idWorker = IdWorker.get(); record.setId(idWorker.nextId()); pushLimitMapper.insertSelective(record); - } else { - pushLimitMapper.updateByPrimaryKeySelective(record); } +// if (record.getId() == null) { +// //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); +// final IdWorker idWorker = IdWorker.get(); +// record.setId(idWorker.nextId()); +// pushLimitMapper.insertSelective(record); +// return record.getId(); +// } else { +// pushLimitMapper.updateByPrimaryKeySelective(record); +// return record.getId(); +// } } @Override public void deleteById(Long id) { pushLimitMapper.deleteByPrimaryKey(id); } - - - - - - - - + + @Override + public PushLimit getDefaultData(String tenantId) { + PushLimit record =new PushLimit(); + record.setTenantId(tenantId); + List list = pushLimitMapper.findList(record); + if(list.size()>0){ + record=list.get(0); + }else{ + record=new PushLimit(); + record.setMsgAmount(3); + record.setRefuseTimeStart("00:00"); + record.setRefuseTimeEnd("23:45"); + record.setCouponDay(10); + record.setCouponAmount(10); + } + return record; + } + + } diff --git a/mallinkService/src/main/resources/mapper/PushLimitMapper.xml b/mallinkService/src/main/resources/mapper/PushLimitMapper.xml index 85d84498b..5f98d8e5a 100644 --- a/mallinkService/src/main/resources/mapper/PushLimitMapper.xml +++ b/mallinkService/src/main/resources/mapper/PushLimitMapper.xml @@ -26,7 +26,7 @@ - and `tenant_id` like concat('%', #{tenantId},'%') + and `tenant_id` = #{tenantId}