523096025 4 年 前
コミット
3e8e1257fa
20 ファイル変更446 行追加21 行削除
  1. 6 0
      huimv-smart-apiservice/pom.xml
  2. 34 0
      huimv-smart-apiservice/src/main/java/com/huimv/apiservice/controller/TokenController.java
  3. 1 1
      huimv-smart-apiservice/src/main/resources/application-dev.yml
  4. 6 0
      huimv-smart-common/pom.xml
  5. 60 0
      huimv-smart-common/src/main/java/com/huimv/common/utils/TokenUtil.java
  6. 36 0
      huimv-smart-gateway/src/main/java/com/huimv/gateway/config/GatewayCrosConfig.java
  7. 0 1
      huimv-smart-gateway/src/main/resources/application.properties
  8. 24 12
      huimv-smart-gateway/src/main/resources/application.yml
  9. 2 0
      huimv-smart-management/src/main/java/com/huimv/management/HuimvSmartManagementApplication.java
  10. 97 0
      huimv-smart-management/src/main/java/com/huimv/management/controller/SleepStatusController.java
  11. 21 0
      huimv-smart-management/src/main/java/com/huimv/management/dao/SleepStatusDao.java
  12. 58 0
      huimv-smart-management/src/main/java/com/huimv/management/entity/SleepStatusEntity.java
  13. 23 0
      huimv-smart-management/src/main/java/com/huimv/management/service/SleepStatusService.java
  14. 48 0
      huimv-smart-management/src/main/java/com/huimv/management/service/impl/SleepStatusServiceImpl.java
  15. 1 1
      huimv-smart-management/src/main/resources/application-dev.yml
  16. 23 0
      huimv-smart-management/src/main/resources/mapper/management/SleepStatusDao.xml
  17. 1 1
      renren-fast/src/main/resources/application-dev.yml
  18. 2 2
      renren-fast/src/main/resources/bootstrap.properties
  19. 1 1
      renren-generator/src/main/resources/application.yml
  20. 2 2
      renren-generator/src/main/resources/generator.properties

+ 6 - 0
huimv-smart-apiservice/pom.xml

@@ -39,6 +39,12 @@
             <artifactId>spring-boot-starter-test</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>5.6.3</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
     <dependencyManagement>
         <dependencies>

+ 34 - 0
huimv-smart-apiservice/src/main/java/com/huimv/apiservice/controller/TokenController.java

@@ -0,0 +1,34 @@
+package com.huimv.apiservice.controller;
+
+import cn.hutool.json.JSONObject;
+import com.huimv.common.utils.TokenUtil;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.apiservice.controller
+ * @Description : TODO
+ * @Author : yuxuexuan
+ * @Create : 2021/4/28 0028 17:24
+ **/
+@RestController
+public class TokenController {
+
+    @RequestMapping("/getToken")
+    public JSONObject login(String  userName){
+
+        JSONObject result = new JSONObject();
+        String token = TokenUtil.sign(userName);
+        System.out.println(token);
+        result.put("state",200);
+        result.put("token",token);
+
+        return  result;
+    }
+
+    @RequestMapping("/verify")
+    public boolean getToken(String  verify){
+        return  TokenUtil.verify(verify);
+    }
+}

+ 1 - 1
huimv-smart-apiservice/src/main/resources/application-dev.yml

@@ -24,7 +24,7 @@ spring:
     type: com.alibaba.druid.pool.DruidDataSource
     druid:
       driver-class-name: com.mysql.cj.jdbc.Driver
-      url: jdbc:mysql://localhost:3306/testdb?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
+      url: jdbc:mysql://localhost:3306/huimv_smart_msg?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
       username: root
       password: root
       initial-size: 10

+ 6 - 0
huimv-smart-common/pom.xml

@@ -74,6 +74,12 @@
             <version>1.5.2</version>
             <!--<scope>provided</scope>-->
         </dependency>
+        <!-- jwt -->
+        <dependency>
+            <groupId>com.auth0</groupId>
+            <artifactId>java-jwt</artifactId>
+            <version>3.8.3</version>
+        </dependency>
 
         <!--knife4j-->
         <dependency>

+ 60 - 0
huimv-smart-common/src/main/java/com/huimv/common/utils/TokenUtil.java

@@ -0,0 +1,60 @@
+package com.huimv.common.utils;
+
+
+import com.auth0.jwt.JWT;
+import com.auth0.jwt.JWTVerifier;
+import com.auth0.jwt.algorithms.Algorithm;
+import com.auth0.jwt.interfaces.DecodedJWT;
+
+import java.util.Date;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.example.demo.util
+ * @Description : TODO
+ * @Author : yuxuexuan
+ * @Create : 2021/2/26 0026 9:06
+ **/
+public class TokenUtil {
+
+    private static final long EXPIRE_TIME = 60*1000;  //有效时长
+    private static final String TOKEN_SECRET = "ben";       // 秘钥
+
+    /**
+     * 签名 生成
+     * @parm userName
+     * */
+    public static String sign(String userName){
+        String token = null;
+        try {
+            Date expiresAt = new Date(System.currentTimeMillis()+EXPIRE_TIME);
+            token = JWT.create()
+                    .withIssuer("auth0")
+                    .withClaim("userName",userName)
+                    .withExpiresAt(expiresAt)
+                    //使用HMAC256算法加密
+                    .sign(Algorithm.HMAC256(TOKEN_SECRET));
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return token;
+    }
+
+    /**
+     * 签名验证
+     * @param token
+     * */
+    public static boolean verify(String token){
+        try {
+            JWTVerifier verifier = JWT.require(Algorithm.HMAC256(TOKEN_SECRET))
+                    .withIssuer("auth0").build();
+            DecodedJWT jwt = verifier.verify(token);
+            System.out.println("认证通过");
+            System.out.println("userName:"+jwt.getClaims().toString());
+            System.out.println("过期时间:"+jwt.getExpiresAt());
+            return true;
+        }catch (Exception e){
+            return false;
+        }
+    }
+}

+ 36 - 0
huimv-smart-gateway/src/main/java/com/huimv/gateway/config/GatewayCrosConfig.java

@@ -0,0 +1,36 @@
+package com.huimv.gateway.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.cors.CorsConfiguration;
+import org.springframework.web.cors.reactive.CorsWebFilter;
+import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;
+
+import java.util.Collections;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.gateway.config
+ * @Description : TODO
+ * @Author : yuxuexuan
+ * @Create : 2021/4/28 0028 15:45
+ **/
+@Configuration
+public class GatewayCrosConfig {
+    @Bean
+    public CorsWebFilter corsWebFilter(){
+
+        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
+        CorsConfiguration corsConfiguration = new CorsConfiguration();
+        //1.配置跨域
+        corsConfiguration.addAllowedHeader("*");
+        corsConfiguration.addAllowedMethod("*");
+//        corsConfiguration.addAllowedOrigin("*");
+        corsConfiguration.setAllowedOriginPatterns(Collections.singletonList("*"));
+        corsConfiguration.setAllowCredentials(true);
+
+
+        source.registerCorsConfiguration("/**",corsConfiguration);
+        return new CorsWebFilter(source);
+    }
+}

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

@@ -1 +0,0 @@
-

+ 24 - 12
huimv-smart-gateway/src/main/resources/application.yml

@@ -1,18 +1,30 @@
 spring:
-#  cloud:
+  cloud:
 #    nacos:
 #      discovery:
 #        server-addr: 127.0.0.1:8848
-
-#    gateway:
-#      routes:
-#        # renren-fast后台管理系统的路由(低优先级的放在下面)
-#        - id: admin_route
-#          uri: lb://renren-fast
-#          predicates:
-#            - Path=/api/**
-#          filters:
-#            - RewritePath=/api/(?<segment>/?.*), /renren-fast/$\{segment}
+    gateway:
+#      globalcors:
+#        cors-configurations:
+#          '[/**]':
+#            allowedHeaders: "*"
+#            allowedOrigins: "*"
+##            allowCredentials: true
+#            allowedMethods:
+#              - GET
+#              - POST
+#              - DELETE
+#              - PUT
+#              - OPTION
+#            maxAge: 1800
+      routes:
+        # renren-fast后台管理系统的路由(低优先级的放在下面)
+        - id: admin_route
+          uri: http://192.168.1.54:9500
+          predicates:
+            - Path=/api/**
+          filters:
+            - RewritePath=/api/(?<segment>/?.*), /renren-fast/$\{segment}
 #      discovery:
 #        locator:
 #          enabled: true                 # 设置为true 请求路径前可以添加微服务名称  http://localhost:88/gateway-provider/goods/findOne/2 -> http://localhost:88/goods/findOne/2
@@ -27,4 +39,4 @@ spring:
 
 
 server:
-  port: 10010
+  port: 88

+ 2 - 0
huimv-smart-management/src/main/java/com/huimv/management/HuimvSmartManagementApplication.java

@@ -1,10 +1,12 @@
 package com.huimv.management;
 
+import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
 
 @SpringBootApplication
+@MapperScan(value = "com.huimv.management.dao")
 public class HuimvSmartManagementApplication {
 
     public static void main(String[] args) {

+ 97 - 0
huimv-smart-management/src/main/java/com/huimv/management/controller/SleepStatusController.java

@@ -0,0 +1,97 @@
+ package com.huimv.management.controller;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.huimv.management.entity.SleepStatusEntity;
+import com.huimv.management.service.SleepStatusService;
+import com.huimv.common.utils.PageUtils;
+import com.huimv.common.utils.R;
+
+
+
+/**
+ * 睡眠状态表
+ *
+ * @author yinhao
+ * @email yinhao@163.com
+ * @date 2021-04-28 13:27:37
+ */
+@RestController
+@RequestMapping("management/sleepstatus")
+public class SleepStatusController {
+    @Autowired
+    private SleepStatusService sleepStatusService;
+
+    /**
+     * 列表
+     */
+    @RequestMapping("/list")
+    //@RequiresPermissions("management:sleepstatus:list")
+    public R list(@RequestParam Map<String, Object> params){
+        PageUtils page = sleepStatusService.queryPage(params);
+
+        return R.ok().put("page", page);
+    }
+    @RequestMapping("/findAll")
+    //@RequiresPermissions("management:sleepstatus:list")
+    public R findAll( ){
+        List<SleepStatusEntity> page = sleepStatusService.findAll();
+
+        return R.ok().put("page", page);
+    }
+
+
+    /**
+     * 信息
+     */
+    @RequestMapping("/info/{id}")
+    //@RequiresPermissions("management:sleepstatus:info")
+    public R info(@PathVariable("id") Integer id){
+		SleepStatusEntity sleepStatus = sleepStatusService.getById(id);
+
+        return R.ok().put("sleepStatus", sleepStatus);
+    }
+
+    /**
+     * 保存
+     */
+    @RequestMapping("/save")
+    //@RequiresPermissions("management:sleepstatus:save")
+    public R save(@RequestBody SleepStatusEntity sleepStatus){
+		sleepStatusService.save(sleepStatus);
+
+        return R.ok();
+    }
+
+    /**
+     * 修改
+     */
+    @RequestMapping("/update")
+    //@RequiresPermissions("management:sleepstatus:update")
+    public R update(@RequestBody SleepStatusEntity sleepStatus){
+		sleepStatusService.updateById(sleepStatus);
+
+        return R.ok();
+    }
+
+    /**
+     * 删除
+     */
+    @RequestMapping("/delete")
+    //@RequiresPermissions("management:sleepstatus:delete")
+    public R delete(@RequestBody Integer[] ids){
+		sleepStatusService.removeByIds(Arrays.asList(ids));
+
+        return R.ok();
+    }
+
+}

+ 21 - 0
huimv-smart-management/src/main/java/com/huimv/management/dao/SleepStatusDao.java

@@ -0,0 +1,21 @@
+package com.huimv.management.dao;
+
+import com.huimv.management.entity.SleepStatusEntity;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+/**
+ * 睡眠状态表
+ * 
+ * @author yinhao
+ * @email yinhao@163.com
+ * @date 2021-04-28 13:27:37
+ */
+@Mapper
+public interface SleepStatusDao extends BaseMapper<SleepStatusEntity> {
+
+
+    List<SleepStatusEntity> findAll();
+}

+ 58 - 0
huimv-smart-management/src/main/java/com/huimv/management/entity/SleepStatusEntity.java

@@ -0,0 +1,58 @@
+package com.huimv.management.entity;
+
+import com.baomidou.mybatisplus.annotation.*;
+
+import java.io.Serializable;
+import java.util.Date;
+import lombok.Data;
+
+/**
+ * 睡眠状态表
+ * 
+ * @author yinhao
+ * @email yinhao@163.com
+ * @date 2021-04-28 13:27:37
+ */
+@Data
+@TableName("mgt_sleep_status")
+public class SleepStatusEntity implements Serializable {
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 
+	 */
+	@TableId
+	private Integer id;
+	/**
+	 * 当前日期
+	 */
+	private Date nowDate;
+	/**
+	 * 入睡时间
+	 */
+	private Date sleepTime;
+	/**
+	 * 睡眠时长
+	 */
+	private String sleepCount;
+	/**
+	 * 采集时间
+	 */
+	private Date collectTime;
+	/**
+	 * 删除状态 0正常 1已删除
+	 */
+	@TableLogic
+	private Boolean deleted;
+	/**
+	 * 创建时间
+	 */
+	@TableField(fill = FieldFill.INSERT)
+	private Date gmtCreate;
+	/**
+	 * 修改时间
+	 */
+	@TableField(fill = FieldFill.INSERT_UPDATE)
+	private Date gmtModified;
+
+}

+ 23 - 0
huimv-smart-management/src/main/java/com/huimv/management/service/SleepStatusService.java

@@ -0,0 +1,23 @@
+package com.huimv.management.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.huimv.common.utils.PageUtils;
+import com.huimv.management.entity.SleepStatusEntity;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 睡眠状态表
+ *
+ * @author yinhao
+ * @email yinhao@163.com
+ * @date 2021-04-28 13:27:37
+ */
+public interface SleepStatusService extends IService<SleepStatusEntity> {
+
+    PageUtils queryPage(Map<String, Object> params);
+
+    List<SleepStatusEntity> findAll();
+}
+

+ 48 - 0
huimv-smart-management/src/main/java/com/huimv/management/service/impl/SleepStatusServiceImpl.java

@@ -0,0 +1,48 @@
+package com.huimv.management.service.impl;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.huimv.common.utils.PageUtils;
+import com.huimv.common.utils.Query;
+
+import com.huimv.management.dao.SleepStatusDao;
+import com.huimv.management.entity.SleepStatusEntity;
+import com.huimv.management.service.SleepStatusService;
+
+
+@Service("sleepStatusService")
+public class SleepStatusServiceImpl extends ServiceImpl<SleepStatusDao, SleepStatusEntity> implements SleepStatusService {
+
+    @Autowired
+    private SleepStatusDao sleepStatusDao;
+
+    @Override
+    public PageUtils queryPage(Map<String, Object> params) {
+
+        QueryWrapper<SleepStatusEntity> queryWrapper = new QueryWrapper<>();
+        queryWrapper.like("sleep_count",params.get("keyWords"));
+        queryWrapper.or().like("gmt_create",params.get("keyWords"));
+        IPage<SleepStatusEntity> page = this.page(
+                new Query<SleepStatusEntity>().getPage(params),
+                queryWrapper
+        );
+
+        return new PageUtils(page);
+    }
+
+
+
+
+    @Override
+    public List<SleepStatusEntity> findAll() {
+
+        return sleepStatusDao.findAll();
+    }
+
+}

+ 1 - 1
huimv-smart-management/src/main/resources/application-dev.yml

@@ -24,7 +24,7 @@ spring:
     type: com.alibaba.druid.pool.DruidDataSource
     druid:
       driver-class-name: com.mysql.cj.jdbc.Driver
-      url: jdbc:mysql://localhost:3306/testdb?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
+      url: jdbc:mysql://localhost:3306/huimv_smart_msg?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
       username: root
       password: root
       initial-size: 10

+ 23 - 0
huimv-smart-management/src/main/resources/mapper/management/SleepStatusDao.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="com.huimv.management.dao.SleepStatusDao">
+
+	<!-- 可根据自己的需求,是否要使用 -->
+    <resultMap type="com.huimv.management.entity.SleepStatusEntity" id="sleepStatusMap">
+        <result property="id" column="id"/>
+        <result property="nowDate" column="now_date"/>
+        <result property="sleepTime" column="sleep_time"/>
+        <result property="sleepCount" column="sleep_count"/>
+        <result property="collectTime" column="collect_time"/>
+        <result property="deleted" column="deleted"/>
+        <result property="gmtCreate" column="gmt_create"/>
+        <result property="gmtModified" column="gmt_modified"/>
+    </resultMap>
+
+    <select id="findAll" resultType="SleepStatusEntity">
+        select * from mgt_sleep_status
+    </select>
+
+
+</mapper>

+ 1 - 1
renren-fast/src/main/resources/application-dev.yml

@@ -3,7 +3,7 @@ spring:
         type: com.alibaba.druid.pool.DruidDataSource
         druid:
             driver-class-name: com.mysql.cj.jdbc.Driver
-            url: jdbc:mysql://localhost:3306/gulimall_admin?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
+            url: jdbc:mysql://localhost:3306/huimv_smart_admin?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
             username: root
             password: root
             initial-size: 10

+ 2 - 2
renren-fast/src/main/resources/bootstrap.properties

@@ -1,8 +1,8 @@
 spring.application.name=renren-fast
 
-spring.cloud.nacos.config.server-addr=127.0.0.1:8848
+#spring.cloud.nacos.config.server-addr=127.0.0.1:8848
 #spring.cloud.nacos.config.namespace=a30af414-c34b-4c17-a783-85d25c5bd4b1
-spring.cloud.nacos.config.namespace=4b390d14-1318-4ae0-941b-2619a8e298f5
+#spring.cloud.nacos.config.namespace=4b390d14-1318-4ae0-941b-2619a8e298f5
 #spring.cloud.nacos.config.group=prod
 #
 #spring.cloud.nacos.config.ext-config[0].data-id=datasource.yml

+ 1 - 1
renren-generator/src/main/resources/application.yml

@@ -7,7 +7,7 @@ spring:
     type: com.alibaba.druid.pool.DruidDataSource
     #MySQL配置
     driverClassName: com.mysql.cj.jdbc.Driver
-    url: jdbc:mysql://localhost:3306/ifm?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
+    url: jdbc:mysql://localhost:3306/huimv_smart_msg?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
     username: root
     password: root
     #oracle配置

+ 2 - 2
renren-generator/src/main/resources/generator.properties

@@ -3,13 +3,13 @@
 mainPath=com.huimv
 #\u5305\u540D
 package=com.huimv
-moduleName=ifm
+moduleName=management
 #\u4F5C\u8005
 author=yinhao
 #Email
 email=yinhao@163.com
 #\u8868\u524D\u7F00(\u7C7B\u540D\u4E0D\u4F1A\u5305\u542B\u8868\u524D\u7F00)
-tablePrefix=ifm_
+tablePrefix=mgt_
 
 #\u7C7B\u578B\u8F6C\u6362\uFF0C\u914D\u7F6E\u4FE1\u606F
 tinyint=Integer