| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- package com.goafanti.admin.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.admin.service.BusinessProjectService;
- import com.goafanti.common.bo.Result;
- import com.goafanti.common.constant.AFTConstants;
- import com.goafanti.common.constant.ErrorConstants;
- import com.goafanti.common.controller.CertifyApiController;
- import com.goafanti.common.enums.AttachmentType;
- import com.goafanti.common.model.BusinessProject;
- import com.goafanti.common.model.ProjectSize;
- import com.goafanti.common.utils.StringUtils;
- @RestController
- @RequestMapping("api/admin/ProjectSize")
- public class BusinessProjectController extends CertifyApiController{
-
- @Resource
- BusinessProjectService businessprojectService;
-
-
-
- /**
- * 新增项目
- */
- @RequestMapping(value = "/addProject" , method = RequestMethod.POST)
- public Result addProject(String bname,String cid,String country,String province,String city,String district) {
- Result res=new Result();
- if (StringUtils.isBlank(bname)) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "项目名称名称为空", "项目名称"));
- return res;
- }
-
- if (StringUtils.isBlank(cid)) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "所属品类为空", "所属品类"));
- return res;
- }
- if (businessprojectService.getBnamecount(bname)>0) {
- res.getError().add(buildError(ErrorConstants.PARAM_BEING_ERROR, "项目名称已存在", "项目名称"));
- return res;
- }
- if(Integer.valueOf(country)==0){
- if (StringUtils.isBlank(province)) {
- res.getError().add(buildError( "至少指定省", "至少指定省"));
- return res;
- }
- }
- res.setData(businessprojectService.insert(bname, cid, country,province,city,district));
- return res;
- }
-
- /**
- * 项目搜索
- */
- @RequestMapping(value = "/listProject" , method = RequestMethod.POST)
- public Result listProject(String bname,String cid,String country,String province,String city,String district,String activityFlag,String status,Integer pageNo, Integer pageSize ){
- Result res=new Result();
- if (country==AFTConstants.USER_TYPE_PERSONAL) {
- if (StringUtils.isBlank(province)) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "所属省份为空", "所属省份"));
- return res;
- }
- }
-
- res.setData(businessprojectService.listProject( bname, cid, country,province, city, district ,activityFlag, status, pageNo,pageSize ));
- return res;
- }
- /**
- * 图片上传
- */
- @RequestMapping(value = "/uploadPicture", method = RequestMethod.POST)
- public Result uploadPicture(HttpServletRequest req, String sign) {
- Result res = new Result();
- AttachmentType attachmentType = AttachmentType.getField(sign);
- if (attachmentType == AttachmentType.BUSINESS_PROJECT_MAX_PICTURE
- || attachmentType == AttachmentType.BUSINESS_PROJECT_MIN_PICTURE
- ) {
- res.setData(handleFiles(res, "/Project/", false, req, sign, "project"));
- } else {
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件"));
- }
- return res;
- }
- /**
- * 获取项目详情
- */
- @RequestMapping(value = "/orgProject", method = RequestMethod.GET)
- public Result orgProject(String id){
- Result res=new Result();
- res.setData(businessprojectService.orgProject(id));
- return res;
- }
- /**
- * 删除项目
- */
- @RequestMapping(value = "/deleteProject", method = RequestMethod.GET)
- public Result deleteProject(String id){
- Result res=new Result();
- res.setData(businessprojectService.deleteProject(id));
- return res;
- }
-
- /**
- * 停用项目
- */
- @RequestMapping(value = "/stopProject", method = RequestMethod.GET)
- public Result stopProject(String id){
- Result res=new Result();
- res.setData(businessprojectService.updateStopProject(id));
- return res;
- }
- /**
- * 获取业务品类全路径()
- */
- @RequestMapping(value = "/getAllCname", method = RequestMethod.GET)
- public Result getAllCname(Integer flag){
- Result res=new Result();
- res.setData(businessprojectService.getAllCnames(flag));
- return res;
- }
-
- /**
- * 编辑基本保存
- */
- @RequestMapping(value = "/updateProject", method = RequestMethod.POST)
- public Result updateProject(BusinessProject s){
- Result res=new Result();
- if (StringUtils.isBlank(s.getBname())) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "项目名称名称为空", "项目名称"));
- return res;
- }
-
- if (StringUtils.isBlank(s.getCid())) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "所属品类为空", "所属品类"));
- return res;
- }
- if (businessprojectService.judgeBeing(s)) {
- res.getError().add(buildError(ErrorConstants.PARAM_BEING_ERROR, "项目名称已存在", "项目名称"));
- return res;
- }
- if(Integer.valueOf(s.getCountry())==0){
- if (StringUtils.isBlank(s.getProvince())) {
- res.getError().add(buildError( "至少指定省", "至少指定省"));
- return res;
- }
- }
- res.setData(businessprojectService.updateProject(s));
- return res;
- }
- /**
- * 新建规格
- */
- @RequestMapping(value = "/addProjectSize", method = RequestMethod.POST)
- public Result addProjectSize(ProjectSize ps){
- Result res=new Result();
- if (businessprojectService.WhetherRepeat(ps)) {
- res.getError().add(buildError(ErrorConstants.PARAM_BEING_ERROR, "规格名称已存在", "规格名称"));
- return res;
- }
- if (businessprojectService.judgeStatus(ps)) {
- res.getError().add(buildError( "项目已停用", "项目已停用"));
- return res;
- }
-
- res.setData(businessprojectService.addProjectSize(ps));
- return res;
- }
-
- /**
- * 编辑保存规格
- */
- @RequestMapping(value = "/orgProjectSize", method = RequestMethod.POST)
- public Result orgProjectSize(ProjectSize ps){
- Result res=new Result();
- res.setData(businessprojectService.updateOrgProjectSize(ps));
- return res;
- }
- /**
- * 规格列表
- */
- @RequestMapping(value = "/listProjectSize", method = RequestMethod.GET)
- public Result listProjectSize(String pid,Integer pNo,Integer Psize){
- Result res=new Result();
- if (StringUtils.isBlank(pid)) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "项目名称名称为空", "项目"));
- return res;
- }
- res.setData(businessprojectService.listProjectSize(pid,pNo, Psize));
- return res;
- }
-
- /**
- * 获取规格详情
- */
- @RequestMapping(value = "/getProjectSize", method = RequestMethod.GET)
- public Result getProjectSize(String id){
- Result res=new Result();
- res.setData(businessprojectService.getProjectSize(id));
- return res;
- }
- /**
- * 删除规格
- */
- @RequestMapping(value = "/deleteProjectSize", method = RequestMethod.GET)
- public Result deleteProjectSize(String id){
- Result res=new Result();
- res.setData(businessprojectService.deleteProjectSize(id));
- return res;
- }
- /**
- * 停用规格
- */
- @RequestMapping(value = "/stopProjectSize", method = RequestMethod.GET)
- public Result stopProjectSize(String id){
- Result res=new Result();
- res.setData(businessprojectService.updateSotpProjectSize(id));
- return res;
- }
- }
|