TemplateConfigController.java 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package com.gitee.gen.controller;
  2. import com.gitee.gen.common.Action;
  3. import com.gitee.gen.common.Result;
  4. import com.gitee.gen.entity.TemplateConfig;
  5. import com.gitee.gen.service.TemplateConfigService;
  6. import org.apache.commons.lang.StringUtils;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.web.bind.annotation.PathVariable;
  9. import org.springframework.web.bind.annotation.RequestBody;
  10. import org.springframework.web.bind.annotation.RequestMapping;
  11. import org.springframework.web.bind.annotation.RestController;
  12. import java.util.List;
  13. /**
  14. * @author tanghc
  15. */
  16. @RestController
  17. @RequestMapping("template")
  18. public class TemplateConfigController {
  19. @Autowired
  20. private TemplateConfigService templateConfigService;
  21. @RequestMapping("/add")
  22. public Result add(@RequestBody TemplateConfig templateConfig) {
  23. templateConfigService.insert(templateConfig);
  24. return Action.ok(templateConfig);
  25. }
  26. @RequestMapping("/get/{id}")
  27. public Result get(@PathVariable("id") int id) {
  28. return Action.ok(templateConfigService.getById(id));
  29. }
  30. @RequestMapping("/list")
  31. public Result list(String groupId) {
  32. List<TemplateConfig> templateConfigs = null;
  33. if(StringUtils.isEmpty(groupId)){
  34. templateConfigs = templateConfigService.listAll();
  35. }else {
  36. templateConfigs = templateConfigService.listByGroupId(groupId);
  37. }
  38. return Action.ok(templateConfigs);
  39. }
  40. @RequestMapping("/update")
  41. public Result update(@RequestBody TemplateConfig templateConfig) {
  42. templateConfigService.update(templateConfig);
  43. return Action.ok();
  44. }
  45. @RequestMapping("/del")
  46. public Result del(@RequestBody TemplateConfig templateConfig) {
  47. templateConfigService.delete(templateConfig);
  48. return Action.ok();
  49. }
  50. }