76 lines
2.3 KiB
Java
76 lines
2.3 KiB
Java
package com.gunshi.project.ss.service;
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.gunshi.project.ss.entity.so.TermiteSurveyPageSo;
|
|
import com.gunshi.project.ss.mapper.TermiteSurveyMapper;
|
|
import com.gunshi.project.ss.model.TermiteSurvey;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import java.util.Date;
|
|
import java.util.Objects;
|
|
|
|
/**
|
|
* 描述: 白蚁普查
|
|
* author: xusan
|
|
* date: 2024-08-28 10:29:58
|
|
*/
|
|
@Service
|
|
@Slf4j
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public class TermiteSurveyService extends ServiceImpl<TermiteSurveyMapper, TermiteSurvey>
|
|
{
|
|
@Autowired
|
|
private TermiteSurveyDetailService detailService;
|
|
|
|
public TermiteSurvey saveData(TermiteSurvey dto) {
|
|
dto.setCreateTime(new Date());
|
|
dto.setId(IdWorker.getId());
|
|
boolean result = this.save(dto);
|
|
if (result) {
|
|
detailService.saveDetail(dto.getDetails(),dto.getId());
|
|
}
|
|
return dto;
|
|
}
|
|
|
|
public TermiteSurvey updateData(TermiteSurvey dto) {
|
|
if (Objects.isNull(this.getById(dto.getId()))) {
|
|
throw new IllegalArgumentException("当前数据不存在");
|
|
}
|
|
boolean result = this.updateById(dto);
|
|
if (result) {
|
|
detailService.updateDetail(dto.getDetails(),dto.getId());
|
|
}
|
|
return dto;
|
|
}
|
|
|
|
public Boolean delData(Long id) {
|
|
if (Objects.isNull(this.getById(id))) {
|
|
throw new IllegalArgumentException("当前数据不存在");
|
|
}
|
|
boolean data = this.removeById(id);
|
|
if (data) {
|
|
detailService.delDetail(id);
|
|
}
|
|
return data;
|
|
}
|
|
|
|
public TermiteSurvey detail(Long id) {
|
|
TermiteSurvey termiteSurvey = this.getById(id);
|
|
if(Objects.isNull(termiteSurvey)){
|
|
throw new IllegalArgumentException("当前数据不存在");
|
|
}
|
|
return detailService.detail(termiteSurvey);
|
|
}
|
|
|
|
public Page<TermiteSurvey> pageQuery(TermiteSurveyPageSo page) {
|
|
return this.baseMapper.pageQuery(page.getPageSo().toPage(),page);
|
|
}
|
|
}
|
|
|
|
|