package com.iailab.module.model.mcs.sche.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.iailab.framework.common.pojo.PageResult; import com.iailab.framework.common.service.impl.BaseServiceImpl; import com.iailab.module.model.mcs.sche.dao.StScheduleEnergyTypeDao; import com.iailab.module.model.mcs.sche.entity.StScheduleEnergyTypeEntity; import com.iailab.module.model.mcs.sche.service.StScheduleEnergyTypeService; import com.iailab.module.model.mcs.sche.vo.StScheduleEnergyTypePageReqVO; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.UUID; /** * @author PanZhibao * @date 2021年07月20日 11:47 */ @Service("stScheduleEnergyTypeService") public class StScheduleEnergyTypeServiceImpl extends BaseServiceImpl implements StScheduleEnergyTypeService { @Override public PageResult page(StScheduleEnergyTypePageReqVO reqVO) { return baseDao.selectPage(reqVO); } private QueryWrapper getWrapper(Map params) { String energytypename = (String) params.get("energytypename"); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.like(StringUtils.isNotBlank(energytypename), "energytypename", energytypename); return wrapper; } public StScheduleEnergyTypeEntity getDetailById(String id) { StScheduleEnergyTypeEntity entity = baseDao.selectById(id); return entity; } @Override @Transactional(rollbackFor = Exception.class) public void saveScheduleEnergyType(StScheduleEnergyTypeEntity scheduleEnergyType) { scheduleEnergyType.setId(UUID.randomUUID().toString()); baseDao.insert(scheduleEnergyType); } @Override @Transactional(rollbackFor = Exception.class) public void update(StScheduleEnergyTypeEntity scheduleEnergyType) { baseDao.updateById(scheduleEnergyType); } @Override @Transactional(rollbackFor = Exception.class) public void deleteBatch(String[] storeTypeIds) { baseDao.deleteBatchIds(Arrays.asList(storeTypeIds)); } @Override public int check(StScheduleEnergyTypeEntity scheduleEnergyType) { String id = scheduleEnergyType.getId(); String energytypename = scheduleEnergyType.getEnergytypename(); QueryWrapper scheduleEnergyTypeWrapper = new QueryWrapper<>(); scheduleEnergyTypeWrapper.ne(StringUtils.isNotBlank(id), "id", id); scheduleEnergyTypeWrapper.and(wrapper -> wrapper.eq("energytypename", energytypename)); List list = baseDao.selectList(scheduleEnergyTypeWrapper); return list.size(); } }