AdminBusinessProjectController.java 7.3 KB

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