StoreSmsConfigController.java 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. package com.kmall.admin.controller;
  2. import java.util.Date;
  3. import java.util.List;
  4. import java.util.Map;
  5. import com.kmall.admin.utils.ShiroUtils;
  6. import com.kmall.common.utils.PageUtils;
  7. import com.kmall.common.utils.Query;
  8. import com.kmall.common.utils.R;
  9. import org.apache.shiro.authz.annotation.RequiresPermissions;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.stereotype.Controller;
  12. import org.springframework.web.bind.annotation.*;
  13. import com.kmall.admin.entity.StoreSmsConfigEntity;
  14. import com.kmall.admin.service.StoreSmsConfigService;
  15. /**
  16. * 门店短信配置表Controller
  17. *
  18. * @author emato
  19. * @email admin@qhdswl.com
  20. * @date 2021-03-11 10:10:10
  21. */
  22. @RestController
  23. @RequestMapping("storesmsconfig")
  24. public class StoreSmsConfigController {
  25. @Autowired
  26. private StoreSmsConfigService storeSmsConfigService;
  27. /**
  28. * 查看列表
  29. */
  30. @RequestMapping("/list")
  31. @ResponseBody
  32. public R list(@RequestParam Map<String, Object> params) {
  33. //查询列表数据
  34. Query query = new Query(params);
  35. List<StoreSmsConfigEntity> storeSmsConfigList = storeSmsConfigService.queryList(query);
  36. int total = storeSmsConfigService.queryTotal(query);
  37. PageUtils pageUtil = new PageUtils(storeSmsConfigList, total, query.getLimit(), query.getPage());
  38. return R.ok().put("page", pageUtil);
  39. }
  40. /**
  41. * 查看信息
  42. */
  43. @RequestMapping("/info/{id}")
  44. @ResponseBody
  45. public R info(@PathVariable("id") Integer id) {
  46. StoreSmsConfigEntity storeSmsConfig = storeSmsConfigService.queryObject(id);
  47. return R.ok().put("storeSmsConfig", storeSmsConfig);
  48. }
  49. /**
  50. * 保存
  51. */
  52. @RequestMapping("/save")
  53. @ResponseBody
  54. public R save(@RequestBody StoreSmsConfigEntity storeSmsConfig) {
  55. StoreSmsConfigEntity entity = storeSmsConfigService.queryObjectByMerchSnAndStoreId(storeSmsConfig.getMerchSn(),storeSmsConfig.getStoreId());
  56. if (entity!=null){
  57. return R.error("该门店已有配置,请在原基础上修改");
  58. }
  59. if ("2".equals(storeSmsConfig.getIsEnable())){
  60. storeSmsConfig.setSendEndTime(null);
  61. storeSmsConfig.setSendStartTime(null);
  62. }
  63. storeSmsConfig.setCreaterSn(ShiroUtils.getUserId().toString());
  64. storeSmsConfig.setCreateTime(new Date());
  65. storeSmsConfig.setModerSn(ShiroUtils.getUserId().toString());
  66. storeSmsConfig.setModTime(new Date());
  67. storeSmsConfigService.save(storeSmsConfig);
  68. return R.ok();
  69. }
  70. /**
  71. * 修改
  72. */
  73. @RequestMapping("/update")
  74. @ResponseBody
  75. public R update(@RequestBody StoreSmsConfigEntity storeSmsConfig) {
  76. storeSmsConfig.setModerSn(ShiroUtils.getUserId().toString());
  77. storeSmsConfig.setModTime(new Date());
  78. if ("2".equals(storeSmsConfig.getIsEnable())){
  79. storeSmsConfig.setSendEndTime(null);
  80. storeSmsConfig.setSendStartTime(null);
  81. }
  82. storeSmsConfigService.update(storeSmsConfig);
  83. return R.ok();
  84. }
  85. /**
  86. * 删除
  87. */
  88. @RequestMapping("/delete")
  89. @ResponseBody
  90. public R delete(@RequestBody Integer[]ids) {
  91. storeSmsConfigService.deleteBatch(ids);
  92. return R.ok();
  93. }
  94. /**
  95. * 查看所有列表
  96. */
  97. @RequestMapping("/queryAll")
  98. @ResponseBody
  99. public R queryAll(@RequestParam Map<String, Object> params) {
  100. List<StoreSmsConfigEntity> list = storeSmsConfigService.queryList(params);
  101. return R.ok().put("list", list);
  102. }
  103. }