|
|
@@ -3,11 +3,16 @@ package com.goafanti.business.service.impl;
|
|
|
import com.goafanti.business.bo.InputRestrictProject;
|
|
|
import com.goafanti.business.service.RestrictProjectService;
|
|
|
import com.goafanti.common.dao.RestrictProjectMapper;
|
|
|
+import com.goafanti.common.error.BusinessException;
|
|
|
+import com.goafanti.common.model.RestrictProject;
|
|
|
import com.goafanti.core.mybatis.BaseMybatisDao;
|
|
|
import com.goafanti.core.shiro.token.TokenManager;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.Date;
|
|
|
|
|
|
+@Service
|
|
|
public class RestrictProjectServiceImpl extends BaseMybatisDao<RestrictProjectMapper> implements RestrictProjectService {
|
|
|
@Resource
|
|
|
private RestrictProjectMapper restrictProjectMapper;
|
|
|
@@ -15,7 +20,18 @@ public class RestrictProjectServiceImpl extends BaseMybatisDao<RestrictProjectMa
|
|
|
public int add(InputRestrictProject in) {
|
|
|
String aid = TokenManager.getAdminId();
|
|
|
in.setAid(aid);
|
|
|
-
|
|
|
- return restrictProjectMapper.insertSelective(in);
|
|
|
+ in.setType(1);
|
|
|
+ in.setLockTime(new Date());
|
|
|
+ RestrictProject use = restrictProjectMapper.selectByPid(in);
|
|
|
+ if (use != null && use.getType() != 0){
|
|
|
+ throw new BusinessException("该项目已存在");
|
|
|
+ }
|
|
|
+ if(use ==null){
|
|
|
+ restrictProjectMapper.insertSelective(in);
|
|
|
+ }else if (use.getType() == 0){
|
|
|
+ in.setId(use.getId());
|
|
|
+ restrictProjectMapper.updateByPrimaryKeySelective(in);
|
|
|
+ }
|
|
|
+ return 1;
|
|
|
}
|
|
|
}
|