Van333
2022-12-29 d8f66b834134f6b755fd3fb93bb91b56f9d31f6f
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
package api.service.impl;
 
import api.bean.PhotovoltaicEntity;
import api.dao.PhotovoltaicEntityDao;
import api.service.PhotovoltaicEntityService;
import api.service.SysUserCompanyService;
import api.service.SysUserRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
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;
 
/**
 * (PhotovoltaicEntity)表服务实现类
 *
 * @author makejava
 * @since 2022-09-28 17:35:51
 */
@Service("photovoltaicEntityService")
public class PhotovoltaicEntityServiceImpl extends ServiceImpl<PhotovoltaicEntityDao, PhotovoltaicEntity> implements PhotovoltaicEntityService {
 
    @Autowired
    private SysUserCompanyService sysUserCompanyService;
    @Autowired
    private SysUserRoleService sysUserRoleService;
 
//    @Autowired
//    private MqttService mqttService;
 
    @Autowired
    private PhotovoltaicEntityDao photovoltaicEntityDao;
 
    @Override
    public PageInfo<PhotovoltaicEntity> list(Integer page, Integer limit, String key, Long userId) {
        System.out.println(userId);
        Long roleId = sysUserRoleService.queryRoleId(userId);
        Long companyId = sysUserCompanyService.queryCompanyId(userId);
 
        List<PhotovoltaicEntity> list;
        if (roleId == 1) {
            PageHelper.startPage(page,limit);
            list = photovoltaicEntityDao.listAll(key);
            System.out.println(list.size());
        }else if (roleId == 2) {
            PageHelper.startPage(page,limit);
            list = photovoltaicEntityDao.listByCompanyId(key, companyId);
        }else {
            PageHelper.startPage(page,limit);
            list = photovoltaicEntityDao.listByUserId(key,  userId);
        }
        PageInfo<PhotovoltaicEntity> pageInfo = new PageInfo<>(list);
 
        return pageInfo;
    }
}