Commit 9f339b91 authored by Quxl's avatar Quxl

x

parent 1cd645d1
package com.egolm.film.api.web.admin;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
......@@ -11,6 +12,10 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
import com.egolm.common.StringUtil;
import com.egolm.common.Util;
......@@ -19,6 +24,7 @@ import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.film.api.service.AdminTokenService;
import com.egolm.film.api.service.ReviewService;
import com.egolm.film.bean.Fc_admin;
import com.egolm.film.bean.Fc_logs_ext;
import com.egolm.film.bean.Fc_member_film;
import com.egolm.film.bean.Fc_member_film_enroll;
import com.egolm.film.config.XRException;
......@@ -42,6 +48,19 @@ public class WebUtilController {
@Autowired
AdminTokenService tokenService;
@Autowired
private RequestMappingHandlerMapping requestMappingHandlerMapping;
@ResponseBody
@PostMapping("verifyAuth")
@ApiOperation("校验权限")
public void verifyAuth() {
Fc_admin admin = (Fc_admin)tokenService.getTokenObj();
if(!admin.getUsername().equals("admin")) {
throw new XRException("权限错误");
}
}
@ResponseBody
@PostMapping("tryNextRound")
@ApiOperation("尝试进入下一轮评选")
......@@ -129,10 +148,32 @@ public class WebUtilController {
return Rjx.jsonOk();
}
private void verifyAuth() {
Fc_admin admin = (Fc_admin)tokenService.getTokenObj();
if(!admin.getUsername().equals("admin")) {
throw new XRException("权限错误");
}
@ResponseBody
@PostMapping("initLogExt")
@ApiOperation("初始化日志扩展表")
public Object initLogExt() {
this.verifyAuth();
List<Object> list = new ArrayList<Object>();
Map<RequestMappingInfo, HandlerMethod> map = requestMappingHandlerMapping.getHandlerMethods();
for (Map.Entry<RequestMappingInfo, HandlerMethod> m : map.entrySet()) {
RequestMappingInfo info = m.getKey();
HandlerMethod handlerMethod = m.getValue();
PatternsRequestCondition p = info.getPatternsCondition();
Method method = handlerMethod.getMethod();
if(method.isAnnotationPresent(ApiOperation.class)) {
ApiOperation apiOperation = method.getAnnotation(ApiOperation.class);
String value = apiOperation.value();
for (String url : p.getPatterns()) {
Fc_logs_ext logsExt = new Fc_logs_ext();
logsExt.setExt(value);
logsExt.setPath(url);
list.add(logsExt);
}
}
}
jdbcTemplate.executeUpdate("delete from fc_logs_ext");
jdbcTemplate.batchSave(list);
return Rjx.jsonOk();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment