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.ModelUtils; 
 | 
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.common.constance.AppConstance; 
 | 
import com.matrix.system.hive.action.util.QueryUtil; 
 | 
import com.matrix.system.shopXcx.dao.ShopProductCommentDao; 
 | 
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 java.util.Map; 
 | 
import com.matrix.system.shopXcx.bean.ShopProductComment; 
 | 
import org.springframework.web.servlet.ModelAndView; 
 | 
  
 | 
/** 
 | 
 * @description 产品评价 
 | 
 * @author jiangyouyao 
 | 
 * @date 2019-06-14 10:06 
 | 
 */ 
 | 
@Controller 
 | 
@RequestMapping(value = "admin/shopProductComment") 
 | 
public class ShopProductCommentAction { 
 | 
  
 | 
    @Autowired 
 | 
    private ShopProductCommentDao shopProductCommentDao; 
 | 
     
 | 
    //记录编辑前的值Before_Edit_Value 
 | 
    public static final String BEV="ShopProductComment_BEV"; 
 | 
     
 | 
     
 | 
    /** 
 | 
     * 列表显示 
 | 
     */ 
 | 
    @RequestMapping(value =  "/showList") 
 | 
    public @ResponseBody AjaxResult showList(ShopProductComment shopProductComment, PaginationVO pageVo) { 
 | 
  
 | 
        String auditStatus = shopProductComment.getAuditStatus(); 
 | 
        if(null != auditStatus && AppConstance.COM_AUDIT_APPROVAL.equals(auditStatus)){ 
 | 
            shopProductComment.setComAuditStatus(AppConstance.AUDITED_PASS); 
 | 
        } 
 | 
        if(null != auditStatus && AppConstance.COM_AUDIT_FAILED.equals(auditStatus)){ 
 | 
            shopProductComment.setComAuditStatus(AppConstance.AUDITED_FAILED); 
 | 
        } 
 | 
        if(null != auditStatus && AppConstance.COM_NOT_AUDITED.equals(auditStatus)){ 
 | 
            shopProductComment.setComAuditStatus(AppConstance.NOT_AUDITED); 
 | 
        } 
 | 
        QueryUtil.setQueryLimitCom(shopProductComment); 
 | 
        List<ShopProductComment> dataList = shopProductCommentDao.selectInPage(shopProductComment, pageVo); 
 | 
        AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, dataList, 
 | 
                shopProductCommentDao.selectTotalRecord(shopProductComment)); 
 | 
        return result; 
 | 
    } 
 | 
  
 | 
     
 | 
     
 | 
     
 | 
    /** 
 | 
     * 修改 
 | 
     */    
 | 
    @RemoveRequestToken     
 | 
       @RequestMapping(value =  "/modifyShopProductComment") 
 | 
    public @ResponseBody AjaxResult modifyShopProductComment(ShopProductComment newShopProductComment) { 
 | 
           ShopProductComment oldShopProductComment = WebUtil.getSessionAttribute(BEV); 
 | 
        int i = 0; 
 | 
        Map<String, Object> modifyMap = null; 
 | 
        try { 
 | 
            if (!ModelUtils.isModified(oldShopProductComment, newShopProductComment)) { 
 | 
                i = MatrixConstance.DML_SUCCESSS; 
 | 
            } 
 | 
            modifyMap = ModelUtils.comparePojo2Map(oldShopProductComment, newShopProductComment); 
 | 
        } catch (Exception e) { 
 | 
            throw new GlobleException(SystemErrorCode.DATA_UPDATE_FAIL, e, newShopProductComment); 
 | 
        } 
 | 
        if (modifyMap.size() > 0) { 
 | 
            modifyMap.put("comId", oldShopProductComment.getComId()); 
 | 
            shopProductCommentDao.updateByMap(modifyMap); 
 | 
        } 
 | 
        i = MatrixConstance.DML_SUCCESSS; 
 | 
        WebUtil.removeSessionAttribute(BEV); 
 | 
        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) { 
 | 
        ShopProductComment shopProductComment = new ShopProductComment(); 
 | 
        ModelAndView modelAndView = new ModelAndView("admin/shop/shopProductComment-form"); 
 | 
        if (id != null) { 
 | 
            shopProductComment = shopProductCommentDao.selectById(id); 
 | 
            WebUtil.setSessionAttribute(BEV, shopProductComment); 
 | 
        } 
 | 
        modelAndView.addObject("obj",shopProductComment); 
 | 
        return modelAndView; 
 | 
    } 
 | 
        
 | 
        
 | 
       /** 
 | 
     * 删除 
 | 
     */   
 | 
     @RequestMapping(value = "/del") 
 | 
    public @ResponseBody AjaxResult del(String keys) { 
 | 
        List<String> ids = StringUtils.strToCollToString(keys, ","); 
 | 
        int i =  shopProductCommentDao.deleteByIds(ids); 
 | 
        if (i > 0) { 
 | 
            return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.DELETE_SUCCES, i); 
 | 
        } else { 
 | 
            throw new GlobleException(SystemErrorCode.DATA_DELETE_FAIL); 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 批量审核通过 
 | 
     */ 
 | 
    @RequestMapping(value = "/auditedPass") 
 | 
    public @ResponseBody AjaxResult startUsing(String keys) { 
 | 
        SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); 
 | 
        String suName = user.getSuName(); 
 | 
        Long suId = user.getSuId(); 
 | 
        List<String> ids = StringUtils.strToCollToString(keys, ","); 
 | 
        int i =  shopProductCommentDao.updateStatusByStateAndIds(ids, 1,suName,suId); 
 | 
        if (i > 0) { 
 | 
            return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.UPDATE_SUCCES, i); 
 | 
        } else { 
 | 
            throw new GlobleException(SystemErrorCode.DATA_UPDATE_FAIL); 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 批量审核不通过 
 | 
     */ 
 | 
    @RequestMapping(value = "/auditedFailed") 
 | 
    public @ResponseBody AjaxResult blockUp(String keys) { 
 | 
        SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); 
 | 
        String suName = user.getSuName(); 
 | 
        Long suId = user.getSuId(); 
 | 
        List<String> ids = StringUtils.strToCollToString(keys, ","); 
 | 
        int i =  shopProductCommentDao.updateStatusByStateAndIds(ids, 2,suName,suId); 
 | 
        if (i > 0) { 
 | 
            return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.UPDATE_SUCCES, i); 
 | 
        } else { 
 | 
            throw new GlobleException(SystemErrorCode.DATA_UPDATE_FAIL); 
 | 
        } 
 | 
    } 
 | 
   
 | 
} 
 |