AdminBusinessProjectController.java 7.5 KB

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