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
60
61
62
package api.service.impl;
 
import api.bean.Pages;
import api.bean.PhotovoltaicError;
import api.dao.PhotovoltaicErrorDao;
import api.service.PhotovoltaicErrorService;
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.ArrayList;
import java.util.List;
 
/**
 * (PhotovoltaicError)表服务实现类
 *
 * @author makejava
 * @since 2022-09-30 11:53:07
 */
@Service("photovoltaicErrorService")
public class PhotovoltaicErrorServiceImpl extends ServiceImpl<PhotovoltaicErrorDao, PhotovoltaicError> implements PhotovoltaicErrorService {
 
    @Autowired
    private SysUserRoleService sysUserRoleService;
 
    @Autowired
    private PhotovoltaicErrorDao photovoltaicErrorDao;
    @Override
    public PageInfo<PhotovoltaicError> list(Pages pages,Long userId) {
        //获取角色列表
        Long roleId = sysUserRoleService.queryRoleId(userId);
 
        if (roleId == null || roleId == 0) {
            return null;
        }
 
        int page = pages.getPage() - 1;
        int size = pages.getSize();
 
        List<PhotovoltaicError> allList = new ArrayList<>();
 
        if (pages.getPhotovoltaicId() == null){
            if (roleId.longValue() == 1) {
                allList = photovoltaicErrorDao.findAllBySort(page, size, pages.getField(), pages.getSort());
            }else{
                allList = photovoltaicErrorDao.findByCompanyBySort(page, size,userId, null, pages.getField(), pages.getSort());
            }
        }else {
            PageHelper.startPage(page, size);
            allList = photovoltaicErrorDao.findByPhotovoltaicId(pages.getPhotovoltaicId());
        }
 
        PageInfo<PhotovoltaicError> pageInfo = new PageInfo<>(allList);
 
        return pageInfo;
 
    }
}