/**
* 修改店铺信息,主要修改可用状态,审核用
*
* @param shopStr
* @param request
* @return
*/
@RequestMapping(value = “/modifyshop”, method = RequestMethod.POST)
@ResponseBody
private Map<String, Object> modifyShop(String shopStr, HttpServletRequest request) {
Map<String, Object> modelMap = new HashMap<String, Object>();
ObjectMapper mapper = new ObjectMapper();
Shop shop = null;
try {
// 获取前端传递过来的shop json字符串,将其转换成shop实例
shop = mapper.readValue(shopStr, Shop.class);
} catch (Exception e) {
modelMap.put(“success”, false);
modelMap.put(“errMsg”, e.toString());
return modelMap;
}
// 空值判断
if (shop != null && shop.getShopId() != null) {
try {
// 若前端传来需要修改的字段,则设置上,否则设置为空,为空则不修改
shop.setShopName(
(shop.getShopName() == null) ? null : (URLDecoder.decode(shop.getShopName(), “UTF-8”)));
shop.setShopDesc(
(shop.getShopDesc() == null) ? null : (URLDecoder.decode(shop.getShopDesc(), “UTF-8”)));
shop.setShopAddr(
(shop.getShopAddr() == null) ? null : (URLDecoder.decode(shop.getShopAddr(), “UTF-8”)));
shop.setAdvice(((shop.getAdvice() == null) || shop.getAdvice().equals("""")) ? null
: (URLDecoder.decode(shop.getAdvice(), “UTF-8”)));
if (shop.getShopCategory() != null && shop.getShopCategory().getShopCategoryId() != null) {
// 若需要修改店铺类别,则先获取店铺类别
ShopCategory sc = shopCategoryService
.getShopCategoryById(shop.getShopCategory().getShopCategoryId());
shop.setShopCategory(sc);
}
// 修改店铺信息
ShopExecution ae = shopService.modifyShop(shop, null);
if (ae.getState() == ShopStateEnum.SUCCESS.getState()) {
modelMap.put(“success”, true);
} else {
modelMap.put(“success”, false);
modelMap.put(“errMsg”, ae.getStateInfo());
}
} catch (Exception e) {
modelMap.put(“success”, false);
modelMap.put(“errMsg”, e.toString());
return modelMap;
}
} else {
modelMap.put(“success”, false);
modelMap.put(“errMsg”, “请输入店铺信息”);
}
return modelMap;
}
图片为空,ShopExecution ae = shopService.modifyShop(shop, null);执行这个方法就报错了,这个问题如何解决?在2.0源码的modifyShop方法和1.0那个是一样的
还有就是时间看起来怪怪的,如何才能改成正常的,找遍了js都没有找到?
SSM商铺V1.0,解决毕设痛点;SpringBoot商铺V2.0,满足工作刚需
了解课程