AppDataController.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package jnpf.controller;
  2. import jnpf.base.controller.SuperController;
  3. import io.swagger.v3.oas.annotations.tags.Tag;
  4. import io.swagger.v3.oas.annotations.Parameter;
  5. import io.swagger.v3.oas.annotations.Parameters;
  6. import io.swagger.v3.oas.annotations.Operation;
  7. import jnpf.base.ActionResult;
  8. import jnpf.constant.MsgCode;
  9. import jnpf.entity.AppDataEntity;
  10. import jnpf.model.AppDataCrForm;
  11. import jnpf.service.AppDataService;
  12. import jnpf.util.JsonUtil;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.web.bind.annotation.*;
  15. import jakarta.validation.Valid;
  16. /**
  17. * app常用数据
  18. *
  19. * @author JNPF开发平台组
  20. * @version V3.1.0
  21. * @copyright 引迈信息技术有限公司(https://www.jnpfsoft.com)
  22. * @date 2021-07-08
  23. */
  24. @Tag(name = "app常用数据", description = "data")
  25. @RestController
  26. @RequestMapping("/api/app/Data")
  27. public class AppDataController extends SuperController<AppDataService, AppDataEntity> {
  28. @Autowired
  29. private AppDataService appDataService;
  30. /**
  31. * 新建
  32. *
  33. * @param appDataCrForm 新建模型
  34. * @return
  35. */
  36. @PostMapping
  37. @Operation(summary = "新建")
  38. @Parameters({
  39. @Parameter(name = "appDataCrForm", description = "常用模型",required = true),
  40. })
  41. public ActionResult create(@RequestBody @Valid AppDataCrForm appDataCrForm) {
  42. AppDataEntity entity = JsonUtil.getJsonToBean(appDataCrForm, AppDataEntity.class);
  43. if (appDataService.isExistByObjectId(entity.getObjectId(),appDataCrForm.getSystemId())) {
  44. return ActionResult.fail(MsgCode.FA036.get());
  45. }
  46. appDataService.create(entity);
  47. return ActionResult.success(MsgCode.SU001.get());
  48. }
  49. /**
  50. * 删除
  51. *
  52. * @param objectId 主键
  53. * @return
  54. */
  55. @Operation(summary = "删除")
  56. @DeleteMapping("/{objectId}")
  57. @Parameters({
  58. @Parameter(name = "objectId", description = "主键", required = true),
  59. })
  60. public ActionResult create(@PathVariable("objectId") String objectId) {
  61. AppDataEntity entity = appDataService.getInfo(objectId);
  62. if (entity != null) {
  63. appDataService.delete(entity);
  64. return ActionResult.success(MsgCode.SU003.get());
  65. }
  66. return ActionResult.fail(MsgCode.FA003.get());
  67. }
  68. }