|
|
@@ -1,9 +1,11 @@
|
|
|
package com.izouma.nineth.web;
|
|
|
+
|
|
|
import com.izouma.nineth.domain.MetaZouMaLight;
|
|
|
+import com.izouma.nineth.dto.MetaRestResult;
|
|
|
import com.izouma.nineth.dto.PageQuery;
|
|
|
import com.izouma.nineth.exception.BusinessException;
|
|
|
-import com.izouma.nineth.repo.MetaZoumaLightRepo;
|
|
|
-import com.izouma.nineth.service.MetaZoumaLightService;
|
|
|
+import com.izouma.nineth.repo.MetaZouMaLightRepo;
|
|
|
+import com.izouma.nineth.service.MetaZouMaLightService;
|
|
|
import com.izouma.nineth.utils.ObjUtils;
|
|
|
import com.izouma.nineth.utils.excel.ExcelUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
@@ -16,44 +18,44 @@ import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
|
|
|
@RestController
|
|
|
-@RequestMapping("/metaZoumaLight")
|
|
|
+@RequestMapping("/metaZouMaLight")
|
|
|
@AllArgsConstructor
|
|
|
-public class MetaZoumaLightController extends BaseController {
|
|
|
- private MetaZoumaLightService metaZoumaLightService;
|
|
|
- private MetaZoumaLightRepo metaZoumaLightRepo;
|
|
|
+public class MetaZouMaLightController extends BaseController {
|
|
|
+
|
|
|
+ private MetaZouMaLightService metaZouMaLightService;
|
|
|
+ private MetaZouMaLightRepo metaZouMaLightRepo;
|
|
|
|
|
|
//@PreAuthorize("hasRole('ADMIN')")
|
|
|
@PostMapping("/save")
|
|
|
public MetaZouMaLight save(@RequestBody MetaZouMaLight record) {
|
|
|
if (record.isPublish()) {
|
|
|
- MetaZouMaLight metaZoumaLight = metaZoumaLightRepo.findByPublishAndDel(true,false);
|
|
|
- if (Objects.nonNull(metaZoumaLight) && !Objects.equals(metaZoumaLight.getId(), record.getId())){
|
|
|
+ MetaZouMaLight metaZoumaLight = metaZouMaLightRepo.findByPublishAndDel(true, false);
|
|
|
+ if (Objects.nonNull(metaZoumaLight) && !Objects.equals(metaZoumaLight.getId(), record.getId())) {
|
|
|
throw new BusinessException("仅允许发布一条!");
|
|
|
}
|
|
|
}
|
|
|
if (record.getId() != null) {
|
|
|
- MetaZouMaLight orig = metaZoumaLightRepo.findById(record.getId()).orElseThrow(new BusinessException("无记录"));
|
|
|
+ MetaZouMaLight orig = metaZouMaLightRepo.findById(record.getId()).orElseThrow(new BusinessException("无记录"));
|
|
|
ObjUtils.merge(orig, record);
|
|
|
- return metaZoumaLightRepo.save(orig);
|
|
|
+ return metaZouMaLightRepo.save(orig);
|
|
|
}
|
|
|
- return metaZoumaLightRepo.save(record);
|
|
|
+ return metaZouMaLightRepo.save(record);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
//@PreAuthorize("hasRole('ADMIN')")
|
|
|
@PostMapping("/all")
|
|
|
public Page<MetaZouMaLight> all(@RequestBody PageQuery pageQuery) {
|
|
|
- return metaZoumaLightService.all(pageQuery);
|
|
|
+ return metaZouMaLightService.all(pageQuery);
|
|
|
}
|
|
|
|
|
|
@GetMapping("/get/{id}")
|
|
|
public MetaZouMaLight get(@PathVariable Long id) {
|
|
|
- return metaZoumaLightRepo.findById(id).orElseThrow(new BusinessException("无记录"));
|
|
|
+ return metaZouMaLightRepo.findById(id).orElseThrow(new BusinessException("无记录"));
|
|
|
}
|
|
|
|
|
|
@PostMapping("/del/{id}")
|
|
|
public void del(@PathVariable Long id) {
|
|
|
- metaZoumaLightRepo.softDelete(id);
|
|
|
+ metaZouMaLightRepo.softDelete(id);
|
|
|
}
|
|
|
|
|
|
@GetMapping("/excel")
|
|
|
@@ -62,5 +64,10 @@ public class MetaZoumaLightController extends BaseController {
|
|
|
List<MetaZouMaLight> data = all(pageQuery).getContent();
|
|
|
ExcelUtils.export(response, data);
|
|
|
}
|
|
|
+
|
|
|
+ @PostMapping("/metaQuery")
|
|
|
+ public MetaRestResult<String> metaQuery() {
|
|
|
+ return MetaRestResult.returnSuccess(metaZouMaLightRepo.findDescriptionByPublishAndDel(true, false));
|
|
|
+ }
|
|
|
}
|
|
|
|