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));
|
}
|
}
|