manailin
2021-06-27 76ed3735c23da4b7ef97b8a0f365facbc14f6903
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package com.panzhihua.service_community.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.ComActEasyPhotoActivityVO;
import com.panzhihua.common.utlis.DateUtils;
import com.panzhihua.service_community.dao.ComActEasyPhotoActivityMapper;
import com.panzhihua.service_community.model.dos.ComActEasyPhotoActivityDO;
import com.panzhihua.service_community.service.ComActEasyPhotoActivityService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
 
import java.util.Date;
import java.util.List;
 
/**
 * @auther lyq
 * @create 2021-06-25 10:34:16
 * @describe 随手拍活动表服务实现类
 */
@Slf4j
@Service
public class ComActEasyPhotoActivityServiceImpl extends ServiceImpl<ComActEasyPhotoActivityMapper, ComActEasyPhotoActivityDO> implements ComActEasyPhotoActivityService {
 
    /**
     * 查询随手拍是否有活动
     * @return  活动详情
     */
    @Override
    public R getEasyPhotoActivity(Long communityId){
        ComActEasyPhotoActivityVO photoActivityVO = new ComActEasyPhotoActivityVO();
        Date nowDate = DateUtils.getCurrentDate(DateUtils.ymdhms_format);
        List<ComActEasyPhotoActivityDO> photoActivityDOS = this.baseMapper.selectList(
                new QueryWrapper<ComActEasyPhotoActivityDO>().lambda().eq(ComActEasyPhotoActivityDO::getCommunityId,communityId)
                        .le(ComActEasyPhotoActivityDO::getActivityStartAt,nowDate).ge(ComActEasyPhotoActivityDO::getActivityEndAt,nowDate));
        if(!photoActivityDOS.isEmpty()){
            ComActEasyPhotoActivityDO photoActivityDO = photoActivityDOS.get(0);
            BeanUtils.copyProperties(photoActivityDO,photoActivityVO);
            return R.ok(photoActivityVO);
        }
        return R.ok();
    }
}