code format

master
erzhongxmu 2024-03-02 18:27:59 +08:00
parent 0da6a22454
commit 70d722afb5
2 changed files with 377 additions and 384 deletions

View File

@ -1,4 +1,5 @@
package com.zzjee.wm.controller; package com.zzjee.wm.controller;
import com.zzjee.md.entity.MdBinEntity; import com.zzjee.md.entity.MdBinEntity;
import com.zzjee.md.entity.MdCusEntity; import com.zzjee.md.entity.MdCusEntity;
import com.zzjee.md.entity.MdGoodsEntity; import com.zzjee.md.entity.MdGoodsEntity;
@ -83,382 +84,380 @@ import org.springframework.http.MediaType;
import org.springframework.web.util.UriComponentsBuilder; import org.springframework.web.util.UriComponentsBuilder;
/** /**
* @author erzhongxmu
* @version V1.0
* @Title: Controller * @Title: Controller
* @Description: * @Description:
* @author erzhongxmu
* @date 2017-10-11 00:26:00 * @date 2017-10-11 00:26:00
* @version V1.0
*
*/ */
@Controller @Controller
@RequestMapping("/wmDayCostConfController") @RequestMapping("/wmDayCostConfController")
public class WmDayCostConfController extends BaseController { public class WmDayCostConfController extends BaseController {
/** /**
* Logger for this class * Logger for this class
*/ */
private static final Logger logger = Logger.getLogger(WmDayCostConfController.class); private static final Logger logger = Logger.getLogger(WmDayCostConfController.class);
@Autowired @Autowired
private WmDayCostConfServiceI wmDayCostConfService; private WmDayCostConfServiceI wmDayCostConfService;
@Autowired @Autowired
private SystemService systemService; private SystemService systemService;
@Autowired @Autowired
private Validator validator; private Validator validator;
@Autowired @Autowired
private CostTask task; private CostTask task;
/** /**
* *
* *
* @return * @return
*/ */
@RequestMapping(params = "list") @RequestMapping(params = "list")
public ModelAndView list(HttpServletRequest request) { public ModelAndView list(HttpServletRequest request) {
return new ModelAndView("com/zzjee/wm/wmDayCostConfList"); return new ModelAndView("com/zzjee/wm/wmDayCostConfList");
} }
/** /**
* easyui AJAX * easyui AJAX
* *
* @param request * @param request
* @param response * @param response
* @param dataGrid * @param dataGrid
*/ */
@RequestMapping(params = "datagrid") @RequestMapping(params = "datagrid")
public void datagrid(WmDayCostConfEntity wmDayCostConf,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) { public void datagrid(WmDayCostConfEntity wmDayCostConf, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
CriteriaQuery cq = new CriteriaQuery(WmDayCostConfEntity.class, dataGrid); CriteriaQuery cq = new CriteriaQuery(WmDayCostConfEntity.class, dataGrid);
//查询条件组装器 //查询条件组装器
org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, wmDayCostConf, request.getParameterMap()); org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, wmDayCostConf, request.getParameterMap());
try{ try {
//自定义追加查询条件 //自定义追加查询条件
}catch (Exception e) { } catch (Exception e) {
throw new BusinessException(e.getMessage()); throw new BusinessException(e.getMessage());
} }
Map<String,Object> map1 = new HashMap<String,Object>(); Map<String, Object> map1 = new HashMap<String, Object>();
map1.put("costDate", "desc"); map1.put("costDate", "desc");
cq.setOrder(map1); cq.setOrder(map1);
cq.add(); cq.add();
this.wmDayCostConfService.getDataGridReturn(cq, true); this.wmDayCostConfService.getDataGridReturn(cq, true);
TagUtil.datagrid(response, dataGrid); TagUtil.datagrid(response, dataGrid);
} }
/** /**
* *
* *
* @return * @return
*/ */
@RequestMapping(params = "doDel") @RequestMapping(params = "doDel")
@ResponseBody @ResponseBody
public AjaxJson doDel(WmDayCostConfEntity wmDayCostConf, HttpServletRequest request) { public AjaxJson doDel(WmDayCostConfEntity wmDayCostConf, HttpServletRequest request) {
String message = null; String message = null;
AjaxJson j = new AjaxJson(); AjaxJson j = new AjaxJson();
wmDayCostConf = systemService.getEntity(WmDayCostConfEntity.class, wmDayCostConf.getId()); wmDayCostConf = systemService.getEntity(WmDayCostConfEntity.class, wmDayCostConf.getId());
message = "计费日期配置删除成功"; message = "计费日期配置删除成功";
try{ try {
wmDayCostConf.setCostSf("N"); wmDayCostConf.setCostSf("N");
wmDayCostConfService.saveOrUpdate(wmDayCostConf); wmDayCostConfService.saveOrUpdate(wmDayCostConf);
systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
}catch(Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
message = "计费日期配置删除失败"; throw new BusinessException(e.getMessage());
throw new BusinessException(e.getMessage()); }
} j.setMsg(message);
j.setMsg(message); return j;
return j; }
}
/** /**
* *
* *
* @return * @return
*/ */
@RequestMapping(params = "doBatchDel") @RequestMapping(params = "doBatchDel")
@ResponseBody @ResponseBody
public AjaxJson doBatchDel(String ids,HttpServletRequest request){ public AjaxJson doBatchDel(String ids, HttpServletRequest request) {
String message = null; String message = null;
AjaxJson j = new AjaxJson(); AjaxJson j = new AjaxJson();
message = "计费日期配置删除成功"; message = "计费日期配置删除成功";
try{ try {
for(String id:ids.split(",")){ for (String id : ids.split(",")) {
WmDayCostConfEntity wmDayCostConf = systemService.getEntity(WmDayCostConfEntity.class, WmDayCostConfEntity wmDayCostConf = systemService.getEntity(WmDayCostConfEntity.class,
id id
); );
wmDayCostConf.setCostSf("N"); wmDayCostConf.setCostSf("N");
wmDayCostConfService.saveOrUpdate(wmDayCostConf); wmDayCostConfService.saveOrUpdate(wmDayCostConf);
// wmDayCostConfService.delete(wmDayCostConf); // wmDayCostConfService.delete(wmDayCostConf);
systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
} }
}catch(Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
message = "计费日期配置删除失败"; throw new BusinessException(e.getMessage());
throw new BusinessException(e.getMessage()); }
} j.setMsg(message);
j.setMsg(message); return j;
return j; }
}
/** /**
* *
* *
* @return * @return
*/ */
@RequestMapping(params = "doAdd") @RequestMapping(params = "doAdd")
@ResponseBody @ResponseBody
public AjaxJson doAdd(WmDayCostConfEntity wmDayCostConf, HttpServletRequest request) { public AjaxJson doAdd(WmDayCostConfEntity wmDayCostConf, HttpServletRequest request) {
String message = null; String message = null;
AjaxJson j = new AjaxJson(); AjaxJson j = new AjaxJson();
message = "计费日期配置添加成功"; message = "计费日期配置添加成功";
try{ try {
wmDayCostConfService.save(wmDayCostConf); wmDayCostConfService.save(wmDayCostConf);
systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO); systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
}catch(Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
message = "计费日期配置添加失败"; throw new BusinessException(e.getMessage());
throw new BusinessException(e.getMessage()); }
} j.setMsg(message);
j.setMsg(message); return j;
return j; }
}
/**
*
*
* @return
*/
@RequestMapping(params = "doCount")
@ResponseBody
public AjaxJson doCount(WmDayCostConfEntity wmDayCostConf, HttpServletRequest request) {
String message = null;
AjaxJson j = new AjaxJson();
message = "费用更新成功";
try {
WmDayCostConfEntity t = wmDayCostConfService.get(WmDayCostConfEntity.class, request.getParameter("id")); /**
*
*
* @return
*/
@RequestMapping(params = "doCount")
@ResponseBody
public AjaxJson doCount(WmDayCostConfEntity wmDayCostConf, HttpServletRequest request) {
String message = null;
AjaxJson j = new AjaxJson();
message = "费用更新成功";
try {
if(t.getCostSf()!=null&&t.getCostSf().equals("Y")){ WmDayCostConfEntity t = wmDayCostConfService.get(WmDayCostConfEntity.class, request.getParameter("id"));
j.setMsg(message);
message = "费用已经更新";
return j;
}
try{
task.costcountv2(DateUtils.date2Str(t.getCostDate(),DateUtils.date_sdf),"Y",t);
}catch (Exception e){
} if (t.getCostSf() != null && t.getCostSf().equals("Y")) {
t.setCostSf("Y"); j.setMsg(message);
systemService.updateEntitie(t); message = "费用已经更新";
return j;
}
try {
task.costcountv2(DateUtils.date2Str(t.getCostDate(), DateUtils.date_sdf), "Y", t);
} catch (Exception e) {
//计算仓租 }
// 再计算 t.setCostSf("Y");
} catch (Exception e) { systemService.updateEntitie(t);
e.printStackTrace();
message = "费用更新失败"; //计算仓租
throw new BusinessException(e.getMessage()); // 再计算
} } catch (Exception e) {
j.setMsg(message); e.printStackTrace();
return j; throw new BusinessException(e.getMessage());
} }
/** j.setMsg(message);
* return j;
* }
* @param ids
* @return /**
*/ *
@RequestMapping(params = "doUpdate") *
@ResponseBody * @param ids
public AjaxJson doUpdate(WmDayCostConfEntity wmDayCostConf, HttpServletRequest request) { * @return
String message = null; */
AjaxJson j = new AjaxJson(); @RequestMapping(params = "doUpdate")
message = "计费日期配置更新成功"; @ResponseBody
WmDayCostConfEntity t = wmDayCostConfService.get(WmDayCostConfEntity.class, wmDayCostConf.getId()); public AjaxJson doUpdate(WmDayCostConfEntity wmDayCostConf, HttpServletRequest request) {
try { String message = null;
MyBeanUtils.copyBeanNotNull2Bean(wmDayCostConf, t); AjaxJson j = new AjaxJson();
wmDayCostConfService.saveOrUpdate(t); message = "计费日期配置更新成功";
systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); WmDayCostConfEntity t = wmDayCostConfService.get(WmDayCostConfEntity.class, wmDayCostConf.getId());
} catch (Exception e) { try {
e.printStackTrace(); MyBeanUtils.copyBeanNotNull2Bean(wmDayCostConf, t);
message = "计费日期配置更新失败"; wmDayCostConfService.saveOrUpdate(t);
throw new BusinessException(e.getMessage()); systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
} } catch (Exception e) {
j.setMsg(message); e.printStackTrace();
return j; throw new BusinessException(e.getMessage());
} }
j.setMsg(message);
return j;
}
/** /**
* *
* *
* @return * @return
*/ */
@RequestMapping(params = "goAdd") @RequestMapping(params = "goAdd")
public ModelAndView goAdd(WmDayCostConfEntity wmDayCostConf, HttpServletRequest req) { public ModelAndView goAdd(WmDayCostConfEntity wmDayCostConf, HttpServletRequest req) {
if (StringUtil.isNotEmpty(wmDayCostConf.getId())) { if (StringUtil.isNotEmpty(wmDayCostConf.getId())) {
wmDayCostConf = wmDayCostConfService.getEntity(WmDayCostConfEntity.class, wmDayCostConf.getId()); wmDayCostConf = wmDayCostConfService.getEntity(WmDayCostConfEntity.class, wmDayCostConf.getId());
req.setAttribute("wmDayCostConfPage", wmDayCostConf); req.setAttribute("wmDayCostConfPage", wmDayCostConf);
} }
return new ModelAndView("com/zzjee/wm/wmDayCostConf-add"); return new ModelAndView("com/zzjee/wm/wmDayCostConf-add");
} }
/**
*
*
* @return
*/
@RequestMapping(params = "goUpdate")
public ModelAndView goUpdate(WmDayCostConfEntity wmDayCostConf, HttpServletRequest req) {
if (StringUtil.isNotEmpty(wmDayCostConf.getId())) {
wmDayCostConf = wmDayCostConfService.getEntity(WmDayCostConfEntity.class, wmDayCostConf.getId());
req.setAttribute("wmDayCostConfPage", wmDayCostConf);
}
return new ModelAndView("com/zzjee/wm/wmDayCostConf-update");
}
/** /**
* *
* *
* @return * @return
*/ */
@RequestMapping(params = "upload") @RequestMapping(params = "goUpdate")
public ModelAndView upload(HttpServletRequest req) { public ModelAndView goUpdate(WmDayCostConfEntity wmDayCostConf, HttpServletRequest req) {
req.setAttribute("controller_name","wmDayCostConfController"); if (StringUtil.isNotEmpty(wmDayCostConf.getId())) {
return new ModelAndView("common/upload/pub_excel_upload"); wmDayCostConf = wmDayCostConfService.getEntity(WmDayCostConfEntity.class, wmDayCostConf.getId());
} req.setAttribute("wmDayCostConfPage", wmDayCostConf);
}
return new ModelAndView("com/zzjee/wm/wmDayCostConf-update");
}
/** /**
* excel *
* *
* @param request * @return
* @param response */
*/ @RequestMapping(params = "upload")
@RequestMapping(params = "exportXls") public ModelAndView upload(HttpServletRequest req) {
public String exportXls(WmDayCostConfEntity wmDayCostConf,HttpServletRequest request,HttpServletResponse response req.setAttribute("controller_name", "wmDayCostConfController");
, DataGrid dataGrid,ModelMap modelMap) { return new ModelAndView("common/upload/pub_excel_upload");
CriteriaQuery cq = new CriteriaQuery(WmDayCostConfEntity.class, dataGrid); }
org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, wmDayCostConf, request.getParameterMap());
List<WmDayCostConfEntity> wmDayCostConfs = this.wmDayCostConfService.getListByCriteriaQuery(cq,false);
modelMap.put(NormalExcelConstants.FILE_NAME,"计费日期配置");
modelMap.put(NormalExcelConstants.CLASS,WmDayCostConfEntity.class);
modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("计费日期配置列表", "导出人:"+ResourceUtil.getSessionUserName().getRealName(),
"导出信息"));
modelMap.put(NormalExcelConstants.DATA_LIST,wmDayCostConfs);
return NormalExcelConstants.JEECG_EXCEL_VIEW;
}
/**
* excel 使
*
* @param request
* @param response
*/
@RequestMapping(params = "exportXlsByT")
public String exportXlsByT(WmDayCostConfEntity wmDayCostConf,HttpServletRequest request,HttpServletResponse response
, DataGrid dataGrid,ModelMap modelMap) {
modelMap.put(NormalExcelConstants.FILE_NAME,"计费日期配置");
modelMap.put(NormalExcelConstants.CLASS,WmDayCostConfEntity.class);
modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("计费日期配置列表", "导出人:"+ResourceUtil.getSessionUserName().getRealName(),
"导出信息"));
modelMap.put(NormalExcelConstants.DATA_LIST,new ArrayList());
return NormalExcelConstants.JEECG_EXCEL_VIEW;
}
@SuppressWarnings("unchecked") /**
@RequestMapping(params = "importExcel", method = RequestMethod.POST) * excel
@ResponseBody *
public AjaxJson importExcel(HttpServletRequest request, HttpServletResponse response) { * @param request
AjaxJson j = new AjaxJson(); * @param response
*/
@RequestMapping(params = "exportXls")
public String exportXls(WmDayCostConfEntity wmDayCostConf, HttpServletRequest request, HttpServletResponse response
, DataGrid dataGrid, ModelMap modelMap) {
CriteriaQuery cq = new CriteriaQuery(WmDayCostConfEntity.class, dataGrid);
org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, wmDayCostConf, request.getParameterMap());
List<WmDayCostConfEntity> wmDayCostConfs = this.wmDayCostConfService.getListByCriteriaQuery(cq, false);
modelMap.put(NormalExcelConstants.FILE_NAME, "计费日期配置");
modelMap.put(NormalExcelConstants.CLASS, WmDayCostConfEntity.class);
modelMap.put(NormalExcelConstants.PARAMS, new ExportParams("计费日期配置列表", "导出人:" + ResourceUtil.getSessionUserName().getRealName(),
"导出信息"));
modelMap.put(NormalExcelConstants.DATA_LIST, wmDayCostConfs);
return NormalExcelConstants.JEECG_EXCEL_VIEW;
}
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; /**
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap(); * excel 使
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) { *
MultipartFile file = entity.getValue();// 获取上传文件对象 * @param request
ImportParams params = new ImportParams(); * @param response
params.setTitleRows(2); */
params.setHeadRows(1); @RequestMapping(params = "exportXlsByT")
params.setNeedSave(true); public String exportXlsByT(WmDayCostConfEntity wmDayCostConf, HttpServletRequest request, HttpServletResponse response
try { , DataGrid dataGrid, ModelMap modelMap) {
List<WmDayCostConfEntity> listWmDayCostConfEntitys = ExcelImportUtil.importExcel(file.getInputStream(),WmDayCostConfEntity.class,params); modelMap.put(NormalExcelConstants.FILE_NAME, "计费日期配置");
for (WmDayCostConfEntity wmDayCostConf : listWmDayCostConfEntitys) { modelMap.put(NormalExcelConstants.CLASS, WmDayCostConfEntity.class);
wmDayCostConfService.save(wmDayCostConf); modelMap.put(NormalExcelConstants.PARAMS, new ExportParams("计费日期配置列表", "导出人:" + ResourceUtil.getSessionUserName().getRealName(),
} "导出信息"));
j.setMsg("文件导入成功!"); modelMap.put(NormalExcelConstants.DATA_LIST, new ArrayList());
} catch (Exception e) { return NormalExcelConstants.JEECG_EXCEL_VIEW;
j.setMsg("文件导入失败!"); }
logger.error(ExceptionUtil.getExceptionMessage(e));
}finally{
try {
file.getInputStream().close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return j;
}
@RequestMapping(method = RequestMethod.GET) @SuppressWarnings("unchecked")
@ResponseBody @RequestMapping(params = "importExcel", method = RequestMethod.POST)
public List<WmDayCostConfEntity> list() { @ResponseBody
List<WmDayCostConfEntity> listWmDayCostConfs=wmDayCostConfService.getList(WmDayCostConfEntity.class); public AjaxJson importExcel(HttpServletRequest request, HttpServletResponse response) {
return listWmDayCostConfs; AjaxJson j = new AjaxJson();
}
@RequestMapping(value = "/{id}", method = RequestMethod.GET) MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
@ResponseBody Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
public ResponseEntity<?> get(@PathVariable("id") String id) { for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
WmDayCostConfEntity task = wmDayCostConfService.get(WmDayCostConfEntity.class, id); MultipartFile file = entity.getValue();// 获取上传文件对象
if (task == null) { ImportParams params = new ImportParams();
return new ResponseEntity(HttpStatus.NOT_FOUND); params.setTitleRows(2);
} params.setHeadRows(1);
return new ResponseEntity(task, HttpStatus.OK); params.setNeedSave(true);
} try {
List<WmDayCostConfEntity> listWmDayCostConfEntitys = ExcelImportUtil.importExcel(file.getInputStream(), WmDayCostConfEntity.class, params);
for (WmDayCostConfEntity wmDayCostConf : listWmDayCostConfEntitys) {
wmDayCostConfService.save(wmDayCostConf);
}
j.setMsg("文件导入成功!");
} catch (Exception e) {
j.setMsg("文件导入失败!");
logger.error(ExceptionUtil.getExceptionMessage(e));
} finally {
try {
file.getInputStream().close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return j;
}
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(method = RequestMethod.GET)
@ResponseBody @ResponseBody
public ResponseEntity<?> create(@RequestBody WmDayCostConfEntity wmDayCostConf, UriComponentsBuilder uriBuilder) { public List<WmDayCostConfEntity> list() {
//调用JSR303 Bean Validator进行校验如果出错返回含400错误码及json格式的错误信息. List<WmDayCostConfEntity> listWmDayCostConfs = wmDayCostConfService.getList(WmDayCostConfEntity.class);
Set<ConstraintViolation<WmDayCostConfEntity>> failures = validator.validate(wmDayCostConf); return listWmDayCostConfs;
if (!failures.isEmpty()) { }
return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
}
//保存 @RequestMapping(value = "/{id}", method = RequestMethod.GET)
try{ @ResponseBody
wmDayCostConfService.save(wmDayCostConf); public ResponseEntity<?> get(@PathVariable("id") String id) {
} catch (Exception e) { WmDayCostConfEntity task = wmDayCostConfService.get(WmDayCostConfEntity.class, id);
e.printStackTrace(); if (task == null) {
return new ResponseEntity(HttpStatus.NO_CONTENT); return new ResponseEntity(HttpStatus.NOT_FOUND);
} }
//按照Restful风格约定创建指向新任务的url, 也可以直接返回id或对象. return new ResponseEntity(task, HttpStatus.OK);
String id = wmDayCostConf.getId(); }
URI uri = uriBuilder.path("/rest/wmDayCostConfController/" + id).build().toUri();
HttpHeaders headers = new HttpHeaders();
headers.setLocation(uri);
return new ResponseEntity(headers, HttpStatus.CREATED); @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
} @ResponseBody
public ResponseEntity<?> create(@RequestBody WmDayCostConfEntity wmDayCostConf, UriComponentsBuilder uriBuilder) {
//调用JSR303 Bean Validator进行校验如果出错返回含400错误码及json格式的错误信息.
Set<ConstraintViolation<WmDayCostConfEntity>> failures = validator.validate(wmDayCostConf);
if (!failures.isEmpty()) {
return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
}
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE) //保存
public ResponseEntity<?> update(@RequestBody WmDayCostConfEntity wmDayCostConf) { try {
//调用JSR303 Bean Validator进行校验如果出错返回含400错误码及json格式的错误信息. wmDayCostConfService.save(wmDayCostConf);
Set<ConstraintViolation<WmDayCostConfEntity>> failures = validator.validate(wmDayCostConf); } catch (Exception e) {
if (!failures.isEmpty()) { e.printStackTrace();
return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST); return new ResponseEntity(HttpStatus.NO_CONTENT);
} }
//按照Restful风格约定创建指向新任务的url, 也可以直接返回id或对象.
String id = wmDayCostConf.getId();
URI uri = uriBuilder.path("/rest/wmDayCostConfController/" + id).build().toUri();
HttpHeaders headers = new HttpHeaders();
headers.setLocation(uri);
//保存 return new ResponseEntity(headers, HttpStatus.CREATED);
try{ }
wmDayCostConfService.saveOrUpdate(wmDayCostConf);
} catch (Exception e) {
e.printStackTrace();
return new ResponseEntity(HttpStatus.NO_CONTENT);
}
//按Restful约定返回204状态码, 无内容. 也可以返回200状态码. @RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
return new ResponseEntity(HttpStatus.NO_CONTENT); public ResponseEntity<?> update(@RequestBody WmDayCostConfEntity wmDayCostConf) {
} //调用JSR303 Bean Validator进行校验如果出错返回含400错误码及json格式的错误信息.
Set<ConstraintViolation<WmDayCostConfEntity>> failures = validator.validate(wmDayCostConf);
if (!failures.isEmpty()) {
return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
}
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE) //保存
@ResponseStatus(HttpStatus.NO_CONTENT) try {
public void delete(@PathVariable("id") String id) { wmDayCostConfService.saveOrUpdate(wmDayCostConf);
wmDayCostConfService.deleteEntityById(WmDayCostConfEntity.class, id); } catch (Exception e) {
} e.printStackTrace();
return new ResponseEntity(HttpStatus.NO_CONTENT);
}
//按Restful约定返回204状态码, 无内容. 也可以返回200状态码.
return new ResponseEntity(HttpStatus.NO_CONTENT);
}
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void delete(@PathVariable("id") String id) {
wmDayCostConfService.deleteEntityById(WmDayCostConfEntity.class, id);
}
} }

View File

@ -315,7 +315,6 @@ public class WmDayCostController extends BaseController {
systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
}catch(Exception e){ }catch(Exception e){
e.printStackTrace(); e.printStackTrace();
message = "费用维护删除失败";
throw new BusinessException(e.getMessage()); throw new BusinessException(e.getMessage());
} }
j.setMsg(message); j.setMsg(message);
@ -343,7 +342,6 @@ public class WmDayCostController extends BaseController {
} }
}catch(Exception e){ }catch(Exception e){
e.printStackTrace(); e.printStackTrace();
message = "费用维护删除失败";
throw new BusinessException(e.getMessage()); throw new BusinessException(e.getMessage());
} }
j.setMsg(message); j.setMsg(message);
@ -368,7 +366,6 @@ public class WmDayCostController extends BaseController {
systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO); systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
}catch(Exception e){ }catch(Exception e){
e.printStackTrace(); e.printStackTrace();
message = "费用维护添加失败";
throw new BusinessException(e.getMessage()); throw new BusinessException(e.getMessage());
} }
j.setMsg(message); j.setMsg(message);
@ -394,7 +391,6 @@ public class WmDayCostController extends BaseController {
systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
message = "费用维护更新失败";
throw new BusinessException(e.getMessage()); throw new BusinessException(e.getMessage());
} }
j.setMsg(message); j.setMsg(message);
@ -420,7 +416,6 @@ public class WmDayCostController extends BaseController {
systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
message = "费用结清失败";
throw new BusinessException(e.getMessage()); throw new BusinessException(e.getMessage());
} }
j.setMsg(message); j.setMsg(message);
@ -440,7 +435,6 @@ public class WmDayCostController extends BaseController {
systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
message = "费用反结清失败";
throw new BusinessException(e.getMessage()); throw new BusinessException(e.getMessage());
} }
j.setMsg(message); j.setMsg(message);