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.framework.common.util.object.BeanUtils;
|
import com.iailab.module.model.mcs.sche.dao.StScheduleModelDao;
|
import com.iailab.module.model.mcs.sche.entity.StScheduleModelEntity;
|
import com.iailab.module.model.mcs.sche.service.StScheduleModelParamService;
|
import com.iailab.module.model.mcs.sche.service.StScheduleModelService;
|
import com.iailab.module.model.mcs.sche.service.StScheduleModelSettingService;
|
import com.iailab.module.model.mcs.sche.vo.StScheduleModelPageReqVO;
|
import com.iailab.module.model.mcs.sche.vo.StScheduleModelSaveReqVO;
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.util.UUID;
|
|
/**
|
* @author PanZhibao
|
* @date 2021年07月20日 14:23
|
*/
|
@Service
|
public class StScheduleModelServiceImpl extends BaseServiceImpl<StScheduleModelDao, StScheduleModelEntity> implements StScheduleModelService {
|
|
@Autowired
|
private StScheduleModelParamService stScheduleModelParamService;
|
|
@Autowired
|
private StScheduleModelSettingService stScheduleModelSettingService;
|
|
@Override
|
public PageResult<StScheduleModelEntity> page(StScheduleModelPageReqVO reqVO) {
|
return baseDao.selectPage(reqVO);
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void create(StScheduleModelSaveReqVO reqVO) {
|
StScheduleModelEntity entity = BeanUtils.toBean(reqVO, StScheduleModelEntity.class);
|
entity.setId(UUID.randomUUID().toString());
|
baseDao.insert(entity);
|
stScheduleModelParamService.saveList(entity.getId(), reqVO.getParamList());
|
stScheduleModelSettingService.saveList(entity.getId(), reqVO.getSettingList());
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void update(StScheduleModelSaveReqVO reqVO) {
|
StScheduleModelEntity entity = BeanUtils.toBean(reqVO, StScheduleModelEntity.class);
|
baseDao.updateById(entity);
|
stScheduleModelParamService.saveList(entity.getId(), reqVO.getParamList());
|
stScheduleModelSettingService.saveList(entity.getId(), reqVO.getSettingList());
|
}
|
|
@Override
|
public StScheduleModelEntity get(String id) {
|
return baseDao.selectById(id);
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void delete(String id) {
|
baseDao.deleteById(id);
|
stScheduleModelParamService.deleteByModelId(id);
|
stScheduleModelSettingService.deleteByModelId(id);
|
}
|
|
@Override
|
public Long check(StScheduleModelSaveReqVO reqVO) {
|
String id = reqVO.getId();
|
String modelname = reqVO.getModelName();
|
QueryWrapper<StScheduleModelEntity> scheduleModelWrapper = new QueryWrapper<>();
|
scheduleModelWrapper.ne(StringUtils.isNotBlank(id), "id", id);
|
scheduleModelWrapper.and(wrapper -> wrapper.eq("model_name", modelname));
|
return baseDao.selectCount(scheduleModelWrapper);
|
}
|
|
@Override
|
public Long count() {
|
QueryWrapper<StScheduleModelEntity> wrapper = new QueryWrapper<>();
|
return baseDao.selectCount(wrapper);
|
}
|
}
|