SettingController.java 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. package com.qxgmat.controller.admin;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.nuliji.tools.Response;
  4. import com.nuliji.tools.ResponseHelp;
  5. import com.qxgmat.data.constants.enums.SettingKey;
  6. import com.qxgmat.data.dao.entity.Setting;
  7. import com.qxgmat.service.inline.SettingService;
  8. import io.swagger.annotations.Api;
  9. import io.swagger.annotations.ApiOperation;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.http.MediaType;
  12. import org.springframework.validation.annotation.Validated;
  13. import org.springframework.web.bind.annotation.RequestBody;
  14. import org.springframework.web.bind.annotation.RequestMapping;
  15. import org.springframework.web.bind.annotation.RequestMethod;
  16. import org.springframework.web.bind.annotation.RestController;
  17. @RestController("AdminSettingController")
  18. @RequestMapping("/admin/common")
  19. @Api(tags = "配置信息接口", description = "全局独立配置设置", produces = MediaType.APPLICATION_JSON_VALUE)
  20. public class SettingController {
  21. @Autowired
  22. private SettingService settingService;
  23. @RequestMapping(value = "/index", method = RequestMethod.PUT)
  24. @ApiOperation(value = "修改首页配置", httpMethod = "PUT")
  25. private Response<Boolean> indexEdit(@RequestBody @Validated JSONObject dto){
  26. Setting entity = settingService.getByKey(SettingKey.INDEX.key);
  27. entity.setValue(dto);
  28. settingService.edit(entity);
  29. return ResponseHelp.success(true);
  30. }
  31. @RequestMapping(value = "/index", method = RequestMethod.GET)
  32. @ApiOperation(value = "获取首页配置", httpMethod = "GET")
  33. private Response<JSONObject> indexGet(){
  34. Setting entity = settingService.getByKey(SettingKey.INDEX.key);
  35. return ResponseHelp.success(entity.getValue());
  36. }
  37. @RequestMapping(value = "/place", method = RequestMethod.PUT)
  38. @ApiOperation(value = "修改考点设置", httpMethod = "PUT")
  39. private Response<Boolean> placeEdit(@RequestBody @Validated JSONObject dto){
  40. Setting entity = settingService.getByKey(SettingKey.PLACE.key);
  41. entity.setValue(dto);
  42. settingService.edit(entity);
  43. return ResponseHelp.success(true);
  44. }
  45. @RequestMapping(value = "/place", method = RequestMethod.GET)
  46. @ApiOperation(value = "获取考点配置", httpMethod = "GET")
  47. private Response<JSONObject> placeGet(){
  48. Setting entity = settingService.getByKey(SettingKey.PLACE.key);
  49. return ResponseHelp.success(entity.getValue());
  50. }
  51. @RequestMapping(value = "/sentence", method = RequestMethod.PUT)
  52. @ApiOperation(value = "修改长难句设置", httpMethod = "PUT")
  53. private Response<Boolean> sentenceEdit(@RequestBody @Validated JSONObject dto){
  54. Setting entity = settingService.getByKey(SettingKey.SENTENCE.key);
  55. entity.setValue(dto);
  56. settingService.edit(entity);
  57. return ResponseHelp.success(true);
  58. }
  59. @RequestMapping(value = "/sentence", method = RequestMethod.GET)
  60. @ApiOperation(value = "获取长难句配置", httpMethod = "GET")
  61. private Response<JSONObject> sentenceGet(){
  62. Setting entity = settingService.getByKey(SettingKey.SENTENCE.key);
  63. return ResponseHelp.success(entity.getValue());
  64. }
  65. @RequestMapping(value = "/time", method = RequestMethod.PUT)
  66. @ApiOperation(value = "修改时间设置", httpMethod = "PUT")
  67. private Response<Boolean> timeEdit(@RequestBody @Validated JSONObject dto){
  68. Setting entity = settingService.getByKey(SettingKey.TIME.key);
  69. entity.setValue(dto);
  70. settingService.edit(entity);
  71. return ResponseHelp.success(true);
  72. }
  73. @RequestMapping(value = "/time", method = RequestMethod.GET)
  74. @ApiOperation(value = "获取时间配置", httpMethod = "GET")
  75. private Response<JSONObject> timeGet(){
  76. Setting entity = settingService.getByKey(SettingKey.TIME.key);
  77. return ResponseHelp.success(entity.getValue());
  78. }
  79. }