浏览代码

更改了jwttoken

wuweihao 5 年之前
父节点
当前提交
7f6d86942d
共有 29 个文件被更改,包括 900 次插入63 次删除
  1. 2 0
      README.md
  2. 7 0
      pom.xml
  3. 2 0
      xiaoan-application/src/main/resources/application-dev.properties
  4. 5 0
      xiaoan-common/pom.xml
  5. 15 12
      xiaoan-common/src/main/java/com/xiaoan/common/interceptor/AuthHeaderSettingFilter.java
  6. 415 0
      xiaoan-common/src/main/java/com/xiaoan/common/util/FileUtils.java
  7. 34 0
      xiaoan-dao/src/main/java/com/xiaoan/dao/backend/CameraRepository.java
  8. 10 0
      xiaoan-dao/src/main/java/com/xiaoan/dao/backend/SceneRepository.java
  9. 6 0
      xiaoan-dao/src/main/java/com/xiaoan/dao/backend/UserRepository.java
  10. 0 23
      xiaoan-domain/src/main/java/com/xiaoan/domain/backend/DataStatisticsEntity.java
  11. 4 0
      xiaoan-domain/src/main/java/com/xiaoan/domain/backend/UserEntity.java
  12. 1 2
      xiaoan-domain/src/main/java/com/xiaoan/domain/dto/request/UserRequest.java
  13. 17 0
      xiaoan-service/src/main/java/com/xiaoan/service/backend/CameraService.java
  14. 6 0
      xiaoan-service/src/main/java/com/xiaoan/service/backend/SceneService.java
  15. 6 1
      xiaoan-service/src/main/java/com/xiaoan/service/backend/UserService.java
  16. 48 0
      xiaoan-service/src/main/java/com/xiaoan/service/backend/impl/CameraServiceImpl.java
  17. 15 0
      xiaoan-service/src/main/java/com/xiaoan/service/backend/impl/SceneServiceImpl.java
  18. 12 1
      xiaoan-service/src/main/java/com/xiaoan/service/backend/impl/UserServiceImpl.java
  19. 4 2
      xiaoan-web/src/main/java/com/xiaoan/web/aop/WebLogAspect.java
  20. 3 1
      xiaoan-web/src/main/java/com/xiaoan/web/backend/BaseController.java
  21. 0 4
      xiaoan-web/src/main/java/com/xiaoan/web/backend/DepartmentController.java
  22. 78 0
      xiaoan-web/src/main/java/com/xiaoan/web/backend/DeviceController.java
  23. 28 4
      xiaoan-web/src/main/java/com/xiaoan/web/backend/IndexController.java
  24. 50 1
      xiaoan-web/src/main/java/com/xiaoan/web/backend/PersonalCenterController.java
  25. 16 3
      xiaoan-web/src/main/java/com/xiaoan/web/backend/RoleController.java
  26. 45 1
      xiaoan-web/src/main/java/com/xiaoan/web/backend/SceneController.java
  27. 55 0
      xiaoan-web/src/main/java/com/xiaoan/web/backend/StatisticsController.java
  28. 4 3
      xiaoan-web/src/main/java/com/xiaoan/web/backend/UserController.java
  29. 12 5
      xiaoan-web/src/main/java/com/xiaoan/web/shiro/MyRealm.java

+ 2 - 0
README.md

@@ -5,5 +5,7 @@
 
 ## 主要事项
   修改用户名,会影响密码的,若果要修改,只能重置密码(而且要先在db手动改好用户名,再重置密码)
+  
+  @WebControllerLog 日志注解格式:部门信息-新增部门,必须要有"-"
 
 

+ 7 - 0
pom.xml

@@ -42,6 +42,7 @@
         <swagger2.version>2.9.2</swagger2.version>
         <shiro.version>1.4.0</shiro.version>
         <jwt.version>3.2.0</jwt.version>
+        <jjwt.version>0.6.0</jjwt.version>
 
 
     </properties>
@@ -178,6 +179,12 @@
                 <version>${jwt.version}</version>
             </dependency>
 
+            <dependency>
+                <groupId>io.jsonwebtoken</groupId>
+                <artifactId>jjwt</artifactId>
+                <version>${jjwt.version}</version>
+            </dependency>
+
             <!-- kaptcha -->
             <dependency>
                 <groupId>com.github.penggle</groupId>

+ 2 - 0
xiaoan-application/src/main/resources/application-dev.properties

@@ -52,3 +52,5 @@ spring.redis.jedis.pool.min-idle=0
 spring.redis.jedis.pool.max-active=8
 # 等待可用连接的最大时间,单位毫秒,默认值为-1,表示永不超时。如果超过等待时间,则直接抛出JedisConnectionException
 spring.redis.jedis.pool.max-wait=-1ms
+
+scene.path=F:\\test\\xiaoan\\

+ 5 - 0
xiaoan-common/pom.xml

@@ -108,6 +108,11 @@
             <artifactId>java-jwt</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>io.jsonwebtoken</groupId>
+            <artifactId>jjwt</artifactId>
+        </dependency>
+
         <!--tk.mybatis 依赖-->
         <dependency>
             <groupId>tk.mybatis</groupId>

+ 15 - 12
xiaoan-common/src/main/java/com/xiaoan/common/interceptor/AuthHeaderSettingFilter.java

@@ -46,18 +46,21 @@ public class AuthHeaderSettingFilter implements Filter {
         HeaderMapRequestWrapper requestWrapper = new HeaderMapRequestWrapper(req);
         String token = req.getHeader("Authorization");
 
-        if ("dev".equals(active)){
-            if (token == null) {
-                // admin 用户测试用
-                token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwYXlsb2FkIjoie1wicm9sZVwiOltcImFkbWluXCJdLFwiaWRcIjo5LFwidXNlck5hbWVcIjpcIjE1OTk5OTk5OTk5XCJ9IiwidXNlck5hbWUiOiIxNTk5OTk5OTk5OSIsImV4cCI6MTU4NDIzMzkyNX0.Uk71Pyt1WC7gHpxof7ktbgk---r85fyrKB_s2tUq0QI";
-                //如果请求中带有这个参数,则进行过滤加一个header头
-                requestWrapper.addHeader("Authorization", token);
-                String userName = "15999999999";
-                // 更新到 redis, 有效期24h, 旧token无效
-                redisTemplate.opsForValue().set(userName, token, Long.parseLong("240000"), TimeUnit.HOURS);
-                chain.doFilter(requestWrapper, response);
-
-            }
+
+        // 排除登录接口
+        if (token == null && !req.getRequestURI().contains("/admin/login")) {
+            if ("dev".equals(active) ){
+                    // admin 用户测试用
+                    token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwYXlsb2FkIjoie1wicm9sZVwiOltcImFkbWluXCJdLFwiaWRcIjo5LFwidXNlck5hbWVcIjpcIjE1OTk5OTk5OTk5XCJ9IiwidXNlck5hbWUiOiIxNTk5OTk5OTk5OSIsImV4cCI6MTU4NDIzMzkyNX0.Uk71Pyt1WC7gHpxof7ktbgk---r85fyrKB_s2tUq0QI";
+                    //如果请求中带有这个参数,则进行过滤加一个header头
+                    requestWrapper.addHeader("Authorization", token);
+                    String userName = "15999999999";
+                    // 更新到 redis, 有效期24h, 旧token无效
+                    redisTemplate.opsForValue().set(userName, token, Long.parseLong("240000"), TimeUnit.HOURS);
+                    chain.doFilter(requestWrapper, response);
+
+                }
+
         } else {
             chain.doFilter(requestWrapper, response);
         }

+ 415 - 0
xiaoan-common/src/main/java/com/xiaoan/common/util/FileUtils.java

@@ -0,0 +1,415 @@
+package com.xiaoan.common.util;
+
+import lombok.extern.log4j.Log4j2;
+import org.springframework.util.ResourceUtils;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
+import java.nio.charset.Charset;
+import java.text.SimpleDateFormat;
+import java.util.Base64;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+/**
+ * Created by Owen on 2019/10/25 0025 14:20
+ */
+@Log4j2
+public class FileUtils {
+
+
+    /**
+     * web 文件下载
+     * @param response
+     * @param path 源文件路径
+     * @param path 源文件名
+     * @return
+     * @throws Exception
+     */
+    public static void fileDownload(HttpServletResponse response, String path) throws Exception {
+        String fileName = path.substring(path.lastIndexOf(File.separator)+1);
+        // 当文件名不是英文名的时候,最好使用url解码器去编码一下,
+        fileName= URLEncoder.encode(fileName,"UTF-8");
+
+        // 获取response的输出流,用来输出文件
+//        ServletOutputStream out = response.getOutputStream();
+        OutputStream out = response.getOutputStream();
+
+        // 将响应的类型
+        response.setContentType("APPLICATION/OCTET-STREAM");
+        response.setHeader("Content-Disposition","attachment; filename="+fileName);
+
+        // 以输入流的形式读取文件
+//        log.info("zipPath: " + path);
+        FileInputStream in = new FileInputStream(path);
+
+        //可以自己 指定缓冲区的大小
+        byte[] buffer = new byte[1024];
+        int len = 0;
+        while ((len = in.read(buffer)) != -1) {
+            out.write(buffer, 0, len);
+            out.flush();
+        }
+        //关闭输入输出流
+        out.close();
+        in.close();
+    }
+
+    /**
+     * 获取类路径
+     */
+    public static String getResource(){
+        String path = "";
+        try {
+            path = ResourceUtils.getURL("classpath:").getPath();
+            path = URLDecoder.decode(path,"utf-8");
+            log.info("classpath path :"+path);
+        } catch (Exception e) {
+            log.error(" classpath Error" + e.getMessage(), e);
+        }
+        return path;
+    }
+
+
+    /**
+     * 创建文件夹
+     * destDirName:文件夹名称
+     */
+    public static void createDir(String destDirName) {
+        File dir = new File(destDirName);
+        // 创建目录
+        if (!dir.exists()) {
+            dir.mkdirs();
+        }
+    }
+
+    /**
+     * 大文件读写
+     *
+     * 1.先将文件中的内容读入到缓冲输入流中
+     * 2.将输入流中的数据通过缓冲输出流写入到目标文件中
+     * 3.关闭输入流和输出流
+     *
+     * in: 输入流
+     * path: 保持位置
+     */
+
+    public static void bigFileWrite(InputStream in, String path) throws IOException {
+//        long start = System.currentTimeMillis();
+        // 输入缓冲流
+        BufferedInputStream inputBuff = new BufferedInputStream(in);
+
+        // 输出缓冲流
+        BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(path));
+        int len = 0;
+        byte[] buffer = new byte[1024];
+        while ((len = inputBuff.read(buffer)) != -1) {
+            stream.write(buffer, 0, len);
+        }
+        stream.flush();
+        stream.close();
+        inputBuff.close();
+
+//        long end = System.currentTimeMillis();
+
+//        System.out.println("total: "+ (end-start)/1000);
+    }
+
+
+    /**
+     *
+     * @param content base64内容
+     * @param path 输出文件路径,需要后缀名
+     * @return
+     */
+    public static  boolean base64ToFileWriter(String content, String path) {
+        if (content == null) {
+            return false;
+        }
+        try {
+            byte[] b = Base64.getDecoder().decode(content);
+            // processing data
+            for (int i = 0; i < b.length; ++i) {
+                if (b[i] < 0) {
+                    b[i] += 256;
+                }
+            }
+            OutputStream out = new FileOutputStream(path);
+            out.write(b);
+            out.flush();
+            out.close();
+            return true;
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
+
+    /**
+     * 读取文件方法
+     * @param Path 文件路径
+     * @return 返回内容
+     */
+    public static String readFile(String Path){
+        BufferedReader reader = null;
+        String laststr = "";
+        try{
+            FileInputStream fileInputStream = new FileInputStream(Path);
+            InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8");
+            reader = new BufferedReader(inputStreamReader);
+            String tempString = null;
+            while((tempString = reader.readLine()) != null){
+                laststr += tempString;
+            }
+            reader.close();
+        }catch(IOException e){
+            e.printStackTrace();
+        }finally{
+            if(reader != null){
+                try {
+                    reader.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return laststr;
+    }
+
+
+    /**
+     * 生成文件
+     * @param content 内容
+     * @param path 生成路径
+     * @throws IOException
+     */
+    public static void fileWriter(String content, String path) throws IOException {
+        FileWriter writer = new FileWriter(path);
+        writer.write(content);
+        writer.flush();
+        writer.close();
+    }
+
+    // 获取时间戳
+    public static String timeMillisStr() {
+        SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
+        String format = df.format(new Date());
+        long timeMillis = System.currentTimeMillis();
+        return format + "_" + timeMillis + "_";
+    }
+
+    //返回年月日时分秒
+    public static String dateStr() {
+        SimpleDateFormat df = new SimpleDateFormat("yyyyMMddhhmmss");
+        String format = df.format(new Date());
+        return format + "_";
+    }
+
+    /**
+     * 删除指定文件夹下所有文件
+     * @param path 文件夹完整绝对路径
+     * @return
+     */
+    public static boolean delAllFile(String path) {
+        boolean flag = false;
+        File file = new File(path);
+        if (!file.exists()) {
+            return flag;
+        }
+        if (!file.isDirectory()) {
+            return flag;
+        }
+        String[] tempList = file.list();
+        File temp = null;
+        for (int i = 0; i < tempList.length; i++) {
+            if (path.endsWith(File.separator)) {
+                temp = new File(path + tempList[i]);
+            } else {
+                temp = new File(path + File.separator + tempList[i]);
+            }
+            if (temp.isFile()) {
+                temp.delete();
+            }
+            if (temp.isDirectory()) {
+                delAllFile(path + "/" + tempList[i]);//先删除文件夹里面的文件
+                delFolder(path + "/" + tempList[i]);//再删除空文件夹
+//                delAllFile(path + tempList[i]);//先删除文件夹里面的文件
+//                delFolder(path + tempList[i]);//再删除空文件夹
+                flag = true;
+            }
+        }
+        return flag;
+    }
+
+
+    /**
+     * 删除文件夹或删除文件
+     * @param folderPath 文件夹完整绝对路径
+     */
+    public static void delFolder(String folderPath) {
+        try {
+
+//            File file = new File(folderPath);
+//            if (file.exists()){
+                //删除完里面所有内容
+                delAllFile(folderPath);
+                String filePath = folderPath;
+                filePath = filePath.toString();
+                File myFilePath = new File(filePath);
+                //删除空文件夹
+                myFilePath.delete();
+//            }
+
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+
+    /**
+     * zip解压
+     * @param zipFileName        zip源文件
+     * @param destDirPath     解压后的目标文件夹
+     * @throws RuntimeException 解压失败会抛出运行时异常
+     */
+    public static boolean unzip(String zipFileName, String destDirPath) throws RuntimeException {
+
+        File srcFile = new File(zipFileName);
+
+
+        long start = System.currentTimeMillis();
+
+        // 判断源文件是否存在
+
+        if (!srcFile.exists()) {
+
+            throw new RuntimeException(srcFile.getPath() + "所指文件不存在");
+
+        }
+
+        // 开始解压
+
+        ZipFile zipFile = null;
+
+        try {
+
+            zipFile = new ZipFile(srcFile, Charset.forName("gbk"));
+
+            Enumeration<?> entries = zipFile.entries();
+
+            while (entries.hasMoreElements()) {
+
+                ZipEntry entry = (ZipEntry) entries.nextElement();
+
+
+//                log.info("解压: " + entry.getName());
+
+                // 如果是文件夹,就创建个文件夹
+
+                if (entry.isDirectory()) {
+
+                    String dirPath = destDirPath + "/" + entry.getName();
+
+                    File dir = new File(dirPath);
+
+                    dir.mkdirs();
+
+                } else {
+
+                    // 如果是文件,就先创建一个文件,然后用io流把内容copy过去
+
+                    File targetFile = new File(destDirPath + "/" + entry.getName());
+
+                    // 保证这个文件的父文件夹必须要存在
+
+                    if(!targetFile.getParentFile().exists()){
+
+                        targetFile.getParentFile().mkdirs();
+
+                    }
+
+                    targetFile.createNewFile();
+
+                    // 将压缩文件内容写入到这个文件中
+
+                    InputStream is = zipFile.getInputStream(entry);
+
+                    FileOutputStream fos = new FileOutputStream(targetFile);
+
+                    int len;
+
+                    byte[] buf = new byte[1024];
+
+                    while ((len = is.read(buf)) != -1) {
+
+                        fos.write(buf, 0, len);
+
+                    }
+
+                    // 关流顺序,先打开的后关闭
+
+                    fos.close();
+
+                    is.close();
+
+                }
+
+            }
+
+            long end = System.currentTimeMillis();
+
+            log.info("解压完成,耗时:" + (end - start) +" ms");
+
+        } catch (Exception e) {
+
+            throw new RuntimeException("unzip error from ZipUtils", e);
+
+        } finally {
+
+            if(zipFile != null){
+
+                try {
+
+                    zipFile.close();
+
+                } catch (IOException e) {
+
+                    e.printStackTrace();
+
+                }
+
+            }
+
+        }
+        return true;
+    }
+
+    /**
+     * 读取json 文件, Linux版
+     */
+    public static String readJsonLinux(String path){
+        String param = FileUtils.readFile(path);
+        return param;
+
+    }
+
+
+
+    public static void main(String[] args) {
+
+//        unzip("F:\\test\\a1_shp2.zip", "F:\\test\\");
+
+        // 这个是可以的,没有目录结构
+//        unzip("F:\\test\\cesium\\clip.zip", "F:\\test\\cesium\\");
+
+        // 这个有目录的,会失败
+//        File file = new File("F:\\test\\clip.zip");
+        unzip("F:\\test\\clip.zip", "F:\\test\\");
+
+    }
+}

+ 34 - 0
xiaoan-dao/src/main/java/com/xiaoan/dao/backend/CameraRepository.java

@@ -0,0 +1,34 @@
+package com.xiaoan.dao.backend;
+
+import com.xiaoan.common.model.PageDto;
+import com.xiaoan.domain.backend.CameraEntity;
+import com.xiaoan.domain.backend.DepartmentEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+
+/**
+ * Created by Hb_zzZ on 2020/2/27.
+ */
+@Mapper
+@Component
+public interface CameraRepository extends IBaseRepository<CameraEntity, Long> {
+
+    @Select(value = "select * from tb_camera where wifi_name = #{code} and rec_status = 'A' ")
+    CameraEntity findByWifiName(String code);
+
+
+    @Select(value = "select * from tb_camera z left join tb_camera_detail d on z.id = d.camera_id where " +
+            "(z.sn_code like #{searchKey} or #{searchKey} is null)" +
+//            "(z.wifi_name like #{searchKey} or #{searchKey} is null)" +
+            " and (d.user_id = #{userId} or #{userId} is null) " +
+            " order by z.create_time desc")
+    List<CameraEntity> findAllBySearchKey(String searchKey, Long userId);
+
+//    @SelectProvider(type = SceneProvider.class, method = "findAllBySearchKey")
+//    List<SceneResponse> findAllBySearchKey(SceneProRequest param, Long userId);
+
+}

+ 10 - 0
xiaoan-dao/src/main/java/com/xiaoan/dao/backend/SceneRepository.java

@@ -3,6 +3,7 @@ package com.xiaoan.dao.backend;
 import com.xiaoan.dao.backend.provider.SceneProvider;
 import com.xiaoan.dao.backend.provider.UserProvider;
 import com.xiaoan.domain.backend.SceneProEntity;
+import com.xiaoan.domain.backend.UserEntity;
 import com.xiaoan.domain.dto.request.SceneProRequest;
 import com.xiaoan.domain.dto.response.LogResponse;
 import com.xiaoan.domain.dto.response.SceneResponse;
@@ -30,6 +31,15 @@ public interface SceneRepository extends IBaseRepository<SceneProEntity, Long> {
     @SelectProvider(type = SceneProvider.class, method = "findAllBySearchKey")
     List<SceneResponse> findAllBySearchKey(SceneProRequest param, Long userId);
 
+    @Select(value = "select SUM(view_count) from tb_scene_pro where rec_status = 'A' ")
+    Integer findAllByViewCount();
+
+    @Select(value = "select id, thumb, view_count from tb_scene_pro where rec_status = 'A' ORDER BY view_count desc LIMIT #{num}")
+    List<SceneResponse> findAllByViewCountLimit(int num);
+
+    @Select(value = "select * from tb_scene_pro where rec_status = 'A' and status = '-2' and num = #{sceneNum}")
+    SceneProEntity findBySceneNum(String sceneNum);
+
 //    @SelectProvider(type = SceneProvider.class, method = "findAllBySearchKeyAndUserId")
 //    List<SceneResponse> findAllBySearchKeyAndUserId(SceneProRequest param, List<Long> ids, Long userId);
 

+ 6 - 0
xiaoan-dao/src/main/java/com/xiaoan/dao/backend/UserRepository.java

@@ -52,4 +52,10 @@ public interface UserRepository extends IBaseRepository<UserEntity, Long> {
             "(tb_user u left join tb_user_role ur on u.id = ur.user_id) left join tb_role r on r.id = ur.role_id  " +
             "WHERE u.id = #{id}")
     List<String> findRoleByUserId(Long id);
+
+    @Select(value = "select SUM(view_count) from tb_user where rec_status = 'A'")
+    Integer findAllByViewCount();
+
+    @Select(value = "select * from tb_user where rec_status = 'A' ORDER BY view_count desc LIMIT #{num}")
+    List<UserEntity> findAllByViewCountLimit(int num);
 }

+ 0 - 23
xiaoan-domain/src/main/java/com/xiaoan/domain/backend/DataStatisticsEntity.java

@@ -1,23 +0,0 @@
-package com.xiaoan.domain.backend;
-
-import com.xiaoan.common.model.BaseModel;
-import lombok.Data;
-
-import javax.persistence.Entity;
-import javax.persistence.Table;
-import java.io.Serializable;
-
-/**
- * Created by owen on 2020/3/4.
- *
- * 数据统计实体
- */
-@Data
-@Entity
-@Table(name = "tb_data_statistics")
-public class DataStatisticsEntity extends BaseModel implements Serializable {
-
-
-
-
-}

+ 4 - 0
xiaoan-domain/src/main/java/com/xiaoan/domain/backend/UserEntity.java

@@ -43,4 +43,8 @@ public class UserEntity extends BaseModel implements Serializable {
     @Column
     private Long departmentId; //部门
 
+    // 登录次数
+    private Integer viewCount;
+
+
 }

+ 1 - 2
xiaoan-domain/src/main/java/com/xiaoan/domain/dto/request/UserRequest.java

@@ -1,13 +1,12 @@
 package com.xiaoan.domain.dto.request;
 
-import com.xiaoan.common.model.PageDto;
 import lombok.Data;
 
 /**
  * Created by owen on 2020/2/18 0018 17:09
  */
 @Data
-public class UserRequest extends PageDto{
+public class UserRequest{
 
     private Long id;
 

+ 17 - 0
xiaoan-service/src/main/java/com/xiaoan/service/backend/CameraService.java

@@ -0,0 +1,17 @@
+package com.xiaoan.service.backend;
+
+import com.xiaoan.common.model.PageDto;
+import com.xiaoan.domain.backend.CameraEntity;
+import com.xiaoan.service.IBaseService;
+
+import java.util.List;
+
+/**
+ * Created by owen on 2020/3/9 0009 15:53
+ */
+public interface CameraService extends IBaseService<CameraEntity, Long> {
+
+    CameraEntity findByWifiName(String code);
+
+    List<CameraEntity> findAllBySearchKey(PageDto param, Long userId);
+}

+ 6 - 0
xiaoan-service/src/main/java/com/xiaoan/service/backend/SceneService.java

@@ -16,5 +16,11 @@ public interface SceneService extends IBaseService<SceneProEntity, Long> {
 
     List<SceneResponse> findAllBySearchKey(SceneProRequest param, Long userId);
 
+    Integer findAllByViewCount();
+
+    List<SceneResponse> findAllByViewCountLimit(int i);
+
+    SceneProEntity findBySceneNum(String sceneNum);
+
 //    List<SceneResponse> findAllBySearchKey(SceneProRequest param, List<Long> ids, Long userId);
 }

+ 6 - 1
xiaoan-service/src/main/java/com/xiaoan/service/backend/UserService.java

@@ -1,5 +1,6 @@
 package com.xiaoan.service.backend;
 
+import com.xiaoan.common.model.PageDto;
 import com.xiaoan.domain.backend.UserEntity;
 import com.xiaoan.domain.dto.request.UserRequest;
 import com.xiaoan.domain.dto.response.UserResponse;
@@ -26,7 +27,11 @@ public interface UserService extends IBaseService<UserEntity, Long> {
 
     List<Long> findUserIdByRealName(String realName);
 
-    List<UserResponse> findAllBySearchKey(UserRequest param);
+    List<UserResponse> findAllBySearchKey(PageDto param);
 
     List<String> findRoleByUserId(Long id);
+
+    Integer findAllByViewCount();
+
+    List<UserEntity> findAllByViewCountLimit(int num);
 }

+ 48 - 0
xiaoan-service/src/main/java/com/xiaoan/service/backend/impl/CameraServiceImpl.java

@@ -0,0 +1,48 @@
+package com.xiaoan.service.backend.impl;
+
+import com.github.pagehelper.PageHelper;
+import com.xiaoan.common.model.PageDto;
+import com.xiaoan.dao.backend.CameraRepository;
+import com.xiaoan.dao.backend.DepartmentRepository;
+import com.xiaoan.dao.backend.IBaseRepository;
+import com.xiaoan.domain.backend.CameraEntity;
+import com.xiaoan.domain.backend.DepartmentEntity;
+import com.xiaoan.service.BaseServiceImpl;
+import com.xiaoan.service.backend.CameraService;
+import com.xiaoan.service.backend.DepartmentService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+/**
+ * Created by Hb_zzZ on 2020/2/27.
+ */
+@Service
+@Transactional
+public class CameraServiceImpl extends BaseServiceImpl<CameraEntity, Long> implements CameraService {
+
+    @Autowired
+    private CameraRepository entityMapper;
+
+    @Override
+    public IBaseRepository<CameraEntity, Long> getBaseMapper() {
+        return this.entityMapper;
+    }
+
+
+    @Override
+    public CameraEntity findByWifiName(String code) {
+        return entityMapper.findByWifiName(code);
+    }
+
+    @Override
+    public List<CameraEntity> findAllBySearchKey(PageDto param, Long userId) {
+        PageHelper.startPage(param.getPageNum(), param.getPageSize());
+        String searchKey = param.getSearchKey();
+        searchKey = "%" + searchKey + "%";
+        return entityMapper.findAllBySearchKey(searchKey, userId);
+
+    }
+}

+ 15 - 0
xiaoan-service/src/main/java/com/xiaoan/service/backend/impl/SceneServiceImpl.java

@@ -39,6 +39,21 @@ public class SceneServiceImpl extends BaseServiceImpl<SceneProEntity, Long> impl
         return sceneRepository.findAllBySearchKey(param, userId);
     }
 
+    @Override
+    public Integer findAllByViewCount() {
+        return sceneRepository.findAllByViewCount();
+    }
+
+    @Override
+    public List<SceneResponse> findAllByViewCountLimit(int i) {
+        return sceneRepository.findAllByViewCountLimit(i);
+    }
+
+    @Override
+    public SceneProEntity findBySceneNum(String sceneNum) {
+        return sceneRepository.findBySceneNum(sceneNum);
+    }
+
 //    @Override
 //    public List<SceneResponse> findAllBySearchKey(SceneProRequest param, List<Long> ids, Long userId) {
 //        PageHelper.startPage(param.getPageNum(), param.getPageSize());

+ 12 - 1
xiaoan-service/src/main/java/com/xiaoan/service/backend/impl/UserServiceImpl.java

@@ -1,6 +1,7 @@
 package com.xiaoan.service.backend.impl;
 
 import com.github.pagehelper.PageHelper;
+import com.xiaoan.common.model.PageDto;
 import com.xiaoan.dao.backend.IBaseRepository;
 import com.xiaoan.dao.backend.UserRepository;
 import com.xiaoan.domain.backend.UserEntity;
@@ -62,7 +63,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserEntity, Long> implement
     }
 
     @Override
-    public List<UserResponse> findAllBySearchKey(UserRequest param) {
+    public List<UserResponse> findAllBySearchKey(PageDto param) {
         PageHelper.startPage(param.getPageNum(), param.getPageSize());
         return userRepository.findAllBySearchKey(param.getSearchKey());
     }
@@ -72,5 +73,15 @@ public class UserServiceImpl extends BaseServiceImpl<UserEntity, Long> implement
         return userRepository.findRoleByUserId(id);
     }
 
+    @Override
+    public Integer findAllByViewCount() {
+        return userRepository.findAllByViewCount();
+    }
+
+    @Override
+    public List<UserEntity> findAllByViewCountLimit(int param) {
+        return userRepository.findAllByViewCountLimit(param);
+    }
+
 
 }

+ 4 - 2
xiaoan-web/src/main/java/com/xiaoan/web/aop/WebLogAspect.java

@@ -3,6 +3,7 @@ package com.xiaoan.web.aop;
 import com.xiaoan.domain.backend.LogEntity;
 import com.xiaoan.service.backend.LogService;
 import com.xiaoan.web.shiro.JWTUtil;
+import com.xiaoan.web.shiro.JwtUtil2;
 import lombok.extern.slf4j.Slf4j;
 import org.aspectj.lang.JoinPoint;
 import org.aspectj.lang.annotation.Aspect;
@@ -44,7 +45,8 @@ public class WebLogAspect {
         String token = request.getHeader("Authorization");
         Long userId = null;
         if (token != null) {
-             userId = JWTUtil.getUserId(token);
+//             userId = JWTUtil.getUserId(token);
+             userId = JwtUtil2.getUserId(token);
         }
 
 
@@ -69,7 +71,7 @@ public class WebLogAspect {
         logEntity.setDescription(detail.get(1));
         logEntity.setUserId(userId);
 
-//        logService.save(logEntity);
+        logService.save(logEntity);
 
     }
 

+ 3 - 1
xiaoan-web/src/main/java/com/xiaoan/web/backend/BaseController.java

@@ -1,6 +1,7 @@
 package com.xiaoan.web.backend;
 
 import com.xiaoan.web.shiro.JWTUtil;
+import com.xiaoan.web.shiro.JwtUtil2;
 import org.springframework.beans.factory.annotation.Autowired;
 
 import javax.servlet.http.HttpServletRequest;
@@ -15,7 +16,8 @@ public class BaseController {
 
     protected String getTokenUserName(){
         String token = request.getHeader("Authorization");
-        return JWTUtil.getUsername(token);
+//        return JWTUtil.getUsername(token);
+        return JwtUtil2.getUsername(token);
     }
 
     protected String getToken(){

+ 0 - 4
xiaoan-web/src/main/java/com/xiaoan/web/backend/DepartmentController.java

@@ -39,10 +39,6 @@ public class DepartmentController extends BaseController {
     @WebControllerLog(description = "部门信息-查询列表")
     @PostMapping("list")
     public ResultJson list(@RequestBody PageDto param){
-
-        String token = request.getHeader("Authorization");
-        System.out.println(token);
-
         Condition condition = new Condition(DepartmentEntity.class);
         condition.and().andLike("name", "%" + param.getSearchKey()+ "%");
         PageInfo<DepartmentEntity> pageInfo = departmentService.findAll(condition, param.getPageNum(), param.getPageSize());

+ 78 - 0
xiaoan-web/src/main/java/com/xiaoan/web/backend/DeviceController.java

@@ -0,0 +1,78 @@
+package com.xiaoan.web.backend;
+
+import com.github.pagehelper.PageInfo;
+import com.xiaoan.common.constant.MsgCode;
+import com.xiaoan.common.model.PageDto;
+import com.xiaoan.common.util.ResultJson;
+import com.xiaoan.domain.backend.CameraEntity;
+import com.xiaoan.domain.backend.DepartmentEntity;
+import com.xiaoan.domain.dto.request.DepartmentRequest;
+import com.xiaoan.service.backend.CameraService;
+import com.xiaoan.service.backend.DepartmentService;
+import com.xiaoan.web.aop.WebControllerLog;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+import tk.mybatis.mapper.entity.Condition;
+
+/**
+ * Created by Hb_zzZ on 2020/2/27.
+ *
+ * 需要admin权限
+ */
+@Api(tags = "DeviceController", description = "后台设备管理")
+@RestController
+@RequestMapping("api/manage/device")
+@Transactional
+public class DeviceController extends BaseController {
+
+    @Autowired
+    private DepartmentService departmentService;
+
+    @Autowired
+    private CameraService cameraService;
+
+    @ApiOperation("分页获取部门列表/搜索")
+    @WebControllerLog(description = "部门信息-查询列表")
+    @PostMapping("list")
+    public ResultJson list(@RequestBody PageDto param){
+        Condition condition = new Condition(DepartmentEntity.class);
+        condition.and().andLike("name", "%" + param.getSearchKey()+ "%");
+        PageInfo<DepartmentEntity> pageInfo = departmentService.findAll(condition, param.getPageNum(), param.getPageSize());
+        return new ResultJson(MsgCode.SUCCESS_CODE, pageInfo);
+    }
+
+    /**
+     * 需要一个mac地址
+     *
+     * WiFi名称,跟mac地址一致
+     * wifi密码:12345678
+     */
+    @ApiOperation("新增相机")
+    @WebControllerLog(description = "设备管理-新增相机")
+    @PostMapping("save/{code}")
+    public ResultJson save(@PathVariable String code){
+        if(StringUtils.isEmpty(code)){
+            return new ResultJson(MsgCode.FAILURE_CODE_3001, MsgCode.FAILURE_MSG_3001);
+        }
+
+
+        CameraEntity cameraEntity = cameraService.findByWifiName(code);
+        if(cameraEntity == null){
+            cameraEntity = new CameraEntity();
+            cameraEntity.setChildName(code);
+            cameraEntity.setWifiName(code);
+            cameraEntity.setWifiPassword("12345678");
+
+
+            cameraService.save(cameraEntity);
+        }
+
+        return new ResultJson(MsgCode.SUCCESS_CODE, MsgCode.SUCCESS_MSG);
+    }
+
+}

+ 28 - 4
xiaoan-web/src/main/java/com/xiaoan/web/backend/IndexController.java

@@ -10,6 +10,7 @@ import com.xiaoan.service.backend.RoleService;
 import com.xiaoan.service.backend.UserService;
 import com.xiaoan.service.backend.dto.ResourceTree;
 import com.xiaoan.web.shiro.JWTUtil;
+import com.xiaoan.web.shiro.JwtUtil2;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.log4j.Log4j2;
@@ -81,24 +82,36 @@ public class IndexController {
         tokenMap.put("id", userEntity.getId());
         tokenMap.put("role", roles);
 
-        String token = JWTUtil.sign(tokenMap, userEntity.getPassword());
+//        String token = JWTUtil.sign(tokenMap, userEntity.getPassword());
+
+        String token = JwtUtil2.createJWT(-1, tokenMap);
 //
 //        String token = JWTUtil.sign(param.getUserName(), userEntity.getPassword());
 //        log.warn("new token: {}", token);
 
         HashMap<String, Object> result = new HashMap<>();
-        result.put("userEntity", userEntity);
+        result.put("user", userEntity);
 //        result.put("resources", resourcesByUserMenu);
         result.put("token", token);
-        result.put("resourcesTreeByUserPermission", resourcesTreeByUserPermission);
+        result.put("permission", resourcesTreeByUserPermission);
 
 
         // 更新到 redis, 有效期24h, 旧token无效
         redisTemplate.opsForValue().set(userEntity.getUserName(), token, Long.parseLong("240000"), TimeUnit.HOURS);
+
+        // 更新登录次数
+        Integer loginCount = userEntity.getViewCount();
+        loginCount++;
+        userEntity.setViewCount(loginCount);
+        userEntity.setUpdateTime(new Date());
+
+        userService.update(userEntity);
+
         return new ResultJson(MsgCode.SUCCESS_CODE, result);
+
     }
 
-    @GetMapping("/logout")
+    @GetMapping("admin/logout")
     public ResultJson logout(HttpServletRequest request) {
         log.info("run logout");
 
@@ -114,4 +127,15 @@ public class IndexController {
         log.info("end logout");
         return new ResultJson(MsgCode.SUCCESS_CODE, MsgCode.SUCCESS_MSG);
     }
+
+    public static void main(String[] args) {
+        int a = 0;
+        for (int i = 0; i < 10; i++) {
+
+            a++;
+        }
+
+        System.out.println(a);
+
+    }
 }

+ 50 - 1
xiaoan-web/src/main/java/com/xiaoan/web/backend/PersonalCenterController.java

@@ -4,9 +4,11 @@ import com.github.pagehelper.PageInfo;
 import com.xiaoan.common.constant.MsgCode;
 import com.xiaoan.common.model.PageDto;
 import com.xiaoan.common.util.ResultJson;
+import com.xiaoan.domain.backend.CameraEntity;
 import com.xiaoan.domain.backend.SceneProEntity;
 import com.xiaoan.domain.dto.request.SceneProRequest;
 import com.xiaoan.domain.dto.response.SceneResponse;
+import com.xiaoan.service.backend.CameraService;
 import com.xiaoan.service.backend.SceneService;
 import com.xiaoan.service.backend.UserService;
 import com.xiaoan.web.aop.WebControllerLog;
@@ -36,6 +38,9 @@ public class PersonalCenterController extends BaseController {
     @Autowired
     private UserService userService;
 
+    @Autowired
+    private CameraService cameraService;
+
     @WebControllerLog(description = "个人中心-我的场景/搜索")
     @ApiOperation("获取场景列表/搜索")
     @PostMapping("scene/list")
@@ -87,6 +92,50 @@ public class PersonalCenterController extends BaseController {
     @PostMapping("camera/list")
     public ResultJson cameraList(@RequestBody PageDto param){
 
-        return new ResultJson(MsgCode.SUCCESS_CODE, "");
+        List<CameraEntity> list = null;
+        List userRole = JWTUtil.getUserRole(getToken());
+        if (userRole.contains("admin")) {
+            list = cameraService.findAllBySearchKey(param, null);
+        } else {
+            Long userId = JWTUtil.getUserId(getToken());
+            list = cameraService.findAllBySearchKey(param, userId);
+        }
+
+        PageInfo<CameraEntity> pageInfo = new PageInfo<>(list);
+
+        return new ResultJson(MsgCode.SUCCESS_CODE, pageInfo);
+    }
+
+
+    /**
+     * 需要一个mac地址
+     *
+     * WiFi名称,跟mac地址一致
+     * wifi密码:12345678
+     */
+    @ApiOperation("新增相机")
+    @WebControllerLog(description = "设备管理-新增相机")
+    @PostMapping("save/{code}")
+    public ResultJson save(@PathVariable String code){
+        if(StringUtils.isEmpty(code)){
+            return new ResultJson(MsgCode.FAILURE_CODE_3001, MsgCode.FAILURE_MSG_3001);
+        }
+
+
+        CameraEntity cameraEntity = cameraService.findByWifiName(code);
+        if(cameraEntity == null){
+            cameraEntity = new CameraEntity();
+            cameraEntity.setChildName(code);
+            cameraEntity.setWifiName(code);
+            cameraEntity.setWifiPassword("12345678");
+
+
+            cameraService.save(cameraEntity);
+        }
+
+        return new ResultJson(MsgCode.SUCCESS_CODE, MsgCode.SUCCESS_MSG);
     }
+
+
+
 }

+ 16 - 3
xiaoan-web/src/main/java/com/xiaoan/web/backend/RoleController.java

@@ -2,10 +2,13 @@ package com.xiaoan.web.backend;
 
 import com.github.pagehelper.PageInfo;
 import com.xiaoan.common.constant.MsgCode;
+import com.xiaoan.common.model.PageDto;
 import com.xiaoan.common.util.ResultJson;
+import com.xiaoan.domain.backend.DepartmentEntity;
 import com.xiaoan.domain.backend.RoleEntity;
 import com.xiaoan.domain.dto.request.RoleRequest;
 import com.xiaoan.service.backend.RoleService;
+import com.xiaoan.web.aop.WebControllerLog;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.shiro.authz.annotation.Logical;
@@ -36,10 +39,20 @@ public class RoleController extends BaseController {
     @Autowired
     private RoleService roleService;
 
-    @ApiOperation("分页获取角色列表")
+    @WebControllerLog(description = "角色权限-查询列表")
+    @ApiOperation("分页获取角色列表/搜索")
+//    @PostMapping("list")
+//    public ResultJson list(@RequestBody RoleRequest param){
+//        PageInfo<RoleEntity> pageInfo = roleService.findAll(param.getPageNum(), param.getPageSize());
+//        return new ResultJson(MsgCode.SUCCESS_CODE, pageInfo);
+//    }
+
     @PostMapping("list")
-    public ResultJson list(@RequestBody RoleRequest param){
-        PageInfo<RoleEntity> pageInfo = roleService.findAll(param.getPageNum(), param.getPageSize());
+    public ResultJson list(@RequestBody PageDto param){
+        Condition condition = new Condition(RoleEntity.class);
+        // 参数名是属性
+        condition.and().andLike("roleName", "%" + param.getSearchKey()+ "%");
+        PageInfo<RoleEntity> pageInfo = roleService.findAll(condition, param.getPageNum(), param.getPageSize());
         return new ResultJson(MsgCode.SUCCESS_CODE, pageInfo);
     }
 

+ 45 - 1
xiaoan-web/src/main/java/com/xiaoan/web/backend/SceneController.java

@@ -1,7 +1,10 @@
 package com.xiaoan.web.backend;
 
+import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.util.ZipUtil;
 import com.github.pagehelper.PageInfo;
 import com.xiaoan.common.constant.MsgCode;
+import com.xiaoan.common.util.FileUtils;
 import com.xiaoan.common.util.ResultJson;
 import com.xiaoan.domain.backend.SceneProEntity;
 import com.xiaoan.domain.dto.request.SceneProRequest;
@@ -11,10 +14,12 @@ import com.xiaoan.service.backend.SceneService;
 import com.xiaoan.service.backend.UserService;
 import com.xiaoan.web.aop.WebControllerLog;
 import com.xiaoan.web.shiro.JWTUtil;
+import com.xiaoan.web.shiro.JwtUtil2;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 import tk.mybatis.mapper.entity.Condition;
@@ -33,6 +38,9 @@ import java.util.Set;
 @Transactional
 public class SceneController extends BaseController {
 
+    @Value("${scene.path}")
+    private String scenePath;
+
     @Autowired
     private SceneService sceneService;
 
@@ -71,7 +79,8 @@ public class SceneController extends BaseController {
 //        }
 
         List<SceneResponse> list = null;
-        List userRole = JWTUtil.getUserRole(getToken());
+//        List userRole = JWTUtil.getUserRole(getToken());
+        List userRole = JwtUtil2.getUserRole(getToken());
         if (userRole.contains("admin")) {
             list = sceneService.findAllBySearchKey(param, null);
         } else {
@@ -82,4 +91,39 @@ public class SceneController extends BaseController {
         PageInfo<SceneResponse> pageInfo = new PageInfo<SceneResponse>(list);
         return new ResultJson(MsgCode.SUCCESS_CODE, pageInfo);
     }
+
+
+    /**
+     * 本地后台修改场景名称
+     */
+    @ApiOperation("下载场景")
+    @WebControllerLog(description = "场景管理-下载场景")
+    @RequestMapping(value = "/downloadTexData/{sceneNum}")
+    public ResultJson downloadTexData(@PathVariable String sceneNum)  {
+
+        if(StringUtils.isEmpty(sceneNum)){
+            return new ResultJson(MsgCode.FAILURE_CODE_3001, MsgCode.FAILURE_MSG_3001);
+        }
+        SceneProEntity sceneProEntity = sceneService.findBySceneNum(sceneNum);
+        if(sceneProEntity == null){
+            return new ResultJson(MsgCode.FAILURE_CODE_3001, MsgCode.FAILURE_MSG_3001);
+        }
+
+        String dataPath = sceneProEntity.getDataSource() + "/caches/tex";
+        String saveZipPath = scenePath + "images/images" + sceneNum;
+//        FileUtils.createDir(saveZipPath);
+        FileUtil.mkdir(saveZipPath);
+
+        String sourcePath = "F:\\test\\test123";
+        ZipUtil.zip(sourcePath, saveZipPath+ "/tex.zip");
+
+//        return new ResultJson(MsgCode.SUCCESS_CODE,mainUrl + "scene/images/images" + sceneNum + "/tex.zip?t=" +System.currentTimeMillis());
+        return new ResultJson(MsgCode.SUCCESS_CODE,"");
+    }
+
+    public static void main(String[] args) {
+        String sourcePath = "F:\\test\\test123";
+        String saveZipPath = "F:\\test\\xiaoan\\";
+        ZipUtil.zip(sourcePath, saveZipPath+ "tex.zip");
+    }
 }

+ 55 - 0
xiaoan-web/src/main/java/com/xiaoan/web/backend/StatisticsController.java

@@ -0,0 +1,55 @@
+package com.xiaoan.web.backend;
+
+import com.github.pagehelper.PageInfo;
+import com.xiaoan.common.constant.MsgCode;
+import com.xiaoan.common.util.ResultJson;
+import com.xiaoan.domain.backend.DepartmentEntity;
+import com.xiaoan.domain.backend.UserEntity;
+import com.xiaoan.service.backend.SceneService;
+import com.xiaoan.service.backend.UserService;
+import io.swagger.annotations.Api;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import tk.mybatis.mapper.entity.Condition;
+
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * Created by owen on 2020/3/9 0009 10:35
+ *
+ * 数据统计
+ * 需要admin权限
+ */
+@Api(tags = "StatisticsController", description = "后台数据统计")
+@RestController
+@RequestMapping("api/manage/statistics")
+@Transactional
+public class StatisticsController {
+
+    @Autowired
+    private UserService userService;
+
+    @Autowired
+    private SceneService sceneService;
+
+    @GetMapping
+    private ResultJson getData() {
+
+        HashMap<Object, Object> map = new HashMap<>();
+        map.put("使用人次", userService.findAllByViewCount());
+        map.put("系统用户数", userService.count());
+        map.put("场景浏览量", sceneService.findAllByViewCount());
+        map.put("场景个数", sceneService.count());
+
+        map.put("系统使用TOP5", userService.findAllByViewCountLimit(5));
+        map.put("场景浏览TOP5", sceneService.findAllByViewCountLimit(5));
+
+        return new ResultJson(MsgCode.SUCCESS_CODE, map);
+
+    }
+
+}

+ 4 - 3
xiaoan-web/src/main/java/com/xiaoan/web/backend/UserController.java

@@ -2,6 +2,7 @@ package com.xiaoan.web.backend;
 
 import com.github.pagehelper.PageInfo;
 import com.xiaoan.common.constant.MsgCode;
+import com.xiaoan.common.model.PageDto;
 import com.xiaoan.common.util.PasswordUtils;
 import com.xiaoan.common.util.ResultJson;
 import com.xiaoan.domain.dto.request.UserRequest;
@@ -37,17 +38,17 @@ public class UserController extends BaseController {
     @Autowired
     private UserService userService;
 
-    @WebControllerLog(description = "用户管理-查看用户列表")
+    @WebControllerLog(description = "用户管理-查看用户列表/搜索")
     @ApiOperation("分页获取用户列表")
     @PostMapping("list")
-    public ResultJson list(@RequestBody UserRequest param){
+    public ResultJson list(@RequestBody PageDto param){
         PageInfo<UserResponse> page =  new PageInfo<UserResponse>(userService.findAllBySearchKey(param));
         return new ResultJson(MsgCode.SUCCESS_CODE, page);
     }
 
     @ApiOperation("新增或修改用户信息")
     @PostMapping("save")
-    public ResultJson save(@RequestBody UserRequest param, HttpServletRequest req){
+    public ResultJson save(@RequestBody UserRequest param){
         UserEntity userEntity = null;
         int n = 0;
         if (param.getId() != null){

+ 12 - 5
xiaoan-web/src/main/java/com/xiaoan/web/shiro/MyRealm.java

@@ -60,7 +60,9 @@ public class MyRealm extends AuthorizingRealm {
      */
     @Override
     protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
-        String username = JWTUtil.getUsername(principals.toString());
+//        String username = JWTUtil.getUsername(principals.toString());
+        String username = JwtUtil2.getUsername(principals.toString());
+
         UserEntity dbUserEntity = userService.findByUserName(username);
 
         SimpleAuthorizationInfo simpleAuthorizationInfo = new SimpleAuthorizationInfo();
@@ -111,9 +113,10 @@ public class MyRealm extends AuthorizingRealm {
     protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken auth) throws AuthenticationException {
 //        log.warn("run doGetAuthenticationInfo");
         String token = (String) auth.getCredentials();
-        log.warn("token: {}", token);
+//        log.warn("token: {}", token);
         // 解密获得username,用于和数据库进行对比
-        String username = JWTUtil.getUsername(token);
+//        String username = JWTUtil.getUsername(token);
+        String username = JwtUtil2.getUsername(token);
         if (username == null) {
             log.info("error token username");
             throw new AuthenticationException("token invalid");
@@ -130,13 +133,17 @@ public class MyRealm extends AuthorizingRealm {
         log.warn("redisToken: {}", redisToken);
         if (!token.equals(redisToken)) {
             log.info("error token redis");
-//            throw new AuthenticationException("token invalid");
             throw new AuthenticationException("token invalid");
 
         }
 
 
-        if (! JWTUtil.verify(token, username, userEntity.getPassword())) {
+//        if (! JWTUtil.verify(token, username, userEntity.getPassword())) {
+//            log.info("error token username or password");
+//            throw new AuthenticationException("token invalid");
+//        }
+
+        if (! JwtUtil2.isVerify(token, username)) {
             log.info("error token username or password");
             throw new AuthenticationException("token invalid");
         }