| package com.doumee.biz.system.impl; | 
|   | 
| import com.doumee.biz.system.SystemJobBiz; | 
| import com.doumee.core.constants.Constants; | 
| import com.doumee.core.constants.ResponseStatus; | 
| import com.doumee.core.exception.BusinessException; | 
| import com.doumee.dao.system.model.SystemJob; | 
| import com.doumee.service.system.SystemJobService; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.stereotype.Service; | 
|   | 
| import java.util.List; | 
|   | 
| @Service | 
| public class SystemJobBizImpl implements SystemJobBiz { | 
|   | 
|     @Autowired | 
|     private SystemJobService systemJobService; | 
|   | 
|     @Override | 
|     public Integer create(SystemJob job) { | 
|         job.setDisabled(Boolean.FALSE); | 
|         SystemJob queryDto = new SystemJob(); | 
|         queryDto.setDisabled(Boolean.FALSE); | 
|         queryDto.setDeleted(Boolean.FALSE); | 
|         queryDto.setHandler(job.getHandler()); | 
|         job.setStatus(Constants.Job.JobStatus.READY.getCode()); | 
|         if (systemJobService.count(queryDto) > 0) { | 
|             throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "已存在任务处理器'" + job.getHandler() + "',请勿重复绑定"); | 
|         } | 
|         return systemJobService.create(job); | 
|     } | 
|   | 
|     @Override | 
|     public void updateById(SystemJob job) { | 
|         SystemJob queryDto = new SystemJob(); | 
|         queryDto.setDisabled(Boolean.FALSE); | 
|         queryDto.setDeleted(Boolean.FALSE); | 
|         queryDto.setHandler(job.getHandler()); | 
|         List<SystemJob> jobs = systemJobService.findList(queryDto); | 
|         if (jobs.size() > 1) { | 
|             throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "已存在任务处理器'" + job.getHandler() + "',请勿重复绑定"); | 
|         } | 
|         if (jobs.size() == 1 && !jobs.get(0).getId().equals(job.getId())) { | 
|             throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "已存在任务处理器'" + job.getHandler() + "',请勿重复绑定"); | 
|         } | 
|         systemJobService.updateById(job); | 
|     } | 
| } |