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.shopXcx.bean.ShopDeliveryInfo;
|
import com.matrix.system.shopXcx.dao.ShopLogisticsInfoDao;
|
import com.matrix.system.shopXcx.api.service.WxShopLogisticsQueryService;
|
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.ShopLogisticsInfo;
|
import org.springframework.web.servlet.ModelAndView;
|
|
/**
|
* @description 物流信息表
|
* @author pengliang
|
* @date 2019-06-17 17:54
|
*/
|
@Controller
|
@RequestMapping(value = "admin/shopLogisticsInfo")
|
public class ShopLogisticsInfoAction {
|
|
@Autowired
|
private ShopLogisticsInfoDao shopLogisticsInfoDao;
|
|
@Autowired
|
private WxShopLogisticsQueryService wxShopLogisticsQueryService;
|
|
//记录编辑前的值Before_Edit_Value
|
public static final String BEV="ShopLogisticsInfo_BEV";
|
|
|
/**
|
* 列表显示
|
*/
|
@RequestMapping(value = "/showList")
|
public @ResponseBody AjaxResult showList(ShopLogisticsInfo shopLogisticsInfo, PaginationVO pageVo) {
|
|
List<ShopLogisticsInfo> dataList = shopLogisticsInfoDao.selectInPage(shopLogisticsInfo, pageVo);
|
AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, dataList,
|
shopLogisticsInfoDao.selectTotalRecord(shopLogisticsInfo));
|
return result;
|
}
|
|
/**
|
* 查询物流信息
|
* @param orderId
|
* @return
|
*/
|
@RequestMapping(value ="/showLogisticsInfo")
|
@ResponseBody
|
public AjaxResult showLogisticsInfo(Integer orderId){
|
ShopDeliveryInfo shopDeliveryInfo = wxShopLogisticsQueryService.selectByorderId(orderId);
|
AjaxResult result = wxShopLogisticsQueryService.selectLogisticsInfo(shopDeliveryInfo);
|
return result;
|
}
|
|
/**
|
* 新增
|
*/
|
@RemoveRequestToken
|
@RequestMapping(value = "/addShopLogisticsInfo")
|
public @ResponseBody AjaxResult addShopLogisticsInfo(ShopLogisticsInfo shopLogisticsInfo) {
|
SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
|
shopLogisticsInfo.setCreateBy(user.getSuName());
|
shopLogisticsInfo.setUpdateBy(user.getSuName());
|
int i=shopLogisticsInfoDao.insert(shopLogisticsInfo);
|
if(i > 0){
|
return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.ADD_SUCCES, "物流信息表");
|
}else {
|
throw new GlobleException(SystemErrorCode.DATA_ADD_FAIL);
|
}
|
}
|
|
|
|
|
|
/**
|
* 修改
|
*/
|
@RemoveRequestToken
|
@RequestMapping(value = "/modifyShopLogisticsInfo")
|
public @ResponseBody AjaxResult modifyShopLogisticsInfo(ShopLogisticsInfo newShopLogisticsInfo) {
|
ShopLogisticsInfo oldShopLogisticsInfo = WebUtil.getSessionAttribute(BEV);
|
int i = 0;
|
Map<String, Object> modifyMap = null;
|
try {
|
if (!ModelUtils.isModified(oldShopLogisticsInfo, newShopLogisticsInfo)) {
|
i = MatrixConstance.DML_SUCCESSS;
|
}
|
modifyMap = ModelUtils.comparePojo2Map(oldShopLogisticsInfo, newShopLogisticsInfo);
|
} catch (Exception e) {
|
throw new GlobleException(SystemErrorCode.DATA_UPDATE_FAIL, e, newShopLogisticsInfo);
|
}
|
if (modifyMap.size() > 0) {
|
modifyMap.put("id", oldShopLogisticsInfo.getId());
|
shopLogisticsInfoDao.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) {
|
ShopLogisticsInfo shopLogisticsInfo = new ShopLogisticsInfo();
|
ModelAndView modelAndView = new ModelAndView("admin/shopLogisticsInfo-form");
|
if (id != null) {
|
shopLogisticsInfo = shopLogisticsInfoDao.selectById(id);
|
WebUtil.setSessionAttribute(BEV, shopLogisticsInfo);
|
}
|
modelAndView.addObject("obj",shopLogisticsInfo);
|
return modelAndView;
|
}
|
|
|
/**
|
* 删除
|
*/
|
@RequestMapping(value = "/del")
|
public @ResponseBody AjaxResult del(String keys) {
|
List<String> ids = StringUtils.strToCollToString(keys, ",");
|
int i = shopLogisticsInfoDao.deleteByIds(ids);
|
if (i > 0) {
|
return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.DELETE_SUCCES, i);
|
} else {
|
throw new GlobleException(SystemErrorCode.DATA_DELETE_FAIL);
|
}
|
}
|
|
}
|