Переглянути джерело

服务项目使用user发布

liliang4869 7 роки тому
батько
коміт
2fa62f1fa3

+ 2 - 0
src/main/java/com/goafanti/business/controller/AdminJtBusinessController.java

@@ -30,6 +30,8 @@ public class AdminJtBusinessController extends CertifyApiController{
 	
 	@Resource JtBusinessServiceWithCategoryMapper JtBusinessServiceWithCategoryMapper;
 	
+
+	
 	/*
 	 * 删除品类
 	 * 

+ 149 - 0
src/main/java/com/goafanti/business/controller/UserJtBusinessController.java

@@ -0,0 +1,149 @@
+package com.goafanti.business.controller;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.goafanti.business.service.JtBusinessService;
+import com.goafanti.business.service.JtBusinessServiceWithCategoryMapper;
+import com.goafanti.common.bo.Result;
+import com.goafanti.common.constant.ErrorConstants;
+import com.goafanti.common.controller.CertifyApiController;
+import com.goafanti.common.enums.AttachmentType;
+import com.goafanti.common.model.JtBusinessCategory;
+import com.goafanti.common.model.JtBusinessProject;
+
+@RestController
+@RequestMapping(value = "/api/user/jtBusiness")
+public class UserJtBusinessController extends CertifyApiController{
+	
+	@Resource 
+	private JtBusinessService jtBusinessService;
+	
+	@Resource JtBusinessServiceWithCategoryMapper JtBusinessServiceWithCategoryMapper;
+	/*
+	 * 
+	 * 新增项目
+	 * 
+	 * */
+	@RequestMapping(value="/project/apply",method=RequestMethod.POST)
+	private Result insertJtBusinessProject(JtBusinessProject jtBusinessProject) {
+		Result result=new Result();
+		disposeProjectParam(result, jtBusinessProject);
+		if(result.getError().size()<=0) {
+			result.setData(jtBusinessService.insertProject(jtBusinessProject));
+		}
+		return result;
+		
+	}
+	private void disposeProjectParam(Result result,JtBusinessProject jtBusinessProject ) {
+		if(jtBusinessProject.getName() == null) {
+			result.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "名称不可为空", "名称"));
+			return ;
+		}
+		if(jtBusinessProject.getCategoryId() == null) {
+			result.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "品类"));
+			return ;
+		}
+		//todo  判断品类是否存在
+		JtBusinessCategory jtBusinessCategory=jtBusinessService.getCategoryById(jtBusinessProject.getCategoryId());
+		if(jtBusinessCategory==null ||jtBusinessCategory.getLayer()!=2) {
+			result.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "二级品类未找到"));
+			return ;
+		}
+		
+		if(jtBusinessProject.getProvince()==null)
+		{
+			result.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "省份"));
+			return ;
+		}
+//		if(jtBusinessProject.getCity()==null)
+//		{
+//			result.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "城市"));
+//			return ;
+//		}
+//		if(jtBusinessProject.getPrice()==null)
+//		{
+//			result.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "价格"));
+//			return ;
+//		}
+		return ;
+	}
+	
+	/*
+	 * 项目详情
+	 * 
+	 * */
+	@RequestMapping(value="/project/detail",method=RequestMethod.GET)
+	private Result getProjectDetail(String id) {
+		Result result=new Result();
+		if(id == null) {
+			result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"","id不能为空,"));
+			return result;
+		}
+		result.setData(jtBusinessService.getBusinessProjectDetail(id));
+		return result;
+	}
+	
+	/*
+	 * 删除项目
+	 * */
+	@RequestMapping(value="/project/delete",method=RequestMethod.GET)
+	private Result deleteProjecById(String id) {
+		Result result=new Result();
+		if(id == null) {
+			result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"","id不能为空,"));
+			return result;
+		}
+		result.setData(jtBusinessService.deleteProjectById(id));
+		return result;
+	}
+	
+	@RequestMapping(value="/project/update",method=RequestMethod.POST)
+	private Result updateProject(JtBusinessProject jtBusinessProject) {
+		Result result=new Result();
+		jtBusinessProject.setCreateTime(null);
+//		jtBusinessProject.setId(null);
+		jtBusinessProject.setNumber(null);
+		disposeProjectParam(result, jtBusinessProject);
+		if(result.getError().size()>0) {
+			return result;
+		}
+		if(jtBusinessProject.getPrice()==null) {
+			result.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "价格不可为空,"));
+		}
+		jtBusinessService.updateProject(jtBusinessProject);
+		return result;
+	}
+	
+
+	
+	@RequestMapping(value = "/project/uploadPicture", method = RequestMethod.POST)
+	public Result uploadProjectPicture(HttpServletRequest req, String sign) {
+		Result res = new Result();
+		AttachmentType attachmentType = AttachmentType.getField(sign);
+
+		if (attachmentType == AttachmentType.JT_PROJECT_PICTURE
+				) {
+			res.setData(handleFiles(res, "/jtProjects/", false, req, sign, ""));
+		} else {
+			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "图片"));
+		}
+		return res;
+	}
+	
+	/*
+	 * 查询品类
+	 * 
+	 * */
+	@RequestMapping(value="/category/list",method=RequestMethod.GET)
+	private Result getCategoryList(JtBusinessCategory jtBusinessCategory,Integer pageNo,Integer pageSize) {
+		Result result=new Result();
+	
+		 result.setData(JtBusinessServiceWithCategoryMapper.getCategoryListByCondition(jtBusinessCategory,pageNo,pageSize));
+		 return result;
+	}
+}

Різницю між файлами не показано, бо вона завелика
+ 884 - 883
src/main/java/com/goafanti/user/controller/UserApiController.java