|
@@ -1,6 +1,7 @@
|
|
|
package com.qs.mp.web.controller.api.admin;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.qs.mp.admin.domain.Marketing;
|
|
|
import com.qs.mp.admin.domain.MarketingAwards;
|
|
|
import com.qs.mp.admin.domain.MarketingAwardsPrize;
|
|
@@ -18,6 +19,7 @@ import com.qs.mp.common.annotation.Log;
|
|
|
import com.qs.mp.common.core.domain.AjaxResult;
|
|
|
import com.qs.mp.common.core.page.TableDataInfo;
|
|
|
import com.qs.mp.common.enums.BusinessType;
|
|
|
+import com.qs.mp.common.enums.MarketingStatusEnum;
|
|
|
import com.qs.mp.web.controller.common.BaseApiController;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -114,4 +116,65 @@ public class MarketingMgrController extends BaseApiController {
|
|
|
return AjaxResult.success(marketingVO);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @PostMapping("/on/{id}")
|
|
|
+ @PreAuthorize("@ss.hasPermi('business:marketing:on')")
|
|
|
+ @ApiOperation("开启活动")
|
|
|
+ public AjaxResult putOn(@PathVariable("id") Long id) {
|
|
|
+ Marketing marketing = marketingService.getById(id);
|
|
|
+ if (Objects.isNull(marketing)) {
|
|
|
+ return AjaxResult.error("活动信息不存在");
|
|
|
+ }
|
|
|
+ if (MarketingStatusEnum.CLOSE.getValue().equals(marketing.getIsOn())) {
|
|
|
+ return AjaxResult.error("已关闭的活动不支持开启");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (MarketingStatusEnum.ON.getValue().equals(marketing.getIsOn())) {
|
|
|
+ return AjaxResult.error("频繁操作,请刷新后重试");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 开启活动
|
|
|
+ marketingService.update(new LambdaUpdateWrapper<Marketing>()
|
|
|
+ .set(Marketing::getIsOn, MarketingStatusEnum.ON.getValue())
|
|
|
+ .eq(Marketing::getId, id));
|
|
|
+
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/off/{id}")
|
|
|
+ @PreAuthorize("@ss.hasPermi('business:marketing:off')")
|
|
|
+ @ApiOperation("关闭活动")
|
|
|
+ public AjaxResult putOff(@PathVariable("id") Long id) {
|
|
|
+ Marketing marketing = marketingService.getById(id);
|
|
|
+ if (Objects.isNull(marketing)) {
|
|
|
+ return AjaxResult.error("活动信息不存在");
|
|
|
+ }
|
|
|
+ if (MarketingStatusEnum.CLOSE.getValue().equals(marketing.getIsOn())) {
|
|
|
+ return AjaxResult.error("频繁操作,请刷新后重试");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 关闭活动
|
|
|
+ marketingService.update(new LambdaUpdateWrapper<Marketing>()
|
|
|
+ .set(Marketing::getIsOn, MarketingStatusEnum.CLOSE.getValue())
|
|
|
+ .eq(Marketing::getId, id));
|
|
|
+
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/delete/{id}")
|
|
|
+ @PreAuthorize("@ss.hasPermi('business:marketing:remove')")
|
|
|
+ @ApiOperation("删除活动")
|
|
|
+ public AjaxResult delete(@PathVariable("id") Long id) {
|
|
|
+ Marketing marketing = marketingService.getById(id);
|
|
|
+ if (Objects.isNull(marketing)) {
|
|
|
+ return AjaxResult.error("活动信息不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!MarketingStatusEnum.OFF.getValue().equals(marketing.getIsOn())) {
|
|
|
+ return AjaxResult.error("频繁操作,请刷新后重试");
|
|
|
+ }
|
|
|
+ marketingService.deleteById(id);
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
}
|