瀏覽代碼

Merge remote-tracking branch 'origin/master'

zhuoning 4 年之前
父節點
當前提交
31dd5b66fe
共有 73 個文件被更改,包括 3031 次插入3 次删除
  1. 53 0
      huimv-mobile-video/huimv-gateway/pom.xml
  2. 13 0
      huimv-mobile-video/huimv-gateway/src/main/java/com/huimv/gateway/HuimvGatewayApplication.java
  3. 32 0
      huimv-mobile-video/huimv-gateway/src/main/resources/application-dev.yml
  4. 1 0
      huimv-mobile-video/huimv-gateway/src/main/resources/application.properties
  5. 13 0
      huimv-mobile-video/huimv-gateway/src/test/java/com/huimv/gateway/HuimvGatewayApplicationTests.java
  6. 54 0
      huimv-mobile-video/huimv-manager/pom.xml
  7. 5 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/HuimvMobileManagerApplication.java
  8. 35 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/config/InterceptorConfig.java
  9. 39 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/config/Knife4jConfiguration.java
  10. 15 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/constant/CommonConstant.java
  11. 29 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/enums/AbstractBaseExceptionEnum.java
  12. 32 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/enums/AdminTypeEnum.java
  13. 86 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/enums/AuthExceptionEnum.java
  14. 33 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/enums/CommonStatusEnum.java
  15. 37 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/exception/AuthException.java
  16. 61 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/exception/RRException.java
  17. 76 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/exception/RRExceptionHandler.java
  18. 101 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/interceptor/JWTInterceptor.java
  19. 60 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/controller/CaptchaController.java
  20. 56 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/controller/MobileUnitManageController.java
  21. 49 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/controller/MobileUserLoginController.java
  22. 53 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/controller/MobileUserManageController.java
  23. 49 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/entity/MobileApi.java
  24. 42 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/entity/MobileAttention.java
  25. 33 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/entity/MobileMemorandum.java
  26. 29 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/entity/MobileRemember.java
  27. 54 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/entity/MobileUnit.java
  28. 77 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/entity/MobileUser.java
  29. 17 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/entity/param/LoginParam.java
  30. 9 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/repository/MobileApiRepository.java
  31. 9 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/repository/MobileAttentionRepository.java
  32. 9 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/repository/MobileMemorandumRepository.java
  33. 9 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/repository/MobileRememberRepository.java
  34. 31 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/repository/MobileUnitRepository.java
  35. 22 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/repository/MobileUserRepository.java
  36. 24 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/service/MobileUnitService.java
  37. 68 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/service/MobileUserService.java
  38. 71 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/service/impl/MobileUnitServiceImpl.java
  39. 191 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/service/impl/MobileUserServiceImpl.java
  40. 63 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/result/R.java
  41. 28 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/result/Result.java
  42. 15 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/result/ResultStatus.java
  43. 53 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/util/IpUtil.java
  44. 140 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/util/JwtUtils.java
  45. 85 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/util/PropertiesUtils.java
  46. 121 0
      huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/util/VerifyUtil.java
  47. 12 2
      huimv-mobile-video/huimv-manager/src/main/resources/application-dev.yml
  48. 29 0
      huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/controller/MobileApiController.java
  49. 36 0
      huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/controller/MobileLastController.java
  50. 70 0
      huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/controller/MobileUserController.java
  51. 44 0
      huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/domain/MobileApi.java
  52. 38 0
      huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/domain/MobileAttention.java
  53. 32 0
      huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/domain/MobileLast.java
  54. 33 0
      huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/domain/MobileMemorandum.java
  55. 29 0
      huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/domain/MobileRemember.java
  56. 44 0
      huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/domain/MobileUnit.java
  57. 68 0
      huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/domain/MobileUser.java
  58. 10 0
      huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/repo/MobileApiRepository.java
  59. 9 0
      huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/repo/MobileAttentionRepository.java
  60. 15 0
      huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/repo/MobileLastRepository.java
  61. 9 0
      huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/repo/MobileMemorandumRepository.java
  62. 9 0
      huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/repo/MobileRememberRepository.java
  63. 10 0
      huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/repo/MobileUnitRepository.java
  64. 12 0
      huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/repo/MobileUserRepository.java
  65. 28 0
      huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/result/Result.java
  66. 14 0
      huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/service/MobileApiService.java
  67. 17 0
      huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/service/MobileLastService.java
  68. 16 0
      huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/service/MobileUserService.java
  69. 32 0
      huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/service/impl/MobileApiServiceImpl.java
  70. 40 0
      huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/service/impl/MobileLastServiceImpl.java
  71. 92 0
      huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/service/impl/MobileUserServiceImpl.java
  72. 100 0
      huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/utils/CheckNumber.java
  73. 1 1
      huimv-mobile-video/pom.xml

+ 53 - 0
huimv-mobile-video/huimv-gateway/pom.xml

@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.4.5</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+    <groupId>com.huimv</groupId>
+    <artifactId>huimv-gateway</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <name>huimv-gateway</name>
+    <description>Demo project for Gateway</description>
+    <properties>
+        <java.version>1.8</java.version>
+        <spring-cloud.version>2020.0.2</spring-cloud.version>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-gateway</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.springframework.cloud</groupId>
+                <artifactId>spring-cloud-dependencies</artifactId>
+                <version>${spring-cloud.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

+ 13 - 0
huimv-mobile-video/huimv-gateway/src/main/java/com/huimv/gateway/HuimvGatewayApplication.java

@@ -0,0 +1,13 @@
+package com.huimv.gateway;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class HuimvGatewayApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(HuimvGatewayApplication.class, args);
+    }
+
+}

+ 32 - 0
huimv-mobile-video/huimv-gateway/src/main/resources/application-dev.yml

@@ -0,0 +1,32 @@
+server:
+  port: 8088
+
+spring:
+  application:
+    name: huimv-gateway
+
+  cloud:
+
+    gateway:
+      globalcors:
+        cors-configurations:
+          '[/**]':
+            allowedHeaders: "*"
+            allowedOrigins: "*"
+#            allowCredentials: true
+            allowedMethods:
+              - GET
+              - POST
+              - DELETE
+              - PUT
+              - OPTION
+            maxAge: 1800
+      routes:
+        - id: huimv-manager
+          uri: http://192.168.1.57:9105/
+          predicates:
+            - Path=/manager/**
+          filters:
+            - RewritePath=/manager/(?<segment>/?.*), /$\{segment}
+
+

+ 1 - 0
huimv-mobile-video/huimv-gateway/src/main/resources/application.properties

@@ -0,0 +1 @@
+spring.profiles.active=dev

+ 13 - 0
huimv-mobile-video/huimv-gateway/src/test/java/com/huimv/gateway/HuimvGatewayApplicationTests.java

@@ -0,0 +1,13 @@
+package com.huimv.gateway;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class HuimvGatewayApplicationTests {
+
+    @Test
+    void contextLoads() {
+    }
+
+}

+ 54 - 0
huimv-mobile-video/huimv-manager/pom.xml

@@ -11,5 +11,59 @@
 
 	<artifactId>huimv-manager</artifactId>
 
+	<dependencies>
+
+		<!--验证码-->
+		<dependency>
+			<groupId>cn.dustlight.captcha</groupId>
+			<artifactId>captcha-core</artifactId>
+			<version>0.0.6</version>
+		</dependency>
+		<dependency>
+			<groupId>cn.dustlight.captcha</groupId>
+			<artifactId>redis-store</artifactId>
+			<version>0.0.6</version>
+		</dependency>
+
+		<!--jwt-->
+		<dependency>
+			<groupId>io.jsonwebtoken</groupId>
+			<artifactId>jjwt</artifactId>
+			<version>0.9.1</version>
+		</dependency>
+
+		<!--hutool-->
+		<dependency>
+			<groupId>cn.hutool</groupId>
+			<artifactId>hutool-all</artifactId>
+			<version>5.5.9</version>
+		</dependency>
+
+		<!--knife4j-->
+		<dependency>
+			<groupId>com.github.xiaoymin</groupId>
+			<artifactId>knife4j-spring-boot-starter</artifactId>
+			<version>2.0.7</version>
+		</dependency>
+		<dependency>
+			<groupId>io.springfox</groupId>
+			<artifactId>springfox-swagger-ui</artifactId>
+			<version>2.10.5</version>
+		</dependency>
+		<dependency>
+			<groupId>io.springfox</groupId>
+			<artifactId>springfox-swagger2</artifactId>
+			<version>2.10.5</version>
+		</dependency>
+
+
+		<dependency>
+			<groupId>org.apache.httpcomponents</groupId>
+			<artifactId>httpcore</artifactId>
+			<version>4.4.12</version>
+		</dependency>
+
+	</dependencies>
+
 
 </project>

+ 5 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/HuimvMobileManagerApplication.java

@@ -1,8 +1,13 @@
 package com.huimv.manager;
 
+import cn.dustlight.captcha.annotations.EnableCaptcha;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 
+/**
+ * @author huimv
+ */
+//@EnableCaptcha
 @SpringBootApplication
 public class HuimvMobileManagerApplication {
 

+ 35 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/config/InterceptorConfig.java

@@ -0,0 +1,35 @@
+package com.huimv.manager.config;
+
+import com.huimv.manager.interceptor.JWTInterceptor;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+/**
+ * @Description: 注册验证tocken的拦截器
+ * @Author
+ * @Date 2021/4/19 20:41
+ * @Version V1.0
+ */
+@Configuration
+public class InterceptorConfig implements WebMvcConfigurer {
+    @Bean
+    public JWTInterceptor jwtInterceptor(){
+        return new JWTInterceptor();
+    }
+
+    @Override
+    public void addInterceptors(InterceptorRegistry registry) {
+        registry.addInterceptor(jwtInterceptor()).
+                excludePathPatterns("/login").
+                excludePathPatterns("logout").
+                excludePathPatterns("/captcha/send").
+                excludePathPatterns("/swagger-resources/**").
+                excludePathPatterns("/").
+                excludePathPatterns("/*.ico").
+                excludePathPatterns("/js/**").
+                excludePathPatterns("/img/**").
+                addPathPatterns("/**");
+    }
+}

+ 39 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/config/Knife4jConfiguration.java

@@ -0,0 +1,39 @@
+package com.huimv.manager.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
+
+/**
+ * @author yinhao
+ * @since 2021/4/19 18:00
+ */
+@Configuration
+@EnableSwagger2WebMvc
+public class Knife4jConfiguration {
+
+    @Bean(value = "defaultApi2")
+    public Docket defaultApi2() {
+        Docket docket = new Docket(DocumentationType.SWAGGER_2)
+                .apiInfo(new ApiInfoBuilder()
+                        //.title("swagger-bootstrap-ui-demo RESTful APIs")
+                        .description("# swagger-bootstrap-ui-demo RESTful APIs")
+                        .termsOfServiceUrl("http://www.huimv.com/")
+                        .contact("xx@qq.com")
+                        .version("1.0")
+                        .build())
+                //分组名称
+                .groupName("2.X版本")
+                .select()
+                //这里指定Controller扫描包路径
+                .apis(RequestHandlerSelectors.basePackage("com.huimv.manager"))
+                .paths(PathSelectors.any())
+                .build();
+        return docket;
+    }
+}

+ 15 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/constant/CommonConstant.java

@@ -0,0 +1,15 @@
+package com.huimv.manager.constant;
+
+public class CommonConstant {
+    //性别 0-女 1-男
+    public static final Integer GENDER_FEMALE = 0;
+    public static final Integer GENDER_MALE = 1;
+
+    //默认分页
+    //初始页面
+    public static final Integer PAGE_NUM = 1;
+    public static final String PAGE_NUM_STR = "1";
+    //一页数据量
+    public static final Integer PAGE_SIZE = 20;
+    public static final String PAGE_SIZE_STR = "20";
+}

+ 29 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/enums/AbstractBaseExceptionEnum.java

@@ -0,0 +1,29 @@
+package com.huimv.manager.enums;
+
+/**
+ * 异常枚举格式规范
+ *
+ * @author yubaoshan
+ * @date 2017/12/17 22:22
+ */
+public interface AbstractBaseExceptionEnum {
+
+    /**
+     * 获取异常的状态码
+     *
+     * @return 状态码
+     * @author yubaoshan
+     * @date 2020/7/9 14:28
+     */
+    Integer getCode();
+
+    /**
+     * 获取异常的提示信息
+     *
+     * @return 提示信息
+     * @author yubaoshan
+     * @date 2020/7/9 14:28
+     */
+    String getMessage();
+
+}

+ 32 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/enums/AdminTypeEnum.java

@@ -0,0 +1,32 @@
+package com.huimv.manager.enums;
+
+import lombok.Getter;
+
+/**
+ * 管理员类型枚举
+ *
+ * @author xuyuxiang
+ * @date 2020/4/5 10:23
+ */
+@Getter
+public enum AdminTypeEnum {
+
+    /**
+     * 超级管理员
+     */
+    ADMIN(1, "管理员"),
+
+    /**
+     * 非管理员
+     */
+    NONE(2, "非管理员");
+
+    private final Integer code;
+
+    private final String message;
+
+    AdminTypeEnum(int code, String message) {
+        this.code = code;
+        this.message = message;
+    }
+}

+ 86 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/enums/AuthExceptionEnum.java

@@ -0,0 +1,86 @@
+package com.huimv.manager.enums;
+
+
+/**
+ * 认证相关的异常的枚举
+ * <p>
+ * 认证和鉴权的区别:
+ * <p>
+ * 认证可以证明你能登录系统,认证的过程是校验token的过程
+ * 鉴权可以证明你有系统的哪些权限,鉴权的过程是校验角色是否包含某些接口的权限
+ *
+ * @author yubaoshan
+ * @date 2019/7/18 22:22
+ */
+public enum AuthExceptionEnum implements AbstractBaseExceptionEnum {
+
+    /**
+     * 账号或密码为空
+     */
+    ACCOUNT_PWD_EMPTY(1, "账号或密码为空!"),
+
+    /**
+     * 账号密码错误
+     */
+    ACCOUNT_PWD_ERROR(2, "账号或密码错误!"),
+
+    /**
+     * 验证码错误
+     */
+    VALID_CODE_ERROR(3, "验证码错误,请检查captcha参数"),
+
+    /**
+     * 请求token为空
+     */
+    REQUEST_TOKEN_EMPTY(4, "请求token为空,请携带token访问本接口"),
+
+    /**
+     * token格式不正确,token请以Bearer开头
+     */
+    NOT_VALID_TOKEN_TYPE(5, "token格式不正确,token请以Bearer开头,并且Bearer后边带一个空格"),
+
+    /**
+     * 请求token错误
+     */
+    REQUEST_TOKEN_ERROR(6, "请求token错误"),
+
+    /**
+     * 账号被冻结
+     */
+    ACCOUNT_FREEZE_ERROR(7, "账号被冻结,请联系管理员"),
+
+    /**
+     * 登录已过期
+     */
+    LOGIN_EXPIRED(8, "登录已过期,请重新登录"),
+
+    /**
+     * 无登录用户
+     */
+    NO_LOGIN_USER(9, "无登录用户"),
+
+    /**
+     * 验证码错误
+     */
+    CONSTANT_EMPTY_ERROR(10, "验证码错误");
+
+    private final Integer code;
+
+    private final String message;
+
+    AuthExceptionEnum(Integer code, String message) {
+        this.code = code;
+        this.message = message;
+    }
+
+    @Override
+    public Integer getCode() {
+        return code;
+    }
+
+    @Override
+    public String getMessage() {
+        return message;
+    }
+
+}

+ 33 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/enums/CommonStatusEnum.java

@@ -0,0 +1,33 @@
+package com.huimv.manager.enums;
+
+import lombok.Getter;
+
+@Getter
+public enum CommonStatusEnum {
+
+    /**
+     * 正常
+     */
+    ENABLE(0, "正常"),
+
+    /**
+     * 停用
+     */
+    DISABLE(1, "停用"),
+
+    /**
+     * 删除
+     */
+    DELETED(2, "删除");
+
+    private final Integer code;
+
+    private final String message;
+
+    CommonStatusEnum(Integer code, String message) {
+        this.code = code;
+        this.message = message;
+    }
+
+
+}

+ 37 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/exception/AuthException.java

@@ -0,0 +1,37 @@
+package com.huimv.manager.exception;
+
+
+import com.huimv.manager.enums.AbstractBaseExceptionEnum;
+
+/**
+ * 认证相关的异常
+ * <p>
+ * 认证和鉴权的区别:
+ * <p>
+ * 认证可以证明你能登录系统,认证的过程是校验token的过程
+ * 鉴权可以证明你有系统的哪些权限,鉴权的过程是校验角色是否包含某些接口的权限
+ *
+ * @author yinhao
+ * @date 2020/3/12 9:55
+ */
+public class AuthException extends RuntimeException {
+
+    private final Integer code;
+
+    private final String errorMessage;
+
+    public Integer getCode() {
+        return code;
+    }
+
+    public String getErrorMessage() {
+        return errorMessage;
+    }
+
+    public AuthException(AbstractBaseExceptionEnum exception) {
+        super(exception.getMessage());
+        this.code = exception.getCode();
+        this.errorMessage = exception.getMessage();
+    }
+
+}

+ 61 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/exception/RRException.java

@@ -0,0 +1,61 @@
+/**
+ * Copyright (c) 2016-2019 人人开源 All rights reserved.
+ *
+ * https://www.renren.io
+ *
+ * 版权所有,侵权必究!
+ */
+
+package com.huimv.manager.exception;
+
+/**
+ * 自定义异常
+ *
+ * @author Mark sunlightcs@gmail.com
+ */
+public class RRException extends RuntimeException {
+	private static final long serialVersionUID = 1L;
+	
+    private String msg;
+    private int code = 500;
+    
+    public RRException(String msg) {
+		super(msg);
+		this.msg = msg;
+	}
+	
+	public RRException(String msg, Throwable e) {
+		super(msg, e);
+		this.msg = msg;
+	}
+	
+	public RRException(String msg, int code) {
+		super(msg);
+		this.msg = msg;
+		this.code = code;
+	}
+	
+	public RRException(String msg, int code, Throwable e) {
+		super(msg, e);
+		this.msg = msg;
+		this.code = code;
+	}
+
+	public String getMsg() {
+		return msg;
+	}
+
+	public void setMsg(String msg) {
+		this.msg = msg;
+	}
+
+	public int getCode() {
+		return code;
+	}
+
+	public void setCode(int code) {
+		this.code = code;
+	}
+	
+	
+}

+ 76 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/exception/RRExceptionHandler.java

@@ -0,0 +1,76 @@
+package com.huimv.manager.exception;
+
+import cn.dustlight.captcha.store.CodeNotExistsException;
+import cn.dustlight.captcha.verifier.VerifyFailException;
+import com.huimv.manager.enums.AuthExceptionEnum;
+import com.huimv.manager.result.R;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.dao.DuplicateKeyException;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
+import org.springframework.web.servlet.NoHandlerFoundException;
+
+/**
+ * 异常处理器
+ *
+ * @author Mark sunlightcs@gmail.com
+ */
+@RestControllerAdvice
+public class RRExceptionHandler {
+	private Logger logger = LoggerFactory.getLogger(getClass());
+
+	/**
+	 * 处理自定义异常
+	 */
+	@ExceptionHandler(RRException.class)
+	public R handleRRException(RRException e){
+		R r = new R();
+		r.put("code", e.getCode());
+		r.put("msg", e.getMessage());
+
+		return r;
+	}
+
+	@ExceptionHandler(NoHandlerFoundException.class)
+	public R handlerNoFoundException(Exception e) {
+		logger.error(e.getMessage(), e);
+		return R.error(404, "路径不存在,请检查路径是否正确");
+	}
+
+	@ExceptionHandler(DuplicateKeyException.class)
+	public R handleDuplicateKeyException(DuplicateKeyException e){
+		logger.error(e.getMessage(), e);
+		return R.error("数据库中已存在该记录");
+	}
+
+//	@ExceptionHandler(AuthorizationException.class)
+//	public R handleAuthorizationException(AuthorizationException e){
+//		logger.error(e.getMessage(), e);
+//		return R.error("没有权限,请联系管理员授权");
+//	}
+
+	@ExceptionHandler(CodeNotExistsException.class)
+	public R handCodeNotExistsException(CodeNotExistsException e){
+		logger.error(e.getMessage(),e);
+		return R.error(AuthExceptionEnum.CONSTANT_EMPTY_ERROR.getMessage());
+	}
+
+	@ExceptionHandler(VerifyFailException.class)
+	public R handVerifyFailException(VerifyFailException e){
+		logger.error(e.getMessage(), e);
+		return R.error(AuthExceptionEnum.CONSTANT_EMPTY_ERROR.getMessage());
+	}
+
+	@ExceptionHandler(AuthException.class)
+	public R handAuthException(AuthException e){
+		logger.error(e.getMessage(), e);
+		return R.error(e.getCode(),e.getErrorMessage());
+	}
+
+	@ExceptionHandler(Exception.class)
+	public R handleException(Exception e){
+		logger.error(e.getMessage(), e);
+		return R.error();
+	}
+}

+ 101 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/interceptor/JWTInterceptor.java

@@ -0,0 +1,101 @@
+package com.huimv.manager.interceptor;
+
+import com.alibaba.fastjson.JSONObject;
+import com.huimv.manager.enums.AdminTypeEnum;
+import com.huimv.manager.modular.entity.MobileUser;
+import com.huimv.manager.modular.service.MobileUserService;
+import com.huimv.manager.result.R;
+import com.huimv.manager.util.JwtUtils;
+import io.jsonwebtoken.Claims;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.StringUtils;
+import org.springframework.web.method.HandlerMethod;
+import org.springframework.web.servlet.HandlerInterceptor;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * <p>
+ *  jwt拦截器
+ * </p>
+ * @author yinhao
+ * @since 2021/4/19
+ */
+
+public class JWTInterceptor implements HandlerInterceptor {
+
+    @Autowired
+    private MobileUserService mobileUserService;
+
+    @Override
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
+        // 如果不是映射到方法,则直接通过
+        if (!(handler instanceof HandlerMethod)) {
+            return true;
+        }
+
+        response.setContentType("application/json;charset=utf-8");
+        // 获取token
+        String token = request.getHeader("token");
+        if (StringUtils.isEmpty(token)) {
+
+            response.getWriter().write(JSONObject.toJSONString(R.error(419,"无token,请先登录!")));
+//            response.sendError(419,"无token,请先登录!");
+            return false;
+        }
+
+        Claims claims = null;
+        try {
+            claims = JwtUtils.getClaims(token);
+        } catch (Exception e) {
+            response.getWriter().write(JSONObject.toJSONString(R.error(419,"token信息有误,请检查!")));
+            return false;
+        }
+        Integer id = claims.get("id", Integer.class);
+        if (mobileUserService == null) {
+
+            response.getWriter().write(JSONObject.toJSONString(R.error(500,"服务器发送错误!")));
+//            response.sendError(500,"服务器发送错误!");
+            return false;
+        }
+
+        MobileUser mobileUser = mobileUserService.findById(id);
+        if (mobileUser == null) {
+            response.getWriter().write(JSONObject.toJSONString(R.error(401,"用户不存在,请先注册!")));
+//            response.sendError(401,"用户不存在,请先注册!");
+            return false;
+        }
+
+        if (!mobileUser.getGrantClass().equals(AdminTypeEnum.ADMIN.getCode())) {
+            response.getWriter().write(JSONObject.toJSONString(R.error(401,"你不是管理员,不能进行该操作!")));
+//            response.sendError(401,"你不是管理员,不能进行该操作!");
+            return false;
+        }
+
+        int result = JwtUtils.verifyToken(claims);
+        if (result >= 1) {
+            response.getWriter().write(JSONObject.toJSONString(R.error(419,"token已失效,请重新登录!")));
+//            response.sendError(419,"token已失效,请重新登录!");
+            return false;
+        }
+//        if (result == -1) {
+//            String jwtToken = JwtUtils.getJwtToken(id);
+////            response.getWriter().write(JSONObject.toJSONString(R.ok("token需要刷新").put("code",30000).put("token",jwtToken)));
+//            return true;
+//        }
+        return true;
+    }
+
+
+    @Override
+    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
+
+    }
+
+    @Override
+    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
+
+    }
+}

+ 60 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/controller/CaptchaController.java

@@ -0,0 +1,60 @@
+package com.huimv.manager.modular.controller;
+
+
+import com.huimv.manager.exception.RRException;
+import com.huimv.manager.util.VerifyUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * <p>
+ * 验证码前端控制器
+ * </p>
+ * @Author yinhao
+ * @Date 2021/4/19 11:56
+ */
+@RestController
+@CrossOrigin
+@RequestMapping("/captcha")
+@Slf4j
+public class CaptchaController {
+
+    @Autowired
+    private RedisTemplate<String, String> redisTemplate;
+
+    /**
+     * 获取验证码
+     * @param request
+     * @param response
+     */
+    @GetMapping("/send")
+    public void createImg(HttpServletRequest request, HttpServletResponse response)  {
+        try {
+            //设置响应类型,告诉浏览器输出的内容为图片
+            response.setContentType("image/jpeg");
+            //设置响应头信息,告诉浏览器不要缓存此内容
+            response.setHeader("Pragma", "No-cache");
+            response.setHeader("Cache-Control", "no-cache");
+            response.setDateHeader("Expire", 0);
+            VerifyUtil randomValidateCode = new VerifyUtil();
+            //输出验证码图片
+            String code = randomValidateCode.getRandcode(request, response);
+            log.info(code);
+            //将生成的随机验证码存放到redis中
+            String remoteHost = request.getRemoteHost();
+            redisTemplate.opsForValue().set(remoteHost,code,300, TimeUnit.SECONDS);
+        } catch (Exception e) {
+            log.error("获取验证码异常:",e);
+            throw new RRException("获取验证码失败!");
+        }
+    }
+}

+ 56 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/controller/MobileUnitManageController.java

@@ -0,0 +1,56 @@
+package com.huimv.manager.modular.controller;
+
+import com.huimv.manager.constant.CommonConstant;
+import com.huimv.manager.modular.entity.MobileUnit;
+import com.huimv.manager.modular.service.MobileUnitService;
+import com.huimv.manager.result.R;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @Author yinhao
+ * @Date 2021/4/20 11:19
+ * @Description
+ */
+
+@CrossOrigin
+@RestController
+@RequestMapping("/unitManage")
+public class MobileUnitManageController {
+
+    @Autowired
+    private MobileUnitService mobileUnitService;
+
+    @GetMapping("/findAll")
+    public R findAll(@RequestParam(value = "pageNum", defaultValue = CommonConstant.PAGE_NUM_STR) Integer pageNum,
+                     @RequestParam(value = "pageSize", defaultValue = CommonConstant.PAGE_SIZE_STR) Integer pageSize,
+                     String keyword) {
+        Page<MobileUnit> page;
+        if (StringUtils.isEmpty(keyword)) {
+            page = mobileUnitService.findAll(pageNum, pageSize);
+        } else {
+            page = mobileUnitService.findAllByKeyword(pageNum, pageSize, keyword);
+        }
+        return R.ok().put("page", page);
+    }
+
+    @PostMapping("/save")
+    public R save(MobileUnit mobileUnit) {
+        mobileUnitService.save(mobileUnit);
+        return R.ok("保存成功!");
+    }
+
+    @GetMapping("/deleteById")
+    public R deleteById(@RequestParam(value = "id") Integer id) {
+        mobileUnitService.deleteById(id);
+        return R.ok("删除成功!");
+    }
+
+    @PostMapping("/batchDeleteByIds")
+    public R batchDeleteByIds(Integer[] ids) {
+        mobileUnitService.batchDeleteByIds(ids);
+        return R.ok("批量删除成功!");
+    }
+}

+ 49 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/controller/MobileUserLoginController.java

@@ -0,0 +1,49 @@
+package com.huimv.manager.modular.controller;
+
+
+import com.huimv.manager.modular.service.MobileUserService;
+import com.huimv.manager.result.R;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * @Author yinhao
+ * @Date 2021/4/19 12:18
+ * @Description
+ */
+@Slf4j
+@CrossOrigin
+@RestController
+public class MobileUserLoginController {
+
+    @Autowired
+    private RedisTemplate<String, String> redisTemplate;
+
+    @Autowired
+    private MobileUserService mobileUserService;
+
+    @PostMapping("/login")
+    public R login(@RequestParam(name = "account") String account,
+                   @RequestParam(name = "password") String password,
+                   @RequestParam(name = "code") String code,
+                   HttpServletRequest request) {
+
+        String remoteHost = request.getRemoteHost();
+        String redisCode = redisTemplate.opsForValue().get(remoteHost);
+        if (redisCode == null) {
+            return R.error("验证码已过期,请点击刷新!");
+        }
+        if (!redisCode.equals(code.toUpperCase())) {
+            return R.error("验证码错误!");
+        }
+        log.info(code);
+        return mobileUserService.login(account, password, code);
+    }
+}

+ 53 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/controller/MobileUserManageController.java

@@ -0,0 +1,53 @@
+package com.huimv.manager.modular.controller;
+
+
+import com.huimv.manager.modular.entity.MobileUser;
+import com.huimv.manager.modular.service.MobileUserService;
+import com.huimv.manager.result.Result;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @Author yinhao
+ * @Date 2021/4/19 12:18
+ * @Description
+ */
+@Slf4j
+@CrossOrigin
+@RestController
+@RequestMapping("/UserManage")
+public class MobileUserManageController {
+
+    @Autowired
+    private MobileUserService service;
+
+    @RequestMapping("/add")
+    public Result add(MobileUser childcareEntity){
+        return service.add(childcareEntity);
+    }
+
+    @RequestMapping("/remove")
+    public Result remove(Integer[] ids)
+    { return service.remove(ids);
+    }
+
+    @RequestMapping("/update")
+    public Result update(MobileUser childcareEntity){
+        return service.update(childcareEntity);
+    }
+
+    @RequestMapping("/findAllById")
+    public Result findAllById(Integer id){ return service.findAllById(id); }
+
+
+    @RequestMapping("/findAll")
+    public Result findAll(String name ,Integer pageNum, Integer pageSize){
+        return service.findAll(name,pageNum,pageSize);
+    }
+
+
+
+}

+ 49 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/entity/MobileApi.java

@@ -0,0 +1,49 @@
+package com.huimv.manager.modular.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+@Data
+@Entity
+@Table(name = "mobile_api")
+public class MobileApi implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @Column(name = "id", nullable = false)
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private Integer id;
+
+    /**
+     * 牧场名称
+     */
+    @ApiModelProperty("牧场名称")
+    @Column(name = "farm_name")
+    private String farmName;
+
+    /**
+     * 牧场id
+     */
+    @Column(name = "farm_id")
+    @ApiModelProperty(value = "牧场id",example = "1")
+    private Integer farmId;
+
+    /**
+     * API接口
+     */
+    @Column(name = "url")
+    @ApiModelProperty("API接口")
+    private String url;
+
+    /**
+     * 备注
+     */
+    @ApiModelProperty("备注")
+    @Column(name = "remark")
+    private String remark;
+
+}

+ 42 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/entity/MobileAttention.java

@@ -0,0 +1,42 @@
+package com.huimv.manager.modular.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+@Data
+@Entity
+@Table(name = "mobile_attention")
+public class MobileAttention implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @Column(name = "id", nullable = false)
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private Integer id;
+
+    /**
+     * 用户id
+     */
+    @Column(name = "user_id")
+    @ApiModelProperty(value = "用户id",example = "1")
+    private Integer userId;
+
+    /**
+     * 显示区域
+     */
+    @Column(name = "area_id")
+    @ApiModelProperty("显示区域")
+    private Integer areaId;
+
+    /**
+     * 单位id
+     */
+    @Column(name = "unit_id")
+    @ApiModelProperty(value = "单位id",example = "1")
+    private Integer unitId;
+
+}

+ 33 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/entity/MobileMemorandum.java

@@ -0,0 +1,33 @@
+package com.huimv.manager.modular.entity;
+
+import lombok.Data;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+@Entity
+@Table(name = "mobile_memorandum")
+public class MobileMemorandum implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @Column(name = "id", nullable = false)
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private Integer id;
+
+    @Column(name = "user_id")
+    private Integer userId;
+
+    @Column(name = "content")
+    private String content;
+
+    @Column(name = "title")
+    private String title;
+
+    @Column(name = "date")
+    private Date date;
+
+}

+ 29 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/entity/MobileRemember.java

@@ -0,0 +1,29 @@
+package com.huimv.manager.modular.entity;
+
+import lombok.Data;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+@Data
+@Entity
+@Table(name = "mobile_remember")
+public class MobileRemember implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @Column(name = "id", nullable = false)
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private Integer id;
+
+    @Column(name = "user_id")
+    private Integer userId;
+
+    @Column(name = "issue")
+    private String issue;
+
+    @Column(name = "answer")
+    private String answer;
+
+}

+ 54 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/entity/MobileUnit.java

@@ -0,0 +1,54 @@
+package com.huimv.manager.modular.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+@Data
+@Entity
+@Table(name = "mobile_unit")
+public class MobileUnit implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @Column(name = "id", nullable = false)
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private Integer id;
+
+    /**
+     * 单位全称
+     */
+    @ApiModelProperty("单位全称")
+    @Column(name = "full_name")
+    private String fullName;
+
+    /**
+     * 单位简称
+     */
+    @ApiModelProperty("单位简称")
+    @Column(name = "short_name")
+    private String shortName;
+
+    /**
+     * 备注
+     */
+    @ApiModelProperty("备注")
+    @Column(name = "remark")
+    private String remark;
+
+    /**
+     * 接口名称
+     */
+    @Column(name = "api")
+    @ApiModelProperty("接口名称")
+    private String api;
+
+
+    @Column(name = "fid")
+    @ApiModelProperty("fid")
+    private Integer fid;
+
+}

+ 77 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/entity/MobileUser.java

@@ -0,0 +1,77 @@
+package com.huimv.manager.modular.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+@Data
+@Entity
+@Table(name = "mobile_user")
+public class MobileUser implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @Column(name = "id", nullable = false)
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private Integer id;
+
+    /**
+     * 姓名
+     */
+    @ApiModelProperty("姓名")
+    @Column(name = "user_name")
+    private String userName;
+
+    /**
+     * 密码
+     */
+    @ApiModelProperty("密码")
+    @Column(name = "password")
+    private String password;
+
+    /**
+     * 账号
+     */
+    @ApiModelProperty("账号")
+    @Column(name = "account")
+    private String account;
+
+    /**
+     * 账号状态
+     */
+    @Column(name = "status")
+    @ApiModelProperty(value = "账号状态",example = "1")
+    private Integer status;
+
+    /**
+     * 所属单位
+     */
+    @Column(name = "unit")
+    @ApiModelProperty("所属单位")
+    private String unit;
+
+    /**
+     * 所属单位id
+     */
+    @Column(name = "unit_id")
+    @ApiModelProperty(value = "所属单位id",example = "1")
+    private Integer unitId;
+
+    /**
+     * 职务
+     */
+    @Column(name = "job")
+    @ApiModelProperty("职务")
+    private String job;
+
+    /**
+     * 权限级别
+     */
+    @ApiModelProperty(value = "权限级别",example = "1")
+    @Column(name = "grant_class")
+    private Integer grantClass;
+
+}

+ 17 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/entity/param/LoginParam.java

@@ -0,0 +1,17 @@
+package com.huimv.manager.modular.entity.param;
+
+import lombok.Data;
+
+/**
+ * @Author yinhao
+ * @Date 2021/4/19 18:16
+ * @Description
+ */
+@Data
+public class LoginParam {
+
+    private String account;
+
+    private String password;
+
+}

+ 9 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/repository/MobileApiRepository.java

@@ -0,0 +1,9 @@
+package com.huimv.manager.modular.repository;
+
+import com.huimv.manager.modular.entity.MobileApi;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+public interface MobileApiRepository extends JpaRepository<MobileApi, Integer>, JpaSpecificationExecutor<MobileApi> {
+
+}

+ 9 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/repository/MobileAttentionRepository.java

@@ -0,0 +1,9 @@
+package com.huimv.manager.modular.repository;
+
+import com.huimv.manager.modular.entity.MobileAttention;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+public interface MobileAttentionRepository extends JpaRepository<MobileAttention, Integer>, JpaSpecificationExecutor<MobileAttention> {
+
+}

+ 9 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/repository/MobileMemorandumRepository.java

@@ -0,0 +1,9 @@
+package com.huimv.manager.modular.repository;
+
+import com.huimv.manager.modular.entity.MobileMemorandum;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+public interface MobileMemorandumRepository extends JpaRepository<MobileMemorandum, Integer>, JpaSpecificationExecutor<MobileMemorandum> {
+
+}

+ 9 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/repository/MobileRememberRepository.java

@@ -0,0 +1,9 @@
+package com.huimv.manager.modular.repository;
+
+import com.huimv.manager.modular.entity.MobileRemember;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+public interface MobileRememberRepository extends JpaRepository<MobileRemember, Integer>, JpaSpecificationExecutor<MobileRemember> {
+
+}

+ 31 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/repository/MobileUnitRepository.java

@@ -0,0 +1,31 @@
+package com.huimv.manager.modular.repository;
+
+import com.huimv.manager.modular.entity.MobileUnit;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
+
+import javax.transaction.Transactional;
+import java.util.List;
+
+public interface MobileUnitRepository extends JpaRepository<MobileUnit, Integer>, JpaSpecificationExecutor<MobileUnit> {
+
+    Page<MobileUnit> findByFullNameLikeOrShortNameLike(String fullName, String shortName, Pageable pageable);
+
+
+    Page<MobileUnit> findByFullNameLike(String fullName,Pageable pageable);
+
+//    @Modifying
+//    @Transactional
+//    @Query(nativeQuery = true,value="delete from mobile_unit mu where mu.id in (:list) ")
+//    void batchDeleteByIds(@Param("list") List<Integer> list);
+
+
+    void deleteMobileUnitByIdIn(@Param("list") List<Integer> list);
+
+    List<MobileUnit> findByShortNameLike(String shortName);
+}

+ 22 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/repository/MobileUserRepository.java

@@ -0,0 +1,22 @@
+package com.huimv.manager.modular.repository;
+
+import com.huimv.manager.modular.entity.MobileUser;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
+
+import java.util.List;
+
+public interface MobileUserRepository extends JpaRepository<MobileUser, Integer>, JpaSpecificationExecutor<MobileUser> {
+
+    MobileUser findByAccount(String account);
+
+
+    @Query(nativeQuery = true ,value = "select * from mobile_user where user_name like %?1% and grant_class != 1 limit ?2 , ?3")
+    List<MobileUser> findAll(String name, Integer startPage, Integer pageSize);
+
+    @Query(nativeQuery = true ,value = "select MAX(id) from mobile_user")
+    Integer findID();
+}

+ 24 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/service/MobileUnitService.java

@@ -0,0 +1,24 @@
+package com.huimv.manager.modular.service;
+
+import com.huimv.manager.modular.entity.MobileUnit;
+import org.springframework.data.domain.Page;
+
+/**
+ * @Author yinhao
+ * @Date 2021/4/20 11:31
+ * @Description
+ */
+public interface MobileUnitService {
+
+
+    Page<MobileUnit> findAll(Integer pageNum, Integer pageSize);
+
+    Page<MobileUnit> findAllByKeyword(Integer pageNum, Integer pageSize, String keyword);
+
+
+    void save(MobileUnit mobileUnit);
+
+    void deleteById(Integer id);
+
+    void batchDeleteByIds(Integer[] ids);
+}

+ 68 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/service/MobileUserService.java

@@ -0,0 +1,68 @@
+package com.huimv.manager.modular.service;
+
+import com.huimv.manager.modular.entity.MobileUser;
+import com.huimv.manager.modular.entity.param.LoginParam;
+import com.huimv.manager.result.R;
+import com.huimv.manager.result.Result;
+
+/**
+ * @Author yinhao
+ * @Date 2021/4/19 18:10
+ * @Description
+ */
+public interface MobileUserService {
+    /**
+     * 登录
+     * @param
+     * @param code
+     * @return
+     */
+    R login(String account,String password, String code);
+
+    /**
+     * 根据id查询用户
+     * @param id
+     * @return
+     */
+    MobileUser findById(Integer id);
+
+
+
+    //添加
+    Result add(MobileUser entity);
+
+    //添加
+    Result remove(Integer[] ids);
+
+    //添加
+    Result update(MobileUser entity);
+
+    //查询
+    Result findAll(String name, Integer pageNum, Integer pageSize);
+
+    //根据id查找
+    Result findAllById(Integer id);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}

+ 71 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/service/impl/MobileUnitServiceImpl.java

@@ -0,0 +1,71 @@
+package com.huimv.manager.modular.service.impl;
+
+import com.huimv.manager.modular.entity.MobileUnit;
+import com.huimv.manager.modular.repository.MobileUnitRepository;
+import com.huimv.manager.modular.service.MobileUnitService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @Author yinhao
+ * @Date 2021/4/20 12:00
+ * @Description
+ */
+@Service
+public class MobileUnitServiceImpl implements MobileUnitService {
+
+    @Autowired
+    private MobileUnitRepository mobileUnitRepository;
+
+
+    @Override
+    public Page<MobileUnit> findAll(Integer pageNum, Integer pageSize) {
+        return mobileUnitRepository.findAll(PageRequest.of(pageNum - 1, pageSize));
+    }
+
+    @Override
+    public Page<MobileUnit> findAllByKeyword(Integer pageNum, Integer pageSize, String keyword) {
+        String condition = "%" + keyword + "%";
+        return mobileUnitRepository.findByFullNameLikeOrShortNameLike(condition,condition, PageRequest.of(pageNum - 1, pageSize));
+    }
+
+    @Override
+    public void save(MobileUnit mobileUnit) {
+        boolean isAdd = null == mobileUnit.getId();
+        saveOrUpdateMobileUnit(isAdd, mobileUnit);
+    }
+
+    private void saveOrUpdateMobileUnit(boolean isAdd, MobileUnit mobileUnit) {
+        MobileUnit entity = new MobileUnit();
+        entity.setFullName(mobileUnit.getFullName());
+        entity.setShortName(mobileUnit.getShortName());
+        entity.setRemark(mobileUnit.getRemark());
+        entity.setApi(mobileUnit.getApi());
+
+        if (isAdd) {
+            mobileUnitRepository.saveAndFlush(entity);
+            return;
+        }
+        entity.setId(mobileUnit.getId());
+        mobileUnitRepository.saveAndFlush(entity);
+    }
+
+    @Override
+    public void deleteById(Integer id) {
+        mobileUnitRepository.deleteById(id);
+    }
+
+    @Override
+    public void batchDeleteByIds(Integer[] ids) {
+        List<Integer> list = new ArrayList<>();
+        Collections.addAll(list, ids);
+//        mobileUnitRepository.batchDeleteByIds(list);
+        mobileUnitRepository.deleteMobileUnitByIdIn(list);
+    }
+}

+ 191 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/service/impl/MobileUserServiceImpl.java

@@ -0,0 +1,191 @@
+package com.huimv.manager.modular.service.impl;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.huimv.manager.enums.AdminTypeEnum;
+import com.huimv.manager.enums.AuthExceptionEnum;
+import com.huimv.manager.exception.AuthException;
+import com.huimv.manager.exception.RRException;
+import com.huimv.manager.modular.entity.MobileUser;
+import com.huimv.manager.modular.repository.MobileUnitRepository;
+import com.huimv.manager.modular.repository.MobileUserRepository;
+import com.huimv.manager.modular.service.MobileUserService;
+import com.huimv.manager.result.R;
+import com.huimv.manager.result.Result;
+import com.huimv.manager.result.ResultStatus;
+import com.huimv.manager.util.JwtUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.DigestUtils;
+import org.springframework.util.StringUtils;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * @Author yinhao
+ * @Date 2021/4/19 18:11
+ * @Description
+ */
+@Slf4j
+@Service
+public class MobileUserServiceImpl implements MobileUserService {
+
+    @Autowired
+    private MobileUserRepository mobileUserRepository;
+
+    @Override
+    public R login(String account, String password, String code) {
+//        String account = loginParam.getAccount();
+//        String password = loginParam.getPassword();
+        if (StringUtils.isEmpty(code)) {
+            throw new AuthException(AuthExceptionEnum.CONSTANT_EMPTY_ERROR);
+        }
+        if (ObjectUtil.hasEmpty(account, password)) {
+            throw new AuthException(AuthExceptionEnum.ACCOUNT_PWD_EMPTY);
+        }
+
+        MobileUser mobileUser = mobileUserRepository.findByAccount(account);
+        if (mobileUser == null) {
+            throw new AuthException(AuthExceptionEnum.ACCOUNT_PWD_ERROR);
+        }
+
+        if (!mobileUser.getGrantClass().equals(AdminTypeEnum.ADMIN.getCode())) {
+            throw new RRException("对不起,你不是管理员,不能登录此系统!", 401);
+        }
+
+        String inputPwdMd5 = DigestUtils.md5DigestAsHex(password.getBytes());
+        if (!inputPwdMd5.equals(mobileUser.getPassword())) {
+            throw new AuthException(AuthExceptionEnum.ACCOUNT_PWD_ERROR);
+        }
+
+        String token = JwtUtils.getJwtToken(mobileUser.getId());
+        mobileUser.setPassword("");
+        return Objects.requireNonNull(R.ok().put("token", token)).put("mobileUser", mobileUser);
+    }
+
+
+    @Autowired
+    MobileUnitRepository mobileUnitRepository;
+
+
+
+    @Override
+    public Result add(MobileUser entity){
+
+
+        if (entity == null){
+            return new Result(10002, ResultStatus.addNull);
+        }
+
+        String account = entity.getAccount();
+        MobileUser mobileUser = mobileUserRepository.findByAccount(account);
+        if (mobileUser != null) {
+            return new Result(10001,"账号已存在,添加失败!");
+        }
+        try {
+            String ycgApi = mobileUnitRepository.findByShortNameLike("油车港").get(0).getApi();
+            String wyApi = mobileUnitRepository.findByShortNameLike("武义").get(0).getApi();
+            String wjjApi = mobileUnitRepository.findByShortNameLike("王江泾").get(0).getApi();
+
+            entity.setPassword(DigestUtils.md5DigestAsHex("123456".getBytes()));
+            mobileUserRepository.save(entity);
+
+            RestTemplate restTemplate  = new RestTemplate();
+            Integer id = mobileUserRepository.findID();
+            Integer grantClass = entity.getGrantClass();
+
+            if (grantClass ==null){
+                return new Result(10000,"msg");
+            }
+            Long start = System.currentTimeMillis();
+
+            restTemplate.getForEntity(ycgApi+"/video/mobileUser/register?account="+start+"&id="+id+"&password=123456",null);
+            restTemplate.getForEntity(wyApi+"/video/mobileUser/register?account="+start+"&id="+id+"&password=123456",null);
+            restTemplate.getForEntity(wjjApi+"/video/mobileUser/register?account="+start+"&id="+id+"&password=123456",null);
+
+            return new Result(10000,ResultStatus.addSuccess);
+        }catch (Exception e){
+            log.error(e.getMessage(),e);
+            return new Result(10001,ResultStatus.addFailed);
+        }
+    }
+
+    @Override
+    public Result remove(Integer[] ids) {
+        if (ids == null || ids.length==0){
+            return new Result(10002,ResultStatus.deleteNull);
+        }
+        String ycgApi = mobileUnitRepository.findByShortNameLike("油车港").get(0).getApi();
+        String wyApi = mobileUnitRepository.findByShortNameLike("武义").get(0).getApi();
+        String wjjApi = mobileUnitRepository.findByShortNameLike("王江泾").get(0).getApi();
+
+
+//        RestTemplate restTemplate  = new RestTemplate();
+//        restTemplate.getForEntity(wjjApi+"/video/mobileUser/remove?ids="+ids,null);
+//        restTemplate.getForEntity(wyApi+"/video/mobileUser/remove?ids="+ids,null);
+//        restTemplate.getForEntity(ycgApi+"/video/mobileUser/remove?ids="+ids,null);
+
+
+        try {
+            for (Integer id : ids) {
+                mobileUserRepository.deleteById(id);
+            }
+            return new Result(10000,ResultStatus.deleteSuccess);
+        }catch (Exception e){
+            return new Result(10001,ResultStatus.deleteFailed);
+        }
+    }
+
+    @Override
+    public Result update(MobileUser entity) {
+        if (entity == null){
+            return new Result(10002,ResultStatus.updateNull);
+        }
+        try {
+            mobileUserRepository.save(entity);
+            return new Result(10000,ResultStatus.updateSuccess);
+        }catch (Exception e){
+            return new Result(10001,ResultStatus.updateFailed);
+        }
+    }
+
+    @Override
+    public Result findAll(String name , Integer pageNum , Integer pageSize) {
+        try {
+            Map map = new HashMap();
+            int size = mobileUserRepository.findAll().size() ;
+            Integer startPage = (pageNum-1) * pageSize;
+            List<MobileUser> all = mobileUserRepository.findAll(name,startPage,pageSize);
+            map.put("total",size);
+            map.put("totalPageNum",(size  +  pageSize  - 1) / pageSize);
+            map.put("data",all);
+
+            return new Result(10000,ResultStatus.findSuccess,map);
+        }catch (Exception e){
+            log.error(e.getMessage(),e);
+            return new Result(10001,ResultStatus.findFailed,null);
+        }
+    }
+
+    @Override
+    public Result findAllById(Integer id) {
+        try {
+            MobileUser entity = mobileUserRepository.findById(id).get();
+            return new Result(10000,ResultStatus.findSuccess,entity);
+        }catch (Exception e){
+            return new Result(10001,ResultStatus.findFailed,null);
+        }
+    }
+
+
+
+
+    @Override
+    public MobileUser findById(Integer id) {
+        return mobileUserRepository.findById(id).orElse(null);
+    }
+}

+ 63 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/result/R.java

@@ -0,0 +1,63 @@
+package com.huimv.manager.result;
+
+import org.apache.http.HttpStatus;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 返回数据
+ *
+ * @author Mark sunlightcs@gmail.com
+ */
+public class R extends HashMap<String, Object> {
+	private static final long serialVersionUID = 1L;
+	
+	public R() {
+		put("code", 10000);
+		put("msg", "success");
+	}
+	
+	public static R error() {
+		return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常,请联系管理员");
+	}
+	
+	public static R error(String msg) {
+		return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg);
+	}
+	
+	public static R error(int code, String msg) {
+		R r = new R();
+		r.put("code", code);
+		r.put("msg", msg);
+		return r;
+	}
+
+	public static R ok(String msg) {
+		R r = new R();
+		r.put("msg", msg);
+		return r;
+	}
+	
+	public static R ok(Map<String, Object> map) {
+		R r = new R();
+		r.putAll(map);
+		return r;
+	}
+	
+	public static R ok() {
+		return new R();
+	}
+
+	@Override
+	public R put(String key, Object value) {
+		super.put(key, value);
+		return this;
+	}
+
+	public static void main(String[] args) {
+		R r = new R();
+		System.out.println(r);
+
+	}
+}

+ 28 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/result/Result.java

@@ -0,0 +1,28 @@
+package com.huimv.manager.result;
+
+import lombok.Data;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.face.result
+ * @Description : TODO
+ * @Author : yuxuexuan
+ * @Create : 2020/12/29 0029 14:46
+ **/
+@Data
+public class Result {
+    private Integer  code;
+    private String msg;
+    private Object data;
+
+    public Result(Integer code, String msg, Object data) {
+        this.code = code;
+        this.msg = msg;
+        this.data = data;
+    }
+
+    public Result(Integer code, String msg) {
+        this.code = code;
+        this.msg = msg;
+    }
+}

+ 15 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/result/ResultStatus.java

@@ -0,0 +1,15 @@
+package com.huimv.manager.result;
+
+public  class ResultStatus {
+	public  final static String addNull = "没有输入参数";
+	public  final static String addSuccess = "添加成功";
+	public  final static String addFailed = "添加失败";
+	public  final static String deleteNull = "没有要删除的数据";
+	public  final static String deleteSuccess = "删除成功";
+	public  final static String deleteFailed = "删除失败";
+	public  final static String updateNull = "没有要修改的数据";
+	public  final static String updateSuccess = "修改成功";
+	public  final static String updateFailed = "修改失败";
+	public  final static String findSuccess = "查询成功";
+	public  final static String findFailed = "查询失败";
+}

+ 53 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/util/IpUtil.java

@@ -0,0 +1,53 @@
+package com.huimv.manager.util;
+
+import javax.servlet.http.HttpServletRequest;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.video.util
+ * @Description : 获取ip地址工具类
+ * @Author : yuxuexuan
+ * @Create : 2021/3/4 0006 14:28
+ **/
+public class IpUtil {
+    public static String getIpAddr(HttpServletRequest request) {
+        String ipAddress = null;
+        try {
+            ipAddress = request.getHeader("x-forwarded-for");
+            if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
+                ipAddress = request.getHeader("Proxy-Client-IP");
+            }
+            if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
+                ipAddress = request.getHeader("WL-Proxy-Client-IP");
+            }
+            if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
+                ipAddress = request.getRemoteAddr();
+                if (ipAddress.equals("127.0.0.1")) {
+                    // 根据网卡取本机配置的IP
+                    InetAddress inet = null;
+                    try {
+                        inet = InetAddress.getLocalHost();
+                    } catch (UnknownHostException e) {
+                        e.printStackTrace();
+                    }
+                    ipAddress = inet.getHostAddress();
+                }
+            }
+            // 对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
+            if (ipAddress != null && ipAddress.length() > 15) { // "***.***.***.***".length()
+                // = 15
+                if (ipAddress.indexOf(",") > 0) {
+                    ipAddress = ipAddress.substring(0, ipAddress.indexOf(","));
+                }
+            }
+        } catch (Exception e) {
+            ipAddress="";
+        }
+        // ipAddress = this.getRequest().getRemoteAddr();
+
+        return ipAddress;
+    }
+
+}

+ 140 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/util/JwtUtils.java

@@ -0,0 +1,140 @@
+package com.huimv.manager.util;
+
+import io.jsonwebtoken.*;
+import org.springframework.util.StringUtils;
+
+import javax.crypto.SecretKey;
+import javax.crypto.spec.SecretKeySpec;
+import javax.servlet.http.HttpServletRequest;
+import java.util.Base64;
+import java.util.Date;
+
+/**
+ * @author yinhao
+ * @since 2021/4/19
+ */
+public class JwtUtils {
+
+//    /**
+//     * 一天
+//     */
+//    private static final long EXPIRE = 1000 * 60 * 60 * 24;
+
+    /**
+     * 一小时
+     */
+    private static final long EXPIRE = 1000 * 60 * 60;
+
+    private static final String APP_SECRET = "ukc8BDbRigUDaY6pZFfWus2jZWLPHO";
+    private static final int REFRESH_TIME = 300;
+
+    public static String getJwtToken(Integer id) {
+
+        String JwtToken = Jwts.builder()
+                //头部信息
+                .setHeaderParam("typ", "JWT")
+                .setHeaderParam("alg", "HS256")
+                .setSubject("hm-user")
+                .setIssuedAt(new Date())
+                //过期时间
+                .setExpiration(new Date(System.currentTimeMillis() + EXPIRE))
+                //token主体部分,存储用户信息
+                .claim("id", id)
+                .signWith(SignatureAlgorithm.HS256, APP_SECRET)
+                .compact();
+
+        return JwtToken;
+    }
+
+    /**
+     * 判断token是否存在与有效
+     *
+     * @param jwtToken
+     * @return
+     */
+    public static boolean checkToken(String jwtToken) {
+        if (StringUtils.isEmpty(jwtToken)) {
+            return false;
+        }
+        try {
+            Jwts.parser().setSigningKey(APP_SECRET).parseClaimsJws(jwtToken);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * 判断token是否存在与有效
+     *
+     * @param request
+     * @return
+     */
+    public static boolean checkToken(HttpServletRequest request) {
+        try {
+            String jwtToken = request.getHeader("token");
+            if (StringUtils.isEmpty(jwtToken)) {
+                return false;
+            }
+            Jwts.parser().setSigningKey(APP_SECRET).parseClaimsJws(jwtToken);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * 根据token获取会员id
+     *
+     * @param request
+     * @return
+     */
+    public static Integer getMemberIdByJwtToken(HttpServletRequest request) {
+        String jwtToken = request.getHeader("token");
+        if (StringUtils.isEmpty(jwtToken)) {
+            return null;
+        }
+        Claims claims = getClaims(jwtToken);
+        return (Integer) claims.get("id");
+    }
+
+
+    /**
+     * 获取claims对象
+     *
+     * @param jwtToken
+     * @return
+     */
+    public static Claims getClaims(String jwtToken) {
+        Jws<Claims> claimsJws = Jwts.parser().setSigningKey(APP_SECRET).parseClaimsJws(jwtToken);
+        return claimsJws.getBody();
+    }
+
+    /**
+     * 是否过期
+     *
+     * @param claims
+     * @return -1:有效,0:有效,1:过期,2:被篡改
+     */
+    public static int verifyToken(Claims claims) {
+        if (claims == null) {
+            return 1;
+        }
+        try {
+            claims.getExpiration()
+                    .before(new Date());
+            // 需要自动刷新TOKEN
+            if ((claims.getExpiration().getTime() - System.currentTimeMillis()) < REFRESH_TIME * 1000) {
+                return -1;
+            } else {
+                return 0;
+            }
+        } catch (ExpiredJwtException ex) {
+            return 1;
+        } catch (Exception e) {
+            return 2;
+        }
+    }
+}

+ 85 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/util/PropertiesUtils.java

@@ -0,0 +1,85 @@
+package com.huimv.manager.util;
+
+import java.io.*;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.video.util
+ * @Description : TODO
+ * @Author : yuxuexuan
+ * @Create : 2021/3/4 0008 16:03
+ **/
+public  class PropertiesUtils {
+
+    /**
+     * 根据key获取prpperties中的某一项值
+     * @param key
+     * @param fileURL properties地址
+     * @return
+     */
+    public static String getFileIO(String key, String fileURL) {
+        java.util.Properties prop = new java.util.Properties();
+        InputStream in=null;
+        try {
+            in = new BufferedInputStream(new FileInputStream(fileURL));
+            prop.load(in);
+            //根据key 获得所对应的value
+            return prop.getProperty(key);
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                in.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return null;
+    }
+    /**
+     * 修改并写properties
+     * @param map
+     * @param fileURL
+     * @return
+     */
+    public static boolean writeData(Map<String, Object> map, String fileURL) {
+        java.util.Properties prop = new java.util.Properties();
+        InputStream fis = null;
+        OutputStream fos = null;
+        try {
+            //获得文件
+            File file = new File(fileURL);
+            //查看文件是否存在
+            if (!file.exists()){
+                return false;
+            }
+            fis = new FileInputStream(file);
+            prop.load(fis);
+            fis.close();// 一定要在修改值之前关闭fis
+            fos = new FileOutputStream(file);
+            Iterator<Map.Entry<String, Object>> valueSet = map.entrySet().iterator();
+            //便利map的值
+            while (valueSet.hasNext()) {
+                Map.Entry<String, Object> entry = (Map.Entry<String, Object>) valueSet.next();
+                String key = entry.getKey().toString();
+                String value= entry.getValue().toString();
+                prop.setProperty(key, value);
+                prop.store(fos, "Update '" + key + "' value");
+            }
+            fos.close();
+            return true;
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                fos.close();
+                fis.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return false;
+    }
+}

+ 121 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/util/VerifyUtil.java

@@ -0,0 +1,121 @@
+package com.huimv.manager.util;
+
+import com.huimv.manager.exception.RRException;
+
+import javax.imageio.ImageIO;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.image.BufferedImage;
+import java.util.Random;
+ 
+ 
+public class VerifyUtil {
+//    public static final String RANDOMCODEKEY = "RANDOMREDISKEY";//放到session中的key
+    private String randString = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";//随机产生数字与字母组合的字符串
+    private int width = 95;// 图片宽
+    private int height = 25;// 图片高
+    private int lineSize = 40;// 干扰线数量
+    private int stringNum = 4;// 随机产生字符数量
+
+    private Random random = new Random();
+
+    /**
+     * 获得字体
+     */
+    private Font getFont() {
+        return new Font("Fixedsys", Font.CENTER_BASELINE, 18);
+    }
+
+    /**
+     * 获得颜色
+     */
+    private Color getRandColor(int fc, int bc) {
+        if (fc > 255) {
+            fc = 255;
+        }
+        if (bc > 255) {
+            bc = 255;
+        }
+        int r = fc + random.nextInt(bc - fc - 16);
+        int g = fc + random.nextInt(bc - fc - 14);
+        int b = fc + random.nextInt(bc - fc - 18);
+        return new Color(r, g, b);
+    }
+
+    /**
+     * 生成随机图片
+     */
+    public String getRandcode(HttpServletRequest request, HttpServletResponse response) {
+        // BufferedImage类是具有缓冲区的Image类,Image类是用于描述图像信息的类
+        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR);
+        // 产生Image对象的Graphics对象,改对象可以在图像上进行各种绘制操作
+        Graphics g = image.getGraphics();
+        //图片大小
+        g.fillRect(0, 0, width, height);
+        //字体大小
+        g.setFont(new Font("Times New Roman", Font.ROMAN_BASELINE, 18));
+        //字体颜色
+        g.setColor(getRandColor(110, 133));
+        // 绘制干扰线
+        for (int i = 0; i <= lineSize; i++) {
+            drowLine(g);
+        }
+        // 绘制随机字符
+        String randomString = "";
+        for (int i = 1; i <= stringNum; i++) {
+            randomString = drowString(g, randomString, i);
+        }
+        //将生成的随机字符串保存到session中
+//        session.removeAttribute(RANDOMCODEKEY);
+//        session.setAttribute(RANDOMCODEKEY, randomString);
+        //设置失效时间1分钟
+//        session.setMaxInactiveInterval(60);
+        g.dispose();
+        try {
+            // 将内存中的图片通过流动形式输出到客户端
+            ImageIO.write(image, "JPEG", response.getOutputStream());
+            return randomString;
+        } catch (Exception e) {
+            throw new RRException("获取验证码失败!");
+        }
+
+    }
+
+    /**
+     * 绘制字符串
+     */
+    private String drowString(Graphics g, String randomString, int i) {
+        g.setFont(getFont());
+        g.setColor(new Color(random.nextInt(101), random.nextInt(111), random
+                .nextInt(121)));
+        String rand = String.valueOf(getRandomString(random.nextInt(randString
+                .length())));
+        randomString += rand;
+        g.translate(random.nextInt(3), random.nextInt(3));
+        g.drawString(rand, 13 * i, 16);
+        return randomString;
+    }
+
+    /**
+     * 绘制干扰线
+     */
+    private void drowLine(Graphics g) {
+        int x = random.nextInt(width);
+        int y = random.nextInt(height);
+        int xl = random.nextInt(13);
+        int yl = random.nextInt(15);
+        g.drawLine(x, y, x + xl, y + yl);
+    }
+
+    /**
+     * 获取随机的字符
+     */
+    public String getRandomString(int num) {
+        return String.valueOf(randString.charAt(num));
+    }
+}
+ 

+ 12 - 2
huimv-mobile-video/huimv-manager/src/main/resources/application-dev.yml

@@ -12,11 +12,21 @@ spring:
   jpa:
     show-sql: true
     database: mysql
-    hibernate:
-      ddl-auto: update
+#    hibernate:
+#      ddl-auto: update
     database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
     open-in-view: true
 
+ # 验证码
+#dustlight:
+#  captcha:
+#    default:
+#      store:
+#        name: "redisCodeStore"
+#    store:
+#      redis:
+#        key-prefix: "CAPTCHA_CODE"
+
     #  redis:
 #    database: 0
 #    host: 119.3.84.55

+ 29 - 0
huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/controller/MobileApiController.java

@@ -0,0 +1,29 @@
+package com.huimv.mobile.controller;
+
+import com.huimv.mobile.domain.MobileApi;
+import com.huimv.mobile.result.Result;
+import com.huimv.mobile.service.MobileApiService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.mobile.controller
+ * @Description : TODO
+ * @Author : yuxuexuan
+ * @Create : 2021/4/19 0019 13:52
+ **/
+@RestController
+@RequestMapping("/api")
+@CrossOrigin
+public class MobileApiController {
+
+    @Autowired
+    private MobileApiService mobileApiService;
+
+    public Result findAll(){
+        return  mobileApiService.findAll();
+    }
+}

+ 36 - 0
huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/controller/MobileLastController.java

@@ -0,0 +1,36 @@
+package com.huimv.mobile.controller;
+
+import com.huimv.mobile.domain.MobileLast;
+import com.huimv.mobile.result.Result;
+import com.huimv.mobile.service.MobileLastService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.mobile.controller
+ * @Description : TODO
+ * @Author : yuxuexuan
+ * @Create : 2021/4/20 0020 17:41
+ **/
+@RestController
+@CrossOrigin
+@RequestMapping("/last")
+public class MobileLastController {
+    @Autowired
+    MobileLastService mobileLastService;
+
+    @RequestMapping("/add")
+    public Result add(MobileLast mobileLast){
+        return mobileLastService.add(mobileLast);
+    }
+
+    @RequestMapping("/findLast")
+    public Result findLast(Integer userId){
+        return mobileLastService.findLast(userId);
+    }
+
+
+}

+ 70 - 0
huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/controller/MobileUserController.java

@@ -0,0 +1,70 @@
+package com.huimv.mobile.controller;
+
+import com.huimv.mobile.result.Result;
+import com.huimv.mobile.service.MobileUserService;
+import com.huimv.mobile.utils.CheckNumber;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.imageio.ImageIO;
+import javax.servlet.http.HttpServletResponse;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.mobile.controller
+ * @Description : TODO
+ * @Author : yuxuexuan
+ * @Create : 2021/4/19 0019 14:22
+ **/
+@RestController
+@RequestMapping("/mobileUser")
+@CrossOrigin
+public class MobileUserController {
+
+    @Autowired
+    private MobileUserService userService;
+
+    @RequestMapping("/login")
+    public Result login(String account,String password){
+        return userService.login(account,password);
+    }
+
+    @RequestMapping("/updatePassword")
+    public Result updatePassword(Integer userId,String oldPassword,String  newPassword){
+        return userService.updatePassword(userId,oldPassword,newPassword);
+    }
+
+
+
+
+    private static String text;
+    //获取验证码
+    @RequestMapping(value = "getCheckNumber", produces = {"text/html;charset=UTF-8"})
+    public void getCheckNumber(HttpServletResponse response) throws IOException {
+        //创建对象
+        CheckNumber checkNumber = new CheckNumber();
+        //获取图片对象
+        BufferedImage image = checkNumber.getImage();
+        //获得图片的文本内容
+        text = checkNumber.getText();
+        //把图片返回前端
+        ImageIO.write(image, "JPEG", response.getOutputStream());
+    }
+
+    @RequestMapping("/checkNumber")
+    public Result checkNumber(String userCaptcha){
+        //获取用户输入的校验码并进行比较
+        // String sessionCheckNumber = (String) session.getAttribute("checkNumber");
+        System.out.println(userCaptcha +":"+ text);
+        if (text.equalsIgnoreCase(userCaptcha)) {
+            return new Result(10001,"验证码正确",true);
+        }
+        return new Result(10002,"验证码错误",false);
+    }
+
+
+}

+ 44 - 0
huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/domain/MobileApi.java

@@ -0,0 +1,44 @@
+package com.huimv.mobile.domain;
+
+import lombok.Data;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+@Entity
+@Table(name = "mobile_api")
+@Data
+public class MobileApi implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id", nullable = false)
+    private Integer id;
+
+    /**
+     * 牧场名称
+     */
+    @Column(name = "farm_name")
+    private String farmName;
+
+    /**
+     * 牧场id
+     */
+    @Column(name = "farm_id")
+    private Integer farmId;
+
+    /**
+     * API接口
+     */
+    @Column(name = "url")
+    private String url;
+
+    /**
+     * 备注
+     */
+    @Column(name = "remark")
+    private String remark;
+
+}

+ 38 - 0
huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/domain/MobileAttention.java

@@ -0,0 +1,38 @@
+package com.huimv.mobile.domain;
+
+import lombok.Data;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+@Entity
+@Table(name = "mobile_attention")
+@Data
+public class MobileAttention implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id", nullable = false)
+    private Integer id;
+
+    /**
+     * 用户id
+     */
+    @Column(name = "user_id")
+    private Integer userId;
+
+    /**
+     * 显示区域
+     */
+    @Column(name = "area_id")
+    private Integer areaId;
+
+    /**
+     * 单位id
+     */
+    @Column(name = "unit_id")
+    private Integer unitId;
+
+}

+ 32 - 0
huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/domain/MobileLast.java

@@ -0,0 +1,32 @@
+package com.huimv.mobile.domain;
+
+import lombok.Data;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+@Entity
+@Data
+@Table(name = "mobile_last")
+public class MobileLast implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id", nullable = false)
+    private Integer id;
+
+    @Column(name = "api")
+    private String api;
+
+    @Column(name = "user_id")
+    private Integer userId;
+
+    @Column(name = "full_name")
+    private String fullName;
+
+    @Column(name = "fid")
+    private Integer fid;
+
+}

+ 33 - 0
huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/domain/MobileMemorandum.java

@@ -0,0 +1,33 @@
+package com.huimv.mobile.domain;
+
+import lombok.Data;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+
+@Entity
+@Table(name = "mobile_memorandum")
+@Data
+public class MobileMemorandum implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id", nullable = false)
+    private Integer id;
+
+    @Column(name = "user_id")
+    private Integer userId;
+
+    @Column(name = "content")
+    private String content;
+
+    @Column(name = "title")
+    private String title;
+
+    @Column(name = "date")
+    private Date date;
+
+}

+ 29 - 0
huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/domain/MobileRemember.java

@@ -0,0 +1,29 @@
+package com.huimv.mobile.domain;
+
+import lombok.Data;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+@Entity
+@Table(name = "mobile_remember")
+@Data
+public class MobileRemember implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id", nullable = false)
+    private Integer id;
+
+    @Column(name = "user_id")
+    private Integer userId;
+
+    @Column(name = "issue")
+    private String issue;
+
+    @Column(name = "answer")
+    private String answer;
+
+}

+ 44 - 0
huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/domain/MobileUnit.java

@@ -0,0 +1,44 @@
+package com.huimv.mobile.domain;
+
+import lombok.Data;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+@Entity
+@Data
+@Table(name = "mobile_unit")
+public class MobileUnit implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id", nullable = false)
+    private Integer id;
+
+    /**
+     * 单位全称
+     */
+    @Column(name = "full_name")
+    private String fullName;
+
+    /**
+     * 单位简称
+     */
+    @Column(name = "short_name")
+    private String shortName;
+
+    /**
+     * 备注
+     */
+    @Column(name = "remark")
+    private String remark;
+
+    /**
+     * api
+     */
+    @Column(name = "api")
+    private String api;
+
+}

+ 68 - 0
huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/domain/MobileUser.java

@@ -0,0 +1,68 @@
+package com.huimv.mobile.domain;
+
+import lombok.Data;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+@Entity
+@Data
+@Table(name = "mobile_user")
+public class MobileUser implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id", nullable = false)
+    private Integer id;
+
+    /**
+     * 姓名
+     */
+    @Column(name = "user_name")
+    private String userName;
+
+    /**
+     * 密码
+     */
+    @Column(name = "password")
+    private String password;
+
+    /**
+     * 账号
+     */
+    @Column(name = "account")
+    private String account;
+
+    /**
+     * 账号状态
+     */
+    @Column(name = "status")
+    private Integer status;
+
+    /**
+     * 所属单位
+     */
+    @Column(name = "unit")
+    private String unit;
+
+    /**
+     * 所属单位id
+     */
+    @Column(name = "unit_id")
+    private Integer unitId;
+
+    /**
+     * 职务
+     */
+    @Column(name = "job")
+    private String job;
+
+    /**
+     * 权限级别
+     */
+    @Column(name = "grant_class")
+    private Integer grantClass;
+
+}

+ 10 - 0
huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/repo/MobileApiRepository.java

@@ -0,0 +1,10 @@
+package com.huimv.mobile.repo;
+
+import com.huimv.mobile.domain.MobileApi;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+public interface MobileApiRepository extends JpaRepository<MobileApi, Integer>, JpaSpecificationExecutor<MobileApi> {
+
+    MobileApi findByFarmId(Integer id);
+}

+ 9 - 0
huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/repo/MobileAttentionRepository.java

@@ -0,0 +1,9 @@
+package com.huimv.mobile.repo;
+
+import com.huimv.mobile.domain.MobileAttention;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+public interface MobileAttentionRepository extends JpaRepository<MobileAttention, Integer>, JpaSpecificationExecutor<MobileAttention> {
+
+}

+ 15 - 0
huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/repo/MobileLastRepository.java

@@ -0,0 +1,15 @@
+package com.huimv.mobile.repo;
+
+import com.huimv.mobile.domain.MobileLast;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
+
+public interface MobileLastRepository extends JpaRepository<MobileLast, Integer>, JpaSpecificationExecutor<MobileLast> {
+
+//    @Query(nativeQuery = true , value ="select * from mobile_last where user_id = ?1 limit 1 DESC ")
+//    MobileLast findByUserId(Integer userId);
+
+
+    MobileLast findByUserId(Integer userId);
+}

+ 9 - 0
huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/repo/MobileMemorandumRepository.java

@@ -0,0 +1,9 @@
+package com.huimv.mobile.repo;
+
+import com.huimv.mobile.domain.MobileMemorandum;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+public interface MobileMemorandumRepository extends JpaRepository<MobileMemorandum, Integer>, JpaSpecificationExecutor<MobileMemorandum> {
+
+}

+ 9 - 0
huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/repo/MobileRememberRepository.java

@@ -0,0 +1,9 @@
+package com.huimv.mobile.repo;
+
+import com.huimv.mobile.domain.MobileRemember;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+public interface MobileRememberRepository extends JpaRepository<MobileRemember, Integer>, JpaSpecificationExecutor<MobileRemember> {
+
+}

+ 10 - 0
huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/repo/MobileUnitRepository.java

@@ -0,0 +1,10 @@
+package com.huimv.mobile.repo;
+
+import com.huimv.mobile.domain.MobileUnit;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+public interface MobileUnitRepository extends JpaRepository<MobileUnit, Integer>, JpaSpecificationExecutor<MobileUnit> {
+
+
+}

+ 12 - 0
huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/repo/MobileUserRepository.java

@@ -0,0 +1,12 @@
+package com.huimv.mobile.repo;
+
+import com.huimv.mobile.domain.MobileUser;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+public interface MobileUserRepository extends JpaRepository<MobileUser, Integer>, JpaSpecificationExecutor<MobileUser> {
+
+    MobileUser findByAccountAndPassword(String account, String password);
+
+
+}

+ 28 - 0
huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/result/Result.java

@@ -0,0 +1,28 @@
+package com.huimv.mobile.result;
+
+import lombok.Data;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.face.result
+ * @Description : TODO
+ * @Author : yuxuexuan
+ * @Create : 2020/12/29 0029 14:46
+ **/
+@Data
+public class Result {
+    private Integer  status;
+    private String msg;
+    private Object data;
+
+    public Result(Integer status, String msg, Object data) {
+        this.status = status;
+        this.msg = msg;
+        this.data = data;
+    }
+
+    public Result(Integer status, String msg) {
+        this.status = status;
+        this.msg = msg;
+    }
+}

+ 14 - 0
huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/service/MobileApiService.java

@@ -0,0 +1,14 @@
+package com.huimv.mobile.service;
+
+import com.huimv.mobile.result.Result;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.mobile.service
+ * @Description : TODO
+ * @Author : yuxuexuan
+ * @Create : 2021/4/19 0019 13:54
+ **/
+public interface MobileApiService {
+    Result findAll();
+}

+ 17 - 0
huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/service/MobileLastService.java

@@ -0,0 +1,17 @@
+package com.huimv.mobile.service;
+
+import com.huimv.mobile.domain.MobileLast;
+import com.huimv.mobile.result.Result;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.mobile.service
+ * @Description : TODO
+ * @Author : yuxuexuan
+ * @Create : 2021/4/20 0020 17:42
+ **/
+public interface MobileLastService {
+    Result add(MobileLast mobileLast);
+
+    Result findLast(Integer userId);
+}

+ 16 - 0
huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/service/MobileUserService.java

@@ -0,0 +1,16 @@
+package com.huimv.mobile.service;
+
+import com.huimv.mobile.result.Result;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.mobile.service
+ * @Description : TODO
+ * @Author : yuxuexuan
+ * @Create : 2021/4/19 0019 14:23
+ **/
+public interface MobileUserService {
+    Result login(String account, String password);
+
+    Result updatePassword(Integer userId, String oldPassword, String newPassword);
+}

+ 32 - 0
huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/service/impl/MobileApiServiceImpl.java

@@ -0,0 +1,32 @@
+package com.huimv.mobile.service.impl;
+
+import com.huimv.mobile.domain.MobileApi;
+import com.huimv.mobile.repo.MobileApiRepository;
+import com.huimv.mobile.result.Result;
+import com.huimv.mobile.service.MobileApiService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.mobile.service.impl
+ * @Description : TODO
+ * @Author : yuxuexuan
+ * @Create : 2021/4/19 0019 13:54
+ **/
+@Service
+public class MobileApiServiceImpl implements MobileApiService {
+
+
+    @Autowired
+    private MobileApiRepository mobileApiRepository;
+
+
+    @Override
+    public Result findAll() {
+        List<MobileApi> all = mobileApiRepository.findAll();
+        return new Result(10000,"查询成功",all);
+    }
+}

+ 40 - 0
huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/service/impl/MobileLastServiceImpl.java

@@ -0,0 +1,40 @@
+package com.huimv.mobile.service.impl;
+
+import com.huimv.mobile.domain.MobileLast;
+import com.huimv.mobile.repo.MobileLastRepository;
+import com.huimv.mobile.result.Result;
+import com.huimv.mobile.service.MobileLastService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.mobile.service.impl
+ * @Description : TODO
+ * @Author : yuxuexuan
+ * @Create : 2021/4/20 0020 17:42
+ **/
+@Service
+public class MobileLastServiceImpl implements MobileLastService {
+    @Autowired
+    private MobileLastRepository lastRepository;
+
+    @Override
+    public Result add(MobileLast mobileLast) {
+
+        MobileLast byUserId = lastRepository.findByUserId(mobileLast.getUserId());
+        if (byUserId != null){
+            mobileLast.setId(byUserId.getId());
+        }
+        lastRepository.save(mobileLast);
+        return new Result(10000,"添加成功");
+    }
+
+    @Override
+    public Result findLast(Integer userId) {
+
+        MobileLast byUserId = lastRepository.findByUserId(userId);
+
+        return new Result(10000,"查询成功",byUserId);
+    }
+}

+ 92 - 0
huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/service/impl/MobileUserServiceImpl.java

@@ -0,0 +1,92 @@
+package com.huimv.mobile.service.impl;
+
+import com.huimv.mobile.domain.MobileApi;
+import com.huimv.mobile.domain.MobileUnit;
+import com.huimv.mobile.domain.MobileUser;
+import com.huimv.mobile.repo.MobileApiRepository;
+import com.huimv.mobile.repo.MobileUnitRepository;
+import com.huimv.mobile.repo.MobileUserRepository;
+import com.huimv.mobile.result.Result;
+import com.huimv.mobile.service.MobileUserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.DigestUtils;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.mobile.service.impl
+ * @Description : TODO
+ * @Author : yuxuexuan
+ * @Create : 2021/4/19 0019 14:23
+ **/
+@Service
+public class MobileUserServiceImpl implements MobileUserService {
+
+    @Autowired
+    private MobileUserRepository userRepository;
+
+    @Autowired
+    private MobileUnitRepository mobileUnitRepository;
+
+    @Override
+    public Result login(String account, String password) {
+
+        password = DigestUtils.md5DigestAsHex(password.getBytes());
+        MobileUser mobileUser = userRepository.findByAccountAndPassword(account, password);
+
+        if (mobileUser == null){
+            return new Result(10001,"用户名或密码错误");
+        }
+        if (mobileUser.getStatus() == 0){
+            return new Result(10001,"该账号已停冻结");
+        }
+
+
+
+        Map endMap  = new HashMap();
+        Integer grant = mobileUser.getGrantClass();
+        if (!grant.equals( 3)){
+            List<MobileUnit> all = mobileUnitRepository.findAll();
+            endMap.put("url",all);
+            endMap.put("userName",mobileUser.getUserName());
+            endMap.put("userId",mobileUser.getId());
+            endMap.put("unit",mobileUser.getUnit());
+            endMap.put("grant",grant);
+            endMap.put("account",mobileUser.getAccount());
+            return new Result(10000,"登录成功",endMap);
+        }
+        if (grant == 3){
+
+            String api =  mobileUnitRepository.findById(mobileUser.getUnitId()).get().getApi();
+            endMap.put("url",api);
+            endMap.put("userName",mobileUser.getUserName());
+            endMap.put("userId",mobileUser.getId());
+            endMap.put("unit",mobileUser.getUnit());
+            endMap.put("grant",grant);
+            return new Result(10000,"登录成功",endMap);
+        }else {
+            return new Result(10002,"未找到权限信息");
+        }
+
+    }
+
+    @Override
+    public Result updatePassword(Integer userId, String oldPassword, String newPassword) {
+        oldPassword = DigestUtils.md5DigestAsHex(oldPassword.getBytes());
+        newPassword = DigestUtils.md5DigestAsHex(newPassword.getBytes());
+
+        MobileUser mobileUser = userRepository.findById(userId).get();
+        if (!mobileUser.getPassword().equals(oldPassword)){
+            return new Result(10001,"原密码错误");
+        }
+        mobileUser.setPassword(newPassword);
+        userRepository.save(mobileUser);
+
+        return new Result(10000,"修改成功");
+    }
+}

+ 100 - 0
huimv-mobile-video/huimv-mobile/src/main/java/com/huimv/mobile/utils/CheckNumber.java

@@ -0,0 +1,100 @@
+package com.huimv.mobile.utils;
+
+import javax.imageio.ImageIO;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Random;
+
+public class CheckNumber {
+    private int w = 70;//验证码图片宽
+    private int h = 35;//验证码图片高
+    private Random r = new Random();//随机对象
+    // {"宋体", "华文楷体", "黑体", "华文新魏", "华文隶书", "微软雅黑", "楷体_GB2312"}
+    private String[] fontNames = {"宋体", "华文楷体", "黑体", "微软雅黑", "楷体_GB2312"};
+    // 可选字符
+    private String codes = "0123456789abcdefghjkmnopqrstuvwxyz";
+    // 背景色
+    private Color bgColor = new Color(255, 255, 255);
+    // 验证码上的文本
+    private String text;
+
+    // 生成随机的颜色
+    private Color randomColor() {
+        int red = r.nextInt(150);
+        int green = r.nextInt(150);
+        int blue = r.nextInt(150);
+        return new Color(red, green, blue);
+    }
+
+    // 生成随机的字体
+    private Font randomFont() {
+        int index = r.nextInt(fontNames.length);
+        String fontName = fontNames[index];//生成随机的字体名称
+        int style = r.nextInt(4);//生成随机的样式, 0(无样式), 1(粗体), 2(斜体), 3(粗体+斜体)
+        int size = r.nextInt(5) + 24; //生成随机字号, 24 ~ 28
+        //Font对象的参数:1.字体名称2.字体样式3.字体大小
+        return new Font(fontName, style, size);
+    }
+
+    // 传入一个BufferImage对象,给图片画干扰线
+    private void drawLine(BufferedImage image) {
+        int num = 3;//一共画3条
+        Graphics2D g2 = (Graphics2D) image.getGraphics();
+        for (int i = 0; i < num; i++) {//生成两个点的坐标,即4个值
+            int x1 = r.nextInt(w);
+            int y1 = r.nextInt(h);
+            int x2 = r.nextInt(w);
+            int y2 = r.nextInt(h);
+            g2.setStroke(new BasicStroke(1.5F));
+            g2.setColor(Color.BLUE); //干扰线是蓝色
+            g2.drawLine(x1, y1, x2, y2);//画线
+        }
+    }
+
+    // 随机生成一个字符
+    private char randomChar() {
+        int index = r.nextInt(codes.length());
+        return codes.charAt(index);
+    }
+
+    // 创建BufferedImage
+    private BufferedImage createImage() {
+        BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
+        Graphics2D g2 = (Graphics2D) image.getGraphics();
+        g2.setColor(this.bgColor);
+        g2.fillRect(0, 0, w, h);
+        return image;
+    }
+
+    // 调用这个方法得到验证码
+    public BufferedImage getImage() {
+        BufferedImage image = createImage();//创建图片缓冲区
+        Graphics2D g2 = (Graphics2D) image.getGraphics();//得到绘制环境
+        StringBuilder sb = new StringBuilder();//用来装载生成的验证码文本
+        // 向图片中画4个字符
+        for (int i = 0; i < 4; i++) {//循环四次,每次生成一个字符
+            String s = randomChar() + "";//随机生成一个字母
+            sb.append(s); //把字母添加到sb中
+            float x = i * 1.0F * w / 4; //设置当前字符的x轴坐标
+            g2.setFont(randomFont()); //设置随机字体
+            g2.setColor(randomColor()); //设置随机颜色
+            g2.drawString(s, x, h - 5); //画图
+        }
+        this.text = sb.toString(); //把生成的字符串赋给了this.text
+        drawLine(image); //添加干扰线
+        return image;
+    }
+
+    // 返回验证码图片上的文本
+    public String getText() {
+        return text;
+    }
+
+    // 保存图片到指定的输出流
+    public static void output(BufferedImage image, OutputStream out)
+            throws IOException {
+        ImageIO.write(image, "JPEG", out);
+    }
+}

+ 1 - 1
huimv-mobile-video/pom.xml

@@ -58,7 +58,7 @@
 		<dependency>
 			<groupId>com.alibaba</groupId>
 			<artifactId>druid-spring-boot-starter</artifactId>
-			<version>1.1.23</version>
+			<version>1.2.2</version>
 		</dependency>
 
 		<dependency>