jz.kai 1 rok pred
rodič
commit
4c3b200b99

+ 30 - 3
web/src/main/java/com/jpsoft/employment/modules/base/api/ParticipateApi.java

@@ -1,9 +1,7 @@
 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.entity.*;
 import com.jpsoft.employment.modules.base.service.*;
 import com.jpsoft.employment.modules.common.dto.MessageResult;
 import com.jpsoft.employment.modules.common.dto.Sort;
@@ -17,6 +15,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -37,6 +36,12 @@ public class ParticipateApi {
     private ParticipateProjectInfoService participateProjectInfoService;
     @Autowired
     private FeedbackMethodService feedbackMethodService;
+    @Autowired
+    private RegUserService regUserService;
+    @Autowired
+    private NewsInfoService newsInfoService;
+    @Autowired
+    private NewsRegUserService newsRegUserService;
 
     @ApiOperation(value="详情")
     @RequestMapping(value = "edit",method = RequestMethod.POST)
@@ -66,6 +71,7 @@ public class ParticipateApi {
 
     @ApiOperation(value="保存")
     @RequestMapping(value = "save",method = RequestMethod.POST)
+    @Transactional(rollbackFor = Exception.class)
     @ApiImplicitParams({
             @ApiImplicitParam(name="loveProjectId", value="loveProjectId", required=true, paramType="query"),
             @ApiImplicitParam(name="feedbackId", value="feedbackId", required=true, paramType="query"),
@@ -98,9 +104,30 @@ public class ParticipateApi {
                 participateProjectInfo.setContacts(contacts);
                 participateProjectInfo.setContactsCompany(contactsCompany);
                 participateProjectInfo.setDelFlag(false);
+
                 participateProjectInfo.setCreateBy(subject);
                 participateProjectInfo.setCreateTime(new Date());
                 participateProjectInfoService.insert(participateProjectInfo);
+
+                NewsInfo newsInfo = new NewsInfo();
+                newsInfo.setId(UUID.randomUUID().toString());
+                newsInfo.setTitle(String.format("{0}参与了{1}项目",regUserService.get(subject).getRealName(),loveProjectService.get(loveProjectId).getTitle()));
+                newsInfo.setType("0");
+                newsInfo.setIsTop(false);
+                newsInfo.setContent(String.format("{0}参与了{1}项目",regUserService.get(subject).getRealName(),loveProjectService.get(loveProjectId).getTitle()));
+                newsInfo.setDelFlag(false);
+                newsInfo.setCreateBy(subject);
+                newsInfo.setCreateTime(new Date());
+                newsInfoService.insert(newsInfo);
+
+                NewsRegUser newsRegUser = new NewsRegUser();
+                newsRegUser.setId(UUID.randomUUID().toString());
+                newsRegUser.setRegUserId(subject);
+                newsRegUser.setNewsId(newsInfo.getId());
+                newsRegUser.setDelFlag(false);
+                newsRegUser.setCreateBy(subject);
+                newsRegUser.setCreateTime(new Date());
+                newsRegUserService.insert(newsRegUser);
             }
             msgResult.setResult(true);
             msgResult.setData(participateProjectInfo);

+ 28 - 8
web/src/main/java/com/jpsoft/employment/modules/base/api/VolunteerApi.java

@@ -1,14 +1,8 @@
 package com.jpsoft.employment.modules.base.api;
 
 import com.github.pagehelper.Page;
-import com.jpsoft.employment.modules.base.entity.MessageBoard;
-import com.jpsoft.employment.modules.base.entity.RegUser;
-import com.jpsoft.employment.modules.base.entity.VolunteerSignRecord;
-import com.jpsoft.employment.modules.base.entity.VolunteerTasks;
-import com.jpsoft.employment.modules.base.service.MessageBoardService;
-import com.jpsoft.employment.modules.base.service.RegUserService;
-import com.jpsoft.employment.modules.base.service.VolunteerSignRecordService;
-import com.jpsoft.employment.modules.base.service.VolunteerTasksService;
+import com.jpsoft.employment.modules.base.entity.*;
+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;
@@ -18,6 +12,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -38,6 +33,10 @@ public class VolunteerApi {
     private VolunteerSignRecordService volunteerSignRecordService;
     @Autowired
     private RegUserService regUserService;
+    @Autowired
+    private NewsInfoService newsInfoService;
+    @Autowired
+    private NewsRegUserService newsRegUserService;
 
     @ApiOperation(value="列表")
     @RequestMapping(value = "list",method = RequestMethod.POST)
@@ -97,6 +96,7 @@ public class VolunteerApi {
 
     @ApiOperation(value="保存")
     @RequestMapping(value = "save",method = RequestMethod.POST)
+    @Transactional(rollbackFor = Exception.class)
     public MessageResult save(String tasksId, String name, String phone, String remark, HttpServletRequest request) {
         MessageResult msgResult = new MessageResult<>();
         String subject = (String)request.getAttribute("subject");
@@ -113,6 +113,26 @@ public class VolunteerApi {
             volunteerSignRecord.setCreateBy(subject);
             volunteerSignRecord.setCreateTime(new Date());
             volunteerSignRecordService.insert(volunteerSignRecord);
+
+            NewsInfo newsInfo = new NewsInfo();
+            newsInfo.setId(UUID.randomUUID().toString());
+            newsInfo.setTitle(String.format("{0}申请了志愿者项目",regUserService.get(subject).getRealName()));
+            newsInfo.setType("0");
+            newsInfo.setIsTop(false);
+            newsInfo.setContent(String.format("{0}申请了志愿者项目“{1}”",regUserService.get(subject).getRealName(),volunteerTasksService.get(tasksId).getIntroduce()));
+            newsInfo.setDelFlag(false);
+            newsInfo.setCreateBy(subject);
+            newsInfo.setCreateTime(new Date());
+            newsInfoService.insert(newsInfo);
+
+            NewsRegUser newsRegUser = new NewsRegUser();
+            newsRegUser.setId(UUID.randomUUID().toString());
+            newsRegUser.setRegUserId(subject);
+            newsRegUser.setNewsId(newsInfo.getId());
+            newsRegUser.setDelFlag(false);
+            newsRegUser.setCreateBy(subject);
+            newsRegUser.setCreateTime(new Date());
+            newsRegUserService.insert(newsRegUser);
         }
         else {
             volunteerSignRecord.setName(name);

+ 27 - 2
web/src/main/java/com/jpsoft/employment/modules/base/api/WishApi.java

@@ -41,6 +41,10 @@ public class WishApi {
     private DataDictionaryService dataDictionaryService;
     @Autowired
     private RegUserService regUserService;
+    @Autowired
+    private NewsInfoService newsInfoService;
+    @Autowired
+    private NewsRegUserService newsRegUserService;
 
     @ApiOperation(value="我的捐赠列表")
     @RequestMapping(value = "myWishList",method = RequestMethod.POST)
@@ -171,10 +175,11 @@ public class WishApi {
 
         try {
             WishInfo wishInfo = wishInfoService.get(id);
-            wishInfo.setRecordAmount(wishInfoUserRecordService.countByWish(id));
-            wishInfo.setAspirationList(studentAspirationsService.findByWish(id));
 
             if (wishInfo != null) {
+                wishInfo.setRecordAmount(wishInfoUserRecordService.countByWish(id));
+                wishInfo.setAspirationList(studentAspirationsService.findByWish(id));
+                
                 msgResult.setResult(true);
                 msgResult.setData(wishInfo);
             } else {
@@ -239,6 +244,26 @@ public class WishApi {
 
                 setAddress(recipients, recipientsPhone, recipientsRegion, recipientsAddress, request);
 
+                NewsInfo newsInfo = new NewsInfo();
+                newsInfo.setId(UUID.randomUUID().toString());
+                newsInfo.setTitle(String.format("{0}参加了{1}的作品互换",regUserService.get(subject).getRealName(),studentAspirationsService.get(studentAspirationsId).getStudentName()));
+                newsInfo.setType("0");
+                newsInfo.setIsTop(false);
+                newsInfo.setContent(String.format("{0}参加了{1}的作品互换",regUserService.get(subject).getRealName(),studentAspirationsService.get(studentAspirationsId).getStudentName()));
+                newsInfo.setDelFlag(false);
+                newsInfo.setCreateBy(subject);
+                newsInfo.setCreateTime(new Date());
+                newsInfoService.insert(newsInfo);
+
+                NewsRegUser newsRegUser = new NewsRegUser();
+                newsRegUser.setId(UUID.randomUUID().toString());
+                newsRegUser.setRegUserId(subject);
+                newsRegUser.setNewsId(newsInfo.getId());
+                newsRegUser.setDelFlag(false);
+                newsRegUser.setCreateBy(subject);
+                newsRegUser.setCreateTime(new Date());
+                newsRegUserService.insert(newsRegUser);
+
                 msgResult.setResult(true);
                 msgResult.setData(wishInfoUserRecord.getId());
             }