xuhy
2023-05-06 0ad75f90e6464b95bef06c88227f521c5c03d41d
management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TCommercialController.java
@@ -1,6 +1,8 @@
package com.stylefeng.guns.modular.system.controller.general;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.base.tips.SuccessTip;
import com.stylefeng.guns.modular.system.controller.util.LabelReplaceUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@@ -11,6 +13,8 @@
import org.springframework.web.bind.annotation.RequestParam;
import com.stylefeng.guns.modular.system.model.TCommercial;
import com.stylefeng.guns.modular.system.service.ITCommercialService;
import java.util.Date;
/**
 * 控制器
@@ -69,6 +73,8 @@
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(TCommercial tCommercial) {
        tCommercial.setHtml(LabelReplaceUtil.replace(tCommercial.getHtml()));
        tCommercial.setCreateTime(new Date());
        tCommercialService.insert(tCommercial);
        return SUCCESS_TIP;
    }
@@ -84,11 +90,44 @@
    }
    /**
     * 上线
     */
    @RequestMapping(value = "/onLine")
    @ResponseBody
    public Object onLine(@RequestParam Integer tCommercialId) {
        TCommercial tCommercial = tCommercialService.selectById(tCommercialId);
        Boolean exit = tCommercialService.isExit(tCommercialId, 1);
        if(exit){
            return new SuccessTip(500,"最多可上架4个弹窗广告!");
        }
        tCommercial.setOnOffLine(1);
        tCommercialService.updateById(tCommercial);
        return SUCCESS_TIP;
    }
    /**
     * 下线
     */
    @RequestMapping(value = "/offLine")
    @ResponseBody
    public Object offLine(@RequestParam Integer tCommercialId) {
        TCommercial tCommercial = tCommercialService.selectById(tCommercialId);
        tCommercial.setOnOffLine(2);
        tCommercialService.updateById(tCommercial);
        return SUCCESS_TIP;
    }
    /**
     * 修改
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(TCommercial tCommercial) {
        if(0 == tCommercial.getIsJump()){
            tCommercial.setJumpType(0);
            tCommercial.setJumpUrl("");
        }
        tCommercial.setHtml(LabelReplaceUtil.replace(tCommercial.getHtml()));
        tCommercialService.updateById(tCommercial);
        return SUCCESS_TIP;
    }