|
|
@ -11,7 +11,11 @@ import com.share.help.entity.LeaveWordEntity; |
|
|
|
import com.share.help.entity.UserEntity; |
|
|
|
import com.share.help.entity.UserEntity; |
|
|
|
import com.share.help.entity.custorm.*; |
|
|
|
import com.share.help.entity.custorm.*; |
|
|
|
import com.share.help.form.*; |
|
|
|
import com.share.help.form.*; |
|
|
|
import com.share.help.res.*; |
|
|
|
import com.share.help.res.DefaultRes; |
|
|
|
|
|
|
|
import com.share.help.res.JSONResponse; |
|
|
|
|
|
|
|
import com.share.help.res.Page; |
|
|
|
|
|
|
|
import com.share.help.res.Result; |
|
|
|
|
|
|
|
import org.apache.commons.lang3.ArrayUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@ -58,9 +62,10 @@ public class ActivityService{ |
|
|
|
/** |
|
|
|
/** |
|
|
|
* 发布求助信息 |
|
|
|
* 发布求助信息 |
|
|
|
* @param sendHelpForm 求助信息表单 |
|
|
|
* @param sendHelpForm 求助信息表单 |
|
|
|
|
|
|
|
* @param friendUserId 手动推荐好友 |
|
|
|
* @return 发布结果 |
|
|
|
* @return 发布结果 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public JSONResponse<SendHelpRes,Void> sendHelp(SendHelpForm sendHelpForm){ |
|
|
|
public JSONResponse<DefaultRes,Void> sendHelp(SendHelpForm sendHelpForm, String[] friendUserId){ |
|
|
|
ActivityEntity activityEntity=new ActivityEntity(); |
|
|
|
ActivityEntity activityEntity=new ActivityEntity(); |
|
|
|
activityEntity.setUserId(sendHelpForm.getUserId()); |
|
|
|
activityEntity.setUserId(sendHelpForm.getUserId()); |
|
|
|
activityEntity.setTitle(sendHelpForm.getTitle()); |
|
|
|
activityEntity.setTitle(sendHelpForm.getTitle()); |
|
|
@ -72,13 +77,45 @@ public class ActivityService{ |
|
|
|
String imageName=imageService.saveImg(sendHelpForm.getActivityImgFile()); |
|
|
|
String imageName=imageService.saveImg(sendHelpForm.getActivityImgFile()); |
|
|
|
if(imageName==null){ |
|
|
|
if(imageName==null){ |
|
|
|
logger.error("活动背景图保存失败"); |
|
|
|
logger.error("活动背景图保存失败"); |
|
|
|
return new JSONResponse<>(SendHelpRes.fail, Result.FAIL); |
|
|
|
return new JSONResponse<>(DefaultRes.fail, Result.FAIL); |
|
|
|
} |
|
|
|
} |
|
|
|
activityEntity.setActivityImg(imageName); |
|
|
|
activityEntity.setActivityImg(imageName); |
|
|
|
activityEntity.setServiceAddress(sendHelpForm.getServiceAddress()); |
|
|
|
activityEntity.setServiceAddress(sendHelpForm.getServiceAddress()); |
|
|
|
return activityMapper.insert(activityEntity)?new JSONResponse<>(SendHelpRes.ok,Result.OK):new JSONResponse<>(SendHelpRes.fail,Result.FAIL); |
|
|
|
|
|
|
|
|
|
|
|
if(activityMapper.insert(activityEntity)) { |
|
|
|
|
|
|
|
switch (sendHelpForm.getRecommendType()) { |
|
|
|
|
|
|
|
case auto: |
|
|
|
|
|
|
|
autoRecommend(sendHelpForm); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case choose: |
|
|
|
|
|
|
|
if (ArrayUtils.isNotEmpty(friendUserId)) { |
|
|
|
|
|
|
|
for (String userId : friendUserId) { |
|
|
|
|
|
|
|
LeaveWordEntity leaveWordEntity = new LeaveWordEntity(); |
|
|
|
|
|
|
|
leaveWordEntity.setType(LeaveWordType.recommend.name()); |
|
|
|
|
|
|
|
leaveWordEntity.setSourceUserId(sendHelpForm.getUserId()); |
|
|
|
|
|
|
|
leaveWordEntity.setTargetUserId(userId); |
|
|
|
|
|
|
|
leaveWordEntity.setCreateTime(new Timestamp(System.currentTimeMillis())); |
|
|
|
|
|
|
|
leaveWordEntity.setActivityId(activityEntity.getActivityId()); |
|
|
|
|
|
|
|
leaveWordMapper.insert(leaveWordEntity); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return new JSONResponse<>(DefaultRes.ok,Result.OK); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
return new JSONResponse<>(DefaultRes.fail,Result.FAIL); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 系统推荐 |
|
|
|
|
|
|
|
* @param sendHelpForm 推荐表单 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void autoRecommend(SendHelpForm sendHelpForm) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 分页查询活动信息 |
|
|
|
* 分页查询活动信息 |
|
|
|
* @param findActivityForm 查询活动信息 |
|
|
|
* @param findActivityForm 查询活动信息 |
|
|
|