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.Customer; import com.gkhy.exam.system.mapper.CustomerMapper; import com.gkhy.exam.system.service.CustomerService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.time.LocalDateTime; import java.util.List; @Service public class CustomerServiceImpl extends ServiceImpl implements CustomerService { @Autowired private CustomerMapper customerMapper; @Override public CommonPage selectCustomerList(Customer customer) { if (!SecurityUtils.adminUser()){ if (customer.getCompanyId()==null){ throw new ApiException("非管理员操作,企业id不可为空"); } } PageUtils.startPage(); List customers = customerMapper.selectCustomerList(customer); return CommonPage.restPage(customers); } @Override public CommonResult insertCustomer(Customer customer) { customer.setCreateBy(SecurityUtils.getUsername()); customer.setCreateTime(LocalDateTime.now()); customerMapper.insert(customer); return CommonResult.success(); } @Override public CommonResult updateCustomer(Customer customer) { customer.setUpdateBy(SecurityUtils.getUsername()); customer.setUpdateTime(LocalDateTime.now()); customerMapper.updateById(customer); return CommonResult.success(); } @Override public CommonResult deletedCustomer(Integer customerId) { Customer customer = new Customer(); customer.setId(customerId); customer.setUpdateTime(LocalDateTime.now()); customer.setUpdateBy(SecurityUtils.getUsername()); customer.setDelFlag(2); customerMapper.updateById(customer); return CommonResult.success(); } }