老师好!关于超级管理员的商铺管理有点问题
来源:15-23 超级管理员系统提点
qq_独闭关中_0
2019-11-03
/**
* 修改店铺信息,主要修改可用状态,审核用
*
* @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都没有找到?
2回答
-
翔仔
2019-11-04
同学好,比如在personinfomanage.js里面有一个
function imgFormater(value, row, index) { var profileImg = row.profileImg; return '<img src="' + profileImg + '" width="100px" height="60px">'; }
这个是拿来修改列的值的
然后在personinfomanage.html里面这样用的
<!-- 表格 --> <table id="personinfoManagementTable" title="用户信息一览" border="0" cellspacing="0" cellpadding="0" iconCls="icon-edit" width="98%" idField="personinfoId" remoteSort="false" pagination="true" singleSelect="false" showFooter="false" striped="true"> <thead> <tr align="center"> <th field="userId" width="50">帐号ID</th> <th field="name" width="100">用户名</th> <th field="birthday" width="100">出生日期</th> <th field="gender" width="100">性别</th> <th field="phone" width="150">联系方式</th> <th field="email" width="150">电子邮箱</th> <th field="profileImg" width="120" formatter="imgFormater">用户相片</th> <th field="customerFlag" width="50">顾客</th> <th field="shopOwnerFlag" width="50">店家</th> <th field="adminFlag" width="50">管理员</th> <th field="createTime" width="100">创建时间</th> <th field="lastEditTime" width="100">最近修改时间</th> <th field="enableStatus" width="50">状态</th> <th field="opt" formatter='optFormater' width="150">操作</th> </tr> </thead> </table>
注意"用户相片"这个字段 就是能够操作该列里的每一行数据,给它赋上对应的值
同样的,对于"创建时间" 可以指定一个formatter 任意命名,可以叫timeformatter
然后js方法可以参考先前我们店铺格式化显示更新时间的方式,结合这里逐行操作
022019-11-05 -
翔仔
2019-11-04
同学好,第一个问题需要调试才能解决呢,看看为什么会报错,然后看看modifyShop执行到哪一步有问题,另外一个可以参考js里面的imgformater方法,主要是针对某一列值的修改 获取到时间并且修改样式赋值回去即可
012019-11-04
相似问题