资源分配

master
wangbing 4 years ago
parent 51f1231506
commit 326899bd64

@ -2,7 +2,6 @@ package ${domain}.config;
import net.sf.ehcache.CacheManager; import net.sf.ehcache.CacheManager;
import net.sf.ehcache.config.CacheConfiguration; import net.sf.ehcache.config.CacheConfiguration;
import net.sf.ehcache.config.DiskStoreConfiguration;
import org.springframework.cache.Cache; import org.springframework.cache.Cache;
import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.ehcache.EhCacheCacheManager; import org.springframework.cache.ehcache.EhCacheCacheManager;
@ -30,10 +29,8 @@ public class CacheConfig {
@Bean @Bean
public EhCacheCacheManager getCacheManager() { public EhCacheCacheManager getCacheManager() {
net.sf.ehcache.config.Configuration configuration = new net.sf.ehcache.config.Configuration(); net.sf.ehcache.config.Configuration configuration = new net.sf.ehcache.config.Configuration();
// todo 需根据服务器物理内存配置
configuration.setMaxBytesLocalHeap("128M");
configuration.updateCheck(false); configuration.updateCheck(false);
configuration.addDiskStore(new DiskStoreConfiguration().path("java.io.tmpdir")); configuration.setUpdateCheck(false);
CacheManager cacheManager = CacheManager.create(configuration); CacheManager cacheManager = CacheManager.create(configuration);
// 添加token缓存 // 添加token缓存
@ -52,6 +49,9 @@ public class CacheConfig {
config.setTimeToLiveSeconds(60 * 60);//最长有效时间 config.setTimeToLiveSeconds(60 * 60);//最长有效时间
config.setTimeToIdleSeconds(60 * 60);//无访问最长有效时间 config.setTimeToIdleSeconds(60 * 60);//无访问最长有效时间
config.setName(TOKEN_CACHE); config.setName(TOKEN_CACHE);
// 分配最大内存的10%作为token的缓存空间
long memory = Runtime.getRuntime().maxMemory();
config.setMaxBytesLocalHeap((long) (memory * 0.1f));
return new net.sf.ehcache.Cache(config); return new net.sf.ehcache.Cache(config);
} }
} }

@ -271,7 +271,7 @@ public class ResManagerImpl implements ResManager {
public void saveRes(String res, Token token) { public void saveRes(String res, Token token) {
ResFindRequest resFindRequest = new ResFindRequest(); ResFindRequest resFindRequest = new ResFindRequest();
resFindRequest.setPageSize(0); resFindRequest.setPageSize(0);
resFindRequest.setResValue(res); resFindRequest.setResValueLike(res);
ResManager resManager = LocalData.getBean(ResManager.class); ResManager resManager = LocalData.getBean(ResManager.class);
ResFindResponse resFindResponse = resManager.find(resFindRequest, token); ResFindResponse resFindResponse = resManager.find(resFindRequest, token);

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="xyz.wbsite.module.wsys.mpr.DataMapper">
<select id="total" resultType="xyz.wbsite.module.wsys.ent.DataTotal">
SELECT
( SELECT COUNT( 1 ) + 1 FROM SYS_USER WHERE IS_DELETED = 0 AND USER_STATUS = '0' ) USER_ALL,
( SELECT COUNT( 1 ) FROM SYS_TOKENS WHERE IS_DELETED = 0 AND VALID = '1' ) USER_LINE,
( SELECT COUNT( 1 ) FROM SYS_DEPT WHERE IS_DELETED = 0 ) DEPT_ALL,
( SELECT COUNT( 1 ) FROM SYS_LOGERR WHERE IS_DELETED = 0 AND LOG_STATE = '0' ) ERROR_UN,
( SELECT COUNT( 1 ) FROM SYS_LOGERR WHERE IS_DELETED = 0 ) ERROR_ALL
</select>
<select id="login" resultType="xyz.wbsite.module.wsys.ent.DataCount">
SELECT * FROM
<foreach collection="list" item="item" index="index" open="(" close=")" separator="UNION ALL">
SELECT #{item.date1} "DATE",COUNT(1) "COUNT" FROM SYS_TOKENS WHERE date(LOGIN_TIME/1000,'unixepoch') = #{item.date2}
</foreach>
ORDER BY DATE
</select>
<select id="error" resultType="xyz.wbsite.module.wsys.ent.DataCount">
SELECT * FROM
<foreach collection="list" item="item" index="index" open="(" close=")" separator="UNION ALL">
SELECT #{item.date1} "DATE",COUNT( 1 ) "COUNT" FROM SYS_LOGERR WHERE date(CREATE_TIME) = #{item.date2}
</foreach>
ORDER BY DATE
</select>
</mapper>

@ -4,8 +4,8 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${domain}.module.wsys.mpr.DictItemMapper"> <mapper namespace="${domain}.module.wsys.mpr.DictItemMapper">
<!--开启缓存--> <!--开启二级缓存update()、delete()、insert()会刷新缓存-->
<cache/> <cache size="1024" type="org.mybatis.caches.ehcache.EhcacheCache"/>
<sql id="table">`SYS_DICT_ITEM`</sql> <sql id="table">`SYS_DICT_ITEM`</sql>

@ -4,7 +4,7 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${domain}.module.wsys.mpr.ResMapper"> <mapper namespace="${domain}.module.wsys.mpr.ResMapper">
<!--开启缓存--> <!--开启二级缓存-->
<cache/> <cache/>
<sql id="table">`SYS_RES`</sql> <sql id="table">`SYS_RES`</sql>
@ -172,6 +172,9 @@
<if test="request.resValue != null and request.resValue != ''"> <if test="request.resValue != null and request.resValue != ''">
AND `RES_VALUE` = ${r'#'}{request.resValue} AND `RES_VALUE` = ${r'#'}{request.resValue}
</if> </if>
<if test="request.resValueLike != null and request.resValueLike != ''">
AND `RES_VALUE` LIKE CONCAT('%',${r"#"}{request.resValueLike},'%')
</if>
<if test="request.supCode != null and request.supCode != ''"> <if test="request.supCode != null and request.supCode != ''">
AND `SUP_CODE` = ${r'#'}{request.supCode} AND `SUP_CODE` = ${r'#'}{request.supCode}
</if> </if>

@ -171,6 +171,9 @@
<if test="request.resValue != null and request.resValue != ''"> <if test="request.resValue != null and request.resValue != ''">
AND "RES_VALUE" = ${r'#'}{request.resValue} AND "RES_VALUE" = ${r'#'}{request.resValue}
</if> </if>
<if test="request.resValueLike != null and request.resValueLike != ''">
AND "RES_VALUE" LIKE '%'||${r"#"}{request.resValueLike}||'%'
</if>
<if test="request.supCode != null and request.supCode != ''"> <if test="request.supCode != null and request.supCode != ''">
AND "SUP_CODE" = ${r'#'}{request.supCode} AND "SUP_CODE" = ${r'#'}{request.supCode}
</if> </if>

@ -4,6 +4,9 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${domain}.module.wsys.mpr.ResMapper"> <mapper namespace="${domain}.module.wsys.mpr.ResMapper">
<!--开启二级缓存-->
<cache/>
<sql id="table">"SYS_RES"</sql> <sql id="table">"SYS_RES"</sql>
<sql id="entityColumnList"> <sql id="entityColumnList">
@ -27,6 +30,7 @@
<result column="LAST_UPDATE_BY" jdbcType="BIGINT" property="lastUpdateBy"/> <result column="LAST_UPDATE_BY" jdbcType="BIGINT" property="lastUpdateBy"/>
<result column="LAST_UPDATE_TIME" jdbcType="TIMESTAMP" property="lastUpdateTime"/> <result column="LAST_UPDATE_TIME" jdbcType="TIMESTAMP" property="lastUpdateTime"/>
</resultMap> </resultMap>
<insert id="insert"> <insert id="insert">
INSERT INTO INSERT INTO
<include refid="table"/> <include refid="table"/>
@ -168,6 +172,9 @@
<if test="request.resValue != null and request.resValue != ''"> <if test="request.resValue != null and request.resValue != ''">
AND RES_VALUE = ${r"#"}{request.resValue} AND RES_VALUE = ${r"#"}{request.resValue}
</if> </if>
<if test="request.resValueLike != null and request.resValueLike != ''">
AND RES_VALUE LIKE '%'||${r"#"}{request.resValueLike}||'%'
</if>
<if test="request.supCode != null and request.supCode != ''"> <if test="request.supCode != null and request.supCode != ''">
AND SUP_CODE = ${r"#"}{request.supCode} AND SUP_CODE = ${r"#"}{request.supCode}
</if> </if>

@ -35,6 +35,11 @@ public class ResFindRequest extends BaseFindRequest {
*/ */
private String resValue; private String resValue;
/**
*
*/
private String resValueLike;
/** /**
* *
*/ */
@ -97,6 +102,14 @@ public class ResFindRequest extends BaseFindRequest {
this.resValue = resValue; this.resValue = resValue;
} }
public String getResValueLike() {
return this.resValueLike;
}
public void setResValueLike(String resValueLike) {
this.resValueLike = resValueLike;
}
public String getSupCode() { public String getSupCode() {
return this.supCode; return this.supCode;
} }

@ -167,6 +167,14 @@
</el-dialog> </el-dialog>
<el-dialog class="form-dialog" :title="formResource.title" :visible.sync="formResource.dialog"> <el-dialog class="form-dialog" :title="formResource.title" :visible.sync="formResource.dialog">
<el-row style="padding: 0 10px 10px 10px;">
<el-checkbox label="父子关联" v-model="config.strictly" name="strictly"></el-checkbox>
<el-checkbox label="创建权限" v-model="config.create"></el-checkbox>
<el-checkbox label="删除权限" v-model="config.delete"></el-checkbox>
<el-checkbox label="修改权限" v-model="config.update"></el-checkbox>
<el-checkbox label="查询权限" v-model="config.find"></el-checkbox>
</el-row>
<el-tree <el-tree
:data="treeData" :data="treeData"
show-checkbox show-checkbox
@ -194,6 +202,13 @@
data: { data: {
module: 'wsys', module: 'wsys',
target: 'role', target: 'role',
config:{
strictly:false,
create:false,
delete:false,
update:false,
find:false,
},
vm: {//条件及分页参数 vm: {//条件及分页参数
code: null, code: null,
name: null, name: null,
@ -299,9 +314,13 @@
var isChecked = status.checkedKeys.indexOf(item.id) !== -1; var isChecked = status.checkedKeys.indexOf(item.id) !== -1;
var list = []; var list = [];
[item].forTree(function (item) { if(!this.config.strictly){
list.push(item); list.push(item)
}) }else{
[item].forTree(function (item) {
list.push(item);
})
}
nav.tipShow("更新中"); nav.tipShow("更新中");
list.forAsync(function (item_, next) { list.forAsync(function (item_, next) {
if (isChecked === (status.checkedKeys.indexOf(item_.id) !== -1) && item_.id !== item.id) { if (isChecked === (status.checkedKeys.indexOf(item_.id) !== -1) && item_.id !== item.id) {

Loading…
Cancel
Save

Powered by TurnKey Linux.