package com.matrix.system.shopXcx.action; 
 | 
  
 | 
  
 | 
import com.matrix.core.constance.MatrixConstance; 
 | 
import com.matrix.core.constance.SystemMessageCode; 
 | 
import com.matrix.core.pojo.PaginationVO; 
 | 
import com.matrix.core.tools.StringUtils; 
 | 
import com.matrix.core.constance.SystemErrorCode; 
 | 
import com.matrix.core.anotations.RemoveRequestToken; 
 | 
import com.matrix.system.common.bean.SysUsers; 
 | 
import com.matrix.system.hive.action.util.QueryUtil; 
 | 
import com.matrix.system.shopXcx.bean.ShopAdvertisType; 
 | 
import com.matrix.system.shopXcx.dao.ShopAdvertisDao; 
 | 
import com.matrix.system.shopXcx.dao.ShopAdvertisTypeDao; 
 | 
import org.springframework.stereotype.Controller; 
 | 
import com.matrix.core.exception.GlobleException; 
 | 
import org.springframework.web.bind.annotation.RequestMapping; 
 | 
import org.springframework.web.bind.annotation.ResponseBody; 
 | 
import com.matrix.core.anotations.SaveRequestToken; 
 | 
import com.matrix.core.pojo.AjaxResult; 
 | 
import com.matrix.core.tools.WebUtil; 
 | 
import org.springframework.beans.factory.annotation.Autowired; 
 | 
  
 | 
import java.util.List; 
 | 
import com.matrix.system.shopXcx.bean.ShopAdvertis; 
 | 
import org.springframework.web.servlet.ModelAndView; 
 | 
  
 | 
/** 
 | 
 * @description 广告表 
 | 
 * @author jyy 
 | 
 * @date 2019-06-05 10:15 
 | 
 */ 
 | 
@Controller 
 | 
@RequestMapping(value = "admin/shopAdvertis") 
 | 
public class ShopAdvertisAction { 
 | 
  
 | 
    @Autowired 
 | 
    private ShopAdvertisDao shopAdvertisDao; 
 | 
    @Autowired 
 | 
    private ShopAdvertisTypeDao shopAdvertisTypeDao; 
 | 
     
 | 
    //记录编辑前的值Before_Edit_Value 
 | 
    public static final String BEV="ShopAdvertis_BEV"; 
 | 
     
 | 
    /** 
 | 
     * 列表显示 
 | 
     */ 
 | 
    @RequestMapping(value =  "/showList") 
 | 
    public @ResponseBody AjaxResult showList(ShopAdvertis shopAdvertis, PaginationVO pageVo) { 
 | 
        QueryUtil.setQueryLimitCom(shopAdvertis); 
 | 
        List<ShopAdvertis> dataList = shopAdvertisDao.selectInPage(shopAdvertis, pageVo); 
 | 
        return new AjaxResult(AjaxResult.STATUS_SUCCESS, dataList, shopAdvertisDao.selectTotalRecord(shopAdvertis)); 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     *获取所有广告类型 
 | 
     */ 
 | 
    @RequestMapping("/getAllAdvertisingType") 
 | 
    @ResponseBody 
 | 
    public AjaxResult getAllAdvertisingType() { 
 | 
        ShopAdvertisType queryParam=new ShopAdvertisType(); 
 | 
        QueryUtil.setQueryLimitCom(queryParam); 
 | 
        List<ShopAdvertisType> list = shopAdvertisTypeDao.selectByModel(queryParam); 
 | 
        return new AjaxResult(AjaxResult.STATUS_SUCCESS, list); 
 | 
    } 
 | 
        
 | 
    /** 
 | 
     * 新增 
 | 
     */    
 | 
    @RemoveRequestToken     
 | 
       @RequestMapping(value =  "/addShopAdvertis") 
 | 
    public @ResponseBody AjaxResult addShopAdvertis(ShopAdvertis shopAdvertis) { 
 | 
        SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); 
 | 
        shopAdvertis.setCreateBy(user.getSuName()); 
 | 
        shopAdvertis.setUpdateBy(user.getSuName()); 
 | 
        shopAdvertis.setCompanyId(user.getCompanyId()); 
 | 
         int i=shopAdvertisDao.insert(shopAdvertis); 
 | 
         if(i > 0){ 
 | 
             return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.ADD_SUCCES, "广告表"); 
 | 
         }else { 
 | 
            throw new GlobleException(SystemErrorCode.DATA_ADD_FAIL); 
 | 
        } 
 | 
    } 
 | 
     
 | 
     
 | 
     
 | 
     
 | 
     
 | 
    /** 
 | 
     * 修改 
 | 
     */    
 | 
    @RemoveRequestToken     
 | 
       @RequestMapping(value =  "/modifyShopAdvertis") 
 | 
    public @ResponseBody AjaxResult modifyShopAdvertis(ShopAdvertis newShopAdvertis) { 
 | 
        if (newShopAdvertis != null && newShopAdvertis.getSort() == null) { 
 | 
            newShopAdvertis.setSort(0); 
 | 
        } 
 | 
        int i = shopAdvertisDao.updateByModel(newShopAdvertis); 
 | 
        if (i > 0) { 
 | 
            return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.UPDATE_SUCCES, "广告表"); 
 | 
        } else { 
 | 
            throw new GlobleException(SystemErrorCode.DATA_UPDATE_FAIL); 
 | 
        } 
 | 
    } 
 | 
     
 | 
     
 | 
     
 | 
     
 | 
       /** 
 | 
     * 进入修改界面 
 | 
     */    
 | 
    @SaveRequestToken 
 | 
       @RequestMapping(value =  "/editForm") 
 | 
    public ModelAndView editForm(Integer id) { 
 | 
        ShopAdvertis shopAdvertis = new ShopAdvertis(); 
 | 
        ModelAndView modelAndView = new ModelAndView("admin/shop/shopAdvertis-form"); 
 | 
        if (id != null) { 
 | 
            shopAdvertis = shopAdvertisDao.selectById(id); 
 | 
            WebUtil.setSessionAttribute(BEV, shopAdvertis); 
 | 
        } 
 | 
        modelAndView.addObject("obj",shopAdvertis); 
 | 
        return modelAndView; 
 | 
    } 
 | 
        
 | 
        
 | 
       /** 
 | 
     * 删除 
 | 
     */   
 | 
     @RequestMapping(value = "/del") 
 | 
    public @ResponseBody AjaxResult del(String keys) { 
 | 
        List<String> ids = StringUtils.strToCollToString(keys, ","); 
 | 
        int i =  shopAdvertisDao.deleteByIds(ids); 
 | 
        if (i > 0) { 
 | 
            return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.DELETE_SUCCES, i); 
 | 
        } else { 
 | 
            throw new GlobleException(SystemErrorCode.DATA_DELETE_FAIL); 
 | 
        } 
 | 
    } 
 | 
   
 | 
} 
 |