heheng
9 天以前 dfdc3c9b786769e5e53b6657d168de1ea922c76b
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
package com.gkhy.exam.system.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gkhy.exam.common.constant.UserConstant;
import com.gkhy.exam.common.exception.ApiException;
import com.gkhy.exam.common.utils.SecurityUtils;
import com.gkhy.exam.system.domain.InformationPlatform;
import com.gkhy.exam.system.mapper.InformationPlatformMapper;
import com.gkhy.exam.system.service.InformationPlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.time.LocalDateTime;
import java.util.List;
 
/**
 * @author Administrator
 */
@Service
public class InformationPlatformServiceImpl extends ServiceImpl<InformationPlatformMapper, InformationPlatform> implements InformationPlatformService {
 
    @Autowired
    private InformationPlatformMapper informationPlatformMapper;
 
    @Override
    public List<InformationPlatform> getInformationPlatforms(Long companyId) {
 
        LambdaQueryWrapper<InformationPlatform> queryWrapper = new LambdaQueryWrapper<>();
        if (companyId != null){
            queryWrapper.eq(InformationPlatform::getCompanyId, companyId);
        }
        queryWrapper.eq(InformationPlatform::getDelFlag, UserConstant.ENABLE);
        queryWrapper.orderByDesc(InformationPlatform::getCreateTime);
 
        return informationPlatformMapper.selectList(queryWrapper);
 
    }
 
    @Override
    public int saveInformationPlatform(InformationPlatform informationPlatform) {
//        Long companyId = informationPlatform.getCompanyId();
//        if (!companyId.equals(SecurityUtils.getCompanyId())){
//            throw new ApiException("无权操作!");
//        }
 
        if (informationPlatform.getId() != null){
            informationPlatform.setUpdateTime(LocalDateTime.now());
            informationPlatform.setUpdateBy(SecurityUtils.getUsername());
            return informationPlatformMapper.updateById(informationPlatform);
        }else {
            informationPlatform.setCreateTime(LocalDateTime.now());
            informationPlatform.setCreateBy(SecurityUtils.getUsername());
            return informationPlatformMapper.insert(informationPlatform);
        }
    }
 
    @Override
    public int delInformationPlatform(Long id) {
        InformationPlatform informationPlatform = new InformationPlatform();
        informationPlatform.setDelFlag(UserConstant.DISENABLE.toString());
        return informationPlatformMapper.update(informationPlatform,new LambdaQueryWrapper<InformationPlatform>().eq(InformationPlatform::getId, id));
    }
}