| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "saveBrand")
|
| | | public void saveBrand(String callback, BrandInfo brandInfo, PrintWriter out) {
|
| | | public void saveBrand(String callback, BrandInfo brandInfo, HttpServletRequest request, PrintWriter out) {
|
| | | try {
|
| | | brandInfoService.saveObject(brandInfo);
|
| | | // 1. 先判断httpRequest 是否含有文件类型 |
| | | if (request instanceof MultipartHttpServletRequest) {
|
| | | MultipartHttpServletRequest fileRequest = (MultipartHttpServletRequest) request;
|
| | | brandInfoService.saveObject(fileRequest.getFile("file"), brandInfo);
|
| | | }else{
|
| | | brandInfoService.saveObject(null, brandInfo);
|
| | | }
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
|
| | | } catch (BrandInfoException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "queryBrand")
|
| | | public void query(String callback, Integer pageIndex, Integer pageSize, String key, Long cid, Integer state,
|
| | | public void queryBrand(String callback, Integer pageIndex, Integer pageSize, String key, Long cid, Integer state,
|
| | | PrintWriter out) {
|
| | |
|
| | | if (pageIndex == null || pageIndex < 1) {
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | for (BrandInfo brandInfo: list) {
|
| | | BrandClass brandClass = brandInfo.getBrandClass();
|
| | | if (brandClass != null && StringUtil.isNullOrEmpty(brandClass.getName())) {
|
| | | BrandClass bclass = brandClassService.selectByPrimaryKey(brandClass.getId());
|
| | | if (bclass != null) {
|
| | | brandInfo.setBrandClass(bclass);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | long count = brandInfoService.countQuery(key, cid, state);
|
| | | int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
|
| | | PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
|