package com.huaxu.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.huaxu.dao.DeviceParmMapper; import com.huaxu.entity.DeviceParmEntity; import com.huaxu.model.LoginUser; import com.huaxu.service.DeviceParmService; import com.huaxu.util.UserUtil; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.Collection; import java.util.Date; import java.util.List; /** * @description 设备参数 * @auto wangli * @data 2020-11-17 11:02 */ @Service public class DeviceParmServiceImpl implements DeviceParmService { @Resource private DeviceParmMapper deviceParmMapper; @Override public DeviceParmEntity selectById(Integer id) { return deviceParmMapper.selectById(id); } @Override public List selectByDeviceId(Integer id) { return deviceParmMapper.selectByDeviceId(id); } @Override public Integer insert(DeviceParmEntity deviceParmEntity) { LoginUser loginUser = UserUtil.getCurrentUser(); deviceParmEntity.setDateUpdate(new Date()); deviceParmEntity.setUpdateBy(loginUser.getUsername()); deviceParmEntity.setDateCreate(new Date()); deviceParmEntity.setCreateBy(loginUser.getUsername()); deviceParmEntity.setStatus(1); deviceParmEntity.setTenantId(loginUser.getTenantId()); return deviceParmMapper.insert(deviceParmEntity); } @Override public Integer batchInsert(List deviceParmEntities){ LoginUser loginUser = UserUtil.getCurrentUser(); for(DeviceParmEntity deviceParmEntity:deviceParmEntities){ deviceParmEntity.setDateUpdate(new Date()); deviceParmEntity.setUpdateBy(loginUser.getUsername()); deviceParmEntity.setDateCreate(new Date()); deviceParmEntity.setCreateBy(loginUser.getUsername()); deviceParmEntity.setStatus(1); deviceParmEntity.setTenantId(loginUser.getTenantId()); } return deviceParmMapper.batchInsert(deviceParmEntities); } @Override public Integer delete(Integer id) { return deviceParmMapper.deleteById(id); } @Override public Integer update(DeviceParmEntity deviceParmEntity) { return deviceParmMapper.update(deviceParmEntity); } @Override public void batchUpdate(List deviceParmEntities) { LoginUser loginUser = UserUtil.getCurrentUser(); for(DeviceParmEntity deviceParmEntity:deviceParmEntities){ deviceParmEntity.setDateUpdate(new Date()); deviceParmEntity.setUpdateBy(loginUser.getUsername()); deviceParmMapper.update(deviceParmEntity); } } @Override public boolean saveOrUpdateBatch(Collection entityList) { for (DeviceParmEntity item : entityList) { if (item.getId() == null) { this.insert(item); } else { this.update(item); } } return true; } @Override public List selectList(DeviceParmEntity deviceParmEntity) { return deviceParmMapper.selectList(deviceParmEntity); } @Override public IPage selectPage(IPage page, DeviceParmEntity deviceParmEntity) { return deviceParmMapper.selectPage(page,deviceParmEntity); } }