Browse Source

项目规格管理新增

anderx 8 years ago
parent
commit
7bf7982546

+ 30 - 0
src/main/java/com/goafanti/admin/bo/BusinessProjectBo.java

@@ -3,6 +3,10 @@ package com.goafanti.admin.bo;
 import java.math.BigDecimal;
 import java.util.Date;
 
+import org.apache.commons.lang3.time.DateFormatUtils;
+
+import com.goafanti.common.constant.AFTConstants;
+
 public class BusinessProjectBo {
 	/**
 	 * This field was generated by MyBatis Generator. This field corresponds to the database column business_project.id
@@ -114,6 +118,10 @@ public class BusinessProjectBo {
 	 * 分类名称
 	 */
 	private String cname;
+	/**
+	 * 创建人名称
+	 */
+	private String createName;
 
 	/**
 	 * This method was generated by MyBatis Generator. This method returns the value of the database column business_project.id
@@ -159,6 +167,13 @@ public class BusinessProjectBo {
 	public Date getCreateTime() {
 		return createTime;
 	}
+	public String getCreateTimeFormattedDate() {
+		if (this.createTime == null) {
+			return null;
+		} else {
+			return DateFormatUtils.format(this.getCreateTime(), AFTConstants.YYYYMMDDHHMMSS);
+		}
+	}
 
 	/**
 	 * This method was generated by MyBatis Generator. This method sets the value of the database column business_project.create_time
@@ -177,6 +192,13 @@ public class BusinessProjectBo {
 	public Date getUpdateTime() {
 		return updateTime;
 	}
+	public String getUpdateTimeFormattedDate() {
+		if (this.updateTime == null) {
+			return null;
+		} else {
+			return DateFormatUtils.format(this.getUpdateTime(), AFTConstants.YYYYMMDDHHMMSS);
+		}
+	}
 
 	/**
 	 * This method was generated by MyBatis Generator. This method sets the value of the database column business_project.update_time
@@ -500,4 +522,12 @@ public class BusinessProjectBo {
 	public void setCname(String cname) {
 		this.cname = cname;
 	}
+
+	public String getCreateName() {
+		return createName;
+	}
+
+	public void setCreateName(String createName) {
+		this.createName = createName;
+	}
 }

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

@@ -9,6 +9,8 @@ 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.bo.BusinessProjectBo;
+import com.goafanti.admin.bo.ProjectSizeBo;
 import com.goafanti.admin.service.BusinessProjectService;
 import com.goafanti.common.bo.Result;
 import com.goafanti.common.constant.AFTConstants;
@@ -16,6 +18,8 @@ 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
@@ -145,14 +149,33 @@ public class BusinessProjectController extends CertifyApiController{
 		return res;
 	}
 	/**
+	 * 编辑保存
+	 */
+	@RequestMapping(value = "/updateProject", method = RequestMethod.POST)
+	public Result updateProject(BusinessProject s){
+		Result res=new Result();
+		res.setData(businessprojectService.updateProject(s));
+		return res;
+	}
+	/**
+	 * 新建规格
+	 */
+	@RequestMapping(value = "/addProjectSize", method = RequestMethod.POST)
+	public Result addProjectSize(ProjectSize ps){
+		Result res=new Result();
+		res.setData(businessprojectService.addProjectSize(ps));
+		return res;
+	}
+	
+	/**
 	 * 编辑规格
 	 */
-	/*@RequestMapping(value = "/orgProjectSize", method = RequestMethod.GET)
-	public Result orgProjectSize(String id){
+	@RequestMapping(value = "/orgProjectSize", method = RequestMethod.POST)
+	public Result orgProjectSize(ProjectSize ps){
 		Result res=new Result();
-		res.setData(businessprojectService.orgProjectSize(id));
+		res.setData(businessprojectService.updateOrgProjectSize(ps));
 		return res;
-	}*/
+	}
 	/**
 	 * 编辑规格
 	 */

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

@@ -7,6 +7,7 @@ import java.util.Map;
 
 import com.goafanti.admin.bo.BusinessProjectBo;
 import com.goafanti.admin.bo.ProjectSizeBo;
+import com.goafanti.common.model.BusinessProject;
 import com.goafanti.common.model.ProjectSize;
 import com.goafanti.core.mybatis.page.Pagination;
 
@@ -21,10 +22,19 @@ public interface BusinessProjectService {
 	
 	int updateStopProject(String id);
 	
+	
 	BusinessProjectBo orgProject(String id);
+	
 	List<Map<String, String>> getAllCname();
+	
 	int updateAddOffset(String id);
+	
 	int updateSubtractOffset(String id);
-	/*ProjectSizeBo orgProjectSize(String id);*/
+	
+	int updateProject(BusinessProject s);
+	
+	int addProjectSize(ProjectSize ps);
+	
+	int updateOrgProjectSize(ProjectSize ps);
 	
 }

+ 111 - 1
src/main/java/com/goafanti/admin/service/impl/BusinessProjectServiceImpl.java

@@ -18,8 +18,10 @@ import com.goafanti.admin.service.BusinessProjectService;
 
 import com.goafanti.common.dao.BusinessProjectMapper;
 import com.goafanti.common.dao.BusinessVarietiesMapper;
+import com.goafanti.common.dao.ProjectSizeMapper;
 import com.goafanti.common.model.BusinessProject;
 import com.goafanti.common.model.BusinessVarieties;
+import com.goafanti.common.model.ProjectSize;
 import com.goafanti.common.utils.StringUtils;
 import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.mybatis.page.Pagination;
@@ -30,6 +32,8 @@ public class BusinessProjectServiceImpl extends BaseMybatisDao<BusinessProjectMa
 	BusinessProjectMapper businessProjectMapper;
 	@Autowired
 	BusinessVarietiesMapper businessVarietiesMapper;
+	@Autowired
+	ProjectSizeMapper projectSizeMapper;
 	
 	@Override
 	public int insert(String bname, String cid, String country, String province, String city, String district) {
@@ -126,10 +130,14 @@ public class BusinessProjectServiceImpl extends BaseMybatisDao<BusinessProjectMa
 	@Override
 	public BusinessProjectBo orgProject(String id) {
 		BusinessProject bp=businessProjectMapper.selectByPrimaryKey(id);
+		
 		BusinessProjectBo bpo=new BusinessProjectBo();
 		BeanUtils.copyProperties(bp,bpo);
 		String cname=getAllCname(bpo.getCid());
-		System.out.println(cname);
+		System.out.println("----------------"+bpo.getCid());
+		String createId=bpo.getCreateId();
+		System.out.println(createId); 
+		bpo.setCreateName(businessProjectMapper.getCreateName(createId));
 		bpo.setCname(cname);
 		return bpo;
 	}
@@ -189,6 +197,108 @@ public class BusinessProjectServiceImpl extends BaseMybatisDao<BusinessProjectMa
 		}
 		return businessProjectMapper.updateByPrimaryKey(bp);
 	}
+	@Override
+	public int updateProject(BusinessProject s) {
+		BusinessProject bp=businessProjectMapper.selectByPrimaryKey(s.getId());
+		TheGinseng(s, bp);
+		return businessProjectMapper.updateByPrimaryKey(bp);
+	}
+	private void TheGinseng(BusinessProject s, BusinessProject bp) {
+		
+		if (StringUtils.isNotBlank(s.getBname())) {
+			bp.setBname(s.getBname());
+		}
+		if (StringUtils.isNotBlank(s.getCid())) {
+			bp.setCid(s.getCid());
+		}
+		if (StringUtils.isNotBlank(s.getCountry())) {
+			bp.setCountry(s.getCountry());
+		}
+		if (StringUtils.isNotBlank(s.getProvince())) {
+			bp.setProvince(s.getProvince());
+		}
+		if (StringUtils.isNotBlank(s.getCity())) {
+			bp.setCity(s.getCity());
+		}
+		if (StringUtils.isNotBlank(s.getDistrict())) {
+			bp.setDistrict(s.getDistrict());
+		}
+		if (null!=s.getPrice()) {
+			bp.setPrice(s.getPrice());
+		}
+		if (null!=(s.getOffset())) {
+			bp.setOffset(s.getOffset());
+		}
+		if (null!=(s.getActivityFlag())) {
+			bp.setActivityFlag(s.getActivityFlag());
+		}
+		if (null!=(s.getMemberPrice())) {
+			bp.setMemberPrice(s.getMemberPrice());
+		}
+		if (null!=(s.getActivityPrice())) {
+			bp.setActivityPrice(s.getActivityPrice());
+		}
+		if (StringUtils.isNotBlank(s.getIntroduce())) {
+			bp.setIntroduce(s.getIntroduce());
+		}
+		if (StringUtils.isNotBlank(s.getValueEffect())) {
+			bp.setValueEffect(s.getValueEffect());
+		}
+		if (StringUtils.isNotBlank(s.getClientSize())) {
+			bp.setClientSize(s.getClientSize());
+		}
+		if (StringUtils.isNotBlank(s.getMinLogo())) {
+			bp.setMinLogo(s.getMinLogo());
+		}
+		if (StringUtils.isNotBlank(s.getMaxLogo())) {
+			bp.setMaxLogo(s.getMaxLogo());
+		}
+		if (null!=(s.getStatus())) {
+			bp.setStatus(s.getStatus());
+		}
+		bp.setUpdateTime(new Date());
+	}
+	@Override
+	public int addProjectSize(ProjectSize ps) {
+		ps.setId(UUID.randomUUID().toString());
+		//bp.setCreateId(TokenManager.getAdminId());
+		ps.setCreateId("f31c0d1a-05bc-4f5c-b4a8-95f983d24131");
+		ps.setCreateTime(new Date());
+		ps.setStatus(0);
+		return projectSizeMapper.insert(ps);
+	}
+	@Override
+	public int updateOrgProjectSize(ProjectSize ps) {
+		ProjectSize psz=projectSizeMapper.selectByPrimaryKey(ps.getId());
+		projectSizeConfiguration(ps, psz);
+		return projectSizeMapper.updateByPrimaryKeySelective(psz);
+	}
+	private void projectSizeConfiguration(ProjectSize ps, ProjectSize psz) {
+		if (StringUtils.isNotBlank(ps.getPid())) {
+			psz.setId(ps.getPid());
+		}
+		if (StringUtils.isNotBlank(ps.getPname())) {
+			psz.setPname(ps.getPname());
+		}
+		if (null!=ps.getPrice()) {
+			psz.setPrice(ps.getPrice());
+		}
+		if (null!=(ps.getOffset())) {
+			psz.setOffset(ps.getOffset());
+		}
+		if (null!=(ps.getActivityFlag())) {
+			psz.setActivityFlag(ps.getActivityFlag());
+		}
+		if (null!=(ps.getMemberPrice())) {
+			psz.setMemberPrice(ps.getMemberPrice());
+		}
+		if (null!=(ps.getActivityPrice())) {
+			psz.setActivityPrice(ps.getActivityPrice());
+		}
+		if (null!=(ps.getStatus())) {
+			psz.setStatus(ps.getStatus());
+		}
+	}
 	
 	/*public ProjectSizeBo orgProjectSize(String id) {
 		

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

@@ -76,4 +76,5 @@ public interface BusinessProjectMapper {
 	
 	int getBnamecount(String bname);
 	
+	String getCreateName(String id);
 }

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

@@ -615,6 +615,14 @@
   
   </select>
   
+  <select id="getCreateName" resultType="string">
+  select 
+  			name
+  		from admin
+  where  id = #{id,jdbcType=VARCHAR}
+  
+  </select>
+  
   
   
 </mapper>

+ 12 - 6
src/main/java/com/goafanti/common/mapper/BusinessVarietiesMapper.xml

@@ -361,7 +361,8 @@
       super_id = #{superId,jdbcType=VARCHAR},
       layer = #{layer,jdbcType=INTEGER},
       status = #{status,jdbcType=VARCHAR}
-    where id = #{id,jdbcType=VARCHAR}
+    
+  	where id = #{id,jdbcType=VARCHAR}
   </update>
   
   <select id="getCount" resultType="string">
@@ -438,25 +439,28 @@
   <select id="ThanCid" resultType="string">
   		select b.id 
   		from business_varieties b
-  		where b.cid= #{cid,jdbcType=VARCHAR}
+  		where b.cid= #{cid,jdbcType=VARCHAR} 
   	</select>
   	
   	<select id="getcname" resultType="Integer">
   		select count(1) 
   		from business_varieties b
-  		where b.cname= #{cname,jdbcType=VARCHAR}
+  		where b.delete_sign=0
+  		and b.cname= #{cname,jdbcType=VARCHAR}
   	</select>
   	
   	<select id="selectSuperid" resultType="com.goafanti.admin.bo.BusinessVarietiesBo">
   		select b.id,b.create_id as createId ,b.create_time as createTime,b.update_time as updateTime,
   		b.delete_sign as deleteSign,b.cid,b.cname,b.super_id superId ,b.layer,b.status
   		from business_varieties b 
-  		where b.super_id= #{superId,jdbcType=VARCHAR}
+  		where b.delete_sign=0
+  		and b.super_id= #{superId,jdbcType=VARCHAR}
   	</select>
   	
   	<select id="getThisCid" resultType="String">
   		select b.cid
   		from business_varieties b
+  		
   		where b.id= #{id,jdbcType=VARCHAR}
   	</select>
   	
@@ -469,12 +473,14 @@
   	<select id="getListId" resultType="String">
   		select b.id
   		from business_varieties b
-  		
+  		where b.delete_sign=0
+  		and b.status=0
   	</select>
   	
   	<select id="getLayer" resultType="Integer">
   		select b.layer
   		from business_varieties b
-  		where b.id= #{superId,jdbcType=VARCHAR}
+  		where b.delete_sign=0
+  		and b.id= #{superId,jdbcType=VARCHAR}
   	</select>
 </mapper>

+ 39 - 0
src/main/java/com/goafanti/common/model/BusinessProject.java

@@ -111,6 +111,32 @@ public class BusinessProject {
 	 */
 	private String clientSize;
 
+	
+	private String MinLogo;
+	
+	public String getMinLogo() {
+		return MinLogo;
+	}
+
+
+
+	public void setMinLogo(String minLogo) {
+		MinLogo = minLogo;
+	}
+
+
+
+	public String getMaxLogo() {
+		return MaxLogo;
+	}
+
+
+
+	public void setMaxLogo(String maxLogo) {
+		MaxLogo = maxLogo;
+	}
+
+	private String MaxLogo;
 	/**
 	 * This method was generated by MyBatis Generator. This method returns the value of the database column business_project.id
 	 * @return  the value of business_project.id
@@ -119,6 +145,8 @@ public class BusinessProject {
 	public String getId() {
 		return id;
 	}
+	
+	
 
 	/**
 	 * This method was generated by MyBatis Generator. This method sets the value of the database column business_project.id
@@ -488,4 +516,15 @@ public class BusinessProject {
 	public void setClientSize(String clientSize) {
 		this.clientSize = clientSize;
 	}
+
+	@Override
+	public String toString() {
+		return "BusinessProject [id=" + id + ", createId=" + createId + ", createTime=" + createTime + ", updateTime="
+				+ updateTime + ", deleteSign=" + deleteSign + ", bname=" + bname + ", cid=" + cid + ", price=" + price
+				+ ", offset=" + offset + ", activityPrice=" + activityPrice + ", activityFlag=" + activityFlag
+				+ ", memberPrice=" + memberPrice + ", introduce=" + introduce + ", status=" + status + ", country="
+				+ country + ", province=" + province + ", city=" + city + ", district=" + district + ", principalId="
+				+ principalId + ", valueEffect=" + valueEffect + ", clientSize=" + clientSize + "]";
+	}
+	
 }