Browse Source

业务项目管理

anderx 8 years ago
parent
commit
81aa8fb2f5

+ 66 - 4
src/main/java/com/goafanti/admin/controller/BusinessProjectController.java

@@ -1,38 +1,100 @@
 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.BaseController;
+
+import com.goafanti.common.controller.CertifyApiController;
+import com.goafanti.common.enums.AttachmentType;
 import com.goafanti.common.utils.StringUtils;
 
 @RestController
 @RequestMapping("open/api/admin/ProjectSize")
-public class BusinessProjectController extends BaseController{
+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) {
+	public Result addProject(String bname,String vid,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(vid)) {
+			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;
+		}
+		res.setData(businessprojectService.insert(bname, vid, 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 (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;
 		}
-		res.setData(businessprojectService.insert(bname, cid, country,province,city,district));
+		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 = "/uploadTextFile", method = RequestMethod.POST)
+	public Result uploadTextFile(HttpServletRequest req, String sign) {
+		Result res = new Result();
+		AttachmentType attachmentType = AttachmentType.getField(sign);
 
+		if (attachmentType == AttachmentType.BUSINESS_PROJECT_MIN_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.POST)
+	public Result orgProject(String id){
+		
+	}*/
 }

+ 10 - 1
src/main/java/com/goafanti/admin/service/BusinessProjectService.java

@@ -1,5 +1,14 @@
 package com.goafanti.admin.service;
 
+
+
+import com.goafanti.admin.bo.BusinessProjectBo;
+import com.goafanti.core.mybatis.page.Pagination;
+
 public interface BusinessProjectService {
-	int insert(String bname,String cid,String country,String province,String city,String district);
+	int insert(String bname,String vid,String country,String province,String city,String district);
+	
+	Pagination<BusinessProjectBo>listProject(String bname,String cid,String country,String province,String city,String district,String activityFlag,
+										String status,Integer pageNo, Integer pageSize );
+	int getBnamecount(String bname);
 }

+ 1 - 2
src/main/java/com/goafanti/admin/service/impl/AdminVarietiesServiceImpl.java

@@ -88,8 +88,7 @@ public class AdminVarietiesServiceImpl extends BaseMybatisDao<BusinessVarietiesM
 			pSize = 10;
 		} 
 		
-		Pagination<?> a = findPage("findVarietiesListByPage", "findVarietiesListCount",
-				disposeParams(cname,superId,layer,status),pNo,pSize);
+		
 		return (Pagination<BusinessVarieties>)findPage("findVarietiesListByPage", "findVarietiesListCount",
 				disposeParams(cname,superId,layer,status),pNo,pSize);
 	}

+ 69 - 4
src/main/java/com/goafanti/admin/service/impl/BusinessProjectServiceImpl.java

@@ -1,33 +1,98 @@
 package com.goafanti.admin.service.impl;
 
 import java.util.Date;
+import java.util.HashMap;
+
+import java.util.Map;
 import java.util.UUID;
 
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.goafanti.admin.bo.BusinessProjectBo;
 import com.goafanti.admin.service.BusinessProjectService;
 
 import com.goafanti.common.dao.BusinessProjectMapper;
+import com.goafanti.common.dao.BusinessVarietiesMapper;
 import com.goafanti.common.model.BusinessProject;
 
-import com.goafanti.core.shiro.token.TokenManager;
+import com.goafanti.common.utils.StringUtils;
+import com.goafanti.core.mybatis.BaseMybatisDao;
+import com.goafanti.core.mybatis.page.Pagination;
 
-public class BusinessProjectServiceImpl implements BusinessProjectService {
+@Service
+public class BusinessProjectServiceImpl extends BaseMybatisDao<BusinessProjectMapper> implements BusinessProjectService {
+	@Autowired
 	BusinessProjectMapper businessProjectMapper;
+	
 	@Override
-	public int insert(String bname, String cid, String country, String province, String city, String district) {
+	public int insert(String bname, String vid, String country, String province, String city, String district) {
 		BusinessProject bp=new BusinessProject();
 		bp.setId(UUID.randomUUID().toString());
 		bp.setBname(bname);
+		bp.setCid(vid);
 		bp.setCountry(country);
 		if (1!=Integer.valueOf(country)) {
 			bp.setProvince(province);
 			bp.setCity(city);
 			bp.setDistrict(district);
 		}
-		bp.setCreateId(TokenManager.getAdminId());
+		//bp.setCreateId(TokenManager.getAdminId());
+		bp.setCreateId("f31c0d1a-05bc-4f5c-b4a8-95f983d24131");
 		bp.setCreateTime(new Date());
 		bp.setStatus("0");
 
 		return businessProjectMapper.insert(bp);
 	}
+	@SuppressWarnings("unchecked")
+	@Override
+	public Pagination<BusinessProjectBo> listProject(String bname, String cid, String country,String province,String city,String district, String activityFlag,
+			String status, Integer pNo, Integer pSize) {
+		if (pNo == null || pNo < 0) {
+			pNo = 1;
+		}
+
+		if (pSize == null || pSize < 0 || pSize > 10) {
+			pSize = 10;
+		} 	
+		
+		return (Pagination<BusinessProjectBo>)findPage("findProjectListByPage", "findProjectListCount",
+				disposeParams(bname,  cid,  country, province, city, district,  activityFlag,
+						 status),pNo,pSize);
+	}
+	private Map<String, Object> disposeParams(String bname, String cid, String country,String province,String city,String district, String activityFlag,
+			String status) {
+		Map<String, Object> params = new HashMap<>();
+		if (StringUtils.isNotBlank(bname)) {
+			params.put("bname", bname);
+		}
+		if (StringUtils.isNotBlank(cid)) {
+			params.put("cid", cid);
+		}
+		if (StringUtils.isNotBlank(country)) {
+			params.put("country", country);
+		}
+		if (StringUtils.isNotBlank(province)) {
+			params.put("province", province);
+		}
+		if (StringUtils.isNotBlank(city)) {
+			params.put("city", city);
+		}
+		if (StringUtils.isNotBlank(district)) {
+			params.put("district", district);
+		}
+		if (StringUtils.isNotBlank(activityFlag)) {
+			params.put("activityFlag", activityFlag);
+		}
+		if (StringUtils.isNotBlank(status)) {
+			params.put("status", status);
+		}
+		return params;
+	}
+	@Override
+	public int getBnamecount(String bname) {
+		
+		return businessProjectMapper.getBnamecount(bname);
+	}
 
 }

+ 2 - 0
src/main/java/com/goafanti/common/dao/BusinessProjectMapper.java

@@ -73,4 +73,6 @@ public interface BusinessProjectMapper {
 	 * @mbg.generated  Mon Dec 04 15:29:25 CST 2017
 	 */
 	int updateByPrimaryKey(BusinessProject record);
+	
+	int getBnamecount(String bname);
 }

+ 4 - 2
src/main/java/com/goafanti/common/enums/AttachmentType.java

@@ -48,8 +48,10 @@ public enum AttachmentType {
 	LECTURE_PICTURE("lecture_picture", "科技讲堂展示图片"),
 	ACTIVITY_TITLE_PICTURE("activity_title_picture", "活动题图"),
 	ACTIVITY_CONTENT_PICTURE("activity_content_picture", "活动内容图片"),
-	CUSTOMER_SYS_FILE("customer_sys_file","客户系统文件");
-
+	CUSTOMER_SYS_FILE("customer_sys_file","客户系统文件"),
+	BUSINESS_PROJECT_MIN_PICTURE("business_project_min_picture","业务项目小图"),
+	BUSINESS_PROJECT_MAX_PICTURE("business_project_min_picture","业务项目大图");
+	
 	private AttachmentType(String code, String desc) {
 		this.code = code;
 		this.desc = desc;

+ 78 - 0
src/main/java/com/goafanti/common/mapper/BusinessProjectMapper.xml

@@ -537,4 +537,82 @@
       client_size = #{clientSize,jdbcType=VARCHAR}
     where id = #{id,jdbcType=VARCHAR}
   </update>
+  
+  	<select id="findProjectListByPage" resultType="com.goafanti.admin.bo.BusinessProjectBo">
+ 		select b.id, b.create_id, b.create_time, b.update_time,  b.delete_sign, b.bname,
+ 		  b.cid,  b.price,  b.offset,  b.activity_price,  b.activity_flag,  b.member_price, 
+ 		  b.introduce,  b.status,  b.country,  b.province,  b.city,  b.district, 
+          b.principal_id,  b.Value_effect,  b.client_size,b2.cname 
+  		from business_project b
+  		left join business_varieties b2 on b.cid = b2.id
+  		where b.delete_sign=0 
+  		<if test="bname != null">
+		and b.bname = #{bname,jdbcType=VARCHAR}
+		</if>
+		<if test="vid != null">
+		and b.cid = #{vid,jdbcType=VARCHAR}
+		</if>
+		<if test="country != null">
+		and b.country = #{country,jdbcType=INTEGER}
+		</if>
+		<if test="province != null">
+		and b.province = #{province,jdbcType=VARCHAR}
+		</if>
+		<if test="city != null">
+		and b.city = #{city,jdbcType=VARCHAR}
+		</if>
+		<if test="district != null">
+		and b.district = #{district,jdbcType=VARCHAR}
+		</if>
+		<if test="activityFlag != null">
+		and b.activityFlag = #{activityFlag,jdbcType=VARCHAR}
+		</if>
+		<if test="status != null">
+		and b.status = #{status,jdbcType=VARCHAR}
+		</if>
+		<if test="page_sql!=null">
+			${page_sql}
+	</if>
+  </select>
+  <select id="findProjectListCount" resultType="Integer">
+ 		select 
+  			count(0)
+  		from business_project b
+  		 left join business_varieties b2 on b.cid = b2.id
+  		where b.delete_sign=0 
+  		<if test="bname != null">
+		and b.bname = #{bname,jdbcType=VARCHAR}
+		</if>
+		<if test="vid != null">
+		and b.cid = #{vid,jdbcType=VARCHAR}
+		</if>
+		<if test="country != null">
+		and b.country = #{country,jdbcType=INTEGER}
+		</if>
+		<if test="province != null">
+		and b.province = #{province,jdbcType=VARCHAR}
+		</if>
+		<if test="city != null">
+		and b.city = #{city,jdbcType=VARCHAR}
+		</if>
+		<if test="district != null">
+		and b.district = #{district,jdbcType=VARCHAR}
+		</if>
+		<if test="activityFlag != null">
+		and b.activityFlag = #{activityFlag,jdbcType=VARCHAR}
+		</if>
+		<if test="status != null">
+		and b.status = #{status,jdbcType=VARCHAR}
+		</if>
+		
+  </select>
+  
+  <select id="getBnamecount" resultType="Integer">
+  select 
+  			count(0)
+  		from business_project
+  where  bname = #{bname,jdbcType=VARCHAR}
+  
+  </select>
+  
 </mapper>