modifyPhone;
40 | }
41 |
--------------------------------------------------------------------------------
/edu-api-admin/src/main/java/com/langyastudio/edu/admin/common/conf/PmsConf.java:
--------------------------------------------------------------------------------
1 | package com.langyastudio.edu.admin.common.conf;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 | import org.springframework.boot.context.properties.ConfigurationProperties;
7 |
8 | import java.io.Serializable;
9 |
10 | /**
11 | * 资源配置
12 | *
13 | * @author jiangjiaxiong
14 | */
15 | @Data
16 | @AllArgsConstructor
17 | @NoArgsConstructor
18 | @ConfigurationProperties(prefix = "langyastudio.disk.pms")
19 | public class PmsConf implements Serializable
20 | {
21 | /**
22 | * 根目录
23 | */
24 | private String root;
25 | /**
26 | * windows 根目录
27 | */
28 | private String winRoot;
29 |
30 | /**
31 | * 文件分片合成目录,需要注意win与linux的切换
32 | */
33 | private String rootFile;
34 | /**
35 | * 文件转码目录,需要注意win与linux的切换
36 | */
37 | private String rootMts;
38 | /**
39 | * 文件分片上传临时目录,需要注意win与linux的切换
40 | */
41 | private String rootTmp;
42 | /**
43 | * 可直接浏览的最大图片大小
44 | */
45 | private Long browseImgMaxSize;
46 | /**
47 | * 可转码的最大图片大小
48 | */
49 | private Long cvtImgMaxSize;
50 | }
51 |
--------------------------------------------------------------------------------
/edu-api-admin/src/main/java/com/langyastudio/edu/admin/common/data/Define.java:
--------------------------------------------------------------------------------
1 | package com.langyastudio.edu.admin.common.data;
2 |
3 | import com.langyastudio.edu.common.data.BasDefine;
4 |
5 | /**
6 | * 常量与配置文件
7 | *
8 | * 注意:表字段的常量值定义到ORM
9 | */
10 | public class Define extends BasDefine
11 | {
12 | /*-------------------------------------------------------------------------------------------------------------- */
13 | // 常用常量定义
14 | /*-------------------------------------------------------------------------------------------------------------- */
15 | public final static Integer SUCESSS = 1;
16 |
17 | //是 or 否
18 | public final static String YES = "1";
19 | public final static String NO = "2";
20 | public final static Integer YESI = 1;
21 | public final static Integer NOI = 2;
22 |
23 | //校验码
24 | public final static String VERITY_REGISTER = "1";
25 | public final static String VERITY_MODIFY = "2";
26 | public final static String VERITY_FINDPWD = "3";
27 | public final static String VERITY_LOGIN = "4";
28 |
29 | //直播类型
30 | public final static String LIVE_NOW = "1";
31 | public final static String LIVE_WILL = "2";
32 | public final static String LIVE_OVER = "3";
33 | public final static String LIVE_ALL = "4";
34 |
35 | //默认分页的起始位置
36 | public final static Integer PAGE_OFFSET = 0;
37 | //默认每页最大数量
38 | public final static Integer PAGE_MAX_SIZE = 500;
39 |
40 | /*-------------------------------------------------------------------------------------------------------------- */
41 | // 资源
42 | /*-------------------------------------------------------------------------------------------------------------- */
43 | //-超过2M再计算hash
44 | public final static Integer FILE_HASH_MIN_SIZE = 2097152;
45 |
46 | public final static String RESOURCE_MEDIA_NAME = "media";
47 | }
--------------------------------------------------------------------------------
/edu-api-admin/src/main/java/com/langyastudio/edu/admin/common/middleware/ApplicationRunnerStart.java:
--------------------------------------------------------------------------------
1 | package com.langyastudio.edu.admin.common.middleware;
2 |
3 | import lombok.RequiredArgsConstructor;
4 | import lombok.extern.log4j.Log4j2;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.beans.factory.annotation.Value;
7 | import org.springframework.boot.ApplicationArguments;
8 | import org.springframework.boot.ApplicationRunner;
9 | import org.springframework.context.ConfigurableApplicationContext;
10 | import org.springframework.core.annotation.Order;
11 | import org.springframework.stereotype.Component;
12 | import org.springframework.web.context.WebApplicationContext;
13 |
14 | import java.net.InetAddress;
15 | import java.util.Arrays;
16 |
17 | /**
18 | * 继承Application接口后项目启动时会按照执行顺序执行run方法
19 | * 通过设置Order的value来指定执行的顺序 值越小越先执行
20 | */
21 | @Component
22 | @Log4j2
23 | @Order(value = 1)
24 | @RequiredArgsConstructor
25 | public class ApplicationRunnerStart implements ApplicationRunner
26 | {
27 | private final ConfigurableApplicationContext context;
28 |
29 | @Autowired
30 | WebApplicationContext applicationContext;
31 |
32 | @Value("${server.port}")
33 | Integer port;
34 |
35 | @Override
36 | public void run(ApplicationArguments args) throws Exception
37 | {
38 | if (context.isActive())
39 | {
40 | String[] activeProfiles = applicationContext.getEnvironment().getActiveProfiles();
41 | InetAddress address = InetAddress.getLocalHost();
42 | String url = String.format("http://%s:%s", address.getHostAddress(), port);
43 |
44 | log.info(" __ ___ _ ___ _ ____ _____ ____ ");
45 | log.info("/ /` / / \\ | |\\/| | |_) | | | |_ | | | |_ ");
46 | log.info("\\_\\_, \\_\\_/ |_| | |_| |_|__ |_|__ |_| |_|__ ");
47 | log.info(" ");
48 | System.out.println("后台-运行环境:" + Arrays.toString(activeProfiles));
49 | log.info("后台-系统启动完毕,地址:{}", url);
50 | }
51 | }
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/edu-api-admin/src/main/java/com/langyastudio/edu/admin/common/middleware/MonitorHealthIndicator.java:
--------------------------------------------------------------------------------
1 | package com.langyastudio.edu.admin.common.middleware;
2 |
3 | import org.springframework.boot.actuate.health.Health;
4 | import org.springframework.boot.actuate.health.HealthIndicator;
5 | import org.springframework.stereotype.Component;
6 |
7 | /**
8 | * actuator health
9 | * @author langyastudio
10 | */
11 | @Component
12 | public class MonitorHealthIndicator implements HealthIndicator
13 | {
14 | @Override
15 | public Health health()
16 | {
17 | //Health.down();
18 | return Health.up()
19 | .withDetail("error", "very good")
20 | .build();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/edu-api-admin/src/main/java/com/langyastudio/edu/admin/common/middleware/ShutDownHook.java:
--------------------------------------------------------------------------------
1 | package com.langyastudio.edu.admin.common.middleware;
2 |
3 | import lombok.extern.log4j.Log4j2;
4 | import org.springframework.context.ApplicationEvent;
5 | import org.springframework.context.event.ContextClosedEvent;
6 | import org.springframework.context.event.EventListener;
7 | import org.springframework.lang.NonNull;
8 | import org.springframework.stereotype.Component;
9 |
10 | /**
11 | * 退出进程
12 | */
13 | @Log4j2
14 | @Component
15 | public class ShutDownHook
16 | {
17 | @EventListener(classes = {ContextClosedEvent.class})
18 | public void onApplicationClosed(@NonNull ApplicationEvent event)
19 | {
20 | log.info("后台-系统已关闭");
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/edu-api-admin/src/main/java/com/langyastudio/edu/admin/common/task/AsyncTask.java:
--------------------------------------------------------------------------------
1 | package com.langyastudio.edu.admin.common.task;
2 |
3 | import lombok.extern.log4j.Log4j2;
4 | import org.springframework.scheduling.annotation.Async;
5 | import org.springframework.scheduling.annotation.AsyncResult;
6 | import org.springframework.stereotype.Component;
7 | import org.springframework.util.concurrent.ListenableFuture;
8 |
9 | @Component
10 | @Log4j2
11 | public class AsyncTask
12 | {
13 | /**
14 | * 使用自定义的 ThreadPoolTaskExecutor
15 | * @param i
16 | */
17 | @Async("customTaskExecutor")
18 | public ListenableFuture loopPrint(Integer i)
19 | {
20 | String res = "async task:" + i;
21 | log.info(res);
22 | return new AsyncResult<>(res);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/edu-api-admin/src/main/java/com/langyastudio/edu/admin/common/task/SchedulingTask.java:
--------------------------------------------------------------------------------
1 | package com.langyastudio.edu.admin.common.task;
2 |
3 | import lombok.extern.log4j.Log4j2;
4 | import org.springframework.scheduling.annotation.Scheduled;
5 | import org.springframework.stereotype.Component;
6 |
7 | /**
8 | * 计划任务
9 | *
10 | * @author langyastudio
11 | */
12 | @Log4j2
13 | @Component
14 | public class SchedulingTask
15 | {
16 | @Scheduled(fixedRate = 60000)
17 | public void fixedRateSchedule()
18 | {
19 | log.info("每 60 秒钟执行fixedRate...");
20 | }
21 |
22 |
23 | /**
24 | * initialDelay 延迟 5 秒后开始执行该任务
25 | */
26 | @Scheduled(initialDelay = 5000, fixedDelayString = "${langyastudio.task.fixedDelaySchedule:10000}")
27 | public void fixedDelaySchedule()
28 | {
29 | log.info("在上次任务完成 10 秒后执行fixedDelay...");
30 | }
31 |
32 | /**
33 | * cron 表达式
34 | */
35 | @Scheduled(cron = "*/30 * * * * *")
36 | public void cronchedule()
37 | {
38 | log.info("每30秒执行cron...");
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/edu-api-admin/src/main/java/com/langyastudio/edu/admin/config/AccountSecurityConfig.java:
--------------------------------------------------------------------------------
1 | package com.langyastudio.edu.admin.config;
2 |
3 | import com.langyastudio.edu.admin.service.SecurityService;
4 | import com.langyastudio.edu.security.config.SecurityConfig;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.context.annotation.Bean;
7 | import org.springframework.context.annotation.Configuration;
8 | import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
9 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
10 | import org.springframework.security.core.userdetails.UserDetailsService;
11 |
12 | /**
13 | * Spring Security模块相关配置
14 | */
15 | @Configuration
16 | @EnableWebSecurity
17 | @EnableGlobalMethodSecurity(prePostEnabled = true)
18 | public class AccountSecurityConfig extends SecurityConfig
19 | {
20 | @Autowired
21 | private SecurityService securityService;
22 |
23 | @Bean
24 | @Override
25 | public UserDetailsService userDetailsService()
26 | {
27 | //获取登录用户信息
28 | return username -> securityService.loadUserByUsername(username);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/edu-api-admin/src/main/java/com/langyastudio/edu/admin/config/DynamicSecurityImpl.java:
--------------------------------------------------------------------------------
1 | package com.langyastudio.edu.admin.config;
2 |
3 | import com.langyastudio.edu.admin.service.SecurityService;
4 | import com.langyastudio.edu.db.model.UmsApi;
5 | import com.langyastudio.edu.security.component.DynamicSecurityService;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.security.access.ConfigAttribute;
8 | import org.springframework.stereotype.Service;
9 |
10 | import java.util.List;
11 | import java.util.Map;
12 | import java.util.concurrent.ConcurrentHashMap;
13 |
14 | /**
15 | * Spring Dynamic Security
16 | *
17 | * @author langyastudio
18 | */
19 | @Service("dynamicSecurityService")
20 | public class DynamicSecurityImpl implements DynamicSecurityService
21 | {
22 | @Autowired
23 | private SecurityService securityService;
24 |
25 | /**
26 | * 加载资源ANT通配符和资源对应MAP
27 | */
28 | @Override
29 | public Map loadDataSource()
30 | {
31 | Map map = new ConcurrentHashMap<>();
32 | List resourceList = securityService.getAuthListAll();
33 | for (UmsApi resource : resourceList)
34 | {
35 | map.put(resource.getApiUrl(),
36 | new org.springframework.security.access.SecurityConfig(resource.getApiId() + ":" + resource.getApiName()));
37 | }
38 |
39 | return map;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/edu-api-admin/src/main/java/com/langyastudio/edu/admin/config/MybatisConfig.java:
--------------------------------------------------------------------------------
1 | package com.langyastudio.edu.admin.config;
2 |
3 | import com.langyastudio.edu.common.config.BaseMybatisConfig;
4 | import org.mybatis.spring.annotation.MapperScan;
5 | import org.springframework.context.annotation.Configuration;
6 | import org.springframework.transaction.annotation.EnableTransactionManagement;
7 |
8 |
9 | /**
10 | * Mybatis Plus
11 | */
12 | @Configuration
13 | @EnableTransactionManagement
14 | @MapperScan({"com.langyastudio.edu.db.mapper", "com.langyastudio.edu.admin.dao"})
15 | public class MybatisConfig extends BaseMybatisConfig
16 | {
17 |
18 | }
--------------------------------------------------------------------------------
/edu-api-admin/src/main/java/com/langyastudio/edu/admin/config/RedisConfig.java:
--------------------------------------------------------------------------------
1 | package com.langyastudio.edu.admin.config;
2 |
3 | import com.langyastudio.edu.common.config.BaseRedisConfig;
4 | import org.springframework.cache.annotation.EnableCaching;
5 | import org.springframework.context.annotation.Configuration;
6 |
7 | /**
8 | * redis配置类
9 | */
10 | @Configuration
11 | @EnableCaching
12 | public class RedisConfig extends BaseRedisConfig
13 | {
14 | }
15 |
--------------------------------------------------------------------------------
/edu-api-admin/src/main/java/com/langyastudio/edu/admin/config/WebSocketConfig.java:
--------------------------------------------------------------------------------
1 | package com.langyastudio.edu.admin.config;
2 |
3 | import org.springframework.context.annotation.Bean;
4 | import org.springframework.context.annotation.Configuration;
5 | import org.springframework.scheduling.TaskScheduler;
6 | import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
7 | import org.springframework.web.socket.server.standard.ServerEndpointExporter;
8 |
9 | /**
10 | * websocket 配置
11 | */
12 | @Configuration
13 | public class WebSocketConfig
14 | {
15 | /**
16 | * ServerEndpointExporter 用于扫描和注册所有携带 ServerEndPoint 注解的实例,
17 | * 若部署到外部容器 则无需提供此类。
18 | */
19 | public ServerEndpointExporter serverEndpointExporter()
20 | {
21 | return new ServerEndpointExporter();
22 | }
23 |
24 | // 解决 不能同时使用websocket和spring的定时注解
25 | @Bean
26 | public TaskScheduler taskScheduler()
27 | {
28 | ThreadPoolTaskScheduler scheduling = new ThreadPoolTaskScheduler();
29 | scheduling.setPoolSize(10);
30 | scheduling.initialize();
31 |
32 | return scheduling;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/edu-api-admin/src/main/java/com/langyastudio/edu/admin/controller/IndexController.java:
--------------------------------------------------------------------------------
1 | package com.langyastudio.edu.admin.controller;
2 |
3 | import com.langyastudio.edu.common.data.ResultInfo;
4 | import org.springframework.beans.factory.annotation.Value;
5 | import org.springframework.web.bind.annotation.RequestMapping;
6 | import org.springframework.web.bind.annotation.RestController;
7 |
8 | import java.util.Map;
9 |
10 | /**
11 | * 根访问
12 | */
13 | @RestController
14 | @RequestMapping("/")
15 | public class IndexController
16 | {
17 | /**
18 | * 当前版本
19 | */
20 | @Value("${spring.application.version}")
21 | private String serviceVersion;
22 |
23 | /**
24 | * 打包时间
25 | */
26 | @Value("${spring.application.package-time}")
27 | private String serviceBuildDate;
28 |
29 | /**
30 | * 主页
31 | */
32 | @RequestMapping("/")
33 | public ResultInfo index()
34 | {
35 | return ResultInfo.data(Map.of("name", "admin api",
36 | "version", serviceVersion,
37 | "time", serviceBuildDate,
38 | "company", "郎涯工作室",
39 | "official", "https://langyastudio.blog.csdn.net/",
40 | "maintainer", "langyastudio 「15589933912」"));
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/edu-api-admin/src/main/java/com/langyastudio/edu/admin/controller/auth/AuthController.java:
--------------------------------------------------------------------------------
1 | package com.langyastudio.edu.admin.controller.auth;
2 |
3 | import com.langyastudio.edu.admin.service.AuthService;
4 | import com.langyastudio.edu.common.anno.LogField;
5 | import com.langyastudio.edu.common.data.ResultInfo;
6 | import lombok.extern.log4j.Log4j2;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.validation.annotation.Validated;
9 | import org.springframework.web.bind.annotation.*;
10 |
11 | import javax.validation.Valid;
12 | import javax.validation.constraints.Size;
13 | import java.util.Map;
14 |
15 | /**
16 | * 权限管理
17 | */
18 | @Log4j2
19 | @Validated
20 | @RestController
21 | @RequestMapping("/admin/auth/auth")
22 | public class AuthController
23 | {
24 | @Autowired
25 | AuthService authService;
26 |
27 | /**
28 | * 获取权限列表
29 | *
30 | * @param roleId 权限Id号
31 | *
32 | * @return
33 | */
34 | @GetMapping("/get_list")
35 | public ResultInfo getList(@Valid @RequestParam(value = "role_id") @Size(min = 32, max = 32) String roleId)
36 | {
37 | //登录验证
38 | String userName = authService.getUserName(true);
39 |
40 | return ResultInfo.data(authService.getAuthListByRoleId(roleId));
41 | }
42 |
43 | /**
44 | * 修改角色权限
45 | *
46 | * @param roleApis 参数
47 | * role_id 角色id号
48 | * api_ids 权限列表(多个使用竖杠分割)
49 | *
50 | * @return
51 | */
52 | @PostMapping("/set_rules")
53 | @LogField("修改角色权限")
54 | public ResultInfo setRules(@Valid @RequestBody Map roleApis)
55 | {
56 | //登录验证
57 | String userName = authService.getUserName(true);
58 |
59 | authService.setAuthByRoleId(roleApis.get("role_id"), roleApis.get("api_ids"));
60 | return ResultInfo.data();
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/edu-api-admin/src/main/java/com/langyastudio/edu/admin/service/AuthService.java:
--------------------------------------------------------------------------------
1 | package com.langyastudio.edu.admin.service;
2 |
3 | import com.langyastudio.edu.db.model.UmsApi;
4 | import com.langyastudio.edu.common.data.PageInfo;
5 |
6 | import java.util.Map;
7 |
8 | /**
9 | * 权限管理
10 | */
11 | public interface AuthService extends BaseService
12 | {
13 | /*-------------------------------------------------------------------------------------------------------------- */
14 | // 权限管理
15 | /*-------------------------------------------------------------------------------------------------------------- */
16 | /**
17 | * 根据角色Id号获取API权限列表
18 | *
19 | * @param roleId 角色Id号
20 | *
21 | * @return
22 | */
23 | PageInfo getAuthListByRoleId(String roleId);
24 |
25 | /**
26 | * 设置角色映射的API权限列表
27 | *
28 | * @param roleId 角色Id号
29 | * @param apiIds API权限Id号列表
30 | *
31 | * @return
32 | */
33 | Integer setAuthByRoleId(String roleId, String apiIds);
34 |
35 | /*-------------------------------------------------------------------------------------------------------------- */
36 | // 用户管理
37 | /*-------------------------------------------------------------------------------------------------------------- */
38 |
39 | /**
40 | * 系统用户列表
41 | *
42 | * @param roleId 角色Id号
43 | * @param userNameKey 用户名关键字
44 | * @param phoneKey 电话号码关键字
45 | * @param fullNameKey 姓名关键字
46 | * @param isAsc 是否升序
47 | * @param offset 页码
48 | * @param pageSize 页数
49 | *
50 | * @return
51 | */
52 | PageInfo