You've already forked FrameTour-BE
后台模板接口及设备接口
This commit is contained in:
@ -9,6 +9,7 @@ import com.ycwl.basic.model.pc.device.resp.DeviceRespVO;
|
||||
import com.ycwl.basic.service.pc.DeviceService;
|
||||
import com.ycwl.basic.utils.ApiResponse;
|
||||
import com.ycwl.basic.utils.SnowFlakeUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -45,6 +46,10 @@ public class DeviceServiceImpl implements DeviceService {
|
||||
Long id = deviceReqQuery.getId();
|
||||
if (id == null) {
|
||||
deviceReqQuery.setId(SnowFlakeUtil.getLongId());
|
||||
if (StringUtils.isBlank(deviceReqQuery.getNo())) {
|
||||
deviceReqQuery.setNo(deviceReqQuery.getId().toString());
|
||||
}
|
||||
deviceReqQuery.setStatus(0);
|
||||
return ApiResponse.success(deviceMapper.add(deviceReqQuery));
|
||||
} else {
|
||||
return ApiResponse.success(deviceMapper.update(deviceReqQuery));
|
||||
|
@ -39,13 +39,24 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
|
||||
@Override
|
||||
public ApiResponse<TemplateRespVO> getById(Long id) {
|
||||
return ApiResponse.success(templateMapper.getById(id));
|
||||
TemplateRespVO data = templateMapper.getById(id);
|
||||
data.setChildren(templateMapper.getByPid(id));
|
||||
return ApiResponse.success(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResponse<Boolean> add(TemplateEntity template) {
|
||||
template.setId(SnowFlakeUtil.getLongId());
|
||||
int i = templateMapper.add(template);
|
||||
if (template.getChildren() != null) {
|
||||
template.getChildren().forEach(item -> {
|
||||
item.setId(SnowFlakeUtil.getLongId());
|
||||
item.setPid(template.getId());
|
||||
item.setScenicId(template.getScenicId());
|
||||
item.setStatus(1);
|
||||
templateMapper.add(item);
|
||||
});
|
||||
}
|
||||
if (i > 0) {
|
||||
return ApiResponse.success(true);
|
||||
}else {
|
||||
@ -57,6 +68,7 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
public ApiResponse<Integer> deleteById(Long id) {
|
||||
int i = templateMapper.deleteById(id);
|
||||
if (i > 0) {
|
||||
templateMapper.deleteByPid(id);
|
||||
return ApiResponse.success(i);
|
||||
}else {
|
||||
return ApiResponse.fail("删除模版失败");
|
||||
@ -66,6 +78,16 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
@Override
|
||||
public ApiResponse<Boolean> update(TemplateEntity template) {
|
||||
int i = templateMapper.update(template);
|
||||
if (template.getChildren() != null) {
|
||||
templateMapper.deleteByPid(template.getId());
|
||||
template.getChildren().forEach(item -> {
|
||||
item.setId(SnowFlakeUtil.getLongId());
|
||||
item.setPid(template.getId());
|
||||
item.setScenicId(template.getScenicId());
|
||||
item.setStatus(1);
|
||||
templateMapper.add(item);
|
||||
});
|
||||
}
|
||||
if (i > 0) {
|
||||
return ApiResponse.success(true);
|
||||
}else {
|
||||
|
Reference in New Issue
Block a user