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
package com.panzhihua.service_property.service.impl;
 
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.panzhihua.common.model.dtos.property.CommonPage;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.service_property.entity.ComPropertyAlarmSetting;
import com.panzhihua.service_property.dao.ComPropertyAlarmSettingDao;
import com.panzhihua.service_property.service.ComPropertyAlarmSettingService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
 
/**
 * (ComPropertyAlarmSetting)表服务实现类
 *
 * @author makejava
 * @since 2021-09-09 09:46:50
 */
@Slf4j
@Service
public class ComPropertyAlarmSettingServiceImpl extends ServiceImpl<ComPropertyAlarmSettingDao, ComPropertyAlarmSetting> implements ComPropertyAlarmSettingService {
    @Resource
    private ComPropertyAlarmSettingDao comPropertyAlarmSettingDao;
    @Resource
    private StringRedisTemplate stringRedisTemplate;
    @Override
    public R pageList(CommonPage commonPage) {
        return null;
    }
 
    @Override
    public R getByCommunityId(Long communityId) {
        return R.ok(comPropertyAlarmSettingDao.getByCommunityId(communityId));
    }
 
    @Override
    public R insert(ComPropertyAlarmSetting comPropertyAlarmSetting) {
        boolean result=this.saveOrUpdate(comPropertyAlarmSetting);
        if(result){
            if(stringRedisTemplate.hasKey(comPropertyAlarmSetting.getCommunityId().toString())){
                stringRedisTemplate.boundValueOps(comPropertyAlarmSetting.getCommunityId().toString()).set(comPropertyAlarmSetting.getTriggerTime().toString());
            }
            return R.ok();
        }
 
        return R.fail();
    }
}