BusinessProjectController.java 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. package com.goafanti.admin.controller;
  2. import javax.annotation.Resource;
  3. import javax.servlet.http.HttpServletRequest;
  4. import org.springframework.web.bind.annotation.RequestMapping;
  5. import org.springframework.web.bind.annotation.RequestMethod;
  6. import org.springframework.web.bind.annotation.RestController;
  7. import com.goafanti.admin.service.BusinessProjectService;
  8. import com.goafanti.common.bo.Result;
  9. import com.goafanti.common.constant.AFTConstants;
  10. import com.goafanti.common.constant.ErrorConstants;
  11. import com.goafanti.common.controller.CertifyApiController;
  12. import com.goafanti.common.enums.AttachmentType;
  13. import com.goafanti.common.model.BusinessProject;
  14. import com.goafanti.common.model.ProjectSize;
  15. import com.goafanti.common.utils.StringUtils;
  16. @RestController
  17. @RequestMapping("api/admin/ProjectSize")
  18. public class BusinessProjectController extends CertifyApiController{
  19. @Resource
  20. BusinessProjectService businessprojectService;
  21. /**
  22. * 新增项目
  23. */
  24. @RequestMapping(value = "/addProject" , method = RequestMethod.POST)
  25. public Result addProject(String bname,String cid,String country,String province,String city,String district) {
  26. Result res=new Result();
  27. if (StringUtils.isBlank(bname)) {
  28. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "项目名称名称为空", "项目名称"));
  29. return res;
  30. }
  31. if (StringUtils.isBlank(cid)) {
  32. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "所属品类为空", "所属品类"));
  33. return res;
  34. }
  35. if (businessprojectService.getBnamecount(bname)>0) {
  36. res.getError().add(buildError(ErrorConstants.PARAM_BEING_ERROR, "项目名称已存在", "项目名称"));
  37. return res;
  38. }
  39. if(Integer.valueOf(country)==0){
  40. if (StringUtils.isBlank(province)) {
  41. res.getError().add(buildError( "至少指定省", "至少指定省"));
  42. return res;
  43. }
  44. }
  45. res.setData(businessprojectService.insert(bname, cid, country,province,city,district));
  46. return res;
  47. }
  48. /**
  49. * 项目搜索
  50. */
  51. @RequestMapping(value = "/listProject" , method = RequestMethod.POST)
  52. public Result listProject(String bname,String cid,String country,String province,String city,String district,String activityFlag,String status,Integer pageNo, Integer pageSize ){
  53. Result res=new Result();
  54. if (country==AFTConstants.USER_TYPE_PERSONAL) {
  55. if (StringUtils.isBlank(province)) {
  56. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "所属省份为空", "所属省份"));
  57. return res;
  58. }
  59. }
  60. res.setData(businessprojectService.listProject( bname, cid, country,province, city, district ,activityFlag, status, pageNo,pageSize ));
  61. return res;
  62. }
  63. /**
  64. * 图片上传
  65. */
  66. @RequestMapping(value = "/uploadPicture", method = RequestMethod.POST)
  67. public Result uploadPicture(HttpServletRequest req, String sign) {
  68. Result res = new Result();
  69. AttachmentType attachmentType = AttachmentType.getField(sign);
  70. if (attachmentType == AttachmentType.BUSINESS_PROJECT_MAX_PICTURE
  71. || attachmentType == AttachmentType.BUSINESS_PROJECT_MIN_PICTURE
  72. ) {
  73. res.setData(handleFiles(res, "/Project/", false, req, sign, "project"));
  74. } else {
  75. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件"));
  76. }
  77. return res;
  78. }
  79. /**
  80. * 获取项目详情
  81. */
  82. @RequestMapping(value = "/orgProject", method = RequestMethod.GET)
  83. public Result orgProject(String id){
  84. Result res=new Result();
  85. res.setData(businessprojectService.orgProject(id));
  86. return res;
  87. }
  88. /**
  89. * 删除项目
  90. */
  91. @RequestMapping(value = "/deleteProject", method = RequestMethod.GET)
  92. public Result deleteProject(String id){
  93. Result res=new Result();
  94. res.setData(businessprojectService.deleteProject(id));
  95. return res;
  96. }
  97. /**
  98. * 停用项目
  99. */
  100. @RequestMapping(value = "/stopProject", method = RequestMethod.GET)
  101. public Result stopProject(String id){
  102. Result res=new Result();
  103. res.setData(businessprojectService.updateStopProject(id));
  104. return res;
  105. }
  106. /**
  107. * 获取业务品类全路径()
  108. */
  109. @RequestMapping(value = "/getAllCname", method = RequestMethod.GET)
  110. public Result getAllCname(Integer flag){
  111. Result res=new Result();
  112. res.setData(businessprojectService.getAllCnames(flag));
  113. return res;
  114. }
  115. /**
  116. * 编辑基本保存
  117. */
  118. @RequestMapping(value = "/updateProject", method = RequestMethod.POST)
  119. public Result updateProject(BusinessProject s){
  120. Result res=new Result();
  121. if (StringUtils.isBlank(s.getBname())) {
  122. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "项目名称名称为空", "项目名称"));
  123. return res;
  124. }
  125. if (StringUtils.isBlank(s.getCid())) {
  126. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "所属品类为空", "所属品类"));
  127. return res;
  128. }
  129. if (businessprojectService.judgeBeing(s)) {
  130. res.getError().add(buildError(ErrorConstants.PARAM_BEING_ERROR, "项目名称已存在", "项目名称"));
  131. return res;
  132. }
  133. if(Integer.valueOf(s.getCountry())==0){
  134. if (StringUtils.isBlank(s.getProvince())) {
  135. res.getError().add(buildError( "至少指定省", "至少指定省"));
  136. return res;
  137. }
  138. }
  139. res.setData(businessprojectService.updateProject(s));
  140. return res;
  141. }
  142. /**
  143. * 新建规格
  144. */
  145. @RequestMapping(value = "/addProjectSize", method = RequestMethod.POST)
  146. public Result addProjectSize(ProjectSize ps){
  147. Result res=new Result();
  148. if (businessprojectService.WhetherRepeat(ps)) {
  149. res.getError().add(buildError(ErrorConstants.PARAM_BEING_ERROR, "规格名称已存在", "规格名称"));
  150. return res;
  151. }
  152. if (businessprojectService.judgeStatus(ps)) {
  153. res.getError().add(buildError( "项目已停用", "项目已停用"));
  154. return res;
  155. }
  156. res.setData(businessprojectService.addProjectSize(ps));
  157. return res;
  158. }
  159. /**
  160. * 编辑保存规格
  161. */
  162. @RequestMapping(value = "/orgProjectSize", method = RequestMethod.POST)
  163. public Result orgProjectSize(ProjectSize ps){
  164. Result res=new Result();
  165. res.setData(businessprojectService.updateOrgProjectSize(ps));
  166. return res;
  167. }
  168. /**
  169. * 规格列表
  170. */
  171. @RequestMapping(value = "/listProjectSize", method = RequestMethod.GET)
  172. public Result listProjectSize(String pid,Integer pNo,Integer Psize){
  173. Result res=new Result();
  174. if (StringUtils.isBlank(pid)) {
  175. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "项目名称名称为空", "项目"));
  176. return res;
  177. }
  178. res.setData(businessprojectService.listProjectSize(pid,pNo, Psize));
  179. return res;
  180. }
  181. /**
  182. * 获取规格详情
  183. */
  184. @RequestMapping(value = "/getProjectSize", method = RequestMethod.GET)
  185. public Result getProjectSize(String id){
  186. Result res=new Result();
  187. res.setData(businessprojectService.getProjectSize(id));
  188. return res;
  189. }
  190. /**
  191. * 删除规格
  192. */
  193. @RequestMapping(value = "/deleteProjectSize", method = RequestMethod.GET)
  194. public Result deleteProjectSize(String id){
  195. Result res=new Result();
  196. res.setData(businessprojectService.deleteProjectSize(id));
  197. return res;
  198. }
  199. /**
  200. * 停用规格
  201. */
  202. @RequestMapping(value = "/stopProjectSize", method = RequestMethod.GET)
  203. public Result stopProjectSize(String id){
  204. Result res=new Result();
  205. res.setData(businessprojectService.updateSotpProjectSize(id));
  206. return res;
  207. }
  208. }