gongdecai 2 éve
szülő
commit
b4108dbe59

+ 2 - 0
winsea-haixin-platform-backend/src/main/resources/application.yml

@@ -138,6 +138,8 @@ auth:
     - /weighingManagement/**/*
     - /biInfoController/**/*
     - /biInfoController/*
+    - /login/**/*
+    - /login/*
   expire-in: 2592000
   login-url: /login.html
   logout-url: /auth/api/logout

+ 2 - 1
winsea-haixin-plugin-base/src/main/java/com/winsea/svc/common/mq/MessageQueueClient.java

@@ -6,6 +6,7 @@ import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.listener.PatternTopic;
 import org.springframework.data.redis.listener.RedisMessageListenerContainer;
 
+import javax.annotation.Resource;
 import java.util.concurrent.TimeUnit;
 
 /**
@@ -15,7 +16,7 @@ import java.util.concurrent.TimeUnit;
  */
 public class MessageQueueClient {
 
-	@Autowired
+	@Resource
 	private RedisTemplate<String, String> redisTemplate;
 
 	@Autowired

+ 18 - 0
winsea-haixin-plugin-wangluohuoyun/pom.xml

@@ -125,6 +125,24 @@
             <artifactId>itext-asian</artifactId>
             <version>5.2.0</version>
         </dependency>
+
+        <dependency>
+            <groupId>com.auth0</groupId>
+            <artifactId>java-jwt</artifactId>
+            <version>3.10.3</version>
+        </dependency>
+        <dependency>
+            <groupId>eu.bitwalker</groupId>
+            <artifactId>UserAgentUtils</artifactId>
+            <version>1.21</version>
+        </dependency>
+        <!-- 验证码 -->
+        <dependency>
+            <groupId>com.github.whvcse</groupId>
+            <artifactId>easy-captcha</artifactId>
+            <version>1.6.2</version>
+        </dependency>
+
         <dependency>
             <groupId>org.bouncycastle</groupId>
             <artifactId>bcprov-jdk15on</artifactId>

+ 2 - 148
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/CommonUserController.java

@@ -8,7 +8,6 @@ import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.extra.qrcode.QrCodeUtil;
 import cn.hutool.extra.qrcode.QrConfig;
 import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.plugins.Page;
 import com.winsea.svc.base.base.entity.CommonCompany;
 import com.winsea.svc.base.base.entity.CommonStaff;
@@ -33,10 +32,7 @@ import com.yh.saas.plugin.yiliangyiyun.entity.UnimallMessage;
 import com.yh.saas.plugin.yiliangyiyun.entity.view.UserDefinedBean;
 import com.yh.saas.plugin.yiliangyiyun.exception.ServiceException;
 import com.yh.saas.plugin.yiliangyiyun.service.ICommonUserService;
-import com.yh.saas.plugin.yiliangyiyun.util.Base64Util;
-import com.yh.saas.plugin.yiliangyiyun.util.FileUtil;
-import com.yh.saas.plugin.yiliangyiyun.util.HttpUtil;
-import com.yh.saas.plugin.yiliangyiyun.util.WebSocket;
+import com.yh.saas.plugin.yiliangyiyun.util.*;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.MediaType;
@@ -61,6 +57,7 @@ import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
+
 /**
  * <p>
  * 前端控制器
@@ -91,149 +88,6 @@ public class CommonUserController {
     @Autowired
     private WebSocket webSocket;
 
-    /**
-     * 缓存放二维码会话,设置1分钟过期
-     */
-    private TimedCache qrCodeSession= CacheUtil.newTimedCache(1000*60);
-
-    /**
-     * 存储token信息
-     */
-    private TimedCache mobileTokenSession=CacheUtil.newTimedCache(1000*60);
-
-
-
-    /**
-     * 生成PC端登录二维码
-     * @return
-     */
-    @GetMapping(value = "/pcQrCode")
-    public Mono<AjaxResult<Map<String,String>>> pcQrCode(){
-        return Mono.create((sink)->{
-            //生成会话编号
-            String sessionId= IdUtil.objectId();
-            log.debug("sessionId={}",sessionId);
-            SessionPojo sessionPojo=new SessionPojo();
-            sessionPojo.setSessionId(sessionId);
-            //0 二维码 生成状态 ,1 扫码状态 2 登录状态
-            sessionPojo.setStatus(0);
-
-            //生成base64二维码
-            QrConfig qrConfig=new QrConfig();
-            qrConfig.setWidth(300);
-            qrConfig.setHeight(300);
-            String base64Code= QrCodeUtil.generateAsBase64(sessionId, qrConfig,"jpeg");
-
-            //绑定返回体数据
-            AjaxResult<Map<String,String>> ajaxResult=AjaxResult.SUCCESS;
-            Map<String,String> resultData=new HashMap<>();
-            resultData.put("sessionId",sessionId);
-            resultData.put("base64Code",base64Code);
-            ajaxResult.setData(resultData);
-
-            //存入缓存
-            qrCodeSession.put(sessionId,sessionPojo);
-
-            sink.success(ajaxResult);
-        });
-    }
-
-
-    /**
-     * 监听二维码 session 状态
-     * @param sessionId
-     * @return
-     */
-    @GetMapping(value = "/getSessionStatus",produces = MediaType.TEXT_EVENT_STREAM_VALUE)
-    public Mono<AjaxResult<SessionPojo>> getSessionStatus(String sessionId){
-        return Mono.create((sink)->{
-            SessionPojo sessionPojo =(SessionPojo)qrCodeSession.get(sessionId);
-            AjaxResult ajaxResult=AjaxResult.SUCCESS;
-            if(ObjectUtil.isNull(sessionPojo)){
-                sessionPojo=new SessionPojo();
-                sessionPojo.setSessionId(sessionId);
-                //0 二维码 生成状态 ,1 扫码成功 2 登录成功  -1 sessionId过期失效
-                sessionPojo.setStatus(-1);
-            }
-            ajaxResult.setData(sessionPojo);
-            sink.success(ajaxResult);
-        });
-    }
-
-    /**
-     * 扫码二维码成功
-     * @return
-     */
-    @PostMapping(value = "/mobileScanOk")
-    public Mono<AjaxResult> mobileScanOk(ServerWebExchange exchange)
-    {
-
-        return exchange.getFormData().flatMap((formData)->{
-            //判断二维码session是否有效
-            String sessionId = formData.getFirst("sessionId");
-            String token=formData.getFirst("token");
-
-            SessionPojo sessionPojo = (SessionPojo) qrCodeSession.get(sessionId);
-            if(ObjectUtil.isNull(sessionPojo)){
-                AjaxResult ajaxResult=AjaxResult.Fail;
-                ajaxResult.setMsg("二维码已失效");
-                return Mono.just(ajaxResult);
-            }
-
-            //判断token是否有效
-            CommonUser userEntity = (CommonUser) mobileTokenSession.get(token);
-
-            //0 二维码 生成状态 ,1 扫码成功 2 登录成功  -1 sessionId过期失效
-            mobileTokenSession.get(token);
-            sessionPojo.setStatus(1);
-            sessionPojo.setUsername(userEntity.getUserName());
-            AjaxResult ajaxResult=AjaxResult.SUCCESS;
-            ajaxResult.setMsg("扫描成功,等待手机端确认操作");
-            return Mono.just(ajaxResult);
-        });
-
-
-    }
-
-
-    /**
-     * 手机端确认登录
-     * @return
-     */
-    @PostMapping(value = "/mobileOkPcLogin")
-    public Mono<AjaxResult> mobileOkPcLogin(ServerWebExchange exchange){
-
-        return exchange.getFormData().flatMap(formData -> {
-            String sessionId = formData.getFirst("sessionId");
-            String token=formData.getFirst("token");
-
-            //判断二维码session是否有效
-            SessionPojo sessionPojo = (SessionPojo) qrCodeSession.get(sessionId);
-            if (ObjectUtil.isNull(sessionPojo)) {
-                AjaxResult ajaxResult = AjaxResult.Fail;
-                ajaxResult.setMsg("二维码已失效");
-                return Mono.just(ajaxResult);
-            }
-
-            //判断token是否有效
-            CommonUser userEntity = (CommonUser) mobileTokenSession.get(token);
-            if (ObjectUtil.isNull(userEntity)) {
-                AjaxResult ajaxResult = AjaxResult.Fail;
-                ajaxResult.setMsg("用户信息验证失效");
-                return Mono.just(ajaxResult);
-            }
-
-            //修改二维码session对象状态
-            //0 二维码 生成状态 ,1 扫码成功 2 登录成功  -1 sessionId过期失效
-            sessionPojo.setUsername(userEntity.getUserName());
-            sessionPojo.setStatus(2);
-
-            AjaxResult ajaxResult = AjaxResult.SUCCESS;
-            ajaxResult.setMsg("PC登录成功");
-            return Mono.just(ajaxResult);
-        });
-
-    }
 
 
 

+ 299 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/QrCodeLoginController.java

@@ -0,0 +1,299 @@
+package com.yh.saas.plugin.yiliangyiyun.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.aliyun.oss.OSSClient;
+import com.aliyun.oss.model.ObjectMetadata;
+import com.aliyun.oss.model.PutObjectRequest;
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.winsea.svc.base.base.mapper.CommonStaffMapper;
+import com.winsea.svc.base.base.service.*;
+import com.winsea.svc.base.security.config.SecurityProperties;
+import com.winsea.svc.base.security.service.IAccountService;
+import com.winsea.svc.notice.service.INoticeBusinessConstantService;
+import com.winsea.svc.notice.service.INoticeBusinessResourceService;
+import com.winsea.svc.notice.service.INoticeTaskService;
+import com.winsea.svc.notice.service.INoticeUtilService;
+import com.yh.saas.plugin.yiliangyiyun.entity.CommonUser;
+import com.yh.saas.plugin.yiliangyiyun.entity.HyCacheComponent;
+import com.yh.saas.plugin.yiliangyiyun.entity.HyCargoOwnerInfo;
+import com.yh.saas.plugin.yiliangyiyun.entity.HyDriverInfo;
+import com.yh.saas.plugin.yiliangyiyun.exception.AppServiceException;
+import com.yh.saas.plugin.yiliangyiyun.exception.ExceptionDefinition;
+import com.yh.saas.plugin.yiliangyiyun.exception.ServiceException;
+import com.yh.saas.plugin.yiliangyiyun.mapper.CommonUserMapper;
+import com.yh.saas.plugin.yiliangyiyun.service.ICargoOwnerInfoService;
+import com.yh.saas.plugin.yiliangyiyun.service.ICommonUserService;
+import com.yh.saas.plugin.yiliangyiyun.service.IDriverInfoService;
+import com.yh.saas.plugin.yiliangyiyun.util.*;
+import io.lettuce.core.dynamic.annotation.Param;
+import lombok.Getter;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.http.entity.ContentType;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.mock.web.MockMultipartFile;
+import org.springframework.stereotype.Controller;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author lx
+ */
+@RestController
+@RequestMapping("/login")
+public class QrCodeLoginController {
+
+
+    private static String VERIFY_CODE_PREFIX = "VERIFY_CODE_";
+    @Autowired
+    private HyCacheComponent hyCacheComponent;
+
+    @Autowired
+    private StringRedisTemplate userRedisTemplate;
+
+    @Autowired
+    private ICargoOwnerInfoService cargoOwnerInfoService;
+    @Autowired
+    private IDriverInfoService driverInfoService;
+    @Autowired
+    private ICommonUserService commonUserService;
+    Connection coon = null;
+    @Value("com.mysql.jdbc.Driver")
+    private String driverClassName;
+    @Value("jdbc:mysql://47.100.3.209:3306/talk-portal?createDatabaseIfNotExist=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true")
+    private String url;
+    @Value("root")
+    private String username;
+    @Value("Ccj841968545")
+    private String password;
+
+    @Autowired
+    private RedisUtil redisUtil;
+
+    @GetMapping("/index")
+    public String index() {
+        return "index";
+    }
+
+    @Autowired
+    private OSSClient ossClient;
+    @Getter
+    @Value("${oss.bucket.name:}")
+    private String bucket;
+    @Getter
+    @Value("${oss.endpoint.internal:}")
+    private String baseUrl;
+
+    private int ii = 0;
+
+    private String phone;
+
+
+    @GetMapping(value = "/loginQrCode")
+    @ResponseBody
+    public Map<String, Object> loginQrCode() {
+        Map<String, Object> data = new HashMap<>();
+        data.put("code", 0);
+        data.put("msg", "获取登录二维码失败!");
+        try {
+            String imgName = +System.currentTimeMillis() + ".png";
+            String flag = String.valueOf(System.currentTimeMillis());
+            File files = new File(new String(("templates" + File.separator + imgName).getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8));
+            FileOutputStream fileOutputStream = new FileOutputStream(files);
+            Map<String, String> res = QrCodeCreateUtil.createQrCode(fileOutputStream, "/login/loginInfo?token=" + flag, 200, "png");
+            FileInputStream fileInputStream = new FileInputStream(files.getAbsoluteFile());
+            MultipartFile multipartFile = new MockMultipartFile(ContentType.APPLICATION_OCTET_STREAM.toString(), fileInputStream);
+            String result = upload(multipartFile, imgName);
+            files.delete();
+            if ("200".equals(res.get("status"))) {
+                data.put("code", 200);
+                data.put("msg", "获取登录二维码成功!");
+                Map<String, Object> param = new HashMap<>();
+                param.put("msg", "获取登录二维码成功!");
+                param.put("code", 200);
+                param.put("src", result);
+                param.put("token", flag);
+                data.put("data", param);
+            }
+            return data;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return data;
+        }
+    }
+
+    /**
+     * 后台通过服务器间接传文件
+     *
+     * @param file
+     * @return
+     * @throws IOException
+     */
+    public String upload(MultipartFile file, String sendCarNo) throws IOException {
+        ObjectMetadata objectMetadata = new ObjectMetadata();
+        objectMetadata.setContentLength(file.getSize());
+        objectMetadata.setContentType(file.getContentType());
+        PutObjectRequest putObjectRequest = new PutObjectRequest(bucket, "QrCodeLogin/" + sendCarNo, file.getInputStream(), objectMetadata);
+        ossClient.putObject(putObjectRequest);
+        return baseUrl + "QrCodeLogin/" + sendCarNo;
+    }
+
+    @GetMapping(value = "/loginInfo")
+    public Map<String, Object> loginInfo(@Param("token") String token) {
+        Map<String, Object> data = new HashMap<>();
+        data.put("code", 0);
+        data.put("msg", "扫描失败!");
+        try {
+            if (token != null && !"".equals(token)) {
+                data.put("code", 200);
+                redisUtil.hPut("login", token, "1");
+                data.put("msg", "扫描成功!");
+
+            }
+            return data;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return data;
+        }
+    }
+
+    @GetMapping(value = "/getLoginStatus")
+    @ResponseBody
+    public Map<String, Object> getLoginStatus(@Param("token") String token) {
+        Map<String, Object> data = new HashMap<>();
+        data.put("code", 0);
+        data.put("msg", "未登录!");
+        try {
+            if (token != null && !"".equals(token)) {
+                ii = ii + 1;
+                if (ii > 30) {
+                    ii = 0;
+                    data.put("code", 4);
+                    data.put("msg", "二维码失效!");
+                }
+                Object check = redisUtil.hGet("login", token);
+                if (check != null && !"".equals(check)) {
+                    data.put("code", 200);
+                    data.put("msg", "扫描成功!");
+                }
+                Object check1 = redisUtil.hGet("status", "denglu");
+                if (check1 != null && !"".equals(check1)) {
+                    redisUtil.hPut("status", "denglu", "");
+                    data.put("code", 200);
+                    if(login()!= null){
+                        data.put("msg", login());
+                        phone = null;
+                    }
+                    else{
+//                        data.put("msg", "200");
+                        data.put("msg", "二维码失效!");
+                    }
+                }
+            }
+            return data;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return data;
+        }
+    }
+
+
+    /**
+     * 快捷登录
+     *
+     * @param commonUser
+     * @return
+     * @throws ServiceException
+     */
+    @PostMapping(value = "/loginCode")
+    @Transactional(rollbackFor = Exception.class)
+    public Map<String, Object> loginCode(@RequestBody CommonUser commonUser) throws ServiceException {
+        Object check = redisUtil.hGet("login", commonUser.getToken());
+        if (check != null && !"".equals(check)) {
+            phone = commonUser.getPhone();
+            Map<String, Object> data = new HashMap<>();
+            data.put("code", 200);
+            data.put("msg", "登陆成功!");
+            redisUtil.hPut("status", "denglu", "1");
+            return data;
+        } else {
+            throw new AppServiceException(ExceptionDefinition.USER_THIRD_PART_LOGIN_FAILED);
+        }
+    }
+
+
+    public CommonUser login() throws ServiceException {
+        if(StringUtils.isNotBlank(phone)) {
+            java.util.Date now = new java.util.Date();
+            //2.校验用户是否存在
+            List<CommonUser> targetUserList = commonUserService.selectList(
+                    new EntityWrapper<CommonUser>()
+                            .eq("phone", phone).eq("identification", "2"));
+            CommonUser userDO = new CommonUser();
+
+            if (CollectionUtils.isEmpty(targetUserList)) {
+                throw new AppServiceException(ExceptionDefinition.USER_PHONE_NOT_EXIST);
+            } else {
+                userDO = targetUserList.get(0);
+                //检查帐号是否已经冻结
+                if (userDO.getStatus() == 0) {
+                    throw new AppServiceException(ExceptionDefinition.USER_CAN_NOT_ACTICE);
+                }
+            }
+            if (phone != null) {
+                DBConnection();
+                String sUserId = null;
+                String password = null;
+                commonUserService.updateById(userDO);
+            }
+            //返回用户DTO
+            hyCacheComponent.del(VERIFY_CODE_PREFIX + phone);
+            String accessToken = GeneratorUtil.genSessionId();
+            CommonUser userDTO = new CommonUser();
+            BeanUtils.copyProperties(userDO, userDTO);
+            userDTO.setAccessToken(accessToken);
+            //放入SESSION专用Redis数据源中
+            userRedisTemplate.opsForValue().set(Const.USER_REDIS_PREFIX + accessToken, JSONObject.toJSONString(userDTO));
+            commonUserService.updateById(userDO);
+            HyCargoOwnerInfo hyCargoOwnerInfo = cargoOwnerInfoService.selectOne(new EntityWrapper<HyCargoOwnerInfo>().eq("common_id", userDTO.getId()));
+            if (hyCargoOwnerInfo != null) {
+                userDTO.setStatusFlag(hyCargoOwnerInfo.getAuthenticationStatus());
+            }
+
+            return userDTO;
+        }
+        else{
+            return null;
+        }
+    }
+
+
+    public void DBConnection() {
+        try {
+            //加载驱动程序
+            Class.forName(driverClassName);
+            coon = (Connection) DriverManager.getConnection(url, username, password);
+            if (!coon.isClosed()) {
+                System.out.println("成功连接数据库!");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+}

+ 5 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/CommonUser.java

@@ -119,6 +119,11 @@ public class CommonUser extends BaseModel<CommonUser> {
      */
     @TableField(exist = false)
     private String  statusFlag ;
+    /**
+     * token
+     */
+    @TableField(exist = false)
+    private String token ;
 
 
     @Override

+ 117 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/util/CaptchaUtils.java

@@ -0,0 +1,117 @@
+package com.yh.saas.plugin.yiliangyiyun.util;
+
+
+import com.wf.captcha.SpecCaptcha;
+import com.wf.captcha.base.Captcha;
+import com.wf.captcha.utils.CaptchaUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.awt.*;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * @author lx
+ * 验证码工具类
+ */
+public class CaptchaUtils extends CaptchaUtil {
+
+    @Autowired
+    private RedisUtil redisCacheManager;
+
+    /**
+     * 生成验证码,session(type=0),key为captcha/redis(type=1)key为system:captcha存储
+     * @param request
+     * @param response
+     * @throws Exception
+     */
+    public Map<String,String> captcha(HttpServletRequest request, HttpServletResponse response, String type) throws Exception {
+        Map<String,String> data=new HashMap<>();
+        // 设置请求头为输出图片类型
+        CaptchaUtil.setHeader(response);
+        // 三个参数分别为宽、高、位数
+        SpecCaptcha specCaptcha = new SpecCaptcha(130, 48, 5);
+        // gif类型
+        //GifCaptcha captcha = new GifCaptcha(130, 48);
+        // 中文类型
+        //ChineseCaptcha captcha = new ChineseCaptcha(130, 48);
+        // 中文gif类型
+        //ChineseGifCaptcha captcha = new ChineseGifCaptcha(130, 48);
+        // 算术类型
+        //ArithmeticCaptcha captcha = new ArithmeticCaptcha(130, 48);
+        //captcha.setLen(3);  // 几位数运算,默认是两位
+        //captcha.getArithmeticString();  // 获取运算的公式:3+2=?
+        //captcha.text();  // 获取运算的结果:5
+
+        // 设置字体 非必填
+        specCaptcha.setFont(new Font("Verdana", Font.PLAIN, 32));
+        // 设置类型,纯数字、纯字母、字母数字混合
+        // * TYPE_DEFAULT	数字和字母混合
+        // * TYPE_ONLY_NUMBER	纯数字
+        // * TYPE_ONLY_CHAR	纯字母
+        // * TYPE_ONLY_UPPER	纯大写字母
+        // * TYPE_ONLY_LOWER	纯小写字母
+        // * TYPE_NUM_AND_UPPER	数字和大写字母
+
+        specCaptcha.setCharType(Captcha.TYPE_ONLY_NUMBER);
+        if ("1".equals(type)){
+            String uuid=UUID.randomUUID().toString();
+            // 验证码存入redis
+            redisCacheManager.hPut("system:captcha",uuid,specCaptcha.text().toLowerCase());
+            data.put("key","system:captcha");
+            data.put("uid",uuid);
+            this.checkCaptchaByRedis(uuid,"");
+        }else {
+            // 验证码存入session
+            request.getSession().setAttribute("captcha", specCaptcha.text().toLowerCase());
+            data.put("key","captcha");
+        }
+        data.put("src",specCaptcha.toBase64());
+        return data;
+    }
+
+    /**
+     * 通过session获取验证码,判断验证码是否正确 0 不正确 1 正确
+     * @param request
+     * @param key session key
+     * @param captcha captcha 验证码
+     * @return
+     * @throws Exception
+     */
+    public Map<String,String> checkCaptchBySession(HttpServletRequest request, String key, String captcha) throws Exception{
+        Map<String,String> data=new HashMap<>();
+        data.put("code","0");
+        // 获取session中的验证码
+        Object sessionCode = request.getSession().getAttribute(key);
+        // 判断验证码
+        if (sessionCode!=null&&sessionCode.equals(captcha.trim().toLowerCase())) {
+            // 清除session中的验证码
+            CaptchaUtil.clear(request);
+            data.put("code","1");
+        }
+        return data;
+    }
+
+    /**
+     * 通过redis获取验证码,判断验证码是否正确 0 不正确 1 正确
+     * @param key
+     * @param captcha
+     * @return
+     */
+    public Map<String,String> checkCaptchaByRedis(String key, String captcha){
+        Map<String,String> data=new HashMap<>();
+        data.put("code","0");
+        // 获取redis中的验证码
+        Object redisCode = redisCacheManager.hGet("system:captcha",key);
+        // 判断验证码
+        if (redisCode!=null&&redisCode.equals(captcha.trim().toLowerCase())) {
+            // 清除redis中的验证码
+            redisCacheManager.hDelete("system:captcha",key);
+            data.put("code","1");
+        }
+        return data;
+    }
+}

+ 43 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/util/PathConfig.java

@@ -0,0 +1,43 @@
+package com.yh.saas.plugin.yiliangyiyun.util;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
+import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
+import org.springframework.web.servlet.view.InternalResourceViewResolver;
+
+/**
+ * @author lx
+ */
+@Configuration
+public class PathConfig extends WebMvcConfigurationSupport {
+
+    @Bean
+    public InternalResourceViewResolver viewResolver() {
+        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
+        viewResolver.setPrefix("/classes/templates/");
+        viewResolver.setSuffix(".html");
+        return viewResolver;
+    }
+    @Override
+    public void addViewControllers(ViewControllerRegistry registry) {
+        registry.addViewController("/").setViewName("index");
+    }
+
+    @Override
+    public void addResourceHandlers(ResourceHandlerRegistry registry) {
+        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
+        registry.addResourceHandler("/img/**").addResourceLocations("file:/Volumes/work/upload/");
+        //阿里云(映射路径去除盘符)
+        //registry.addResourceHandler("/ueditor/image/**").addResourceLocations("/upload/image/");
+        //registry.addResourceHandler("/ueditor/video/**").addResourceLocations("/upload/video/");
+    }
+
+    @Override
+    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
+        configurer.enable();
+    }
+
+}

+ 117 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/util/QrCodeCreateUtil.java

@@ -0,0 +1,117 @@
+package com.yh.saas.plugin.yiliangyiyun.util;
+
+import com.google.zxing.*;
+import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
+import com.google.zxing.common.BitMatrix;
+import com.google.zxing.common.HybridBinarizer;
+import com.google.zxing.qrcode.QRCodeReader;
+import com.google.zxing.qrcode.QRCodeWriter;
+import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
+
+import javax.imageio.ImageIO;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+
+/**
+ * @author lx
+ * @describe 二维码工具类
+ */
+public class QrCodeCreateUtil {
+
+    /**
+     * 37      * 生成包含字符串信息的二维码图片
+     * 38      * @param outputStream 文件输出流路径
+     * 39      * @param content 二维码携带信息
+     * 40      * @param qrCodeSize 二维码图片大小
+     * 41      * @param imageFormat 二维码的格式 jpg、png
+     * 42      * @throws WriterException
+     * 43      * @throws IOException
+     * 44
+     */
+    public static Map<String,String> createQrCode(OutputStream outputStream, String content, int qrCodeSize, String imageFormat) throws WriterException, IOException {
+
+        Map<String,String> data=new HashMap<>();
+        data.put("status","0");
+        data.put("msg","无内容,无法进行二维码生成!");
+        if (content==null||"".equals(content)){
+            return data;
+        }
+        /**
+         * com.google.zxing.EncodeHintType:编码提示类型,枚举类型
+         * EncodeHintType.CHARACTER_SET:设置字符编码类型
+         * EncodeHintType.ERROR_CORRECTION:设置误差校正
+         *      ErrorCorrectionLevel:误差校正等级,L = ~7% correction、M = ~15% correction、Q = ~25% correction、H = ~30% correction
+         *      不设置时,默认为 L 等级,等级不一样,生成的图案不同,但扫描的结果是一样的
+         * EncodeHintType.MARGIN:设置二维码边距,单位像素,值越小,二维码距离四周越近
+         * */
+        Hashtable<EncodeHintType, ErrorCorrectionLevel> hintMap = new Hashtable<EncodeHintType, ErrorCorrectionLevel>();
+        // 矫错级别
+        hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
+        /**
+         * MultiFormatWriter/QRCodeWriter:多格式写入,这是一个工厂类,里面重载了两个 encode 方法,用于写入条形码或二维码
+         *      encode(String contents,BarcodeFormat format,int width, int height,Map<EncodeHintType,?> hints)
+         *      contents:条形码/二维码内容
+         *      format:编码类型,如 条形码,二维码 等
+         *      width:码的宽度
+         *      height:码的高度
+         *      hints:码内容的编码类型
+         * BarcodeFormat:枚举该程序包已知的条形码格式,即创建何种码,如 1 维的条形码,2 维的二维码 等
+         * BitMatrix:位(比特)矩阵或叫2D矩阵,也就是需要的二维码
+         **/
+        QRCodeWriter qrCodeWriter = new QRCodeWriter();
+        //创建比特矩阵(位矩阵)的QR码编码的字符串
+        BitMatrix byteMatrix = qrCodeWriter.encode(content, BarcodeFormat.QR_CODE, qrCodeSize, qrCodeSize, hintMap);
+        // 使BufferedImage勾画QRCode  (matrixWidth 是行二维码像素点)
+        int matrixWidth = byteMatrix.getWidth();
+        BufferedImage image = new BufferedImage(matrixWidth, matrixWidth, BufferedImage.TYPE_INT_RGB);
+        image.createGraphics();
+        Graphics2D graphics = (Graphics2D) image.getGraphics();
+        graphics.setColor(Color.WHITE);
+        graphics.fillRect(0, 0, matrixWidth, matrixWidth);
+        // 使用比特矩阵画并保存图像
+        graphics.setColor(Color.BLACK);
+        for (int i = 0; i < matrixWidth; i++) {
+            for (int j = 0; j < matrixWidth; j++) {
+                if (byteMatrix.get(i, j)) {
+                    graphics.fillRect(i, j, 1, 1);
+                }
+            }
+        }
+       boolean check=ImageIO.write(image, imageFormat, outputStream);
+        if (check){
+            data.put("status","200");
+            data.put("msg","成功!");
+            return data;
+        }else {
+            data.put("msg","图像保存失败!");
+            return data;
+        }
+    }
+
+
+    /**
+     * 读二维码并输出携带的信息
+     */
+    public static String readQrCode(InputStream inputStream) throws IOException {
+        //从输入流中获取字符串信息
+        BufferedImage image = ImageIO.read(inputStream);
+        //将图像转换为二进制位图源
+        LuminanceSource source = new BufferedImageLuminanceSource(image);
+        BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
+        QRCodeReader reader = new QRCodeReader();
+        Result result = null;
+        try {
+            result = reader.decode(bitmap);
+            return result.getText();
+        } catch (ReaderException e) {
+            e.printStackTrace();
+            return "";
+        }
+    }
+}

+ 1401 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/util/RedisUtil.java

@@ -0,0 +1,1401 @@
+package com.yh.saas.plugin.yiliangyiyun.util;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.connection.DataType;
+import org.springframework.data.redis.core.Cursor;
+import org.springframework.data.redis.core.ScanOptions;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.data.redis.core.ZSetOperations.TypedTuple;
+import org.springframework.stereotype.Component;
+
+import java.util.*;
+import java.util.Map.Entry;
+import java.util.concurrent.TimeUnit;
+
+@Component
+public class RedisUtil {
+
+
+        @Autowired
+        private StringRedisTemplate redisTemplate;
+
+        public void setRedisTemplate(StringRedisTemplate redisTemplate) {
+            this.redisTemplate = redisTemplate;
+        }
+
+        public StringRedisTemplate getRedisTemplate() {
+            return this.redisTemplate;
+        }
+
+
+        /** -------------------key相关操作--------------------- */
+
+        /**
+         * 删除key
+         *
+         * @param key
+         */
+        public void delete(String key) {
+            redisTemplate.delete(key);
+        }
+
+        /**
+         * 批量删除key
+         *
+         * @param keys
+         */
+        public void delete(Collection<String> keys) {
+            redisTemplate.delete(keys);
+        }
+
+        /**
+         * 序列化key
+         *
+         * @param key
+         * @return
+         */
+        public byte[] dump(String key) {
+            return redisTemplate.dump(key);
+        }
+
+        /**
+         * 是否存在key
+         *
+         * @param key
+         * @return
+         */
+        public Boolean hasKey(String key) {
+            return redisTemplate.hasKey(key);
+        }
+
+        /**
+         * 设置过期时间
+         *
+         * @param key
+         * @param timeout
+         * @param unit
+         * @return
+         */
+        public Boolean expire(String key, long timeout, TimeUnit unit) {
+            return redisTemplate.expire(key, timeout, unit);
+        }
+
+        /**
+         * 设置过期时间
+         *
+         * @param key
+         * @param date
+         * @return
+         */
+        public Boolean expireAt(String key, Date date) {
+            return redisTemplate.expireAt(key, date);
+        }
+
+        /**
+         * 查找匹配的key
+         *
+         * @param pattern
+         * @return
+         */
+        public Set<String> keys(String pattern) {
+            return redisTemplate.keys(pattern);
+        }
+
+        /**
+         * 将当前数据库的 key 移动到给定的数据库 db 当中
+         *
+         * @param key
+         * @param dbIndex
+         * @return
+         */
+        public Boolean move(String key, int dbIndex) {
+            return redisTemplate.move(key, dbIndex);
+        }
+
+        /**
+         * 移除 key 的过期时间,key 将持久保持
+         *
+         * @param key
+         * @return
+         */
+        public Boolean persist(String key) {
+            return redisTemplate.persist(key);
+        }
+
+        /**
+         * 返回 key 的剩余的过期时间
+         *
+         * @param key
+         * @param unit
+         * @return
+         */
+        public Long getExpire(String key, TimeUnit unit) {
+            return redisTemplate.getExpire(key, unit);
+        }
+
+        /**
+         * 返回 key 的剩余的过期时间
+         *
+         * @param key
+         * @return
+         */
+        public Long getExpire(String key) {
+            return redisTemplate.getExpire(key);
+        }
+
+        /**
+         * 从当前数据库中随机返回一个 key
+         *
+         * @return
+         */
+        public String randomKey() {
+            return redisTemplate.randomKey();
+        }
+
+        /**
+         * 修改 key 的名称
+         *
+         * @param oldKey
+         * @param newKey
+         */
+        public void rename(String oldKey, String newKey) {
+            redisTemplate.rename(oldKey, newKey);
+        }
+
+        /**
+         * 仅当 newkey 不存在时,将 oldKey 改名为 newkey
+         *
+         * @param oldKey
+         * @param newKey
+         * @return
+         */
+        public Boolean renameIfAbsent(String oldKey, String newKey) {
+            return redisTemplate.renameIfAbsent(oldKey, newKey);
+        }
+
+        /**
+         * 返回 key 所储存的值的类型
+         *
+         * @param key
+         * @return
+         */
+        public DataType type(String key) {
+            return redisTemplate.type(key);
+        }
+
+        /** -------------------string相关操作--------------------- */
+
+        /**
+         * 设置指定 key 的值
+         * @param key
+         * @param value
+         */
+        public void set(String key, String value) {
+            redisTemplate.opsForValue().set(key, value);
+        }
+
+        /**
+         * 获取指定 key 的值
+         * @param key
+         * @return
+         */
+        public String get(String key) {
+            return redisTemplate.opsForValue().get(key);
+        }
+
+        /**
+         * 返回 key 中字符串值的子字符
+         * @param key
+         * @param start
+         * @param end
+         * @return
+         */
+        public String getRange(String key, long start, long end) {
+            return redisTemplate.opsForValue().get(key, start, end);
+        }
+
+        /**
+         * 将给定 key 的值设为 value ,并返回 key 的旧值(old value)
+         *
+         * @param key
+         * @param value
+         * @return
+         */
+        public String getAndSet(String key, String value) {
+            return redisTemplate.opsForValue().getAndSet(key, value);
+        }
+
+        /**
+         * 对 key 所储存的字符串值,获取指定偏移量上的位(bit)
+         *
+         * @param key
+         * @param offset
+         * @return
+         */
+        public Boolean getBit(String key, long offset) {
+            return redisTemplate.opsForValue().getBit(key, offset);
+        }
+
+        /**
+         * 批量获取
+         *
+         * @param keys
+         * @return
+         */
+        public List<String> multiGet(Collection<String> keys) {
+            return redisTemplate.opsForValue().multiGet(keys);
+        }
+
+        /**
+         * 设置ASCII码, 字符串'a'的ASCII码是97, 转为二进制是'01100001', 此方法是将二进制第offset位值变为value
+         *
+         * @param key
+         * @param offset
+         *            位置
+         * @param value
+         *            值,true为1, false为0
+         * @return
+         */
+        public boolean setBit(String key, long offset, boolean value) {
+            return redisTemplate.opsForValue().setBit(key, offset, value);
+        }
+
+        /**
+         * 将值 value 关联到 key ,并将 key 的过期时间设为 timeout
+         *
+         * @param key
+         * @param value
+         * @param timeout
+         *            过期时间
+         * @param unit
+         *            时间单位, 天:TimeUnit.DAYS 小时:TimeUnit.HOURS 分钟:TimeUnit.MINUTES
+         *            秒:TimeUnit.SECONDS 毫秒:TimeUnit.MILLISECONDS
+         */
+        public void setEx(String key, String value, long timeout, TimeUnit unit) {
+            redisTemplate.opsForValue().set(key, value, timeout, unit);
+        }
+
+        /**
+         * 只有在 key 不存在时设置 key 的值
+         *
+         * @param key
+         * @param value
+         * @return 之前已经存在返回false,不存在返回true
+         */
+        public boolean setIfAbsent(String key, String value) {
+            return redisTemplate.opsForValue().setIfAbsent(key, value);
+        }
+
+        /**
+         * 用 value 参数覆写给定 key 所储存的字符串值,从偏移量 offset 开始
+         *
+         * @param key
+         * @param value
+         * @param offset
+         *            从指定位置开始覆写
+         */
+        public void setRange(String key, String value, long offset) {
+            redisTemplate.opsForValue().set(key, value, offset);
+        }
+
+        /**
+         * 获取字符串的长度
+         *
+         * @param key
+         * @return
+         */
+        public Long size(String key) {
+            return redisTemplate.opsForValue().size(key);
+        }
+
+        /**
+         * 批量添加
+         *
+         * @param maps
+         */
+        public void multiSet(Map<String, String> maps) {
+            redisTemplate.opsForValue().multiSet(maps);
+        }
+
+        /**
+         * 同时设置一个或多个 key-value 对,当且仅当所有给定 key 都不存在
+         *
+         * @param maps
+         * @return 之前已经存在返回false,不存在返回true
+         */
+        public boolean multiSetIfAbsent(Map<String, String> maps) {
+            return redisTemplate.opsForValue().multiSetIfAbsent(maps);
+        }
+
+        /**
+         * 增加(自增长), 负数则为自减
+         *
+         * @param key
+         * @param increment
+         * @return
+         */
+        public Long incrBy(String key, long increment) {
+            return redisTemplate.opsForValue().increment(key, increment);
+        }
+
+        /**
+         *
+         * @param key
+         * @param increment
+         * @return
+         */
+        public Double incrByFloat(String key, double increment) {
+            return redisTemplate.opsForValue().increment(key, increment);
+        }
+
+        /**
+         * 追加到末尾
+         *
+         * @param key
+         * @param value
+         * @return
+         */
+        public Integer append(String key, String value) {
+            return redisTemplate.opsForValue().append(key, value);
+        }
+
+        /** -------------------hash相关操作------------------------- */
+
+        /**
+         * 获取存储在哈希表中指定字段的值
+         *
+         * @param key
+         * @param field
+         * @return
+         */
+        public Object hGet(String key, String field) {
+            return redisTemplate.opsForHash().get(key, field);
+        }
+
+        /**
+         * 获取所有给定字段的值
+         *
+         * @param key
+         * @return
+         */
+        public Map<Object, Object> hGetAll(String key) {
+            return redisTemplate.opsForHash().entries(key);
+        }
+
+        /**
+         * 获取所有给定字段的值
+         *
+         * @param key
+         * @param fields
+         * @return
+         */
+        public List<Object> hMultiGet(String key, Collection<Object> fields) {
+            return redisTemplate.opsForHash().multiGet(key, fields);
+        }
+
+        public void hPut(String key, String hashKey, String value) {
+            redisTemplate.opsForHash().put(key, hashKey, value);
+        }
+
+        public void hPutAll(String key, Map<String, String> maps) {
+            redisTemplate.opsForHash().putAll(key, maps);
+        }
+
+        /**
+         * 仅当hashKey不存在时才设置
+         *
+         * @param key
+         * @param hashKey
+         * @param value
+         * @return
+         */
+        public Boolean hPutIfAbsent(String key, String hashKey, String value) {
+            return redisTemplate.opsForHash().putIfAbsent(key, hashKey, value);
+        }
+
+        /**
+         * 删除一个或多个哈希表字段
+         *
+         * @param key
+         * @param fields
+         * @return
+         */
+        public Long hDelete(String key, Object... fields) {
+            return redisTemplate.opsForHash().delete(key, fields);
+        }
+
+        /**
+         * 查看哈希表 key 中,指定的字段是否存在
+         *
+         * @param key
+         * @param field
+         * @return
+         */
+        public boolean hExists(String key, String field) {
+            return redisTemplate.opsForHash().hasKey(key, field);
+        }
+
+        /**
+         * 为哈希表 key 中的指定字段的整数值加上增量 increment
+         *
+         * @param key
+         * @param field
+         * @param increment
+         * @return
+         */
+        public Long hIncrBy(String key, Object field, long increment) {
+            return redisTemplate.opsForHash().increment(key, field, increment);
+        }
+
+        /**
+         * 为哈希表 key 中的指定字段的整数值加上增量 increment
+         *
+         * @param key
+         * @param field
+         * @param delta
+         * @return
+         */
+        public Double hIncrByFloat(String key, Object field, double delta) {
+            return redisTemplate.opsForHash().increment(key, field, delta);
+        }
+
+        /**
+         * 获取所有哈希表中的字段
+         *
+         * @param key
+         * @return
+         */
+        public Set<Object> hKeys(String key) {
+            return redisTemplate.opsForHash().keys(key);
+        }
+
+        /**
+         * 获取哈希表中字段的数量
+         *
+         * @param key
+         * @return
+         */
+        public Long hSize(String key) {
+            return redisTemplate.opsForHash().size(key);
+        }
+
+        /**
+         * 获取哈希表中所有值
+         *
+         * @param key
+         * @return
+         */
+        public List<Object> hValues(String key) {
+            return redisTemplate.opsForHash().values(key);
+        }
+
+        /**
+         * 迭代哈希表中的键值对
+         *
+         * @param key
+         * @param options
+         * @return
+         */
+        public Cursor<Entry<Object, Object>> hScan(String key, ScanOptions options) {
+            return redisTemplate.opsForHash().scan(key, options);
+        }
+
+        /** ------------------------list相关操作---------------------------- */
+
+        /**
+         * 通过索引获取列表中的元素
+         *
+         * @param key
+         * @param index
+         * @return
+         */
+        public String lIndex(String key, long index) {
+            return redisTemplate.opsForList().index(key, index);
+        }
+
+        /**
+         * 获取列表指定范围内的元素
+         *
+         * @param key
+         * @param start
+         *            开始位置, 0是开始位置
+         * @param end
+         *            结束位置, -1返回所有
+         * @return
+         */
+        public List<String> lRange(String key, long start, long end) {
+            return redisTemplate.opsForList().range(key, start, end);
+        }
+
+        /**
+         * 存储在list头部
+         *
+         * @param key
+         * @param value
+         * @return
+         */
+        public Long lLeftPush(String key, String value) {
+            return redisTemplate.opsForList().leftPush(key, value);
+        }
+
+        /**
+         *
+         * @param key
+         * @param value
+         * @return
+         */
+        public Long lLeftPushAll(String key, String... value) {
+            return redisTemplate.opsForList().leftPushAll(key, value);
+        }
+
+        /**
+         *
+         * @param key
+         * @param value
+         * @return
+         */
+        public Long lLeftPushAll(String key, Collection<String> value) {
+            return redisTemplate.opsForList().leftPushAll(key, value);
+        }
+
+        /**
+         * 当list存在的时候才加入
+         *
+         * @param key
+         * @param value
+         * @return
+         */
+        public Long lLeftPushIfPresent(String key, String value) {
+            return redisTemplate.opsForList().leftPushIfPresent(key, value);
+        }
+
+        /**
+         * 如果pivot存在,再pivot前面添加
+         *
+         * @param key
+         * @param pivot
+         * @param value
+         * @return
+         */
+        public Long lLeftPush(String key, String pivot, String value) {
+            return redisTemplate.opsForList().leftPush(key, pivot, value);
+        }
+
+        /**
+         *
+         * @param key
+         * @param value
+         * @return
+         */
+        public Long lRightPush(String key, String value) {
+            return redisTemplate.opsForList().rightPush(key, value);
+        }
+
+        /**
+         *
+         * @param key
+         * @param value
+         * @return
+         */
+        public Long lRightPushAll(String key, String... value) {
+            return redisTemplate.opsForList().rightPushAll(key, value);
+        }
+
+        /**
+         *
+         * @param key
+         * @param value
+         * @return
+         */
+        public Long lRightPushAll(String key, Collection<String> value) {
+            return redisTemplate.opsForList().rightPushAll(key, value);
+        }
+
+        /**
+         * 为已存在的列表添加值
+         *
+         * @param key
+         * @param value
+         * @return
+         */
+        public Long lRightPushIfPresent(String key, String value) {
+            return redisTemplate.opsForList().rightPushIfPresent(key, value);
+        }
+
+        /**
+         * 在pivot元素的右边添加值
+         *
+         * @param key
+         * @param pivot
+         * @param value
+         * @return
+         */
+        public Long lRightPush(String key, String pivot, String value) {
+            return redisTemplate.opsForList().rightPush(key, pivot, value);
+        }
+
+        /**
+         * 通过索引设置列表元素的值
+         *
+         * @param key
+         * @param index
+         *            位置
+         * @param value
+         */
+        public void lSet(String key, long index, String value) {
+            redisTemplate.opsForList().set(key, index, value);
+        }
+
+        /**
+         * 移出并获取列表的第一个元素
+         *
+         * @param key
+         * @return 删除的元素
+         */
+        public String lLeftPop(String key) {
+            return redisTemplate.opsForList().leftPop(key);
+        }
+
+        /**
+         * 移出并获取列表的第一个元素, 如果列表没有元素会阻塞列表直到等待超时或发现可弹出元素为止
+         *
+         * @param key
+         * @param timeout
+         *            等待时间
+         * @param unit
+         *            时间单位
+         * @return
+         */
+        public String lBLeftPop(String key, long timeout, TimeUnit unit) {
+            return redisTemplate.opsForList().leftPop(key, timeout, unit);
+        }
+
+        /**
+         * 移除并获取列表最后一个元素
+         *
+         * @param key
+         * @return 删除的元素
+         */
+        public String lRightPop(String key) {
+            return redisTemplate.opsForList().rightPop(key);
+        }
+
+        /**
+         * 移出并获取列表的最后一个元素, 如果列表没有元素会阻塞列表直到等待超时或发现可弹出元素为止
+         *
+         * @param key
+         * @param timeout
+         *            等待时间
+         * @param unit
+         *            时间单位
+         * @return
+         */
+        public String lBRightPop(String key, long timeout, TimeUnit unit) {
+            return redisTemplate.opsForList().rightPop(key, timeout, unit);
+        }
+
+        /**
+         * 移除列表的最后一个元素,并将该元素添加到另一个列表并返回
+         *
+         * @param sourceKey
+         * @param destinationKey
+         * @return
+         */
+        public String lRightPopAndLeftPush(String sourceKey, String destinationKey) {
+            return redisTemplate.opsForList().rightPopAndLeftPush(sourceKey,
+                    destinationKey);
+        }
+
+        /**
+         * 从列表中弹出一个值,将弹出的元素插入到另外一个列表中并返回它; 如果列表没有元素会阻塞列表直到等待超时或发现可弹出元素为止
+         *
+         * @param sourceKey
+         * @param destinationKey
+         * @param timeout
+         * @param unit
+         * @return
+         */
+        public String lBRightPopAndLeftPush(String sourceKey, String destinationKey,
+                                            long timeout, TimeUnit unit) {
+            return redisTemplate.opsForList().rightPopAndLeftPush(sourceKey,
+                    destinationKey, timeout, unit);
+        }
+
+        /**
+         * 删除集合中值等于value得元素
+         *
+         * @param key
+         * @param index
+         *            index=0, 删除所有值等于value的元素; index>0, 从头部开始删除第一个值等于value的元素;
+         *            index<0, 从尾部开始删除第一个值等于value的元素;
+         * @param value
+         * @return
+         */
+        public Long lRemove(String key, long index, String value) {
+            return redisTemplate.opsForList().remove(key, index, value);
+        }
+
+        /**
+         * 裁剪list
+         *
+         * @param key
+         * @param start
+         * @param end
+         */
+        public void lTrim(String key, long start, long end) {
+            redisTemplate.opsForList().trim(key, start, end);
+        }
+
+        /**
+         * 获取列表长度
+         *
+         * @param key
+         * @return
+         */
+        public Long lLen(String key) {
+            return redisTemplate.opsForList().size(key);
+        }
+
+        /** --------------------set相关操作-------------------------- */
+
+        /**
+         * set添加元素
+         *
+         * @param key
+         * @param values
+         * @return
+         */
+        public Long sAdd(String key, String... values) {
+            return redisTemplate.opsForSet().add(key, values);
+        }
+
+        /**
+         * set移除元素
+         *
+         * @param key
+         * @param values
+         * @return
+         */
+        public Long sRemove(String key, Object... values) {
+            return redisTemplate.opsForSet().remove(key, values);
+        }
+
+        /**
+         * 移除并返回集合的一个随机元素
+         *
+         * @param key
+         * @return
+         */
+        public String sPop(String key) {
+            return redisTemplate.opsForSet().pop(key);
+        }
+
+        /**
+         * 将元素value从一个集合移到另一个集合
+         *
+         * @param key
+         * @param value
+         * @param destKey
+         * @return
+         */
+        public Boolean sMove(String key, String value, String destKey) {
+            return redisTemplate.opsForSet().move(key, value, destKey);
+        }
+
+        /**
+         * 获取集合的大小
+         *
+         * @param key
+         * @return
+         */
+        public Long sSize(String key) {
+            return redisTemplate.opsForSet().size(key);
+        }
+
+        /**
+         * 判断集合是否包含value
+         *
+         * @param key
+         * @param value
+         * @return
+         */
+        public Boolean sIsMember(String key, Object value) {
+            return redisTemplate.opsForSet().isMember(key, value);
+        }
+
+        /**
+         * 获取两个集合的交集
+         *
+         * @param key
+         * @param otherKey
+         * @return
+         */
+        public Set<String> sIntersect(String key, String otherKey) {
+            return redisTemplate.opsForSet().intersect(key, otherKey);
+        }
+
+        /**
+         * 获取key集合与多个集合的交集
+         *
+         * @param key
+         * @param otherKeys
+         * @return
+         */
+        public Set<String> sIntersect(String key, Collection<String> otherKeys) {
+            return redisTemplate.opsForSet().intersect(key, otherKeys);
+        }
+
+        /**
+         * key集合与otherKey集合的交集存储到destKey集合中
+         *
+         * @param key
+         * @param otherKey
+         * @param destKey
+         * @return
+         */
+        public Long sIntersectAndStore(String key, String otherKey, String destKey) {
+            return redisTemplate.opsForSet().intersectAndStore(key, otherKey,
+                    destKey);
+        }
+
+        /**
+         * key集合与多个集合的交集存储到destKey集合中
+         *
+         * @param key
+         * @param otherKeys
+         * @param destKey
+         * @return
+         */
+        public Long sIntersectAndStore(String key, Collection<String> otherKeys,
+                                       String destKey) {
+            return redisTemplate.opsForSet().intersectAndStore(key, otherKeys,
+                    destKey);
+        }
+
+        /**
+         * 获取两个集合的并集
+         *
+         * @param key
+         * @param otherKeys
+         * @return
+         */
+        public Set<String> sUnion(String key, String otherKeys) {
+            return redisTemplate.opsForSet().union(key, otherKeys);
+        }
+
+        /**
+         * 获取key集合与多个集合的并集
+         *
+         * @param key
+         * @param otherKeys
+         * @return
+         */
+        public Set<String> sUnion(String key, Collection<String> otherKeys) {
+            return redisTemplate.opsForSet().union(key, otherKeys);
+        }
+
+        /**
+         * key集合与otherKey集合的并集存储到destKey中
+         *
+         * @param key
+         * @param otherKey
+         * @param destKey
+         * @return
+         */
+        public Long sUnionAndStore(String key, String otherKey, String destKey) {
+            return redisTemplate.opsForSet().unionAndStore(key, otherKey, destKey);
+        }
+
+        /**
+         * key集合与多个集合的并集存储到destKey中
+         *
+         * @param key
+         * @param otherKeys
+         * @param destKey
+         * @return
+         */
+        public Long sUnionAndStore(String key, Collection<String> otherKeys,
+                                   String destKey) {
+            return redisTemplate.opsForSet().unionAndStore(key, otherKeys, destKey);
+        }
+
+        /**
+         * 获取两个集合的差集
+         *
+         * @param key
+         * @param otherKey
+         * @return
+         */
+        public Set<String> sDifference(String key, String otherKey) {
+            return redisTemplate.opsForSet().difference(key, otherKey);
+        }
+
+        /**
+         * 获取key集合与多个集合的差集
+         *
+         * @param key
+         * @param otherKeys
+         * @return
+         */
+        public Set<String> sDifference(String key, Collection<String> otherKeys) {
+            return redisTemplate.opsForSet().difference(key, otherKeys);
+        }
+
+        /**
+         * key集合与otherKey集合的差集存储到destKey中
+         *
+         * @param key
+         * @param otherKey
+         * @param destKey
+         * @return
+         */
+        public Long sDifference(String key, String otherKey, String destKey) {
+            return redisTemplate.opsForSet().differenceAndStore(key, otherKey,
+                    destKey);
+        }
+
+        /**
+         * key集合与多个集合的差集存储到destKey中
+         *
+         * @param key
+         * @param otherKeys
+         * @param destKey
+         * @return
+         */
+        public Long sDifference(String key, Collection<String> otherKeys,
+                                String destKey) {
+            return redisTemplate.opsForSet().differenceAndStore(key, otherKeys,
+                    destKey);
+        }
+
+        /**
+         * 获取集合所有元素
+         *
+         * @param key
+         * @return
+         */
+        public Set<String> setMembers(String key) {
+            return redisTemplate.opsForSet().members(key);
+        }
+
+        /**
+         * 随机获取集合中的一个元素
+         *
+         * @param key
+         * @return
+         */
+        public String sRandomMember(String key) {
+            return redisTemplate.opsForSet().randomMember(key);
+        }
+
+        /**
+         * 随机获取集合中count个元素
+         *
+         * @param key
+         * @param count
+         * @return
+         */
+        public List<String> sRandomMembers(String key, long count) {
+            return redisTemplate.opsForSet().randomMembers(key, count);
+        }
+
+        /**
+         * 随机获取集合中count个元素并且去除重复的
+         *
+         * @param key
+         * @param count
+         * @return
+         */
+        public Set<String> sDistinctRandomMembers(String key, long count) {
+            return redisTemplate.opsForSet().distinctRandomMembers(key, count);
+        }
+
+        /**
+         *
+         * @param key
+         * @param options
+         * @return
+         */
+        public Cursor<String> sScan(String key, ScanOptions options) {
+            return redisTemplate.opsForSet().scan(key, options);
+        }
+
+        /**------------------zSet相关操作--------------------------------*/
+
+        /**
+         * 添加元素,有序集合是按照元素的score值由小到大排列
+         *
+         * @param key
+         * @param value
+         * @param score
+         * @return
+         */
+        public Boolean zAdd(String key, String value, double score) {
+            return redisTemplate.opsForZSet().add(key, value, score);
+        }
+
+        /**
+         *
+         * @param key
+         * @param values
+         * @return
+         */
+        public Long zAdd(String key, Set<TypedTuple<String>> values) {
+            return redisTemplate.opsForZSet().add(key, values);
+        }
+
+        /**
+         *
+         * @param key
+         * @param values
+         * @return
+         */
+        public Long zRemove(String key, Object... values) {
+            return redisTemplate.opsForZSet().remove(key, values);
+        }
+
+        /**
+         * 增加元素的score值,并返回增加后的值
+         *
+         * @param key
+         * @param value
+         * @param delta
+         * @return
+         */
+        public Double zIncrementScore(String key, String value, double delta) {
+            return redisTemplate.opsForZSet().incrementScore(key, value, delta);
+        }
+
+        /**
+         * 返回元素在集合的排名,有序集合是按照元素的score值由小到大排列
+         *
+         * @param key
+         * @param value
+         * @return 0表示第一位
+         */
+        public Long zRank(String key, Object value) {
+            return redisTemplate.opsForZSet().rank(key, value);
+        }
+
+        /**
+         * 返回元素在集合的排名,按元素的score值由大到小排列
+         *
+         * @param key
+         * @param value
+         * @return
+         */
+        public Long zReverseRank(String key, Object value) {
+            return redisTemplate.opsForZSet().reverseRank(key, value);
+        }
+
+        /**
+         * 获取集合的元素, 从小到大排序
+         *
+         * @param key
+         * @param start
+         *            开始位置
+         * @param end
+         *            结束位置, -1查询所有
+         * @return
+         */
+        public Set<String> zRange(String key, long start, long end) {
+            return redisTemplate.opsForZSet().range(key, start, end);
+        }
+
+        /**
+         * 获取集合元素, 并且把score值也获取
+         *
+         * @param key
+         * @param start
+         * @param end
+         * @return
+         */
+        public Set<TypedTuple<String>> zRangeWithScores(String key, long start,
+                                                        long end) {
+            return redisTemplate.opsForZSet().rangeWithScores(key, start, end);
+        }
+
+        /**
+         * 根据Score值查询集合元素
+         *
+         * @param key
+         * @param min
+         *            最小值
+         * @param max
+         *            最大值
+         * @return
+         */
+        public Set<String> zRangeByScore(String key, double min, double max) {
+            return redisTemplate.opsForZSet().rangeByScore(key, min, max);
+        }
+
+        /**
+         * 根据Score值查询集合元素, 从小到大排序
+         *
+         * @param key
+         * @param min
+         *            最小值
+         * @param max
+         *            最大值
+         * @return
+         */
+        public Set<TypedTuple<String>> zRangeByScoreWithScores(String key,
+                                                               double min, double max) {
+            return redisTemplate.opsForZSet().rangeByScoreWithScores(key, min, max);
+        }
+
+        /**
+         *
+         * @param key
+         * @param min
+         * @param max
+         * @param start
+         * @param end
+         * @return
+         */
+        public Set<TypedTuple<String>> zRangeByScoreWithScores(String key,
+                                                               double min, double max, long start, long end) {
+            return redisTemplate.opsForZSet().rangeByScoreWithScores(key, min, max,
+                    start, end);
+        }
+
+        /**
+         * 获取集合的元素, 从大到小排序
+         *
+         * @param key
+         * @param start
+         * @param end
+         * @return
+         */
+        public Set<String> zReverseRange(String key, long start, long end) {
+            return redisTemplate.opsForZSet().reverseRange(key, start, end);
+        }
+
+        /**
+         * 获取集合的元素, 从大到小排序, 并返回score值
+         *
+         * @param key
+         * @param start
+         * @param end
+         * @return
+         */
+        public Set<TypedTuple<String>> zReverseRangeWithScores(String key,
+                                                               long start, long end) {
+            return redisTemplate.opsForZSet().reverseRangeWithScores(key, start,
+                    end);
+        }
+
+        /**
+         * 根据Score值查询集合元素, 从大到小排序
+         *
+         * @param key
+         * @param min
+         * @param max
+         * @return
+         */
+        public Set<String> zReverseRangeByScore(String key, double min,
+                                                double max) {
+            return redisTemplate.opsForZSet().reverseRangeByScore(key, min, max);
+        }
+
+        /**
+         * 根据Score值查询集合元素, 从大到小排序
+         *
+         * @param key
+         * @param min
+         * @param max
+         * @return
+         */
+        public Set<TypedTuple<String>> zReverseRangeByScoreWithScores(
+                String key, double min, double max) {
+            return redisTemplate.opsForZSet().reverseRangeByScoreWithScores(key,
+                    min, max);
+        }
+
+        /**
+         *
+         * @param key
+         * @param min
+         * @param max
+         * @param start
+         * @param end
+         * @return
+         */
+        public Set<String> zReverseRangeByScore(String key, double min,
+                                                double max, long start, long end) {
+            return redisTemplate.opsForZSet().reverseRangeByScore(key, min, max,
+                    start, end);
+        }
+
+        /**
+         * 根据score值获取集合元素数量
+         *
+         * @param key
+         * @param min
+         * @param max
+         * @return
+         */
+        public Long zCount(String key, double min, double max) {
+            return redisTemplate.opsForZSet().count(key, min, max);
+        }
+
+        /**
+         * 获取集合大小
+         *
+         * @param key
+         * @return
+         */
+        public Long zSize(String key) {
+            return redisTemplate.opsForZSet().size(key);
+        }
+
+        /**
+         * 获取集合大小
+         *
+         * @param key
+         * @return
+         */
+        public Long zZCard(String key) {
+            return redisTemplate.opsForZSet().zCard(key);
+        }
+
+        /**
+         * 获取集合中value元素的score值
+         *
+         * @param key
+         * @param value
+         * @return
+         */
+        public Double zScore(String key, Object value) {
+            return redisTemplate.opsForZSet().score(key, value);
+        }
+
+        /**
+         * 移除指定索引位置的成员
+         *
+         * @param key
+         * @param start
+         * @param end
+         * @return
+         */
+        public Long zRemoveRange(String key, long start, long end) {
+            return redisTemplate.opsForZSet().removeRange(key, start, end);
+        }
+
+        /**
+         * 根据指定的score值的范围来移除成员
+         *
+         * @param key
+         * @param min
+         * @param max
+         * @return
+         */
+        public Long zRemoveRangeByScore(String key, double min, double max) {
+            return redisTemplate.opsForZSet().removeRangeByScore(key, min, max);
+        }
+
+        /**
+         * 获取key和otherKey的并集并存储在destKey中
+         *
+         * @param key
+         * @param otherKey
+         * @param destKey
+         * @return
+         */
+        public Long zUnionAndStore(String key, String otherKey, String destKey) {
+            return redisTemplate.opsForZSet().unionAndStore(key, otherKey, destKey);
+        }
+
+        /**
+         *
+         * @param key
+         * @param otherKeys
+         * @param destKey
+         * @return
+         */
+        public Long zUnionAndStore(String key, Collection<String> otherKeys,
+                                   String destKey) {
+            return redisTemplate.opsForZSet()
+                    .unionAndStore(key, otherKeys, destKey);
+        }
+
+        /**
+         * 交集
+         *
+         * @param key
+         * @param otherKey
+         * @param destKey
+         * @return
+         */
+        public Long zIntersectAndStore(String key, String otherKey,
+                                       String destKey) {
+            return redisTemplate.opsForZSet().intersectAndStore(key, otherKey,
+                    destKey);
+        }
+
+        /**
+         * 交集
+         *
+         * @param key
+         * @param otherKeys
+         * @param destKey
+         * @return
+         */
+        public Long zIntersectAndStore(String key, Collection<String> otherKeys,
+                                       String destKey) {
+            return redisTemplate.opsForZSet().intersectAndStore(key, otherKeys,
+                    destKey);
+        }
+
+        /**
+         *
+         * @param key
+         * @param options
+         * @return
+         */
+        public Cursor<TypedTuple<String>> zScan(String key, ScanOptions options) {
+            return redisTemplate.opsForZSet().scan(key, options);
+        }
+
+//	 /**
+//     * 获取Redis List 序列化
+//     * @param key
+//     * @param targetClass
+//     * @param <T>
+//     * @return
+//     */
+//    public <T> List<T> getListCache(final String key, Class<T> targetClass) {
+//        byte[] result = redisTemplate.execute(new RedisCallback<byte[]>() {
+//            @Override
+//            public byte[] doInRedis(RedisConnection connection) throws DataAccessException {
+//                return connection.get(key.getBytes());
+//            }
+//        });
+//        if (result == null) {
+//            return null;
+//        }
+//        return ProtoStuffSerializerUtil.deserializeList(result, targetClass);
+//    }
+//
+//    /***
+//     * 将List 放进缓存里面
+//     * @param key
+//     * @param objList
+//     * @param expireTime
+//     * @param <T>
+//     * @return
+//     */
+//    public <T> boolean putListCacheWithExpireTime(String key, List<T> objList, final long expireTime) {
+//        final byte[] bkey = key.getBytes();
+//        final byte[] bvalue = ProtoStuffSerializerUtil.serializeList(objList);
+//        boolean result = redisTemplate.execute(new RedisCallback<Boolean>() {
+//            @Override
+//            public Boolean doInRedis(RedisConnection connection) throws DataAccessException {
+//                connection.setEx(bkey, expireTime, bvalue);
+//                return true;
+//            }
+//        });
+//        return result;
+//    }
+
+}