package com.gkhy.exam.system.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.gkhy.exam.common.api.CommonPage; import com.gkhy.exam.common.api.CommonResult; import com.gkhy.exam.common.exception.ApiException; import com.gkhy.exam.common.utils.PageUtils; import com.gkhy.exam.common.utils.SecurityUtils; import com.gkhy.exam.system.domain.CustomerCommunication; import com.gkhy.exam.system.mapper.CustomerCommunicationMapper; import com.gkhy.exam.system.service.CustomerCommunicationService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.time.LocalDateTime; import java.util.List; @Service public class CustomerCommunicationServiceImpl extends ServiceImpl implements CustomerCommunicationService { @Autowired private CustomerCommunicationMapper customerCommunicationMapper; @Override public CommonPage selectCustomerCommunicationList(CustomerCommunication customerCommunication) { if (!SecurityUtils.adminUser()){ if (customerCommunication.getCompanyId()==null){ throw new ApiException("非管理员操作,查询条件不可为空"); } } PageUtils.startPage(); List customerCommunications = customerCommunicationMapper.selectCommunicationList(customerCommunication); return CommonPage.restPage(customerCommunications); } @Override public CommonResult insertCustomerCommunication(CustomerCommunication customerCommunication) { customerCommunication.setCreateBy(SecurityUtils.getUsername()); customerCommunication.setCreateTime(LocalDateTime.now()); int insert = customerCommunicationMapper.insert(customerCommunication); if (insert>0){ return CommonResult.success(); } return CommonResult.failed(); } @Override public CommonResult updateCustomerCommunication(CustomerCommunication customerCommunication) { customerCommunication.setUpdateBy(SecurityUtils.getUsername()); customerCommunication.setUpdateTime(LocalDateTime.now()); int i = customerCommunicationMapper.updateById(customerCommunication); if (i>0){ return CommonResult.success(); } return CommonResult.failed(); } @Override public CommonResult deletedCustomerCommunication(Integer communId) { CustomerCommunication customerCommunication = new CustomerCommunication(); customerCommunication.setId(communId); customerCommunication.setUpdateBy(SecurityUtils.getUsername()); customerCommunication.setUpdateTime(LocalDateTime.now()); customerCommunication.setDelFlag(2); int i = customerCommunicationMapper.updateById(customerCommunication); if (i>0){ return CommonResult.success(); } return CommonResult.failed(); } }