Van333
2022-10-26 b54ea64cbb2cf8d613ca1ecf6ed9e5140abb4b9f
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
package api.service;
 
import api.bean.ReqParams;
import api.bean.WeatherEntity;
import api.dao.WeatherDao;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
/**
 * @program: wog
 * @description:
 * @author: YSS
 * @create: 2020-09-26 16:38
 **/
@Service
public class WeatherService {
    @Autowired
    private AccessService accessService;
    @Autowired
    private WeatherDao weatherDao;
    public PageInfo<WeatherEntity> selectList(Long userId, ReqParams reqParams) {
        Long roleId = accessService.getRoleId(userId);
 
        if (roleId == null || roleId == 0) {
            return null;
        }
 
        List<WeatherEntity> list = null;
 
        if (roleId.longValue() == 1) {
            PageHelper.startPage(reqParams.getPage(), reqParams.getLimit());
            list = weatherDao.selectAll();
        } else if (roleId.longValue() == 2) {
            PageHelper.startPage(reqParams.getPage(), reqParams.getLimit());
            list = weatherDao.selectByCompany(userId);
        } else if (roleId.longValue() == 3) {
            PageHelper.startPage(reqParams.getPage(), reqParams.getLimit());
            list = weatherDao.selectByUserId(userId);
        }
 
        PageInfo<WeatherEntity> page = new PageInfo<>(list);
        return page;
    }
 
    public PageInfo<WeatherEntity> selectByStreetlightId(ReqParams reqParams) {
        PageHelper.startPage(reqParams.getPage(),reqParams.getLimit());
        List<WeatherEntity> list = weatherDao.selectByStreetlightId(reqParams.getLightId());
        PageInfo<WeatherEntity> page = new PageInfo<>(list);
        return page;
    }
}