BusinessProjectController.java 7.4 KB

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