value
2024-04-30 ce10da906c58596fce43bffa6a6d177268ca177b
framework/src/main/java/com/yuanchu/mom/common/AllController.java
@@ -1,8 +1,10 @@
package com.yuanchu.mom.common;
import com.yuanchu.mom.annotation.ValueAuth;
import com.yuanchu.mom.annotation.ValueClassify;
import com.yuanchu.mom.mapper.AuthMapper;
import io.swagger.annotations.ApiOperation;
import org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration;
import org.springframework.stereotype.Component;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.method.HandlerMethod;
@@ -11,6 +13,7 @@
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.lang.reflect.Method;
import java.util.Map;
@Component
@@ -28,31 +31,39 @@
        for (HandlerMethod value : methodMap.values()) {
            ApiOperation annotation = value.getMethodAnnotation(ApiOperation.class);
            ValueAuth valueAuth = value.getMethodAnnotation(ValueAuth.class);
            if (valueAuth==null){
                if (annotation != null) {
            ValueClassify valueClassify = value.getMethodAnnotation(ValueClassify.class);
            if (valueAuth == null) {
                if (valueClassify !=null) {
                    String type = valueClassify.value();
                    String remark = annotation.value();
                    String type = "修改";
                    if (remark.contains("获取")||remark.contains("查询")){
                        type = "查询";
                    } else if(remark.contains("删除")){
                        type = "删除";
                    } else if(remark.contains("添加")||remark.contains("新增")||remark.contains("认领")){
                        type = "添加";
                    } else if(remark.contains("导入")){
                        type = "导入";
                    } else if(remark.contains("导出")){
                        type = "导出";
                    }
                    try {
                        authMapper.insertPower(value.getMethod().getName(), remark, type);
                    }catch (Exception e){
                        System.err.println(value.getMethod());
                    authMapper.insertPower(value.getMethod().getName(),remark,type);
                }else{
                    if (annotation != null) {
                        String remark = annotation.value();
                        String type = "修改";
                        if (remark.contains("获取") || remark.contains("查询")) {
                            type = "查询";
                        } else if (remark.contains("删除")) {
                            type = "删除";
                        } else if (remark.contains("添加") || remark.contains("新增") || remark.contains("认领")) {
                            type = "添加";
                        } else if (remark.contains("导入")) {
                            type = "导入";
                        } else if (remark.contains("导出")) {
                            type = "导出";
                        }
                        try {
                            authMapper.insertPower(value.getMethod().getName(), remark, type);
                        } catch (Exception e) {
                            System.err.println(value.getMethod());
                            e.printStackTrace();
                        }
                    }
                }
                }
            }
            System.out.println("********************权限菜单完成********************");
        }
        System.out.println("********************权限菜单完成********************");
    }
    @PostConstruct
    public void pingStart() {