API数据表更新
This commit is contained in:
@@ -0,0 +1,18 @@
|
|||||||
|
package com.mini.capi.biz.controller;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author gaoxq
|
||||||
|
* @since 2025-08-29
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/biz/apiMenus")
|
||||||
|
public class ApiMenusController {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.mini.capi.biz.controller;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author gaoxq
|
||||||
|
* @since 2025-08-29
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/biz/apiModule")
|
||||||
|
public class ApiModuleController {
|
||||||
|
|
||||||
|
}
|
||||||
65
src/main/java/com/mini/capi/biz/domain/ApiMenus.java
Normal file
65
src/main/java/com/mini/capi/biz/domain/ApiMenus.java
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
package com.mini.capi.biz.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author gaoxq
|
||||||
|
* @since 2025-08-29
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@TableName("biz_api_menus")
|
||||||
|
public class ApiMenus implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@TableField("menu_id")
|
||||||
|
private String menuId;
|
||||||
|
|
||||||
|
@TableField("menu_name")
|
||||||
|
private String menuName;
|
||||||
|
|
||||||
|
@TableField("menu_code")
|
||||||
|
private String menuCode;
|
||||||
|
|
||||||
|
@TableField("c_icon")
|
||||||
|
private String cIcon;
|
||||||
|
|
||||||
|
@TableField("c_href")
|
||||||
|
private String cHref;
|
||||||
|
|
||||||
|
@TableField("module_code")
|
||||||
|
private String moduleCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 租户id
|
||||||
|
*/
|
||||||
|
@TableField("f_tenant_id")
|
||||||
|
private String fTenantId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流程id
|
||||||
|
*/
|
||||||
|
@TableField("f_flow_id")
|
||||||
|
private String fFlowId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流程任务主键
|
||||||
|
*/
|
||||||
|
@TableField("f_flow_task_id")
|
||||||
|
private String fFlowTaskId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流程任务状态
|
||||||
|
*/
|
||||||
|
@TableField("f_flow_state")
|
||||||
|
private Integer fFlowState;
|
||||||
|
}
|
||||||
62
src/main/java/com/mini/capi/biz/domain/ApiModule.java
Normal file
62
src/main/java/com/mini/capi/biz/domain/ApiModule.java
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
package com.mini.capi.biz.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author gaoxq
|
||||||
|
* @since 2025-08-29
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@TableName("biz_api_module")
|
||||||
|
public class ApiModule implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@TableField("module_id")
|
||||||
|
private String moduleId;
|
||||||
|
|
||||||
|
@TableField("module_name")
|
||||||
|
private String moduleName;
|
||||||
|
|
||||||
|
@TableField("module_code")
|
||||||
|
private String moduleCode;
|
||||||
|
|
||||||
|
@TableField("c_icon")
|
||||||
|
private String cIcon;
|
||||||
|
|
||||||
|
@TableField("c_href")
|
||||||
|
private String cHref;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 租户id
|
||||||
|
*/
|
||||||
|
@TableField("f_tenant_id")
|
||||||
|
private String fTenantId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流程id
|
||||||
|
*/
|
||||||
|
@TableField("f_flow_id")
|
||||||
|
private String fFlowId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流程任务主键
|
||||||
|
*/
|
||||||
|
@TableField("f_flow_task_id")
|
||||||
|
private String fFlowTaskId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流程任务状态
|
||||||
|
*/
|
||||||
|
@TableField("f_flow_state")
|
||||||
|
private Integer fFlowState;
|
||||||
|
}
|
||||||
16
src/main/java/com/mini/capi/biz/mapper/ApiMenusMapper.java
Normal file
16
src/main/java/com/mini/capi/biz/mapper/ApiMenusMapper.java
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package com.mini.capi.biz.mapper;
|
||||||
|
|
||||||
|
import com.mini.capi.biz.domain.ApiMenus;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author gaoxq
|
||||||
|
* @since 2025-08-29
|
||||||
|
*/
|
||||||
|
public interface ApiMenusMapper extends BaseMapper<ApiMenus> {
|
||||||
|
|
||||||
|
}
|
||||||
16
src/main/java/com/mini/capi/biz/mapper/ApiModuleMapper.java
Normal file
16
src/main/java/com/mini/capi/biz/mapper/ApiModuleMapper.java
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package com.mini.capi.biz.mapper;
|
||||||
|
|
||||||
|
import com.mini.capi.biz.domain.ApiModule;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author gaoxq
|
||||||
|
* @since 2025-08-29
|
||||||
|
*/
|
||||||
|
public interface ApiModuleMapper extends BaseMapper<ApiModule> {
|
||||||
|
|
||||||
|
}
|
||||||
16
src/main/java/com/mini/capi/biz/service/ApiMenusService.java
Normal file
16
src/main/java/com/mini/capi/biz/service/ApiMenusService.java
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package com.mini.capi.biz.service;
|
||||||
|
|
||||||
|
import com.mini.capi.biz.domain.ApiMenus;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author gaoxq
|
||||||
|
* @since 2025-08-29
|
||||||
|
*/
|
||||||
|
public interface ApiMenusService extends IService<ApiMenus> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.mini.capi.biz.service;
|
||||||
|
|
||||||
|
import com.mini.capi.biz.domain.ApiModule;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author gaoxq
|
||||||
|
* @since 2025-08-29
|
||||||
|
*/
|
||||||
|
public interface ApiModuleService extends IService<ApiModule> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.mini.capi.biz.service.impl;
|
||||||
|
|
||||||
|
import com.mini.capi.biz.domain.ApiMenus;
|
||||||
|
import com.mini.capi.biz.mapper.ApiMenusMapper;
|
||||||
|
import com.mini.capi.biz.service.ApiMenusService;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author gaoxq
|
||||||
|
* @since 2025-08-29
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ApiMenusServiceImpl extends ServiceImpl<ApiMenusMapper, ApiMenus> implements ApiMenusService {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.mini.capi.biz.service.impl;
|
||||||
|
|
||||||
|
import com.mini.capi.biz.domain.ApiModule;
|
||||||
|
import com.mini.capi.biz.mapper.ApiModuleMapper;
|
||||||
|
import com.mini.capi.biz.service.ApiModuleService;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author gaoxq
|
||||||
|
* @since 2025-08-29
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ApiModuleServiceImpl extends ServiceImpl<ApiModuleMapper, ApiModule> implements ApiModuleService {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -29,7 +29,7 @@ public class demo {
|
|||||||
.pathInfo(Collections.singletonMap(OutputFile.xml, System.getProperty("user.dir") + "/src/main/resources/mapper"));
|
.pathInfo(Collections.singletonMap(OutputFile.xml, System.getProperty("user.dir") + "/src/main/resources/mapper"));
|
||||||
})
|
})
|
||||||
.strategyConfig(builder -> {
|
.strategyConfig(builder -> {
|
||||||
builder.addInclude("biz_api_user")
|
builder.addInclude("biz_api_module,biz_api_menus")
|
||||||
.addTablePrefix("biz_")
|
.addTablePrefix("biz_")
|
||||||
.entityBuilder()
|
.entityBuilder()
|
||||||
.enableLombok()
|
.enableLombok()
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
package com.mini.capi.sys.controller;
|
package com.mini.capi.sys.controller;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.mini.capi.biz.domain.ApiMenus;
|
||||||
|
import com.mini.capi.biz.domain.ApiModule;
|
||||||
import com.mini.capi.biz.domain.ApiUser;
|
import com.mini.capi.biz.domain.ApiUser;
|
||||||
import com.mini.capi.biz.service.ApiUserService;
|
import com.mini.capi.biz.service.ApiUserService;
|
||||||
import com.mini.capi.model.auth.Result;
|
import com.mini.capi.model.auth.Result;
|
||||||
|
import com.mini.capi.sys.service.PortalService;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpSession;
|
import jakarta.servlet.http.HttpSession;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
|
||||||
@@ -24,6 +26,9 @@ public class LoginController {
|
|||||||
@Resource
|
@Resource
|
||||||
private ApiUserService userService;
|
private ApiUserService userService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PortalService portalService;
|
||||||
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class LoginRequest implements Serializable {
|
public static class LoginRequest implements Serializable {
|
||||||
@@ -63,4 +68,20 @@ public class LoginController {
|
|||||||
return Result.error("登录失败,请稍后重试");
|
return Result.error("登录失败,请稍后重试");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/modules")
|
||||||
|
public List<ApiModule> modules() {
|
||||||
|
return portalService.listModules();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/menus")
|
||||||
|
public List<ApiMenus> menus(@RequestParam String moduleCode) {
|
||||||
|
return portalService.listMenus(moduleCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/me")
|
||||||
|
public ApiUser me(HttpServletRequest request) {
|
||||||
|
return portalService.currentUser(request);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
95
src/main/java/com/mini/capi/sys/service/PortalService.java
Normal file
95
src/main/java/com/mini/capi/sys/service/PortalService.java
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
package com.mini.capi.sys.service;
|
||||||
|
|
||||||
|
import com.mini.capi.biz.domain.ApiMenus;
|
||||||
|
import com.mini.capi.biz.domain.ApiModule;
|
||||||
|
import com.mini.capi.biz.domain.ApiUser;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpSession;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class PortalService {
|
||||||
|
|
||||||
|
|
||||||
|
private final List<ApiModule> modules = Arrays.asList(
|
||||||
|
createModule("m1","API管理","API","fa-code","#api"),
|
||||||
|
createModule("m2","邮件管理","MAIL","fa-envelope","#mail"),
|
||||||
|
createModule("m3","数据管理","DATA","fa-database","#data"),
|
||||||
|
createModule("m4","系统管理","SYS","fa-cog","#system")
|
||||||
|
);
|
||||||
|
|
||||||
|
private final List<ApiMenus> menus = Arrays.asList(
|
||||||
|
// API
|
||||||
|
createMenu("m1-1","新增API","API_ADD","fa-plus-circle","#api/add","API"),
|
||||||
|
createMenu("m1-2","API列表","API_LIST","fa-list","#api/list","API"),
|
||||||
|
createMenu("m1-3","调用统计","API_STAT","fa-bar-chart","#api/stat","API"),
|
||||||
|
createMenu("m1-4","密钥管理","API_KEY","fa-key","#api/key","API"),
|
||||||
|
createMenu("m1-5","权限设置","API_PERM","fa-shield","#api/perm","API"),
|
||||||
|
createMenu("m1-6","调用记录","API_LOG","fa-history","#api/log","API"),
|
||||||
|
|
||||||
|
// MAIL
|
||||||
|
createMenu("m2-1","发送邮件","MAIL_SEND","fa-pencil","#mail/send","MAIL"),
|
||||||
|
createMenu("m2-2","收件箱","MAIL_INBOX","fa-inbox","#mail/inbox","MAIL"),
|
||||||
|
createMenu("m2-3","已发送","MAIL_SENT","fa-paper-plane","#mail/sent","MAIL"),
|
||||||
|
createMenu("m2-4","垃圾箱","MAIL_TRASH","fa-trash","#mail/trash","MAIL"),
|
||||||
|
createMenu("m2-5","星标邮件","MAIL_STAR","fa-star","#mail/star","MAIL"),
|
||||||
|
createMenu("m2-6","邮件设置","MAIL_SET","fa-cog","#mail/set","MAIL"),
|
||||||
|
|
||||||
|
// DATA
|
||||||
|
createMenu("m3-1","数据列表","DATA_LIST","fa-table","#data/list","DATA"),
|
||||||
|
createMenu("m3-2","数据筛选","DATA_FILTER","fa-filter","#data/filter","DATA"),
|
||||||
|
createMenu("m3-3","数据导出","DATA_EXPORT","fa-download","#data/export","DATA"),
|
||||||
|
createMenu("m3-4","数据导入","DATA_IMPORT","fa-upload","#data/import","DATA"),
|
||||||
|
createMenu("m3-5","数据分析","DATA_ANALYZE","fa-bar-chart","#data/analyze","DATA"),
|
||||||
|
createMenu("m3-6","操作记录","DATA_LOG","fa-history","#data/log","DATA"),
|
||||||
|
|
||||||
|
// SYS
|
||||||
|
createMenu("m4-1","用户管理","SYS_USER","fa-user","#sys/user","SYS"),
|
||||||
|
createMenu("m4-2","角色权限","SYS_ROLE","fa-users","#sys/role","SYS"),
|
||||||
|
createMenu("m4-3","系统设置","SYS_SET","fa-sliders","#sys/set","SYS"),
|
||||||
|
createMenu("m4-4","插件管理","SYS_PLUGIN","fa-plug","#sys/plugin","SYS"),
|
||||||
|
createMenu("m4-5","安全中心","SYS_SECURE","fa-shield","#sys/secure","SYS"),
|
||||||
|
createMenu("m4-6","关于系统","SYS_ABOUT","fa-info-circle","#sys/about","SYS")
|
||||||
|
);
|
||||||
|
|
||||||
|
public List<ApiModule> listModules() {
|
||||||
|
return modules;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ApiMenus> listMenus(String moduleCode) {
|
||||||
|
return menus.stream()
|
||||||
|
.filter(m -> m.getModuleCode().equalsIgnoreCase(moduleCode))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiUser currentUser(HttpServletRequest request) {
|
||||||
|
HttpSession session = request.getSession();
|
||||||
|
return (ApiUser) session.getAttribute("Authorization");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- helper ---------- */
|
||||||
|
private ApiModule createModule(String id, String name, String code, String icon, String href) {
|
||||||
|
ApiModule m = new ApiModule();
|
||||||
|
m.setModuleId(id);
|
||||||
|
m.setModuleName(name);
|
||||||
|
m.setModuleCode(code);
|
||||||
|
m.setCIcon(icon);
|
||||||
|
m.setCHref(href);
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApiMenus createMenu(String id, String name, String code, String icon, String href, String moduleCode) {
|
||||||
|
ApiMenus m = new ApiMenus();
|
||||||
|
m.setMenuId(id);
|
||||||
|
m.setMenuName(name);
|
||||||
|
m.setMenuCode(code);
|
||||||
|
m.setCIcon(icon);
|
||||||
|
m.setCHref(href);
|
||||||
|
m.setModuleCode(moduleCode);
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
}
|
||||||
24
src/main/resources/mapper/ApiMenusMapper.xml
Normal file
24
src/main/resources/mapper/ApiMenusMapper.xml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.mini.capi.biz.mapper.ApiMenusMapper">
|
||||||
|
|
||||||
|
<!-- 通用查询映射结果 -->
|
||||||
|
<resultMap id="BaseResultMap" type="com.mini.capi.biz.domain.ApiMenus">
|
||||||
|
<result column="menu_id" property="menuId" />
|
||||||
|
<result column="menu_name" property="menuName" />
|
||||||
|
<result column="menu_code" property="menuCode" />
|
||||||
|
<result column="c_icon" property="cIcon" />
|
||||||
|
<result column="c_href" property="cHref" />
|
||||||
|
<result column="module_code" property="moduleCode" />
|
||||||
|
<result column="f_tenant_id" property="fTenantId" />
|
||||||
|
<result column="f_flow_id" property="fFlowId" />
|
||||||
|
<result column="f_flow_task_id" property="fFlowTaskId" />
|
||||||
|
<result column="f_flow_state" property="fFlowState" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<!-- 通用查询结果列 -->
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
menu_id, menu_name, menu_code, c_icon, c_href, module_code, f_tenant_id, f_flow_id, f_flow_task_id, f_flow_state
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
23
src/main/resources/mapper/ApiModuleMapper.xml
Normal file
23
src/main/resources/mapper/ApiModuleMapper.xml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.mini.capi.biz.mapper.ApiModuleMapper">
|
||||||
|
|
||||||
|
<!-- 通用查询映射结果 -->
|
||||||
|
<resultMap id="BaseResultMap" type="com.mini.capi.biz.domain.ApiModule">
|
||||||
|
<result column="module_id" property="moduleId" />
|
||||||
|
<result column="module_name" property="moduleName" />
|
||||||
|
<result column="module_code" property="moduleCode" />
|
||||||
|
<result column="c_icon" property="cIcon" />
|
||||||
|
<result column="c_href" property="cHref" />
|
||||||
|
<result column="f_tenant_id" property="fTenantId" />
|
||||||
|
<result column="f_flow_id" property="fFlowId" />
|
||||||
|
<result column="f_flow_task_id" property="fFlowTaskId" />
|
||||||
|
<result column="f_flow_state" property="fFlowState" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<!-- 通用查询结果列 -->
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
module_id, module_name, module_code, c_icon, c_href, f_tenant_id, f_flow_id, f_flow_task_id, f_flow_state
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -1,10 +1,408 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="zh-CN">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Title</title>
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
</head>
|
<title>智能化管理系统</title>
|
||||||
<body>
|
<!-- 引入Tailwind CSS -->
|
||||||
|
<script src="https://cdn.tailwindcss.com"></script>
|
||||||
|
<!-- 引入Font Awesome图标库 -->
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
|
||||||
|
|
||||||
|
<!-- 配置Tailwind自定义颜色 -->
|
||||||
|
<script>
|
||||||
|
tailwind.config = {
|
||||||
|
theme: {
|
||||||
|
extend: {
|
||||||
|
colors: {
|
||||||
|
primary: '#165DFF',
|
||||||
|
secondary: '#0FC6C2',
|
||||||
|
neutral: '#F5F7FA',
|
||||||
|
dark: '#1D2129',
|
||||||
|
light: '#F2F3F5'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style type="text/tailwindcss">
|
||||||
|
@layer utilities {
|
||||||
|
.content-auto {
|
||||||
|
content-visibility: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-hover {
|
||||||
|
@apply transition-all duration-300 hover:shadow-lg hover:-translate-y-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-item {
|
||||||
|
@apply flex items-center gap-2 px-4 py-3 rounded-lg cursor-pointer transition-all duration-200;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-item-active {
|
||||||
|
@apply bg-primary/10 text-primary font-medium;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-item-inactive {
|
||||||
|
@apply hover:bg-light;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-enter {
|
||||||
|
animation: fadeIn 0.3s ease-out forwards;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-exit {
|
||||||
|
animation: fadeOut 0.3s ease-in forwards;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes fadeIn {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(-10px) scale(0.98);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateY(0) scale(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@keyframes fadeOut {
|
||||||
|
from {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateY(0) scale(1);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(-10px) scale(0.98);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body class="bg-neutral min-h-screen font-sans text-dark overflow-x-hidden">
|
||||||
|
<!-- 顶部导航栏 - 优化Flex布局,确保Logo左、用户右、菜单居中 -->
|
||||||
|
<!-- 顶部导航栏 -->
|
||||||
|
<header class="bg-white shadow-sm sticky top-0 z-40 h-16">
|
||||||
|
<div class="flex items-center h-full px-6">
|
||||||
|
<!-- 1. 系统 Logo + 名称:最左侧固定 -->
|
||||||
|
<div class="flex items-center space-x-3 flex-shrink-0">
|
||||||
|
<div class="w-10 h-10 rounded-lg bg-primary flex items-center justify-center">
|
||||||
|
<i class="fa fa-cubes text-white text-xl"></i>
|
||||||
|
</div>
|
||||||
|
<h1 class="text-xl font-bold whitespace-nowrap">智能管理平台</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 2. 模块导航:中间自适应 -->
|
||||||
|
<nav class="flex-1 flex justify-center items-center space-x-1"
|
||||||
|
id="moduleContainer">
|
||||||
|
<!-- 动态加载的模块 -->
|
||||||
|
<div class="menu-item menu-item-inactive" id="loadingModules">
|
||||||
|
<i class="fa fa-spinner fa-spin text-lg"></i>
|
||||||
|
<span>加载模块中...</span>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<!-- 3. 用户信息:最右侧固定 -->
|
||||||
|
<div class="relative flex-shrink-0" id="adminContainer">
|
||||||
|
<div class="menu-item menu-item-inactive flex items-center cursor-pointer">
|
||||||
|
<i class="fa fa-user-circle text-xl"></i>
|
||||||
|
<span class="ml-2">加载用户中...</span>
|
||||||
|
<i class="fa fa-angle-down ml-1"></i>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 下拉菜单内容 -->
|
||||||
|
<div class="absolute right-0 mt-2 w-48 bg-white rounded-lg shadow-lg py-2 hidden z-50 border border-gray-100"
|
||||||
|
id="adminMenu">
|
||||||
|
<a href="#"
|
||||||
|
class="flex items-center gap-2 px-4 py-2 text-sm hover:bg-light transition-colors duration-200">
|
||||||
|
<i class="fa fa-sign-out text-gray-500"></i>
|
||||||
|
<span>退出系统</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<!-- 主内容区 - 保持不变 -->
|
||||||
|
<main class="container mx-auto px-6 py-8">
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<!-- 弹窗背景遮罩 - 保持不变 -->
|
||||||
|
<div id="modalOverlay"
|
||||||
|
class="fixed inset-0 bg-black/50 backdrop-blur-sm z-50 hidden opacity-0 transition-opacity duration-300"></div>
|
||||||
|
|
||||||
|
<!-- 动态菜单弹窗 - 保持不变 -->
|
||||||
|
<div id="dynamicModal" class="fixed w-[600px] bg-white rounded-xl shadow-xl z-50 hidden">
|
||||||
|
<div class="p-6 border-b">
|
||||||
|
<div class="flex justify-between items-center">
|
||||||
|
<h3 class="text-lg font-semibold flex items-center" id="modalTitle">
|
||||||
|
<i class="modal-icon fa text-primary mr-2"></i>
|
||||||
|
<span id="modalModuleName"></span>
|
||||||
|
</h3>
|
||||||
|
<button class="modal-close text-gray-400 hover:text-gray-600">
|
||||||
|
<i class="fa fa-times"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="p-6" id="menuContainer">
|
||||||
|
<!-- 菜单将在这里动态加载 -->
|
||||||
|
<div class="flex justify-center items-center h-40">
|
||||||
|
<i class="fa fa-spinner fa-spin text-2xl text-gray-400"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// 模拟API请求函数 - 保持不变
|
||||||
|
const api = {
|
||||||
|
getModules: () =>
|
||||||
|
fetch('Sys/login/modules').then(res => res.json()),
|
||||||
|
|
||||||
|
getMenusByModuleCode: (moduleCode) =>
|
||||||
|
fetch(`Sys/login/menus?moduleCode=${moduleCode}`).then(res => res.json()),
|
||||||
|
|
||||||
|
getCurrentUser: () =>
|
||||||
|
fetch('Sys/login/me').then(res => res.json())
|
||||||
|
};
|
||||||
|
|
||||||
|
// 页面逻辑 - 仅优化管理员区域渲染时的对齐方式
|
||||||
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
const moduleContainer = document.getElementById('moduleContainer');
|
||||||
|
const adminContainer = document.getElementById('adminContainer');
|
||||||
|
const menuContainer = document.getElementById('menuContainer');
|
||||||
|
const modalTitle = document.getElementById('modalTitle');
|
||||||
|
const modalModuleName = document.getElementById('modalModuleName');
|
||||||
|
const modalIcon = document.querySelector('.modal-icon');
|
||||||
|
const dynamicModal = document.getElementById('dynamicModal');
|
||||||
|
const modalOverlay = document.getElementById('modalOverlay');
|
||||||
|
const modalCloseButtons = document.querySelectorAll('.modal-close');
|
||||||
|
|
||||||
|
// 加载模块列表 - 保持不变
|
||||||
|
loadModules();
|
||||||
|
|
||||||
|
// 加载当前用户信息 - 优化用户区域对齐(右对齐)
|
||||||
|
loadCurrentUser();
|
||||||
|
|
||||||
|
async function loadModules() {
|
||||||
|
try {
|
||||||
|
const modules = await api.getModules();
|
||||||
|
moduleContainer.innerHTML = '';
|
||||||
|
|
||||||
|
modules.forEach(module => {
|
||||||
|
const moduleElement = document.createElement('div');
|
||||||
|
moduleElement.className = 'menu-item menu-item-inactive';
|
||||||
|
moduleElement.setAttribute('data-module-code', module.moduleCode);
|
||||||
|
moduleElement.setAttribute('data-module-name', module.moduleName);
|
||||||
|
moduleElement.setAttribute('data-module-icon', module.cicon);
|
||||||
|
|
||||||
|
moduleElement.innerHTML = `
|
||||||
|
<i class="fa ${module.cicon} text-lg"></i>
|
||||||
|
<span>${module.moduleName}</span>
|
||||||
|
`;
|
||||||
|
|
||||||
|
moduleElement.addEventListener('click', function () {
|
||||||
|
const moduleCode = this.getAttribute('data-module-code');
|
||||||
|
const moduleName = this.getAttribute('data-module-name');
|
||||||
|
const moduleIcon = this.getAttribute('data-module-icon');
|
||||||
|
showModuleMenus(moduleCode, moduleName, moduleIcon, this);
|
||||||
|
});
|
||||||
|
|
||||||
|
moduleContainer.appendChild(moduleElement);
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
moduleContainer.innerHTML = `
|
||||||
|
<div class="menu-item menu-item-inactive text-red-500">
|
||||||
|
<i class="fa fa-exclamation-circle text-lg"></i>
|
||||||
|
<span>模块加载失败</span>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
console.error('加载模块失败:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 优化点:管理员区域渲染时保持右对齐
|
||||||
|
async function loadCurrentUser() {
|
||||||
|
try {
|
||||||
|
const user = await api.getCurrentUser();
|
||||||
|
|
||||||
|
// 关键优化:用户信息区域采用justify-end右对齐
|
||||||
|
adminContainer.innerHTML = `
|
||||||
|
<div class="menu-item menu-item-inactive flex items-center justify-end cursor-pointer" id="adminUser">
|
||||||
|
<i class="fa fa-user-circle text-xl"></i>
|
||||||
|
<span class="ml-2">${user.uname}</span>
|
||||||
|
<i class="fa fa-angle-down ml-1"></i>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="absolute right-0 mt-2 w-48 bg-white rounded-lg shadow-lg py-2 hidden z-50 border border-gray-100" id="adminMenu">
|
||||||
|
<a href="#" class="flex items-center gap-2 px-4 py-2 text-sm hover:bg-light transition-colors duration-200">
|
||||||
|
<i class="fa fa-sign-out text-gray-300"></i>
|
||||||
|
<span>退出系统</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
// 重新绑定管理员下拉菜单事件
|
||||||
|
const adminUser = document.getElementById('adminUser');
|
||||||
|
const adminMenu = document.getElementById('adminMenu');
|
||||||
|
|
||||||
|
adminUser.addEventListener('click', function (e) {
|
||||||
|
e.stopPropagation();
|
||||||
|
adminMenu.classList.toggle('hidden');
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
adminContainer.innerHTML = `
|
||||||
|
<div class="menu-item menu-item-inactive flex items-center justify-end text-red-500">
|
||||||
|
<i class="fa fa-user-circle text-xl"></i>
|
||||||
|
<span class="ml-2">用户信息加载失败</span>
|
||||||
|
<i class="fa fa-angle-down ml-1"></i>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
console.error('加载用户信息失败:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 显示模块菜单 - 保持不变
|
||||||
|
async function showModuleMenus(moduleCode, moduleName, moduleIcon, menuItemElement) {
|
||||||
|
try {
|
||||||
|
modalModuleName.textContent = `${moduleName}菜单`;
|
||||||
|
modalIcon.className = `modal-icon fa ${moduleIcon} text-primary mr-2`;
|
||||||
|
|
||||||
|
menuContainer.innerHTML = `
|
||||||
|
<div class="flex justify-center items-center h-40">
|
||||||
|
<i class="fa fa-spinner fa-spin text-2xl text-gray-400"></i>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
const menus = await api.getMenusByModuleCode(moduleCode);
|
||||||
|
|
||||||
|
if (menus.length > 0) {
|
||||||
|
let menuHtml = '<div class="grid grid-cols-3 gap-4">';
|
||||||
|
|
||||||
|
menus.forEach(menu => {
|
||||||
|
menuHtml += `
|
||||||
|
<button class="flex flex-col items-center justify-center p-4 border border-gray-100 rounded-lg hover:border-primary hover:bg-primary/5 transition-colors"
|
||||||
|
onclick="window.location.href='${menu.chref}'">
|
||||||
|
<i class="fa ${menu.cicon} text-primary text-2xl mb-2"></i>
|
||||||
|
<span>${menu.menuName}</span>
|
||||||
|
</button>
|
||||||
|
`;
|
||||||
|
});
|
||||||
|
|
||||||
|
menuHtml += '</div>';
|
||||||
|
menuContainer.innerHTML = menuHtml;
|
||||||
|
} else {
|
||||||
|
menuContainer.innerHTML = `
|
||||||
|
<div class="flex flex-col justify-center items-center h-40 text-gray-500">
|
||||||
|
<i class="fa fa-folder-open-o text-3xl mb-2"></i>
|
||||||
|
<p>该模块暂无菜单</p>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
document.querySelectorAll('.menu-item').forEach(item => {
|
||||||
|
item.classList.remove('menu-item-active');
|
||||||
|
item.classList.add('menu-item-inactive');
|
||||||
|
});
|
||||||
|
menuItemElement.classList.remove('menu-item-inactive');
|
||||||
|
menuItemElement.classList.add('menu-item-active');
|
||||||
|
|
||||||
|
const rect = menuItemElement.getBoundingClientRect();
|
||||||
|
const windowWidth = window.innerWidth;
|
||||||
|
|
||||||
|
let leftPos = rect.left + window.scrollX;
|
||||||
|
if (leftPos + 600 > windowWidth) {
|
||||||
|
leftPos = windowWidth - 620;
|
||||||
|
}
|
||||||
|
|
||||||
|
dynamicModal.style.top = (rect.bottom + window.scrollY + 10) + 'px';
|
||||||
|
dynamicModal.style.left = leftPos + 'px';
|
||||||
|
|
||||||
|
dynamicModal.classList.remove('hidden');
|
||||||
|
dynamicModal.classList.add('modal-enter');
|
||||||
|
modalOverlay.classList.remove('hidden');
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
modalOverlay.style.opacity = '1';
|
||||||
|
}, 10);
|
||||||
|
|
||||||
|
document.body.style.overflow = 'hidden';
|
||||||
|
} catch (error) {
|
||||||
|
menuContainer.innerHTML = `
|
||||||
|
<div class="flex flex-col justify-center items-center h-40 text-red-500">
|
||||||
|
<i class="fa fa-exclamation-circle text-3xl mb-2"></i>
|
||||||
|
<p>菜单加载失败</p>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
console.error('加载菜单失败:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 关闭弹窗 - 保持不变
|
||||||
|
function closeModal() {
|
||||||
|
const activeModal = document.querySelector('.modal-enter');
|
||||||
|
if (activeModal) {
|
||||||
|
activeModal.classList.remove('modal-enter');
|
||||||
|
activeModal.classList.add('modal-exit');
|
||||||
|
|
||||||
|
modalOverlay.style.opacity = '0';
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
activeModal.classList.add('hidden');
|
||||||
|
activeModal.classList.remove('modal-exit');
|
||||||
|
modalOverlay.classList.add('hidden');
|
||||||
|
document.body.style.overflow = '';
|
||||||
|
|
||||||
|
document.querySelectorAll('.menu-item').forEach(menu => {
|
||||||
|
menu.classList.remove('menu-item-active');
|
||||||
|
menu.classList.add('menu-item-inactive');
|
||||||
|
});
|
||||||
|
}, 300);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 弹窗关闭事件 - 保持不变
|
||||||
|
modalCloseButtons.forEach(button => {
|
||||||
|
button.addEventListener('click', closeModal);
|
||||||
|
});
|
||||||
|
|
||||||
|
modalOverlay.addEventListener('click', closeModal);
|
||||||
|
|
||||||
|
document.addEventListener('keydown', function (e) {
|
||||||
|
if (e.key === 'Escape') {
|
||||||
|
closeModal();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 下拉菜单关闭事件 - 保持不变
|
||||||
|
document.addEventListener('click', function () {
|
||||||
|
const adminMenu = document.getElementById('adminMenu');
|
||||||
|
if (adminMenu) {
|
||||||
|
adminMenu.classList.add('hidden');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 窗口 resize 事件 - 保持不变
|
||||||
|
window.addEventListener('resize', function () {
|
||||||
|
const activeModal = document.querySelector('.modal-enter');
|
||||||
|
if (activeModal) {
|
||||||
|
const activeMenuItem = document.querySelector('.menu-item-active');
|
||||||
|
if (activeMenuItem) {
|
||||||
|
const rect = activeMenuItem.getBoundingClientRect();
|
||||||
|
const windowWidth = window.innerWidth;
|
||||||
|
|
||||||
|
let leftPos = rect.left + window.scrollX;
|
||||||
|
if (leftPos + 600 > windowWidth) {
|
||||||
|
leftPos = windowWidth - 620;
|
||||||
|
}
|
||||||
|
|
||||||
|
activeModal.style.top = (rect.bottom + window.scrollY + 10) + 'px';
|
||||||
|
activeModal.style.left = leftPos + 'px';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user