|
|
|
@ -6,6 +6,7 @@ import com.xydl.cac.service.LxService;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.List;
|
|
|
|
@ -24,13 +25,21 @@ public class LxServiceImpl implements LxService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Lx add(Lx item) {
|
|
|
|
|
public Lx add(Lx item) throws Exception {
|
|
|
|
|
item.setId(null);
|
|
|
|
|
List<Lx> list = repository.findByMc(item.getMc());
|
|
|
|
|
if (!CollectionUtils.isEmpty(list)) {
|
|
|
|
|
throw new Exception("该名称已被使用");
|
|
|
|
|
}
|
|
|
|
|
return repository.save(item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void update(Lx item) {
|
|
|
|
|
public void update(Lx item) throws Exception {
|
|
|
|
|
List<Lx> list = repository.findByMcAndIdIsNot(item.getMc(), item.getId());
|
|
|
|
|
if (!CollectionUtils.isEmpty(list)) {
|
|
|
|
|
throw new Exception("该名称已被使用");
|
|
|
|
|
}
|
|
|
|
|
repository.save(item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|