|
@@ -0,0 +1,76 @@
|
|
|
+package cn.com.qmth.examcloud.core.basic.api.provider;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import cn.com.qmth.examcloud.commons.base.util.DateUtil;
|
|
|
+import cn.com.qmth.examcloud.commons.base.util.DateUtil.DatePatterns;
|
|
|
+import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.SysConfigCloudService;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.request.GetSysConfigReq;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.request.SetSysConfigReq;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.response.GetSysConfigResp;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.response.SetSysConfigResp;
|
|
|
+import cn.com.qmth.examcloud.core.basic.service.SysConfigService;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 类注释
|
|
|
+ *
|
|
|
+ * @author WANGWEI
|
|
|
+ * @date 2018年12月3日
|
|
|
+ * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
|
|
|
+ */
|
|
|
+@Transactional
|
|
|
+@RestController
|
|
|
+@RequestMapping("${$rmp.cloud.basic}" + "sysConfig")
|
|
|
+public class SysConfigCloudServiceProvider extends ControllerSupport
|
|
|
+ implements
|
|
|
+ SysConfigCloudService {
|
|
|
+
|
|
|
+ private static final long serialVersionUID = 2299432976949405946L;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ SysConfigService sysConfigService;
|
|
|
+
|
|
|
+ @ApiOperation(value = "设置配置")
|
|
|
+ @PostMapping("setSysConfig")
|
|
|
+ @Override
|
|
|
+ public SetSysConfigResp setSysConfig(@RequestBody SetSysConfigReq req) {
|
|
|
+ String key = req.getKey();
|
|
|
+ String value = req.getValue();
|
|
|
+ sysConfigService.set(key, value);
|
|
|
+
|
|
|
+ SetSysConfigResp resp = new SetSysConfigResp();
|
|
|
+ resp.setKey(key);
|
|
|
+ resp.setValue(value);
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "获取配置")
|
|
|
+ @PostMapping("getSysConfig")
|
|
|
+ @Override
|
|
|
+ public GetSysConfigResp getSysConfig(@RequestBody GetSysConfigReq req) {
|
|
|
+ String key = req.getKey();
|
|
|
+ Object value = sysConfigService.get(key);
|
|
|
+
|
|
|
+ String strValue = null;
|
|
|
+ if (value instanceof Date) {
|
|
|
+ strValue = DateUtil.format((Date) value, DatePatterns.ISO);
|
|
|
+ } else {
|
|
|
+ strValue = String.valueOf(value);
|
|
|
+ }
|
|
|
+
|
|
|
+ GetSysConfigResp resp = new GetSysConfigResp();
|
|
|
+ resp.setKey(key);
|
|
|
+ resp.setValue(strValue);
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|