mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
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
105
106
107
108
109
110
111
package com.panzhihua.service_community.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.panzhihua.common.constants.NeighborCircleConstants;
import com.panzhihua.common.model.vos.community.CommunityPublicityVO;
import org.springframework.stereotype.Service;
 
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.service_community.dao.SysConfMapper;
import com.panzhihua.service_community.model.dos.SysConfDO;
import com.panzhihua.service_community.service.SysConfService;
 
import lombok.extern.slf4j.Slf4j;
 
import java.util.Date;
 
/**
 * @auther lyq
 * @create 2021-06-23 10:41:36
 * @describe 系统配置表服务实现类
 */
@Slf4j
@Service
public class SysConfServiceImpl extends ServiceImpl<SysConfMapper, SysConfDO> implements SysConfService {
 
    /**
     * 根据系统code以及社区id查询配置表value值
     * @param key   系统code
     * @param communityId   社区id
     * @return  系统配置value值
     */
    @Override
    public R getSysConfValue(String key, Long communityId){
        return R.ok(this.baseMapper.getSysConfValue(key,communityId));
    }
 
    /**
     * 新增系统code配置数据
     * @param key   系统code
     * @param communityId   社区id
     * @return  新增结果
     */
    @Override
    public R addSysConfValue(String key, Long communityId,String name,String value){
        SysConfDO confDO = new SysConfDO();
        confDO.setCode(key);
        confDO.setCreateAt(new Date());
        confDO.setCommunityId(communityId);
        confDO.setValue(value);
        confDO.setName(name);
        if(this.baseMapper.insert(confDO) > 0){
            return R.ok(confDO.getValue());
        }else{
            return R.fail();
        }
    }
 
    @Override
    public R editSysConfValue(Long communityId, Integer status){
        String key = NeighborCircleConstants.NEIGHBOR_CIRCLE_AUTO_EXAMINE;
 
        SysConfDO confDO = this.baseMapper.selectOne(new QueryWrapper<SysConfDO>().lambda().eq(SysConfDO::getCommunityId,communityId)
                .eq(SysConfDO::getCode,key + communityId));
        if(confDO == null){
            return R.fail("未查询到该系统配置");
        }
        confDO.setCommunityId(communityId);
        confDO.setCode(key + communityId);
        confDO.setValue(status+"");
        if(this.baseMapper.updateById(confDO) > 0){
            return R.ok(confDO.getValue());
        }else{
            return R.fail();
        }
    }
 
 
 
 
    @Override
    public CommunityPublicityVO getData(String communityId) {
        return baseMapper.getData(communityId);
    }
 
    @Override
    public int addDate(CommunityPublicityVO item)
    {
        CommunityPublicityVO vo=baseMapper.getData(item.getCommunityId());
        if(vo==null)
        {
            return baseMapper.addDate(item);
        }
        else
        {
            return baseMapper.editDate(item);
        }
    }
 
    @Override
    public int editDate(CommunityPublicityVO item) {
        return baseMapper.editDate(item);
    }
 
    @Override
    public int deleteData(String communityId) {
        return baseMapper.deleteData(communityId);
    }
 
 
}