Antiloveg 8 years ago
parent
commit
4df991fb66

+ 1 - 1
src/main/java/com/goafanti/achievement/controller/AchievementApiController.java

@@ -207,7 +207,7 @@ public class AchievementApiController extends CertifyApiController {
 
 		Achievement a = new Achievement();
 		BeanUtils.copyProperties(ia, a);
-		achievementService.updateAchievement(a, keywords);
+		achievementService.updateAchievement(a, keywords, null);
 		return res;
 	}
 

+ 1 - 1
src/main/java/com/goafanti/achievement/service/AchievementService.java

@@ -24,7 +24,7 @@ public interface AchievementService {
 
 	void saveAchievement(Achievement a, String[] keywords);
 
-	int updateAchievement(Achievement a, String[] keywords);
+	int updateAchievement(Achievement a, String[] keywords, Integer switchSign);
 
 	Achievement selectByPrimaryKey(String id);
 

+ 7 - 2
src/main/java/com/goafanti/achievement/service/impl/AchievementServiceImpl.java

@@ -33,6 +33,7 @@ import com.goafanti.common.dao.UserIdentityMapper;
 import com.goafanti.common.dao.UserRoleMapper;
 import com.goafanti.common.enums.AchievementAuditStatus;
 import com.goafanti.common.enums.AchievementReleaseStatus;
+import com.goafanti.common.enums.AchievementSwitchSign;
 import com.goafanti.common.enums.DeleteStatus;
 import com.goafanti.common.enums.DemandAuditStatus;
 import com.goafanti.common.enums.DemandReleaseStatus;
@@ -140,13 +141,17 @@ public class AchievementServiceImpl extends BaseMybatisDao<AchievementMapper> im
 	}
 
 	@Override
-	public int updateAchievement(Achievement a, String[] keywords) {
+	public int updateAchievement(Achievement a, String[] keywords, Integer switchSign) {
 		if (AchievementAuditStatus.SUBMIT.getCode().equals(a.getAuditStatus())) {
 			a.setAuditStatus(DemandAuditStatus.INAUDIT.getCode());
 			createAuditorNotice(a);
 		}
 		disposeAchievementKeyword(keywords, a, true);
-		return achievementMapper.updateByPrimaryKeySelective(a);
+		achievementMapper.updateByPrimaryKeySelective(a);
+		if (null != switchSign && AchievementSwitchSign.CLOSE.equals(switchSign)){
+			achievementMapper.updateOwnerId(a.getId());
+		}
+		return 1;
 	}
 
 	@Override

+ 14 - 2
src/main/java/com/goafanti/admin/controller/AdminAchievementApiController.java

@@ -35,6 +35,7 @@ import com.goafanti.common.enums.AchievementFields;
 import com.goafanti.common.enums.AchievementImportFields;
 import com.goafanti.common.enums.AchievementOrderStatus;
 import com.goafanti.common.enums.AchievementReleaseStatus;
+import com.goafanti.common.enums.AchievementSwitchSign;
 import com.goafanti.common.enums.AttachmentType;
 import com.goafanti.common.enums.DeleteStatus;
 import com.goafanti.common.model.Achievement;
@@ -188,7 +189,7 @@ public class AdminAchievementApiController extends CertifyApiController {
 	 * 修改成果
 	 */
 	@RequestMapping(value = "/update", method = RequestMethod.POST)
-	public Result update(@Valid InputAchievement ia, BindingResult bindingResult,
+	public Result update(@Valid InputAchievement ia, BindingResult bindingResult, Integer switchSign,
 			@RequestParam(name = "keywords[]", required = false) String[] keywords) {
 		Result res = new Result();
 		if (bindingResult.hasErrors()) {
@@ -197,6 +198,17 @@ public class AdminAchievementApiController extends CertifyApiController {
 			return res;
 		}
 
+		if (null == switchSign) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到开关标记", "开关标记"));
+			return res;
+		}
+
+		if (!AchievementSwitchSign.CLOSE.getCode().equals(switchSign)
+				&& !AchievementSwitchSign.OPEN.getCode().equals(switchSign)) {
+			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "开关标记"));
+			return res;
+		}
+
 		if (StringUtils.isBlank(ia.getId())) {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到成果ID", "成果ID"));
 			return res;
@@ -221,7 +233,7 @@ public class AdminAchievementApiController extends CertifyApiController {
 
 		Achievement a = new Achievement();
 		BeanUtils.copyProperties(ia, a);
-		achievementService.updateAchievement(a, keywords);
+		achievementService.updateAchievement(a, keywords, switchSign);
 		return res;
 	}
 

+ 9 - 2
src/main/java/com/goafanti/admin/controller/AdminDemandApiController.java

@@ -35,6 +35,7 @@ import com.goafanti.common.enums.DemandFields;
 import com.goafanti.common.enums.DemandImportFields;
 import com.goafanti.common.enums.DemandOrderStatus;
 import com.goafanti.common.enums.DemandReleaseStatus;
+import com.goafanti.common.enums.DemandSwitchSign;
 import com.goafanti.common.model.AftFile;
 import com.goafanti.common.model.Demand;
 import com.goafanti.common.model.DemandOrder;
@@ -362,7 +363,7 @@ public class AdminDemandApiController extends CertifyApiController {
 	 * 修改需求
 	 */
 	@RequestMapping(value = "/update", method = RequestMethod.POST)
-	public Result updateUser(@Valid InputDemand demand, BindingResult bindingResult,
+	public Result updateUser(@Valid InputDemand demand, BindingResult bindingResult, Integer switchSign,
 			@RequestParam(name = "keywords[]", required = false) String[] keywords,
 			String validityPeriodFormattedDate) {
 		Result res = new Result();
@@ -381,6 +382,12 @@ public class AdminDemandApiController extends CertifyApiController {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求雇主", "需求雇主"));
 			return res;
 		}
+		
+		if (!DemandSwitchSign.CLOSE.getCode().equals(switchSign)
+				&& !DemandSwitchSign.OPEN.getCode().equals(switchSign)) {
+			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "开关标记"));
+			return res;
+		}
 
 		if (!DemandAuditStatus.CREATE.getCode().equals(demand.getAuditStatus())
 				&& !DemandAuditStatus.SUBMIT.getCode().equals(demand.getAuditStatus())
@@ -396,7 +403,7 @@ public class AdminDemandApiController extends CertifyApiController {
 
 		Demand d = new Demand();
 		BeanUtils.copyProperties(demand, d);
-		res.setData(demandService.updateUserDemand(d, validityPeriodFormattedDate, keywords));
+		res.setData(demandService.updateUserDemand(d, validityPeriodFormattedDate, keywords, switchSign));
 		return res;
 	}
 

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

@@ -47,4 +47,6 @@ public interface AchievementMapper {
 
 	List<AchievementPortalSimilarListBo> findOrgPortalSimilarByFieldA(@Param("fieldA") Integer fieldA,
 			@Param("id") String id);
+
+	int updateOwnerId(String id);
 }

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

@@ -45,4 +45,6 @@ public interface DemandMapper {
 
 	List<DemandPortalSimilarListBo> findByIndustryCategoryA(@Param("industryCategoryA") Integer industryCategoryA,
 			@Param("id") String id);
+
+	int updateEmployerId(String id);
 }

+ 56 - 0
src/main/java/com/goafanti/common/enums/AchievementSwitchSign.java

@@ -0,0 +1,56 @@
+package com.goafanti.common.enums;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.lang3.StringUtils;
+
+public enum AchievementSwitchSign {
+	
+	OPEN(0, "不删除成果所有人ID"),
+	CLOSE(1,"删除成果所有人ID"),
+	OTHER(2, "其他");
+
+	private AchievementSwitchSign(Integer code, String desc) {
+		this.code = code;
+		this.desc = desc;
+	}
+
+	private static Map<Integer, AchievementSwitchSign> status = new HashMap<Integer, AchievementSwitchSign>();
+
+	static {
+		for (AchievementSwitchSign value : AchievementSwitchSign.values()) {
+			status.put(value.getCode(), value);
+		}
+	}
+
+	public static AchievementSwitchSign getStatus(Integer code) {
+		if (containsType(code)) {
+			return status.get(code);
+		}
+		return OTHER;
+	}
+
+	public static AchievementSwitchSign getStatus(String code) {
+		if (StringUtils.isNumeric(code)) {
+			return getStatus(Integer.parseInt(code));
+		}
+		return OTHER;
+	}
+
+	public static boolean containsType(Integer code) {
+		return status.containsKey(code);
+	}
+
+	private Integer	code;
+	private String	desc;
+
+	public Integer getCode() {
+		return code;
+	}
+
+	public String getDesc() {
+		return desc;
+	}
+
+}

+ 54 - 0
src/main/java/com/goafanti/common/enums/DemandSwitchSign.java

@@ -0,0 +1,54 @@
+package com.goafanti.common.enums;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.lang3.StringUtils;
+
+public enum DemandSwitchSign {
+	OPEN(0, "不删除成果所有人ID"),
+	CLOSE(1,"删除成果所有人ID"),
+	OTHER(2, "其他");
+
+	private DemandSwitchSign(Integer code, String desc) {
+		this.code = code;
+		this.desc = desc;
+	}
+
+	private static Map<Integer, DemandSwitchSign> status = new HashMap<Integer, DemandSwitchSign>();
+
+	static {
+		for (DemandSwitchSign value : DemandSwitchSign.values()) {
+			status.put(value.getCode(), value);
+		}
+	}
+
+	public static DemandSwitchSign getStatus(Integer code) {
+		if (containsType(code)) {
+			return status.get(code);
+		}
+		return OTHER;
+	}
+
+	public static DemandSwitchSign getStatus(String code) {
+		if (StringUtils.isNumeric(code)) {
+			return getStatus(Integer.parseInt(code));
+		}
+		return OTHER;
+	}
+
+	public static boolean containsType(Integer code) {
+		return status.containsKey(code);
+	}
+
+	private Integer	code;
+	private String	desc;
+
+	public Integer getCode() {
+		return code;
+	}
+
+	public String getDesc() {
+		return desc;
+	}
+}

+ 6 - 0
src/main/java/com/goafanti/common/mapper/AchievementMapper.xml

@@ -1235,4 +1235,10 @@
 	order by a.serial_number desc
 	limit 5 
   </select>
+  
+  <update id="updateOwnerId" parameterType="java.lang.String" >
+  	update achievement
+  		set owner_id = null 
+  	where id = #{id,jdbcType=VARCHAR}
+  </update>
 </mapper>

+ 7 - 0
src/main/java/com/goafanti/common/mapper/DemandMapper.xml

@@ -1112,4 +1112,11 @@
     order by d.serial_number desc
     limit 5
   </select>
+  
+  <update id="updateEmployerId" parameterType="java.lang.String" >
+  	update 
+  		demand 
+  	set employer_id = null 
+  	where id = #{id,jdbcType=VARCHAR}
+  </update>
 </mapper>

+ 1 - 1
src/main/java/com/goafanti/demand/controller/DemandApiController.java

@@ -192,7 +192,7 @@ public class DemandApiController extends CertifyApiController {
 		Demand d = new Demand();
 		BeanUtils.copyProperties(demand, d);
 		d.setEmployerId(TokenManager.getUserId());
-		res.setData(demandService.updateUserDemand(d, validityPeriodFormattedDate, keywords));
+		res.setData(demandService.updateUserDemand(d, validityPeriodFormattedDate, keywords, null));
 		return res;
 	}
 

+ 1 - 1
src/main/java/com/goafanti/demand/service/DemandService.java

@@ -30,7 +30,7 @@ public interface DemandService {
 
 	void saveUserDemand(Demand d, String validityPeriodFormattedDate, String[] keywords);
 
-	int updateUserDemand(Demand d, String validityPeriodFormattedDate, String[] keywords);
+	int updateUserDemand(Demand d, String validityPeriodFormattedDate, String[] keywords, Integer switchSign);
 
 	DemandManageDetailBo selectUserDemandDetail(String id);
 

+ 7 - 2
src/main/java/com/goafanti/demand/service/impl/DemandServiceImpl.java

@@ -33,6 +33,7 @@ import com.goafanti.common.enums.DemandInfoSourceStatus;
 import com.goafanti.common.enums.DemandPortalSearchSignType;
 import com.goafanti.common.enums.DemandReleaseStatus;
 import com.goafanti.common.enums.DemandStatus;
+import com.goafanti.common.enums.DemandSwitchSign;
 import com.goafanti.common.enums.NoticeReadStatus;
 import com.goafanti.common.enums.NoticeStatus;
 import com.goafanti.common.enums.UserType;
@@ -185,7 +186,7 @@ public class DemandServiceImpl extends BaseMybatisDao<DemandMapper> implements D
 	}
 
 	@Override
-	public int updateUserDemand(Demand d, String validityPeriodFormattedDate, String[] keywords) {
+	public int updateUserDemand(Demand d, String validityPeriodFormattedDate, String[] keywords, Integer switchSign) {
 		Date validityPeriod = null;
 		if (!StringUtils.isBlank(validityPeriodFormattedDate)) {
 			try {
@@ -200,7 +201,11 @@ public class DemandServiceImpl extends BaseMybatisDao<DemandMapper> implements D
 			createAuditorNotice(d);
 		}
 		disposeDemandKeyword(keywords, d, true);
-		return demandMapper.updateByPrimaryKeySelective(d);
+		demandMapper.updateByPrimaryKeySelective(d);
+		if (null != switchSign && DemandSwitchSign.CLOSE.equals(switchSign)) {
+			demandMapper.updateEmployerId(d.getId());
+		}
+		return 1;
 	}
 
 	@Override