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.CustomerInventory; import com.gkhy.exam.system.domain.CustomerRecord; import com.gkhy.exam.system.domain.CustomerRecordNeed; import com.gkhy.exam.system.mapper.CustomerCommunicationMapper; import com.gkhy.exam.system.mapper.CustomerInventoryMapper; import com.gkhy.exam.system.mapper.CustomerRecordMapper; import com.gkhy.exam.system.mapper.CustomerRecordNeedMapper; import com.gkhy.exam.system.service.CustomerInventoryService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; import java.util.List; @Service public class CustomerInventoryServiceImpl extends ServiceImpl implements CustomerInventoryService { @Autowired private CustomerInventoryMapper customerInventoryMapper; @Override public CommonPage selectCustomerInventoryList(CustomerInventory customerInventory) { if (!SecurityUtils.adminUser()){ if (customerInventory.getCompanyId()==null){ throw new ApiException("非管理员操作,查询条件不可为空"); } } PageUtils.startPage(); List customerInventories = customerInventoryMapper.selectInventoryList(customerInventory); return CommonPage.restPage(customerInventories); } @Override public CommonResult insertCustomerInventory(CustomerInventory customerInventory) { customerInventory.setCreateBy(SecurityUtils.getUsername()); customerInventory.setCreateTime(LocalDateTime.now()); int insert = customerInventoryMapper.insert(customerInventory); if (insert > 0) { return CommonResult.success(); } return CommonResult.failed(); } @Override public CommonResult updateCustomerInventory(CustomerInventory customerInventory) { customerInventory.setUpdateBy(SecurityUtils.getUsername()); customerInventory.setUpdateTime(LocalDateTime.now()); int insert = customerInventoryMapper.updateById(customerInventory); if (insert > 0) { return CommonResult.success(); } return CommonResult.failed(); } @Override public CommonResult deletedCustomerInventory(Integer customerId) { CustomerInventory customerInventory = new CustomerInventory(); customerInventory.setId(customerId); customerInventory.setUpdateBy(SecurityUtils.getUsername()); customerInventory.setUpdateTime(LocalDateTime.now()); customerInventory.setDelFlag(2); int insert = customerInventoryMapper.updateById(customerInventory); if (insert > 0) { return CommonResult.success(); } return CommonResult.failed(); } @Override public CommonResult selectCustomerInventoryListAll(CustomerInventory customerInventory) { List customerInventories = customerInventoryMapper.selectInventoryList(customerInventory); return CommonResult.success(customerInventories); } }