TrafficSubsidyController.java 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. package cn.com.lzt.trafficsubsidy.controller;
  2. import java.io.IOException;
  3. import java.net.URI;
  4. import java.util.ArrayList;
  5. import java.util.HashMap;
  6. import java.util.List;
  7. import java.util.Map;
  8. import java.util.Set;
  9. import javax.servlet.http.HttpServletRequest;
  10. import javax.servlet.http.HttpServletResponse;
  11. import javax.validation.ConstraintViolation;
  12. import javax.validation.Validator;
  13. import org.apache.log4j.Logger;
  14. import org.jeecgframework.core.beanvalidator.BeanValidators;
  15. import org.jeecgframework.core.common.controller.BaseController;
  16. import org.jeecgframework.core.common.exception.BusinessException;
  17. import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery;
  18. import org.jeecgframework.core.common.model.json.AjaxJson;
  19. import org.jeecgframework.core.common.model.json.DataGrid;
  20. import org.jeecgframework.core.constant.Globals;
  21. import org.jeecgframework.core.util.ExceptionUtil;
  22. import org.jeecgframework.core.util.MyBeanUtils;
  23. import org.jeecgframework.core.util.ResourceUtil;
  24. import org.jeecgframework.core.util.StringUtil;
  25. import org.jeecgframework.poi.excel.ExcelImportUtil;
  26. import org.jeecgframework.poi.excel.entity.ExportParams;
  27. import org.jeecgframework.poi.excel.entity.ImportParams;
  28. import org.jeecgframework.poi.excel.entity.vo.NormalExcelConstants;
  29. import org.jeecgframework.tag.core.easyui.TagUtil;
  30. import org.jeecgframework.web.system.service.SystemService;
  31. import org.springframework.beans.factory.annotation.Autowired;
  32. import org.springframework.http.HttpHeaders;
  33. import org.springframework.http.HttpStatus;
  34. import org.springframework.http.MediaType;
  35. import org.springframework.http.ResponseEntity;
  36. import org.springframework.stereotype.Controller;
  37. import org.springframework.ui.ModelMap;
  38. import org.springframework.web.bind.annotation.PathVariable;
  39. import org.springframework.web.bind.annotation.RequestBody;
  40. import org.springframework.web.bind.annotation.RequestMapping;
  41. import org.springframework.web.bind.annotation.RequestMethod;
  42. import org.springframework.web.bind.annotation.ResponseBody;
  43. import org.springframework.web.bind.annotation.ResponseStatus;
  44. import org.springframework.web.multipart.MultipartFile;
  45. import org.springframework.web.multipart.MultipartHttpServletRequest;
  46. import org.springframework.web.servlet.ModelAndView;
  47. import org.springframework.web.util.UriComponentsBuilder;
  48. import cn.com.lzt.certificatesubsidy.entity.CertificateSubsidyEntity;
  49. import cn.com.lzt.trafficsubsidy.entity.TrafficSubsidyEntity;
  50. import cn.com.lzt.trafficsubsidy.service.TrafficSubsidyServiceI;
  51. /**
  52. * @Title: Controller
  53. * @Description: 交通补贴
  54. * @author onlineGenerator
  55. * @date 2017-10-18 18:02:16
  56. * @version V1.0
  57. *
  58. */
  59. @Controller
  60. @RequestMapping("/trafficSubsidyController")
  61. public class TrafficSubsidyController extends BaseController {
  62. /**
  63. * Logger for this class
  64. */
  65. private static final Logger logger = Logger.getLogger(TrafficSubsidyController.class);
  66. @Autowired
  67. private TrafficSubsidyServiceI trafficSubsidyService;
  68. @Autowired
  69. private SystemService systemService;
  70. @Autowired
  71. private Validator validator;
  72. /**
  73. * 交通补贴列表 页面跳转
  74. *
  75. * @return
  76. */
  77. @RequestMapping(params = "list")
  78. public ModelAndView list(HttpServletRequest request) {
  79. return new ModelAndView("cn/com/lzt/trafficsubsidy/trafficSubsidyList");
  80. }
  81. /**
  82. * easyui AJAX请求数据
  83. *
  84. * @param request
  85. * @param response
  86. * @param dataGrid
  87. * @param user
  88. */
  89. @RequestMapping(params = "datagrid")
  90. public void datagrid(TrafficSubsidyEntity trafficSubsidy,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
  91. CriteriaQuery cq = new CriteriaQuery(TrafficSubsidyEntity.class, dataGrid);
  92. //查询条件组装器
  93. org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, trafficSubsidy, request.getParameterMap());
  94. try{
  95. //自定义追加查询条件
  96. String[] status = new String[]{Globals.Enabled_Status.toString(), Globals.Disabled_Status.toString()};
  97. cq.in("status", status);
  98. cq.eq("deleteFlag", Globals.Delete_Normal.toString());
  99. Map map = new HashMap();
  100. map.put("createDate", "desc");
  101. cq.setOrder(map);
  102. }catch (Exception e) {
  103. throw new BusinessException(e.getMessage());
  104. }
  105. cq.add();
  106. this.trafficSubsidyService.getDataGridReturn(cq, true);
  107. TagUtil.datagrid(response, dataGrid);
  108. }
  109. /**
  110. * 保存新增/更新的行数据
  111. * @param page
  112. * @return
  113. */
  114. @RequestMapping(params = "saveRows")
  115. @ResponseBody
  116. public AjaxJson saveRows(TrafficSubsidyEntity trafficSubsidy, HttpServletRequest request){
  117. String message = null;
  118. AjaxJson j = new AjaxJson();
  119. message = "";
  120. if (StringUtil.isNotEmpty(trafficSubsidy.getId())) {
  121. TrafficSubsidyEntity t = trafficSubsidyService.get(TrafficSubsidyEntity.class, trafficSubsidy.getId());
  122. try {
  123. MyBeanUtils.copyBeanNotNull2Bean(trafficSubsidy, t);
  124. trafficSubsidyService.updateEntitie(t);
  125. systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
  126. message = "交通补贴更新成功";
  127. } catch (Exception e) {
  128. e.printStackTrace();
  129. message = "交通补贴更新失败";
  130. throw new BusinessException(e.getMessage());
  131. }
  132. } else {
  133. try{
  134. trafficSubsidy.setDeleteFlag(Globals.Delete_Normal.toString());
  135. trafficSubsidy.setStatus(Globals.Enabled_Status.toString());
  136. trafficSubsidyService.save(trafficSubsidy);
  137. systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
  138. message = "交通补贴添加成功";
  139. }catch(Exception e){
  140. e.printStackTrace();
  141. message = "交通补贴添加失败";
  142. throw new BusinessException(e.getMessage());
  143. }
  144. }
  145. j.setMsg(message);
  146. return j;
  147. }
  148. /**
  149. * 删除交通补贴
  150. *
  151. * @return
  152. */
  153. @RequestMapping(params = "doDel")
  154. @ResponseBody
  155. public AjaxJson doDel(TrafficSubsidyEntity trafficSubsidy, HttpServletRequest request) {
  156. String message = null;
  157. AjaxJson j = new AjaxJson();
  158. trafficSubsidy = systemService.getEntity(TrafficSubsidyEntity.class, trafficSubsidy.getId());
  159. message = "交通补贴删除成功";
  160. try{
  161. trafficSubsidyService.delete(trafficSubsidy);
  162. systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
  163. }catch(Exception e){
  164. e.printStackTrace();
  165. message = "交通补贴删除失败";
  166. throw new BusinessException(e.getMessage());
  167. }
  168. j.setMsg(message);
  169. return j;
  170. }
  171. /**
  172. * 批量删除交通补贴
  173. *
  174. * @return
  175. */
  176. @RequestMapping(params = "doBatchDel")
  177. @ResponseBody
  178. public AjaxJson doBatchDel(String ids,HttpServletRequest request){
  179. String message = null;
  180. AjaxJson j = new AjaxJson();
  181. message = "交通补贴删除成功";
  182. try{
  183. for(String id:ids.split(",")){
  184. TrafficSubsidyEntity trafficSubsidy = systemService.getEntity(TrafficSubsidyEntity.class,
  185. id
  186. );
  187. trafficSubsidyService.delete(trafficSubsidy);
  188. systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
  189. }
  190. }catch(Exception e){
  191. e.printStackTrace();
  192. message = "交通补贴删除失败";
  193. throw new BusinessException(e.getMessage());
  194. }
  195. j.setMsg(message);
  196. return j;
  197. }
  198. /**
  199. * 批量逻辑删除交通补贴
  200. *
  201. * @return
  202. */
  203. @RequestMapping(params = "doBatchLogicDel")
  204. @ResponseBody
  205. public AjaxJson doBatchLogicDel(String ids,HttpServletRequest request){
  206. String message = null;
  207. AjaxJson j = new AjaxJson();
  208. message = "交通补贴删除成功";
  209. List<TrafficSubsidyEntity> pojoList = new ArrayList<TrafficSubsidyEntity>();
  210. try{
  211. for(String id:ids.split(",")){
  212. TrafficSubsidyEntity trafficSubsidy = systemService.getEntity(TrafficSubsidyEntity.class, id);
  213. trafficSubsidy.setDeleteFlag(Globals.Delete_Forbidden.toString());// 设置为1已删除
  214. pojoList.add(trafficSubsidy);
  215. }
  216. trafficSubsidyService.batchUpdate(pojoList);// 执行批量更新
  217. systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
  218. }catch(Exception e){
  219. e.printStackTrace();
  220. message = "交通补贴删除失败";
  221. throw new BusinessException(e.getMessage());
  222. }
  223. j.setMsg(message);
  224. return j;
  225. }
  226. /**
  227. * 启用交通补贴
  228. *
  229. * @return
  230. */
  231. @RequestMapping(params = "doEnableObj")
  232. @ResponseBody
  233. public AjaxJson doEnableObj(String ids,HttpServletRequest request){
  234. String message = null;
  235. AjaxJson j = new AjaxJson();
  236. message = "交通补贴启用成功";
  237. List<TrafficSubsidyEntity> pojoList = new ArrayList<TrafficSubsidyEntity>();
  238. try{
  239. for(String id:ids.split(",")){
  240. TrafficSubsidyEntity trafficSubsidy = systemService.getEntity(TrafficSubsidyEntity.class, id);
  241. trafficSubsidy.setStatus(Globals.Enabled_Status.toString());// 设置为0启用
  242. pojoList.add(trafficSubsidy);
  243. }
  244. trafficSubsidyService.batchUpdate(pojoList);// 执行批量更新
  245. systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
  246. }catch(Exception e){
  247. e.printStackTrace();
  248. message = "交通补贴启用失败";
  249. throw new BusinessException(e.getMessage());
  250. }
  251. j.setMsg(message);
  252. return j;
  253. }
  254. /**
  255. * 停用交通补贴
  256. *
  257. * @return
  258. */
  259. @RequestMapping(params = "doDisableObj")
  260. @ResponseBody
  261. public AjaxJson doDisableObj(String ids,HttpServletRequest request){
  262. String message = null;
  263. AjaxJson j = new AjaxJson();
  264. message = "交通补贴停用成功";
  265. List<TrafficSubsidyEntity> pojoList = new ArrayList<TrafficSubsidyEntity>();
  266. try{
  267. for(String id:ids.split(",")){
  268. TrafficSubsidyEntity trafficSubsidy = systemService.getEntity(TrafficSubsidyEntity.class, id);
  269. trafficSubsidy.setStatus(Globals.Disabled_Status.toString());// 设置为1停用
  270. pojoList.add(trafficSubsidy);
  271. }
  272. trafficSubsidyService.batchUpdate(pojoList);// 执行批量更新
  273. systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
  274. }catch(Exception e){
  275. e.printStackTrace();
  276. message = "交通补贴停用失败";
  277. throw new BusinessException(e.getMessage());
  278. }
  279. j.setMsg(message);
  280. return j;
  281. }
  282. /**
  283. * 补贴名称重复校验
  284. *
  285. * @param ids
  286. * @return
  287. */
  288. @RequestMapping(params = "checkName")
  289. @ResponseBody
  290. public Map<String,Object> checkName(TrafficSubsidyEntity trafficSubsidy, HttpServletRequest request) {
  291. Boolean flag = trafficSubsidyService.findByName(trafficSubsidy);
  292. Map<String,Object> res = new HashMap<String, Object>();
  293. res.put("flag",flag);
  294. return res;
  295. }
  296. /**
  297. * 添加交通补贴
  298. *
  299. * @param ids
  300. * @return
  301. */
  302. @RequestMapping(params = "doAdd")
  303. @ResponseBody
  304. public AjaxJson doAdd(TrafficSubsidyEntity trafficSubsidy, HttpServletRequest request) {
  305. String message = null;
  306. AjaxJson j = new AjaxJson();
  307. message = "交通补贴添加成功";
  308. try{
  309. trafficSubsidy.setDeleteFlag(Globals.Delete_Normal.toString());
  310. trafficSubsidy.setStatus(Globals.Enabled_Status.toString());
  311. trafficSubsidyService.save(trafficSubsidy);
  312. systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
  313. }catch(Exception e){
  314. e.printStackTrace();
  315. message = "交通补贴添加失败";
  316. throw new BusinessException(e.getMessage());
  317. }
  318. j.setMsg(message);
  319. return j;
  320. }
  321. /**
  322. * 更新交通补贴
  323. *
  324. * @param ids
  325. * @return
  326. */
  327. @RequestMapping(params = "doUpdate")
  328. @ResponseBody
  329. public AjaxJson doUpdate(TrafficSubsidyEntity trafficSubsidy, HttpServletRequest request) {
  330. String message = null;
  331. AjaxJson j = new AjaxJson();
  332. message = "交通补贴更新成功";
  333. TrafficSubsidyEntity t = trafficSubsidyService.get(TrafficSubsidyEntity.class, trafficSubsidy.getId());
  334. try {
  335. MyBeanUtils.copyBeanNotNull2Bean(trafficSubsidy, t);
  336. trafficSubsidyService.saveOrUpdate(t);
  337. systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
  338. } catch (Exception e) {
  339. e.printStackTrace();
  340. message = "交通补贴更新失败";
  341. throw new BusinessException(e.getMessage());
  342. }
  343. j.setMsg(message);
  344. return j;
  345. }
  346. /**
  347. * 交通补贴新增页面跳转
  348. *
  349. * @return
  350. */
  351. @RequestMapping(params = "goAdd")
  352. public ModelAndView goAdd(TrafficSubsidyEntity trafficSubsidy, HttpServletRequest req) {
  353. if (StringUtil.isNotEmpty(trafficSubsidy.getId())) {
  354. trafficSubsidy = trafficSubsidyService.getEntity(TrafficSubsidyEntity.class, trafficSubsidy.getId());
  355. req.setAttribute("trafficSubsidyPage", trafficSubsidy);
  356. }
  357. return new ModelAndView("cn/com/lzt/trafficsubsidy/trafficSubsidy-add");
  358. }
  359. /**
  360. * 交通补贴编辑页面跳转
  361. *
  362. * @return
  363. */
  364. @RequestMapping(params = "goUpdate")
  365. public ModelAndView goUpdate(TrafficSubsidyEntity trafficSubsidy, HttpServletRequest req) {
  366. if (StringUtil.isNotEmpty(trafficSubsidy.getId())) {
  367. trafficSubsidy = trafficSubsidyService.getEntity(TrafficSubsidyEntity.class, trafficSubsidy.getId());
  368. req.setAttribute("trafficSubsidyPage", trafficSubsidy);
  369. }
  370. return new ModelAndView("cn/com/lzt/trafficsubsidy/trafficSubsidy-update");
  371. }
  372. /**
  373. * 导入功能跳转
  374. *
  375. * @return
  376. */
  377. @RequestMapping(params = "upload")
  378. public ModelAndView upload(HttpServletRequest req) {
  379. req.setAttribute("controller_name","trafficSubsidyController");
  380. return new ModelAndView("common/upload/pub_excel_upload");
  381. }
  382. /**
  383. * 导出excel
  384. *
  385. * @param request
  386. * @param response
  387. */
  388. @RequestMapping(params = "exportXls")
  389. public String exportXls(TrafficSubsidyEntity trafficSubsidy,HttpServletRequest request,HttpServletResponse response
  390. , DataGrid dataGrid,ModelMap modelMap) {
  391. CriteriaQuery cq = new CriteriaQuery(TrafficSubsidyEntity.class, dataGrid);
  392. org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, trafficSubsidy, request.getParameterMap());
  393. List<TrafficSubsidyEntity> trafficSubsidys = this.trafficSubsidyService.getListByCriteriaQuery(cq,false);
  394. modelMap.put(NormalExcelConstants.FILE_NAME,"交通补贴");
  395. modelMap.put(NormalExcelConstants.CLASS,TrafficSubsidyEntity.class);
  396. modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("交通补贴列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
  397. "导出信息"));
  398. modelMap.put(NormalExcelConstants.DATA_LIST,trafficSubsidys);
  399. return NormalExcelConstants.JEECG_EXCEL_VIEW;
  400. }
  401. /**
  402. * 导出excel 使模板
  403. *
  404. * @param request
  405. * @param response
  406. */
  407. @RequestMapping(params = "exportXlsByT")
  408. public String exportXlsByT(TrafficSubsidyEntity trafficSubsidy,HttpServletRequest request,HttpServletResponse response
  409. , DataGrid dataGrid,ModelMap modelMap) {
  410. modelMap.put(NormalExcelConstants.FILE_NAME,"交通补贴");
  411. modelMap.put(NormalExcelConstants.CLASS,TrafficSubsidyEntity.class);
  412. modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("交通补贴列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
  413. "导出信息"));
  414. modelMap.put(NormalExcelConstants.DATA_LIST,new ArrayList());
  415. return NormalExcelConstants.JEECG_EXCEL_VIEW;
  416. }
  417. @SuppressWarnings("unchecked")
  418. @RequestMapping(params = "importExcel", method = RequestMethod.POST)
  419. @ResponseBody
  420. public AjaxJson importExcel(HttpServletRequest request, HttpServletResponse response) {
  421. AjaxJson j = new AjaxJson();
  422. MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
  423. Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
  424. for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
  425. MultipartFile file = entity.getValue();// 获取上传文件对象
  426. ImportParams params = new ImportParams();
  427. params.setTitleRows(2);
  428. params.setHeadRows(1);
  429. params.setNeedSave(true);
  430. try {
  431. List<TrafficSubsidyEntity> listTrafficSubsidyEntitys = ExcelImportUtil.importExcel(file.getInputStream(),TrafficSubsidyEntity.class,params);
  432. for (TrafficSubsidyEntity trafficSubsidy : listTrafficSubsidyEntitys) {
  433. trafficSubsidyService.save(trafficSubsidy);
  434. }
  435. j.setMsg("文件导入成功!");
  436. } catch (Exception e) {
  437. j.setMsg("文件导入失败!");
  438. logger.error(ExceptionUtil.getExceptionMessage(e));
  439. }finally{
  440. try {
  441. file.getInputStream().close();
  442. } catch (IOException e) {
  443. e.printStackTrace();
  444. }
  445. }
  446. }
  447. return j;
  448. }
  449. @RequestMapping(method = RequestMethod.GET)
  450. @ResponseBody
  451. public List<TrafficSubsidyEntity> list() {
  452. List<TrafficSubsidyEntity> listTrafficSubsidys=trafficSubsidyService.getList(TrafficSubsidyEntity.class);
  453. return listTrafficSubsidys;
  454. }
  455. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  456. @ResponseBody
  457. public ResponseEntity<?> get(@PathVariable("id") String id) {
  458. TrafficSubsidyEntity task = trafficSubsidyService.get(TrafficSubsidyEntity.class, id);
  459. if (task == null) {
  460. return new ResponseEntity(HttpStatus.NOT_FOUND);
  461. }
  462. return new ResponseEntity(task, HttpStatus.OK);
  463. }
  464. @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
  465. @ResponseBody
  466. public ResponseEntity<?> create(@RequestBody TrafficSubsidyEntity trafficSubsidy, UriComponentsBuilder uriBuilder) {
  467. //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息.
  468. Set<ConstraintViolation<TrafficSubsidyEntity>> failures = validator.validate(trafficSubsidy);
  469. if (!failures.isEmpty()) {
  470. return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
  471. }
  472. //保存
  473. try{
  474. trafficSubsidyService.save(trafficSubsidy);
  475. } catch (Exception e) {
  476. e.printStackTrace();
  477. return new ResponseEntity(HttpStatus.NO_CONTENT);
  478. }
  479. //按照Restful风格约定,创建指向新任务的url, 也可以直接返回id或对象.
  480. String id = trafficSubsidy.getId();
  481. URI uri = uriBuilder.path("/rest/trafficSubsidyController/" + id).build().toUri();
  482. HttpHeaders headers = new HttpHeaders();
  483. headers.setLocation(uri);
  484. return new ResponseEntity(headers, HttpStatus.CREATED);
  485. }
  486. @RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
  487. public ResponseEntity<?> update(@RequestBody TrafficSubsidyEntity trafficSubsidy) {
  488. //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息.
  489. Set<ConstraintViolation<TrafficSubsidyEntity>> failures = validator.validate(trafficSubsidy);
  490. if (!failures.isEmpty()) {
  491. return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
  492. }
  493. //保存
  494. try{
  495. trafficSubsidyService.saveOrUpdate(trafficSubsidy);
  496. } catch (Exception e) {
  497. e.printStackTrace();
  498. return new ResponseEntity(HttpStatus.NO_CONTENT);
  499. }
  500. //按Restful约定,返回204状态码, 无内容. 也可以返回200状态码.
  501. return new ResponseEntity(HttpStatus.NO_CONTENT);
  502. }
  503. @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
  504. @ResponseStatus(HttpStatus.NO_CONTENT)
  505. public void delete(@PathVariable("id") String id) {
  506. trafficSubsidyService.deleteEntityById(TrafficSubsidyEntity.class, id);
  507. }
  508. }