AdminBusinessProjectController.java 7.6 KB

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