Bladeren bron

基地授牌

jz.kai 1 jaar geleden
bovenliggende
commit
994cbffd72

+ 3 - 0
common/src/main/java/com/jpsoft/employment/modules/base/dao/ParticipateProjectInfoDAO.java

@@ -1,6 +1,8 @@
 package com.jpsoft.employment.modules.base.dao;
 
 import java.util.List;
+
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 import com.jpsoft.employment.modules.base.entity.ParticipateProjectInfo;
 import java.util.Map;
@@ -15,4 +17,5 @@ public interface ParticipateProjectInfoDAO {
 	int delete(String id);
 	List<ParticipateProjectInfo> list();
 	List<ParticipateProjectInfo> search(Map<String, Object> searchParams, List<Sort> sortList);
+	ParticipateProjectInfo getByIds(@Param(value="regUserId") String regUserId, @Param(value="feedbackId") String feedbackId, @Param(value="loveProjectId") String loveProjectId);
 }

+ 1 - 0
common/src/main/java/com/jpsoft/employment/modules/base/service/ParticipateProjectInfoService.java

@@ -14,4 +14,5 @@ public interface ParticipateProjectInfoService {
 	int delete(String id);
 	List<ParticipateProjectInfo> list();
 	Page<ParticipateProjectInfo> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize, boolean count, List<Sort> sortList);
+	ParticipateProjectInfo getByIds(String regUserId, String feedbackId, String loveProjectId);
 }

+ 6 - 0
common/src/main/java/com/jpsoft/employment/modules/base/service/impl/ParticipateProjectInfoServiceImpl.java

@@ -67,4 +67,10 @@ public class ParticipateProjectInfoServiceImpl implements ParticipateProjectInfo
         
         return page;
 	}
+
+	@Override
+	public ParticipateProjectInfo getByIds(String regUserId, String feedbackId, String loveProjectId) {
+		// TODO Auto-generated method stub
+		return participateProjectInfoDAO.getByIds(regUserId, feedbackId, loveProjectId);
+	}
 }

+ 8 - 0
common/src/main/resources/mapper/base/ParticipateProjectInfo.xml

@@ -107,6 +107,14 @@
 	<select id="list" resultMap="ParticipateProjectInfoMap">
 		select * from base_participate_project_info
 	</select>
+	<select id="getByIds" parameterType="string" resultMap="ParticipateProjectInfoMap">
+		SELECT * FROM base_participate_project_info
+		WHERE del_flag = 0
+		AND reg_user_id = #{regUserId}
+		AND feedback_id = #{feedbackId}
+		AND love_project_id = #{loveProjectId}
+		LIMIT 1
+	</select>
 	<select id="search" parameterType="hashmap" resultMap="ParticipateProjectInfoMap">
 		<![CDATA[
 			select a.* from base_participate_project_info a

+ 110 - 0
web/src/main/java/com/jpsoft/employment/modules/base/api/ParticipateApi.java

@@ -0,0 +1,110 @@
+package com.jpsoft.employment.modules.base.api;
+
+import com.github.pagehelper.Page;
+import com.jpsoft.employment.modules.base.entity.FeedbackMethod;
+import com.jpsoft.employment.modules.base.entity.LoveProject;
+import com.jpsoft.employment.modules.base.entity.ParticipateProjectInfo;
+import com.jpsoft.employment.modules.base.service.*;
+import com.jpsoft.employment.modules.common.dto.MessageResult;
+import com.jpsoft.employment.modules.common.dto.Sort;
+import com.jpsoft.employment.modules.common.utils.PojoUtils;
+import com.jpsoft.employment.modules.sys.service.DataDictionaryService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.*;
+
+@RestController
+@RequestMapping("/base/api/participate")
+@Api(description = "爱心回馈")
+public class ParticipateApi {
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    @Autowired
+    private ParticipateProjectInfoService participateProjectInfoService;
+
+    @ApiOperation(value="详情")
+    @RequestMapping(value = "edit",method = RequestMethod.POST)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name="loveProjectId", value="loveProjectId", required=true, paramType="query"),
+            @ApiImplicitParam(name="feedbackId", value="feedbackId", required=true, paramType="query"),
+    })
+    public MessageResult edit(String loveProjectId, String feedbackId, HttpServletRequest request){
+        MessageResult msgResult = new MessageResult<>();
+        String subject = (String)request.getAttribute("subject");
+
+        try {
+            ParticipateProjectInfo participateProjectInfo = participateProjectInfoService.getByIds(subject, feedbackId, loveProjectId);
+
+            msgResult.setResult(true);
+            msgResult.setData(participateProjectInfo);
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="保存")
+    @RequestMapping(value = "save",method = RequestMethod.POST)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name="loveProjectId", value="loveProjectId", required=true, paramType="query"),
+            @ApiImplicitParam(name="feedbackId", value="feedbackId", required=true, paramType="query"),
+    })
+    public MessageResult save(String loveProjectId, String feedbackId, String cooperativeCompany, String contacts, String contactsCompany, HttpServletRequest request){
+        MessageResult msgResult = new MessageResult<>();
+        String subject = (String)request.getAttribute("subject");
+
+        try {
+            ParticipateProjectInfo participateProjectInfo = participateProjectInfoService.getByIds(subject, feedbackId, loveProjectId);
+
+            if (participateProjectInfo != null) {
+                participateProjectInfo.setCooperativeCompany(cooperativeCompany);
+                participateProjectInfo.setContacts(contacts);
+                participateProjectInfo.setContactsCompany(contactsCompany);
+                participateProjectInfo.setUpdateBy(subject);
+                participateProjectInfo.setUpdateTime(new Date());
+                participateProjectInfoService.update(participateProjectInfo);
+            } else {
+                participateProjectInfo = new ParticipateProjectInfo();
+                participateProjectInfo.setId(UUID.randomUUID().toString());
+                participateProjectInfo.setRegUserId(subject);
+                participateProjectInfo.setFeedbackId(feedbackId);
+                participateProjectInfo.setLoveProjectId(loveProjectId);
+                participateProjectInfo.setStatus("1");
+                participateProjectInfo.setCooperativeCompany(cooperativeCompany);
+                participateProjectInfo.setContacts(contacts);
+                participateProjectInfo.setContactsCompany(contactsCompany);
+                participateProjectInfo.setDelFlag(false);
+                participateProjectInfo.setCreateBy(subject);
+                participateProjectInfo.setCreateTime(new Date());
+                participateProjectInfoService.insert(participateProjectInfo);
+            }
+            msgResult.setResult(true);
+            msgResult.setData(participateProjectInfo);
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+}