Administrator
3 days ago d120983e88c1abd495c87eedbd76d558baeab294
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package cc.mrbird.febs.mall.service.impl;
 
import cc.mrbird.febs.common.entity.FebsResponse;
import cc.mrbird.febs.common.enumerates.StateUpDownEnum;
import cc.mrbird.febs.mall.dto.activity.ApiScInfoDto;
import cc.mrbird.febs.mall.entity.HappySocialCircle;
import cc.mrbird.febs.mall.entity.HappySocialCircleCategory;
import cc.mrbird.febs.mall.entity.MallMember;
import cc.mrbird.febs.mall.mapper.HappySocialCircleCategoryMapper;
import cc.mrbird.febs.mall.mapper.HappySocialCircleMapper;
import cc.mrbird.febs.mall.mapper.MallMemberMapper;
import cc.mrbird.febs.mall.service.ApiHappySocialCircleService;
import cc.mrbird.febs.mall.vo.ApiActivityInfoVo;
import cc.mrbird.febs.mall.vo.activity.ApiScCategoryInfoVo;
import cc.mrbird.febs.mall.vo.activity.ApiScInfoVo;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.List;
 
@Slf4j
@Service
@RequiredArgsConstructor
public class ApiHappySocialCircleServiceImpl extends ServiceImpl<HappySocialCircleMapper, HappySocialCircle> implements ApiHappySocialCircleService {
 
    private final HappySocialCircleCategoryMapper happySocialCircleCategoryMapper;
    private final MallMemberMapper  mallMemberMapper;
    @Override
    public FebsResponse allCategory() {
        ArrayList<ApiScCategoryInfoVo> objects = new ArrayList<>();
        List<HappySocialCircleCategory> happySocialCircleCategories = happySocialCircleCategoryMapper.selectList(
                new LambdaQueryWrapper<HappySocialCircleCategory>()
                        .select(HappySocialCircleCategory::getId, HappySocialCircleCategory::getName)
                        .eq(HappySocialCircleCategory::getState, StateUpDownEnum.UP.getCode())
                        .eq(HappySocialCircleCategory::getDeleteFlag, StateUpDownEnum.DOWN.getCode())
                        .orderByDesc(HappySocialCircleCategory::getOrderCnt)
        );
        if(CollUtil.isNotEmpty(happySocialCircleCategories)){
            for (HappySocialCircleCategory happySocialCircleCategory : happySocialCircleCategories) {
                ApiScCategoryInfoVo apiScCategoryInfoVo = new ApiScCategoryInfoVo();
                apiScCategoryInfoVo.setId(happySocialCircleCategory.getId());
                apiScCategoryInfoVo.setName(happySocialCircleCategory.getName());
                objects.add(apiScCategoryInfoVo);
            }
        }
        return new FebsResponse().success().data(objects);
    }
 
    @Override
    public FebsResponse indexCategory() {
        ArrayList<ApiScCategoryInfoVo> objects = new ArrayList<>();
        List<HappySocialCircleCategory> happySocialCircleCategories = happySocialCircleCategoryMapper.selectList(
                new LambdaQueryWrapper<HappySocialCircleCategory>()
                        .select(HappySocialCircleCategory::getId, HappySocialCircleCategory::getName)
                        .eq(HappySocialCircleCategory::getState, StateUpDownEnum.UP.getCode())
                        .eq(HappySocialCircleCategory::getHotState, StateUpDownEnum.UP.getCode())
                        .eq(HappySocialCircleCategory::getDeleteFlag, StateUpDownEnum.DOWN.getCode())
                        .orderByDesc(HappySocialCircleCategory::getOrderCnt)
        );
        if(CollUtil.isNotEmpty(happySocialCircleCategories)){
            for (HappySocialCircleCategory happySocialCircleCategory : happySocialCircleCategories) {
                ApiScCategoryInfoVo apiScCategoryInfoVo = new ApiScCategoryInfoVo();
                apiScCategoryInfoVo.setId(happySocialCircleCategory.getId());
                apiScCategoryInfoVo.setName(happySocialCircleCategory.getName());
                objects.add(apiScCategoryInfoVo);
            }
        }
        return new FebsResponse().success().data(objects);
    }
 
    @Override
    public FebsResponse scList(ApiScInfoDto dto) {
        // 创建分页对象,传入当前页和每页大小
        Page<ApiScInfoVo> page = new Page<>(dto.getPageNow(), dto.getPageSize());
        // 调用Mapper方法获取活动分页数据
        Page<ApiScInfoVo> happyActivityPage = this.baseMapper.selectListInPage(page, dto);
        return new FebsResponse().success().data(happyActivityPage);
    }
 
    @Override
    public FebsResponse scInfo(Long id) {
        ApiScInfoVo apiScInfoVo = new ApiScInfoVo();
        HappySocialCircle happySocialCircle = this.baseMapper.selectById(id);
        if(happySocialCircle!=null){
 
            MallMember mallMember = mallMemberMapper.selectById(happySocialCircle.getMemberId());
 
            apiScInfoVo.setId(happySocialCircle.getId());
            apiScInfoVo.setAvatar(mallMember.getAvatar());
            apiScInfoVo.setMemberName(mallMember.getName());
            apiScInfoVo.setName(happySocialCircle.getName());
            apiScInfoVo.setIndexFile(happySocialCircle.getIndexFile());
            apiScInfoVo.setContent(happySocialCircle.getContent());
            apiScInfoVo.setCreatedTime(happySocialCircle.getCreatedTime());
        }
        return new FebsResponse().success().data(apiScInfoVo);
    }
}