|
|
@ -25,7 +25,9 @@ import com.elink.esua.epdc.commons.tools.constant.NumConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|
|
|
import com.elink.esua.epdc.dto.activity.ActivityInfoDTO; |
|
|
|
import com.elink.esua.epdc.dto.activity.form.ActivityDetailFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.activity.form.ActivityInfoFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.activity.result.ActivityDetailResultDTO; |
|
|
|
import com.elink.esua.epdc.dto.activity.result.ActivityInfoResultDTO; |
|
|
|
import com.elink.esua.epdc.modules.activity.dao.ActivityInfoDao; |
|
|
|
import com.elink.esua.epdc.modules.activity.dao.ActivityParticipantDao; |
|
|
@ -91,10 +93,9 @@ public class ActivityInfoServiceImpl extends BaseServiceImpl<ActivityInfoDao, Ac |
|
|
|
@Override |
|
|
|
public ActivityInfoDTO get(String id) { |
|
|
|
ActivityInfoEntity entity = baseDao.selectById(id); |
|
|
|
Map<String, Object> params = new HashMap<>(1); |
|
|
|
params.put("id", id); |
|
|
|
List<ActivityParticipantEntity> activityParticipantNum = activityParticipantDao.selectListOfActivityParticipant(params); |
|
|
|
entity.setSignUpNum(activityParticipantNum.size()); |
|
|
|
// 查询活动参与人数
|
|
|
|
Integer signUpNum = getSignUpNumber(id); |
|
|
|
entity.setSignUpNum(signUpNum); |
|
|
|
return ConvertUtils.sourceToTarget(entity, ActivityInfoDTO.class); |
|
|
|
} |
|
|
|
|
|
|
@ -128,21 +129,47 @@ public class ActivityInfoServiceImpl extends BaseServiceImpl<ActivityInfoDao, Ac |
|
|
|
// sql limit条件转换
|
|
|
|
formDto.setPageIndex((formDto.getPageIndex() - NumConstant.ONE) * formDto.getPageSize()); |
|
|
|
List<ActivityInfoEntity> entityList = baseDao.listActivity(formDto); |
|
|
|
// 多一步转换,丰富字段
|
|
|
|
List<ActivityInfoDTO> dtoList = ConvertUtils.sourceToTarget(entityList, ActivityInfoDTO.class); |
|
|
|
dtoList.forEach(dto -> { |
|
|
|
// 查询前端样式
|
|
|
|
SectionCategoryEntity sectionCategoryEntity = sectionCategoryDao.selectByCode(dto.getCategoryCode()); |
|
|
|
dto.setFrontStyle(sectionCategoryEntity.getFrontStyle()); |
|
|
|
// 查询当前用户是否参与活动
|
|
|
|
ActivityParticipantEntity entity = activityParticipantDao.selectParticipant(dto.getId(), formDto.getUserId()); |
|
|
|
dto.setSignUpFlag(entity != null ? NumConstant.ZERO_STR : NumConstant.ONE_STR); |
|
|
|
String signUpFlag = isParticipate(dto.getId(), formDto.getUserId()); |
|
|
|
dto.setSignUpFlag(signUpFlag); |
|
|
|
// 查询活动参与人数
|
|
|
|
Map<String, Object> params = new HashMap<>(1); |
|
|
|
params.put("id", dto.getId()); |
|
|
|
List<ActivityParticipantEntity> activityParticipantNum = activityParticipantDao.selectListOfActivityParticipant(params); |
|
|
|
dto.setSignUpNum(activityParticipantNum.size()); |
|
|
|
Integer signUpNum = getSignUpNumber(dto.getId()); |
|
|
|
dto.setSignUpNum(signUpNum); |
|
|
|
}); |
|
|
|
|
|
|
|
return ConvertUtils.sourceToTarget(dtoList, ActivityInfoResultDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ActivityDetailResultDTO activityDetail(ActivityDetailFormDTO formDto) { |
|
|
|
ActivityInfoEntity entity = baseDao.activityDetail(formDto); |
|
|
|
ActivityDetailResultDTO dto = ConvertUtils.sourceToTarget(entity, ActivityDetailResultDTO.class); |
|
|
|
// 查询活动参与人数
|
|
|
|
Integer signUpNum = getSignUpNumber(dto.getId()); |
|
|
|
dto.setSignUpNum(signUpNum); |
|
|
|
// 查询当前用户是否参与活动
|
|
|
|
String signUpFlag = isParticipate(formDto.getActivityId(), formDto.getUserId()); |
|
|
|
dto.setSignUpFlag(signUpFlag); |
|
|
|
return dto; |
|
|
|
} |
|
|
|
|
|
|
|
private String isParticipate(String activityId, String userId) { |
|
|
|
// 查询当前用户是否参与活动
|
|
|
|
ActivityParticipantEntity entity = activityParticipantDao.selectParticipant(activityId, userId); |
|
|
|
return entity != null ? NumConstant.ZERO_STR : NumConstant.ONE_STR; |
|
|
|
} |
|
|
|
|
|
|
|
private Integer getSignUpNumber(String activityId) { |
|
|
|
// 查询活动参与人数
|
|
|
|
Map<String, Object> params = new HashMap<>(1); |
|
|
|
params.put("id", activityId); |
|
|
|
List<ActivityParticipantEntity> activityParticipantNum = activityParticipantDao.selectListOfActivityParticipant(params); |
|
|
|
return activityParticipantNum.size(); |
|
|
|
} |
|
|
|
} |