120 changed files with 4970 additions and 2243 deletions
@ -1,11 +1,220 @@ |
|||
package com.dreamchaser.depository_manage.service.impl; |
|||
|
|||
import com.alibaba.excel.util.StringUtils; |
|||
import com.dreamchaser.depository_manage.service.RedisService; |
|||
import org.apache.commons.collections4.CollectionUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.data.redis.core.RedisTemplate; |
|||
import org.springframework.data.redis.core.StringRedisTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.Collection; |
|||
import java.util.Objects; |
|||
import java.util.Set; |
|||
import java.util.concurrent.TimeUnit; |
|||
|
|||
/** |
|||
* 操作redis |
|||
* @author shy |
|||
* @date 2020/12/10 10:01 |
|||
*/ |
|||
@Service |
|||
public class RedisServiceImpl implements RedisService { |
|||
|
|||
@Autowired |
|||
private StringRedisTemplate stringRedisTemplate; |
|||
|
|||
@Autowired |
|||
private RedisTemplate<String,String> redisTemplate; |
|||
|
|||
/** |
|||
* 判断String类型key是否存在 |
|||
* |
|||
* @param key |
|||
* @return |
|||
* @author shy |
|||
* @date 2018年11月13日 下午1:40:37 |
|||
*/ |
|||
public boolean hasStringKey(String key) { |
|||
if (StringUtils.isBlank(key)) { |
|||
throw new RuntimeException(); |
|||
} |
|||
return stringRedisTemplate.opsForValue().getOperations().hasKey(key); |
|||
} |
|||
|
|||
/** |
|||
* 判断String类型key是否存在 |
|||
* |
|||
* @param key |
|||
* @return |
|||
* @author shy |
|||
* @date 2018年11月13日 下午1:43:51 |
|||
*/ |
|||
public boolean nonStringKey(String key) { |
|||
return !hasStringKey(key); |
|||
} |
|||
|
|||
/** |
|||
* 设置String类型key,String类型value,过期时间timeout,TimeUnit |
|||
* |
|||
* @param key |
|||
* @param value |
|||
* @param timeout |
|||
* @param timeUnit |
|||
* @author shy |
|||
* @date 2018年12月10日13:53:38 |
|||
*/ |
|||
public void setStringKey(String key, String value, Long timeout, TimeUnit timeUnit) { |
|||
if (StringUtils.isBlank(key) || Objects.isNull(timeout)) { |
|||
throw new RuntimeException(); |
|||
} |
|||
stringRedisTemplate.opsForValue().set(key, value, timeout, timeUnit); |
|||
} |
|||
|
|||
public void setStringKey(String key, String value) { |
|||
if (StringUtils.isBlank(key)) { |
|||
throw new RuntimeException(); |
|||
} |
|||
stringRedisTemplate.opsForValue().set(key, value); |
|||
} |
|||
|
|||
/** |
|||
* 获取String类型value |
|||
* |
|||
* @param key |
|||
* @return |
|||
* @author shy |
|||
* @date 2018年11月12日 下午7:09:31 |
|||
*/ |
|||
public String getStringValue(String key) { |
|||
if (StringUtils.isBlank(key)) { |
|||
throw new RuntimeException(); |
|||
} |
|||
return stringRedisTemplate.opsForValue().get(key); |
|||
} |
|||
|
|||
/** |
|||
* 获取Key的过期时间 |
|||
* |
|||
* @param key |
|||
* @return |
|||
* @author shy |
|||
* @date 2019年4月25日17:28:36 |
|||
*/ |
|||
public Long getExpire(String key) { |
|||
if (StringUtils.isBlank(key)) { |
|||
throw new RuntimeException(); |
|||
} |
|||
return stringRedisTemplate.getExpire(key); |
|||
} |
|||
|
|||
/** |
|||
* 设置Key的过期时间 |
|||
* |
|||
* @param key |
|||
* @return |
|||
* @author shy |
|||
* @date 2019年4月25日17:28:36 |
|||
*/ |
|||
public Boolean setExpire(String key,Long timeout, TimeUnit timeUnit) { |
|||
if (StringUtils.isBlank(key)) { |
|||
throw new RuntimeException(); |
|||
} |
|||
return stringRedisTemplate.expire(key, timeout, timeUnit); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* value自增+n |
|||
* @param key |
|||
* @return |
|||
* @author shy |
|||
* @date 2019年4月8日15:54:30 |
|||
*/ |
|||
public Long setIncrementValue(String key) { |
|||
if (StringUtils.isBlank(key)) { |
|||
throw new RuntimeException(); |
|||
} |
|||
return stringRedisTemplate.opsForValue().increment(key, 1L); |
|||
} |
|||
|
|||
/** |
|||
* 设置String类型key,Object类型value,过期时间timeout |
|||
* |
|||
* @param key |
|||
* @param value |
|||
* @param timeout |
|||
* @author shy |
|||
* @date 2018年12月10日13:54:07 |
|||
*/ |
|||
public void setObjectKey(String key, String value, Long timeout,TimeUnit time) { |
|||
if (StringUtils.isBlank(key) || Objects.isNull(timeout)) { |
|||
throw new RuntimeException(); |
|||
} |
|||
redisTemplate.opsForValue().set(key, value, timeout, time); |
|||
} |
|||
|
|||
public void setObjectKey(String key, String value) { |
|||
if (StringUtils.isBlank(key)) { |
|||
throw new RuntimeException(); |
|||
} |
|||
redisTemplate.opsForValue().set(key, value); |
|||
} |
|||
|
|||
/** |
|||
* 获取Object类型value |
|||
* |
|||
* @param key |
|||
* @param clazz |
|||
* @return |
|||
* @author shy |
|||
* @date 2019年11月6日10:01:30 |
|||
*/ |
|||
@SuppressWarnings("unchecked") |
|||
public <T> T getObjectValue(String key, Class<T> clazz) { |
|||
if (StringUtils.isBlank(key)) { |
|||
return null; |
|||
} |
|||
return (T) redisTemplate.opsForValue().get(key); |
|||
} |
|||
|
|||
/** |
|||
* 移除单个String类型key |
|||
* |
|||
* @param key |
|||
* @author shy |
|||
* @date 2018年11月13日 上午10:42:01 |
|||
*/ |
|||
public void removeSingleStringKey(String key) { |
|||
if (StringUtils.isBlank(key)) { |
|||
throw new RuntimeException(); |
|||
} |
|||
stringRedisTemplate.opsForValue().getOperations().delete(key); |
|||
} |
|||
|
|||
/** |
|||
* 移除Collection<String>类型keys |
|||
* |
|||
* @param keys |
|||
* @author shy |
|||
* @date 2018年11月13日 下午3:15:16 |
|||
*/ |
|||
public void removeMultiStringKey(Collection<String> keys) { |
|||
if (CollectionUtils.isNotEmpty(keys)) { |
|||
stringRedisTemplate.opsForValue().getOperations().delete(keys); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* redis key 模糊查询 |
|||
* @author shy |
|||
* @date 2021年1月4日 上午11:21:45 |
|||
* @param key |
|||
* @return |
|||
*/ |
|||
public Set<String> queryStringKeys(String key) { |
|||
return redisTemplate.keys(key + "*"); |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
@ -1,97 +0,0 @@ |
|||
<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<meta charset="utf-8"> |
|||
<title>修改密码</title> |
|||
<meta name="renderer" content="webkit"> |
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
|||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> |
|||
<link rel="stylesheet" href="/static/lib/layui-v2.6.3/css/layui.css" media="all"> |
|||
<link rel="stylesheet" href="/static/css/public.css" media="all"> |
|||
<style> |
|||
.layui-form-item .layui-input-company {width: auto;padding-right: 10px;line-height: 38px;} |
|||
</style> |
|||
</head> |
|||
<body> |
|||
|
|||
<div class="layuimini-container"> |
|||
<div class="layuimini-main"> |
|||
<div class="layui-form layuimini-form"> |
|||
<div class="layui-form-item"> |
|||
<input style="display: none" name="email" th:value="${user.getEmail()}"> |
|||
<label class="layui-form-label required">旧的密码</label> |
|||
<div class="layui-input-block"> |
|||
<input type="password" name="old_password" lay-verify="required" lay-reqtext="旧的密码不能为空" placeholder="请输入旧的密码" value="" class="layui-input"> |
|||
<tip>填写自己账号的旧的密码。</tip> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label required">新的密码</label> |
|||
<div class="layui-input-block"> |
|||
<input type="password" name="new_password" lay-verify="required" lay-reqtext="新的密码不能为空" placeholder="请输入新的密码" value="" class="layui-input"> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label required">新的密码</label> |
|||
<div class="layui-input-block"> |
|||
<input type="password" name="again_password" lay-verify="required|confirmPass" lay-reqtext="新的密码不能为空" placeholder="请输入新的密码" value="" class="layui-input"> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="layui-form-item"> |
|||
<div class="layui-input-block"> |
|||
<button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script> |
|||
<script src="/static/js/lay-config.js?v=1.0.4" charset="utf-8"></script> |
|||
<script> |
|||
layui.use(['form','miniTab'], function () { |
|||
var form = layui.form, |
|||
layer = layui.layer, |
|||
miniTab = layui.miniTab; |
|||
$ = layui.$; |
|||
form.verify({ |
|||
confirmPass:function(value){ |
|||
if($('input[name=new_password]').val() !== value) |
|||
return '提示:两次输入密码不一致!'; |
|||
} |
|||
}); |
|||
//监听提交 |
|||
form.on('submit(saveBtn)', function (data) { |
|||
data = data.field; |
|||
$.ajax({ |
|||
url: "/edit_password", |
|||
type: 'post', |
|||
dataType: 'json', |
|||
contentType: "application/json;charset=utf-8", |
|||
data: JSON.stringify(data), |
|||
beforeSend: function () { |
|||
this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']}); |
|||
}, |
|||
success: function (data) { |
|||
layer.close(this.layerIndex); |
|||
if (data.status >= 300) { |
|||
layer.msg(data.statusInfo.message);//失败的表情 |
|||
return; |
|||
} else { |
|||
layer.msg("密码修改成功", { |
|||
icon: 6,//成功的表情 |
|||
time: 500 //1秒关闭(如果不配置,默认是3秒) |
|||
},function(){ |
|||
window.location='/user_password' |
|||
}) |
|||
} |
|||
} |
|||
}) |
|||
return false; |
|||
}); |
|||
|
|||
}); |
|||
</script> |
|||
</body> |
|||
</html> |
|||
@ -0,0 +1,116 @@ |
|||
<!DOCTYPE html> |
|||
<html lang="en" xmlns:th="http://www.thymeleaf.org"> |
|||
<head> |
|||
<meta charset="utf-8"> |
|||
<title>layui</title> |
|||
<meta name="renderer" content="webkit"> |
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
|||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> |
|||
<link rel="stylesheet" href="/static/lib/layui-v2.6.3/css/layui.css" media="all"> |
|||
<link rel="stylesheet" href="/static/css/public.css" media="all"> |
|||
<style> |
|||
body { |
|||
background-color: #ffffff; |
|||
} |
|||
</style> |
|||
</head> |
|||
<body> |
|||
<div class="layui-form layuimini-form"> |
|||
<input type="text" name="userid" th:value="${userByPort.getId()}" style="display: none"> |
|||
<input type="text" name="roleId" th:value="${roleId}" style="display: none"> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label required">用户名</label> |
|||
<div class="layui-input-block"> |
|||
<input type="text" lay-verify="required" lay-reqtext="用户名不能为空" placeholder="请输入用户名" th:value="${userByPort.getName()}" class="layui-input" readonly> |
|||
<tip>填写自己管理账号的名称。</tip> |
|||
</div> |
|||
</div> |
|||
<div class=" layui-form-item" style="display:none;"> |
|||
<label class="layui-form-label required">权限:</label> |
|||
<div class="layui-inline " style="margin-bottom: 10px"> |
|||
<select name="authority" class="layui-input-inline"> |
|||
<option value="">请选择权限</option> |
|||
<option th:each="role,iterStar:${roles}" th:value="${role?.getId()}" th:text="${role?.getName()}" th:selected="${userByPort.getRolename() == role.getName()}">系统管理员</option> |
|||
</select> |
|||
</div> |
|||
</div> |
|||
<div class=" layui-form-item" > |
|||
<label class="layui-form-label required">负责仓库:</label> |
|||
<div class="layui-inline" style="margin-bottom: 10px"> |
|||
<!--<select name="depositoryId" lay-verify="required"> |
|||
<option value="">请选择仓库</option> |
|||
<option th:each="depository,iterStar:${depositories}" th:value="${depository?.getId()}" th:text="${depository?.getDname()}" th:selected="${userByPort.getDepositoryName() == depository.getDname()}" >外芯仓库</option> |
|||
</select>--> |
|||
<input type="text" placeholder="请选择仓库" class="layui-input" id="openSonByDepository" readonly th:value="${userByPort.getDepositoryName()}" |
|||
lay-verify="required"/> |
|||
<input type="text" th:value="${depositoryId}" name="depositoryId" class="layui-input" id="depositoryId" style="display: none" lay-verify="required"/> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="layui-form-item"> |
|||
<div class="layui-input-block"> |
|||
<button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script> |
|||
<script> |
|||
layui.use(['form','layer','laydate'], function () { |
|||
var form = layui.form, |
|||
layer = layui.layer, |
|||
laydate=layui.laydate, |
|||
$ = layui.$; |
|||
$('#openSonByDepository').on('click', function(){ |
|||
layer.open({ |
|||
type: 2, |
|||
title: '弹窗内容', |
|||
skin: 'layui-layer-rim', |
|||
maxmin: true, |
|||
shadeClose: true, //点击遮罩关闭层 |
|||
area : ['800px' , '500px'], |
|||
content: '/selectDepository?type=2', |
|||
}); |
|||
}); |
|||
//日期 |
|||
laydate.render({ |
|||
elem: '#date' |
|||
}); |
|||
//监听提交 |
|||
form.on('submit(saveBtn)', function (data) { |
|||
data=data.field; |
|||
//去除对应的仓库id |
|||
if (data.depositoryId===""){ |
|||
delete data.depositoryId; |
|||
} |
|||
$.ajax({ |
|||
url: "/sys/userRole_edit", |
|||
type: 'post', |
|||
dataType: 'json', |
|||
contentType: "application/json;charset=utf-8", |
|||
data: JSON.stringify(data), |
|||
beforeSend: function () { |
|||
this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']}); |
|||
}, |
|||
success: function (data) { |
|||
layer.close(this.layerIndex); |
|||
if (data.status >= 300) { |
|||
layer.msg(data.statusInfo.message);//失败的表情 |
|||
return; |
|||
} else { |
|||
layer.msg("申请提交成功", { |
|||
icon: 6,//成功的表情 |
|||
time: 500 //1秒关闭(如果不配置,默认是3秒) |
|||
},function(){ |
|||
var index = parent.layer.getFrameIndex(window.name); |
|||
parent.layer.close(index);//关闭当前页 |
|||
}) |
|||
} |
|||
} |
|||
}) |
|||
return false; |
|||
}); |
|||
|
|||
}); |
|||
</script> |
|||
</body> |
|||
</html> |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue