AdminPatentNewApiController.java 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. package com.goafanti.patent.controller;
  2. import java.text.ParseException;
  3. import java.text.SimpleDateFormat;
  4. import java.util.Date;
  5. import javax.annotation.Resource;
  6. import javax.servlet.http.HttpServletRequest;
  7. import org.springframework.stereotype.Controller;
  8. import org.springframework.web.bind.annotation.RequestMapping;
  9. import org.springframework.web.bind.annotation.RequestMethod;
  10. import com.goafanti.common.bo.Result;
  11. import com.goafanti.common.constant.AFTConstants;
  12. import com.goafanti.common.constant.ErrorConstants;
  13. import com.goafanti.common.controller.CertifyApiController;
  14. import com.goafanti.common.utils.StringUtils;
  15. import com.goafanti.patent.bo.PatentNewBo;
  16. import com.goafanti.patent.service.PatentNewService;
  17. @Controller
  18. @RequestMapping(value = "/api/admin/patentNew")
  19. public class AdminPatentNewApiController extends CertifyApiController {
  20. @Resource
  21. private PatentNewService patentNewService;
  22. /**
  23. * 新增专利信息
  24. */
  25. @RequestMapping(value = "/addPatentNew", method = RequestMethod.POST)
  26. public Result addPatentNew(PatentNewBo p){
  27. Result res = new Result();
  28. if (StringUtils.isBlank(p.getPatentNo())|| StringUtils.isBlank(p.getName())) {
  29. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "专利", "专利"));
  30. return res;
  31. }
  32. if ( StringUtils.isBlank(p.getApplyDates())|| StringUtils.isBlank(p.getAuthorizationDates())) {
  33. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "时间", "时间"));
  34. return res;
  35. }else {
  36. SimpleDateFormat sdf = new SimpleDateFormat( AFTConstants.YYYYMMDD);
  37. try {
  38. p.setApplyDate(sdf.parse(p.getApplyDates()));
  39. p.setAuthorizationDate(sdf.parse(p.getAuthorizationDates()));
  40. } catch (ParseException e) {
  41. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "时间", "时间"));
  42. return res;
  43. }
  44. }
  45. return res.data(patentNewService.addPatenNew(p));
  46. }
  47. /**
  48. * 修改专利信息
  49. */
  50. @RequestMapping(value = "/updatePatentNew", method = RequestMethod.POST)
  51. public Result updatePatentNew(PatentNewBo p){
  52. Result res = new Result();
  53. if (StringUtils.isBlank(p.getPatentNo())|| StringUtils.isBlank(p.getName())||StringUtils.isBlank(p.getCertificateUrl())) {
  54. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "专利", "专利"));
  55. return res;
  56. }
  57. SimpleDateFormat sdf = new SimpleDateFormat( AFTConstants.YYYYMMDD);
  58. try {
  59. p.setApplyDate(sdf.parse(p.getApplyDates()));
  60. p.setAuthorizationDate(sdf.parse(p.getAuthorizationDates()));
  61. } catch (ParseException e) {
  62. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "时间", "时间"));
  63. return res;
  64. }
  65. return res.data(patentNewService.updatePatenNew(p));
  66. }
  67. /**
  68. * 专利列表
  69. */
  70. @RequestMapping(value = "/selectPatentNew", method = RequestMethod.GET)
  71. public Result selectPatentNew(PatentNewBo p,Integer pageSize,Integer pageNo){
  72. Result res = new Result();
  73. return res.data(patentNewService.selectPatentNew(p,pageSize,pageNo));
  74. }
  75. /** 证件上传 **/
  76. @RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
  77. public Result uploadRefundOrderFile(HttpServletRequest req,String sign){
  78. Result res = new Result();
  79. //order_refund_file
  80. res.setData(handleFile(res, "/patent_certificate/", false, req, sign));
  81. return res;
  82. }
  83. }