package com.thhy.mobile.modules.biz.checkdevice.service.impl; import com.thhy.general.config.SysUserInfo; import com.thhy.general.utils.DeepCopyUtils; import com.thhy.general.utils.UserInfoUtils; import com.thhy.mobile.modules.biz.checkdevice.entity.*; import com.thhy.mobile.modules.biz.checkdevice.mapper.CheckDeviceFileMapper; import com.thhy.mobile.modules.biz.checkdevice.mapper.CheckDeviceMapper; import com.thhy.mobile.modules.biz.checkdevice.service.CheckDeviceService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.io.Serializable; import java.util.HashMap; import java.util.List; /** * 服务实现类 * @author zhang_xiao_bo * @since 2023-09-25 16:02:35 */ @Service public class CheckDeviceServiceImpl implements CheckDeviceService { @Autowired private CheckDeviceMapper checkDeviceMapper; @Autowired private CheckDeviceFileMapper fileMapper; public CheckDevice get(Serializable id){ return checkDeviceMapper.queryById(id); } public List findList(CheckDeviceDto checkDeviceDto){ return checkDeviceMapper.findList(checkDeviceDto); } public CheckDeviceListVo checkDeviceInfo(CheckDeviceDto checkDeviceDto){ CheckDeviceListVo deviceListVo = checkDeviceMapper.queryInfoById(checkDeviceDto.getId()); List fileList = fileMapper.findAll(deviceListVo.getId()); deviceListVo.setFileList(fileList); return deviceListVo; } /** * 增加和修改 * @param checkDeviceAddDto */ @Transactional public void addCheckDevice(CheckDeviceAddDto checkDeviceAddDto){ SysUserInfo userInfo = UserInfoUtils.getInstance().getUserInfo(); List fileList = checkDeviceAddDto.getFileList(); CheckDevice checkDevice = new CheckDevice(); DeepCopyUtils.copy(checkDeviceAddDto,checkDevice); if(checkDevice.getId() == null){ //增加操作 checkDevice.setAdminUser(userInfo.getUserId()); checkDeviceMapper.insert(checkDevice); }else{ //修改操作 checkDeviceMapper.update(checkDevice); fileMapper.deleteByCheckId(checkDevice.getId()); } for(CheckDeviceFile deviceFile : fileList){ deviceFile.setCheckId(checkDevice.getId()); fileMapper.insert(deviceFile); } } /** * 修改 * @param checkDevice */ public void update(CheckDevice checkDevice){ checkDeviceMapper.update(checkDevice); } /** * 删除 * @param id */ public void delete(Serializable id){ checkDeviceMapper.deletelogic(id); } @Override public List> deviceList() { SysUserInfo userInfo = UserInfoUtils.getInstance().getUserInfo(); return checkDeviceMapper.deviceList(userInfo.getCompanyId()); } }