|
|
@@ -1,18 +1,19 @@
|
|
|
package com.miekir.shibei.controller.api;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
-import com.miekir.shibei.bean.Feedback;
|
|
|
-import com.miekir.shibei.bean.ResponseResult;
|
|
|
-import com.miekir.shibei.bean.ResultCode;
|
|
|
-import com.miekir.shibei.bean.UpgradeBean;
|
|
|
+import com.miekir.shibei.bean.*;
|
|
|
import com.miekir.shibei.repository.FeedbackRepository;
|
|
|
+import com.miekir.shibei.repository.SystemRepository;
|
|
|
import com.miekir.shibei.repository.UpgradeRepository;
|
|
|
+import com.miekir.shibei.repository.UserRepository;
|
|
|
+import com.miekir.shibei.tool.RequestTool;
|
|
|
import com.miekir.shibei.tool.email.EmailTool;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.web.bind.annotation.RequestHeader;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
@@ -30,6 +31,12 @@ public class SystemController {
|
|
|
@Autowired
|
|
|
UpgradeRepository upgradeRepository;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private UserRepository userRepository;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SystemRepository systemRepository;
|
|
|
+
|
|
|
/**
|
|
|
* 意见反馈
|
|
|
*/
|
|
|
@@ -83,6 +90,44 @@ public class SystemController {
|
|
|
return entity;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询系统设置
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/api/getSystemConfig", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
|
|
|
+ @ResponseBody
|
|
|
+ public String getSystemConfig() {
|
|
|
+ ResponseResult<SystemBean> responseResult = new ResponseResult<SystemBean>();
|
|
|
+ SystemBean systemBean = systemRepository.findSystemBean();
|
|
|
+ responseResult.setContent(systemBean);
|
|
|
+ responseResult.setCode(ResultCode.SUCCESS);
|
|
|
+ responseResult.setMessage("获取成功");
|
|
|
+ return JSON.toJSONString(responseResult);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置API是否为会员专属
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/api/setApiConfig", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
|
|
|
+ @ResponseBody
|
|
|
+ public String setApiConfig(@RequestHeader HttpHeaders header, boolean isApiVipOnly) {
|
|
|
+ ResponseResult<String> responseResult = new ResponseResult<String>();
|
|
|
+ responseResult.setMessage("设置失败");
|
|
|
+ if (!RequestTool.isRequestAdminValid(header, userRepository)) {
|
|
|
+ return JSON.toJSONString(responseResult);
|
|
|
+ }
|
|
|
+
|
|
|
+ SystemBean systemBean = systemRepository.findSystemBean();
|
|
|
+ if (systemBean == null) {
|
|
|
+ systemBean = new SystemBean();
|
|
|
+ }
|
|
|
+ systemBean.isVipLimit = isApiVipOnly;
|
|
|
+ systemRepository.save(systemBean);
|
|
|
+
|
|
|
+ responseResult.setCode(ResultCode.SUCCESS);
|
|
|
+ responseResult.setMessage("设置成功");
|
|
|
+ return JSON.toJSONString(responseResult);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 查询版本更新信息
|
|
|
*/
|