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.StScheduleDao;
|
import com.iailab.module.model.mcs.sche.entity.StScheduleEntity;
|
import com.iailab.module.model.mcs.sche.service.StScheduleService;
|
import com.iailab.module.model.mcs.sche.vo.StSchedulePageReqVO;
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.util.*;
|
|
/**
|
* @author PanZhibao
|
* @date 2021年07月20日 11:37
|
*/
|
@Service("stScheduleService")
|
public class StScheduleServiceImpl extends BaseServiceImpl<StScheduleDao, StScheduleEntity> implements StScheduleService {
|
|
@Override
|
public PageResult<StScheduleEntity> page(StSchedulePageReqVO reqVO) {
|
return baseDao.selectPage(reqVO);
|
}
|
|
private QueryWrapper<StScheduleEntity> getWrapper(Map<String, Object> params) {
|
String name = (String) params.get("name");
|
|
QueryWrapper<StScheduleEntity> wrapper = new QueryWrapper<>();
|
wrapper.like(StringUtils.isNotBlank(name), "name", name);
|
|
return wrapper;
|
}
|
|
public StScheduleEntity getDetailById(String id) {
|
return baseDao.selectById(id);
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void saveSchedule(StScheduleEntity schedule) {
|
schedule.setId(UUID.randomUUID().toString());
|
schedule.setScheduletime(new Date());
|
baseDao.insert(schedule);
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void update(StScheduleEntity schedule) {
|
baseDao.updateById(schedule);
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void deleteBatch(String[] storeTypeIds) {
|
baseDao.deleteBatchIds(Arrays.asList(storeTypeIds));
|
}
|
|
@Override
|
public int check(StScheduleEntity schedule) {
|
String id = schedule.getId();
|
String name = schedule.getName();
|
QueryWrapper<StScheduleEntity> scheduleWrapper = new QueryWrapper<>();
|
scheduleWrapper.ne(StringUtils.isNotBlank(id), "id", id);
|
scheduleWrapper.and(wrapper -> wrapper.eq("name", name));
|
|
List<StScheduleEntity> list = baseDao.selectList(scheduleWrapper);
|
return list.size();
|
}
|
}
|