update
This commit is contained in:
parent
e58a30566f
commit
ffe70503e0
135
src/main/java/com/smallchill/common/tool/SysCache.java
Normal file
135
src/main/java/com/smallchill/common/tool/SysCache.java
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
package com.smallchill.common.tool;
|
||||
|
||||
import com.smallchill.core.constant.ConstCache;
|
||||
import com.smallchill.core.interfaces.ILoader;
|
||||
import com.smallchill.core.plugins.dao.Blade;
|
||||
import com.smallchill.core.toolbox.Func;
|
||||
import com.smallchill.core.toolbox.Paras;
|
||||
import com.smallchill.core.toolbox.kit.CacheKit;
|
||||
import com.smallchill.core.toolbox.kit.StrKit;
|
||||
import com.smallchill.system.model.Dept;
|
||||
import com.smallchill.system.model.Dict;
|
||||
import com.smallchill.system.model.Parameter;
|
||||
import com.smallchill.system.model.Role;
|
||||
import com.smallchill.system.model.User;
|
||||
|
||||
public class SysCache {
|
||||
/**
|
||||
* 获取字典表对应中文
|
||||
* @param code 字典编号
|
||||
* @param num 字典序号
|
||||
* @return
|
||||
*/
|
||||
public static String getDictName(final Object code, final Object num) {
|
||||
Dict dict = CacheKit.get(ConstCache.DICT_CACHE, "getDictName_" + code + "_" + num, new ILoader() {
|
||||
@Override
|
||||
public Object load() {
|
||||
return Blade.create(Dict.class).findFirstBy("code=#{code} and num=#{num}", Paras.create().set("code", code).set("num", num));
|
||||
}
|
||||
});
|
||||
if(null == dict){
|
||||
return "";
|
||||
}
|
||||
return dict.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对应角色名
|
||||
* @param roleId 角色id
|
||||
* @return
|
||||
*/
|
||||
public static String getRoleName(final Object roleIds) {
|
||||
if(Func.isEmpty(roleIds)){
|
||||
return "";
|
||||
}
|
||||
final String [] roleIdArr = roleIds.toString().split(",");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(int i = 0 ; i < roleIdArr.length; i++){
|
||||
final String roleId = roleIdArr[i];
|
||||
Role role = CacheKit.get(ConstCache.ROLE_CACHE, "getRoleName" + "_" + roleId, new ILoader() {
|
||||
@Override
|
||||
public Object load() {
|
||||
return Blade.create(Role.class).findById(roleId);
|
||||
}
|
||||
});
|
||||
sb.append(role.getName()).append(",");
|
||||
}
|
||||
return StrKit.removeSuffix(sb.toString(), ",");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对应角色别名
|
||||
* @param roleId 角色id
|
||||
* @return
|
||||
*/
|
||||
public static String getRoleAlias(final Object roleIds) {
|
||||
if(Func.isEmpty(roleIds)){
|
||||
return "";
|
||||
}
|
||||
final String [] roleIdArr = roleIds.toString().split(",");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(int i = 0 ; i < roleIdArr.length; i++){
|
||||
final String roleId = roleIdArr[i];
|
||||
Role role = CacheKit.get(ConstCache.ROLE_CACHE, "getRoleAlias" + "_" + roleId, new ILoader() {
|
||||
@Override
|
||||
public Object load() {
|
||||
return Blade.create(Role.class).findById(roleId);
|
||||
}
|
||||
});
|
||||
sb.append(role.getTips()).append(",");
|
||||
}
|
||||
return StrKit.removeSuffix(sb.toString(), ",");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对应用户名
|
||||
* @param userId 用户id
|
||||
* @return
|
||||
*/
|
||||
public static String getUserName(final Object userId) {
|
||||
User user = CacheKit.get(ConstCache.USER_CACHE, "getUserName" + "_" + userId, new ILoader() {
|
||||
@Override
|
||||
public Object load() {
|
||||
return Blade.create(User.class).findById(userId);
|
||||
}
|
||||
});
|
||||
if(null == user){
|
||||
return "";
|
||||
}
|
||||
return user.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对应部门名
|
||||
* @param deptIds 部门id集合
|
||||
* @return
|
||||
*/
|
||||
public static String getDeptName(final Object deptIds) {
|
||||
if(Func.isEmpty(deptIds)){
|
||||
return "";
|
||||
}
|
||||
final String [] deptIdArr = deptIds.toString().split(",");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(int i = 0 ; i < deptIdArr.length; i++){
|
||||
final String deptId = deptIdArr[i];
|
||||
Dept dept = CacheKit.get(ConstCache.DEPT_CACHE, "getDeptName" + "_" + deptId, new ILoader() {
|
||||
@Override
|
||||
public Object load() {
|
||||
return Blade.create(Dept.class).findById(deptId);
|
||||
}
|
||||
});
|
||||
sb.append(dept.getSimplename()).append(",");
|
||||
}
|
||||
return StrKit.removeSuffix(sb.toString(), ",");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取参数表参数值
|
||||
* @param code 参数编号
|
||||
* @return String
|
||||
*/
|
||||
public static String getParamByCode(String code){
|
||||
Parameter param = Blade.create(Parameter.class).findFirstBy("code = #{code} and status = 1", Paras.create().set("code", code));
|
||||
return param.getPara();
|
||||
}
|
||||
}
|
||||
|
|
@ -19,6 +19,7 @@ import java.io.Serializable;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.smallchill.common.tool.SysCache;
|
||||
import com.smallchill.core.constant.ConstCache;
|
||||
import com.smallchill.core.interfaces.ILoader;
|
||||
import com.smallchill.core.plugins.dao.Db;
|
||||
|
|
@ -47,7 +48,7 @@ public class ShiroUser implements Serializable {
|
|||
public ShiroUser(Object id, Object deptId, String loginName, String name, List<String> roleList) {
|
||||
this.id = id;
|
||||
this.deptId = deptId;
|
||||
this.deptName = Func.getDeptName(deptId);
|
||||
this.deptName = SysCache.getDeptName(deptId);
|
||||
this.loginName = loginName;
|
||||
this.name = name;
|
||||
this.roleList = roleList;
|
||||
|
|
|
|||
|
|
@ -53,14 +53,15 @@ public class AopContext {
|
|||
private String sql;
|
||||
|
||||
/**
|
||||
* 追加SQL条件(程序自动生成) 格式: where xxx = xxx
|
||||
* 追加SQL条件(程序自动生成)
|
||||
*/
|
||||
private String condition;
|
||||
|
||||
/**
|
||||
* 自定义SQL覆盖默认查询条件 格式: where xxx = xxx
|
||||
* 自定义SQL覆盖默认查询条件
|
||||
*/
|
||||
private String where;
|
||||
|
||||
/**
|
||||
* 自定义SQL参数(map形式)
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import java.util.Enumeration;
|
|||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
|
|
@ -67,13 +66,13 @@ public class LogAop {
|
|||
value = request.getParameter(key);
|
||||
Func.builder(sb, key, "=", value, "&");
|
||||
}
|
||||
if (StringUtils.isEmpty(sb)) {
|
||||
if (Func.isEmpty(sb)) {
|
||||
Func.builder(sb, request.getQueryString());
|
||||
}
|
||||
}
|
||||
try {
|
||||
String msg = Func.format("[类名]:{} [方法]:{} [参数]:{}", className, methodName, StrKit.removeSuffix(sb.toString(), "&"));
|
||||
BladeLogManager.doLog(user, msg, (ObjectKit.isNull(doLog) ? getLogName(methodName) : doLog.name()), request, true);
|
||||
BladeLogManager.doLog((ObjectKit.isNull(doLog) ? getLogName(methodName) : doLog.name()), msg, true);
|
||||
log.info(msg);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.smallchill.common.vo.ShiroUser;
|
||||
import com.smallchill.core.constant.Const;
|
||||
import com.smallchill.core.constant.ConstCache;
|
||||
import com.smallchill.core.constant.ConstCurd;
|
||||
|
|
@ -40,7 +39,6 @@ import com.smallchill.core.constant.Cst;
|
|||
import com.smallchill.core.exception.NoPermissionException;
|
||||
import com.smallchill.core.exception.NoUserException;
|
||||
import com.smallchill.core.interfaces.IQuery;
|
||||
import com.smallchill.core.shiro.ShiroKit;
|
||||
import com.smallchill.core.toolbox.Paras;
|
||||
import com.smallchill.core.toolbox.ajax.AjaxResult;
|
||||
import com.smallchill.core.toolbox.file.BladeFile;
|
||||
|
|
@ -358,8 +356,7 @@ public class BladeController implements ConstCurd, ConstCache{
|
|||
}
|
||||
try {
|
||||
if(StrKit.notBlank(msg)){
|
||||
ShiroUser user = ShiroKit.getUser();
|
||||
BladeLogManager.doLog(user, msg, "异常日志", request, false);
|
||||
BladeLogManager.doLog("异常日志", msg, false);
|
||||
}
|
||||
} catch (Exception logex) {
|
||||
LogKit.logNothing(logex);
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.smallchill.common.tool.SysCache;
|
||||
import com.smallchill.core.constant.ConstCache;
|
||||
import com.smallchill.core.constant.ConstConfig;
|
||||
import com.smallchill.core.interfaces.ILoader;
|
||||
|
|
@ -517,19 +518,19 @@ public class BeetlExt {
|
|||
|
||||
|
||||
public String getDictName(final Object code, final Object num) {
|
||||
return Func.getDictName(code, num);
|
||||
return SysCache.getDictName(code, num);
|
||||
}
|
||||
|
||||
public String getRoleName(final Object roleId) {
|
||||
return Func.getRoleName(roleId);
|
||||
return SysCache.getRoleName(roleId);
|
||||
}
|
||||
|
||||
public String getUserName(final Object userId) {
|
||||
return Func.getUserName(userId);
|
||||
return SysCache.getUserName(userId);
|
||||
}
|
||||
|
||||
public String getDeptName(final Object deptId) {
|
||||
return Func.getDeptName(deptId);
|
||||
return SysCache.getDeptName(deptId);
|
||||
}
|
||||
|
||||
public boolean isOracle() {
|
||||
|
|
|
|||
|
|
@ -15,9 +15,6 @@
|
|||
*/
|
||||
package com.smallchill.core.interfaces;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.smallchill.common.vo.ShiroUser;
|
||||
import com.smallchill.core.toolbox.Paras;
|
||||
|
||||
/**
|
||||
|
|
@ -42,10 +39,9 @@ public interface ILog {
|
|||
|
||||
/**
|
||||
* 日志记录
|
||||
* @param user 当前用户
|
||||
* @param logName 日志名称
|
||||
* @param msg 返回消息
|
||||
* @param request
|
||||
* @return boolean
|
||||
*/
|
||||
boolean doLog(ShiroUser user, String msg, String logName, HttpServletRequest request, boolean succeed);
|
||||
boolean doLog(String logName, String msg, boolean succeed);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import java.util.Map;
|
|||
import org.apache.shiro.authc.SimpleAuthenticationInfo;
|
||||
|
||||
import com.smallchill.common.vo.ShiroUser;
|
||||
import com.smallchill.common.vo.User;
|
||||
import com.smallchill.system.model.User;
|
||||
|
||||
/**
|
||||
* 定义shirorealm所需数据的接口
|
||||
|
|
|
|||
|
|
@ -26,13 +26,13 @@ import org.apache.shiro.crypto.hash.Md5Hash;
|
|||
import org.apache.shiro.util.ByteSource;
|
||||
|
||||
import com.smallchill.common.vo.ShiroUser;
|
||||
import com.smallchill.common.vo.User;
|
||||
import com.smallchill.core.constant.ConstCache;
|
||||
import com.smallchill.core.interfaces.IShiro;
|
||||
import com.smallchill.core.plugins.dao.Blade;
|
||||
import com.smallchill.core.plugins.dao.Db;
|
||||
import com.smallchill.core.toolbox.Func;
|
||||
import com.smallchill.core.toolbox.Paras;
|
||||
import com.smallchill.system.model.User;
|
||||
|
||||
public class DefaultShiroFactroy implements IShiro{
|
||||
|
||||
|
|
|
|||
|
|
@ -36,9 +36,9 @@ import org.apache.shiro.realm.AuthorizingRealm;
|
|||
import org.apache.shiro.subject.PrincipalCollection;
|
||||
|
||||
import com.smallchill.common.vo.ShiroUser;
|
||||
import com.smallchill.common.vo.User;
|
||||
import com.smallchill.core.interfaces.IShiro;
|
||||
import com.smallchill.core.toolbox.Func;
|
||||
import com.smallchill.system.model.User;
|
||||
|
||||
public class ShiroDbRealm extends AuthorizingRealm {
|
||||
private static Logger log = LogManager.getLogger(ShiroDbRealm.class);
|
||||
|
|
|
|||
|
|
@ -25,20 +25,11 @@ import java.util.Map;
|
|||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import com.smallchill.common.vo.User;
|
||||
import com.smallchill.core.constant.ConstCache;
|
||||
import com.smallchill.core.constant.ConstConfig;
|
||||
import com.smallchill.core.interfaces.ILoader;
|
||||
import com.smallchill.core.plugins.dao.Blade;
|
||||
import com.smallchill.core.toolbox.kit.CacheKit;
|
||||
import com.smallchill.core.toolbox.kit.CharsetKit;
|
||||
import com.smallchill.core.toolbox.kit.StrKit;
|
||||
import com.smallchill.core.toolbox.kit.URLKit;
|
||||
import com.smallchill.core.toolbox.support.Convert;
|
||||
import com.smallchill.system.model.Dept;
|
||||
import com.smallchill.system.model.Dict;
|
||||
import com.smallchill.system.model.Parameter;
|
||||
import com.smallchill.system.model.Role;
|
||||
|
||||
/**
|
||||
* 高频方法集合类
|
||||
|
|
@ -423,125 +414,6 @@ public class Func {
|
|||
sb.append(str);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典表对应中文
|
||||
* @param code 字典编号
|
||||
* @param num 字典序号
|
||||
* @return
|
||||
*/
|
||||
public static String getDictName(final Object code, final Object num) {
|
||||
Dict dict = CacheKit.get(ConstCache.DICT_CACHE, "getDictName_" + code + "_" + num, new ILoader() {
|
||||
@Override
|
||||
public Object load() {
|
||||
return Blade.create(Dict.class).findFirstBy("code=#{code} and num=#{num}", Paras.create().set("code", code).set("num", num));
|
||||
}
|
||||
});
|
||||
if(null == dict){
|
||||
return "";
|
||||
}
|
||||
return dict.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对应角色名
|
||||
* @param roleId 角色id
|
||||
* @return
|
||||
*/
|
||||
public static String getRoleName(final Object roleIds) {
|
||||
if(isEmpty(roleIds)){
|
||||
return "";
|
||||
}
|
||||
final String [] roleIdArr = roleIds.toString().split(",");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(int i = 0 ; i < roleIdArr.length; i++){
|
||||
final String roleId = roleIdArr[i];
|
||||
Role role = CacheKit.get(ConstCache.ROLE_CACHE, "getRoleName" + "_" + roleId, new ILoader() {
|
||||
@Override
|
||||
public Object load() {
|
||||
return Blade.create(Role.class).findById(roleId);
|
||||
}
|
||||
});
|
||||
sb.append(role.getName()).append(",");
|
||||
}
|
||||
return StrKit.removeSuffix(sb.toString(), ",");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对应角色别名
|
||||
* @param roleId 角色id
|
||||
* @return
|
||||
*/
|
||||
public static String getRoleAlias(final Object roleIds) {
|
||||
if(isEmpty(roleIds)){
|
||||
return "";
|
||||
}
|
||||
final String [] roleIdArr = roleIds.toString().split(",");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(int i = 0 ; i < roleIdArr.length; i++){
|
||||
final String roleId = roleIdArr[i];
|
||||
Role role = CacheKit.get(ConstCache.ROLE_CACHE, "getRoleAlias" + "_" + roleId, new ILoader() {
|
||||
@Override
|
||||
public Object load() {
|
||||
return Blade.create(Role.class).findById(roleId);
|
||||
}
|
||||
});
|
||||
sb.append(role.getTips()).append(",");
|
||||
}
|
||||
return StrKit.removeSuffix(sb.toString(), ",");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对应用户名
|
||||
* @param userId 用户id
|
||||
* @return
|
||||
*/
|
||||
public static String getUserName(final Object userId) {
|
||||
User user = CacheKit.get(ConstCache.USER_CACHE, "getUserName" + "_" + userId, new ILoader() {
|
||||
@Override
|
||||
public Object load() {
|
||||
return Blade.create(User.class).findById(userId);
|
||||
}
|
||||
});
|
||||
if(null == user){
|
||||
return "";
|
||||
}
|
||||
return user.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对应部门名
|
||||
* @param deptIds 部门id集合
|
||||
* @return
|
||||
*/
|
||||
public static String getDeptName(final Object deptIds) {
|
||||
if(isEmpty(deptIds)){
|
||||
return "";
|
||||
}
|
||||
final String [] deptIdArr = deptIds.toString().split(",");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(int i = 0 ; i < deptIdArr.length; i++){
|
||||
final String deptId = deptIdArr[i];
|
||||
Dept dept = CacheKit.get(ConstCache.DEPT_CACHE, "getDeptName" + "_" + deptId, new ILoader() {
|
||||
@Override
|
||||
public Object load() {
|
||||
return Blade.create(Dept.class).findById(deptId);
|
||||
}
|
||||
});
|
||||
sb.append(dept.getSimplename()).append(",");
|
||||
}
|
||||
return StrKit.removeSuffix(sb.toString(), ",");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取参数表参数值
|
||||
* @param code 参数编号
|
||||
* @return String
|
||||
*/
|
||||
public static String getParamByCode(String code){
|
||||
Parameter param = Blade.create(Parameter.class).findFirstBy("code = #{code} and status = 1", Paras.create().set("code", code));
|
||||
return param.getPara();
|
||||
}
|
||||
|
||||
public static boolean isOracle() {
|
||||
return (ConstConfig.dbType.equals("oracle"));
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class BladeFile {
|
|||
this.file = file;
|
||||
this.fileName = file.getName();
|
||||
this.originalFileName = file.getOriginalFilename();
|
||||
this.uploadPath = Cst.me().getUploadRealPath() + File.separator + DateKit.getDays() + File.separator + this.originalFileName;
|
||||
this.uploadPath = File.separator + Cst.me().getUploadRealPath() + File.separator + DateKit.getDays() + File.separator + this.originalFileName;
|
||||
this.uploadVirtualPath = Cst.me().getUploadCtxPath().replace(Cst.me().getContextPath(), "") + File.separator + DateKit.getDays() + File.separator + this.originalFileName;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@ package com.smallchill.core.toolbox.log;
|
|||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.smallchill.common.vo.OperationLog;
|
||||
import com.smallchill.common.vo.ShiroUser;
|
||||
import com.smallchill.core.constant.Const;
|
||||
|
|
@ -28,6 +26,7 @@ import com.smallchill.core.interfaces.ILoader;
|
|||
import com.smallchill.core.interfaces.ILog;
|
||||
import com.smallchill.core.plugins.dao.Blade;
|
||||
import com.smallchill.core.plugins.dao.Db;
|
||||
import com.smallchill.core.shiro.ShiroKit;
|
||||
import com.smallchill.core.toolbox.Func;
|
||||
import com.smallchill.core.toolbox.Paras;
|
||||
import com.smallchill.core.toolbox.kit.CacheKit;
|
||||
|
|
@ -71,7 +70,8 @@ public class BladeLogFactory implements ILog {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean doLog(ShiroUser user, String msg, String logName, HttpServletRequest request, boolean succeed) {
|
||||
public boolean doLog(String logName, String msg, boolean succeed) {
|
||||
ShiroUser user = ShiroKit.getUser();
|
||||
if (null == user) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,9 +15,6 @@
|
|||
*/
|
||||
package com.smallchill.core.toolbox.log;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.smallchill.common.vo.ShiroUser;
|
||||
import com.smallchill.core.constant.Cst;
|
||||
import com.smallchill.core.interfaces.ILog;
|
||||
import com.smallchill.core.toolbox.Paras;
|
||||
|
|
@ -65,7 +62,7 @@ public class BladeLogManager {
|
|||
return me.defaultLogFactory.isDoLog();
|
||||
}
|
||||
|
||||
public static boolean doLog(ShiroUser user, String msg,String logName, HttpServletRequest request, boolean succeed) {
|
||||
return me.defaultLogFactory.doLog(user, msg, logName, request, succeed);
|
||||
public static boolean doLog(String logName, String msg, boolean succeed) {
|
||||
return me.defaultLogFactory.doLog(logName, msg, succeed);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.smallchill.common.base.BaseController;
|
||||
import com.smallchill.common.tool.SysCache;
|
||||
import com.smallchill.core.plugins.dao.Blade;
|
||||
import com.smallchill.core.plugins.dao.Md;
|
||||
import com.smallchill.core.toolbox.Func;
|
||||
import com.smallchill.core.toolbox.Paras;
|
||||
import com.smallchill.core.toolbox.ajax.AjaxResult;
|
||||
import com.smallchill.core.toolbox.kit.JsonKit;
|
||||
|
|
@ -51,12 +51,12 @@ public class NoticeController extends BaseController {
|
|||
@RequestMapping(KEY_VIEW + "/{id}")
|
||||
public String view(@PathVariable String id, ModelMap mm) {
|
||||
Notice notice = Blade.create(Notice.class).findById(id);
|
||||
//将javabean转化为rd
|
||||
Paras rd = Paras.parse(notice);
|
||||
//使用Func.getDictName方法从缓存中获取对应字典项的中文值
|
||||
rd.set("dic_f_it_lx", Func.getDictName(102, notice.getF_it_lx()));
|
||||
//将javabean转化为map
|
||||
Paras ps = Paras.parse(notice);
|
||||
//使用SysCache.getDictName方法从缓存中获取对应字典项的中文值
|
||||
ps.set("dic_f_it_lx", SysCache.getDictName(102, notice.getF_it_lx()));
|
||||
//将rd传回前台
|
||||
mm.put("model", JsonKit.toJson(rd));
|
||||
mm.put("model", JsonKit.toJson(ps));
|
||||
mm.put("id", id);
|
||||
mm.put("code", CODE);
|
||||
return BASE_PATH + "notice_view.html";
|
||||
|
|
|
|||
|
|
@ -23,10 +23,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.smallchill.common.base.BaseController;
|
||||
import com.smallchill.common.tool.SysCache;
|
||||
import com.smallchill.core.annotation.Before;
|
||||
import com.smallchill.core.annotation.Permission;
|
||||
import com.smallchill.core.constant.ConstShiro;
|
||||
import com.smallchill.core.toolbox.Func;
|
||||
import com.smallchill.core.toolbox.Paras;
|
||||
import com.smallchill.core.toolbox.ajax.AjaxResult;
|
||||
import com.smallchill.core.toolbox.kit.CacheKit;
|
||||
|
|
@ -91,7 +91,7 @@ public class RoleController extends BaseController{
|
|||
Role parent = service.findById(role.getPid());
|
||||
String pName = (null == parent) ? "" : parent.getName();
|
||||
Paras rd = Paras.parse(role);
|
||||
rd.set("deptName", Func.getDeptName(role.getDeptid()))
|
||||
rd.set("deptName", SysCache.getDeptName(role.getDeptid()))
|
||||
.set("pName", pName);
|
||||
mm.put("model", JsonKit.toJson(rd));
|
||||
mm.put("code", CODE);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.smallchill.common.base.BaseController;
|
||||
import com.smallchill.common.vo.User;
|
||||
import com.smallchill.common.tool.SysCache;
|
||||
import com.smallchill.core.annotation.Before;
|
||||
import com.smallchill.core.annotation.Permission;
|
||||
import com.smallchill.core.aop.AopContext;
|
||||
|
|
@ -46,6 +46,7 @@ import com.smallchill.system.meta.intercept.PasswordValidator;
|
|||
import com.smallchill.system.meta.intercept.UserIntercept;
|
||||
import com.smallchill.system.meta.intercept.UserValidator;
|
||||
import com.smallchill.system.model.RoleExt;
|
||||
import com.smallchill.system.model.User;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/user")
|
||||
|
|
@ -86,7 +87,7 @@ public class UserController extends BaseController implements ConstShiro{
|
|||
public String edit(@PathVariable String id, ModelMap mm) {
|
||||
User user = Blade.create(User.class).findById(id);
|
||||
Paras rd = Paras.parse(user);
|
||||
rd.set("roleName", Func.getRoleName(user.getRoleid()));
|
||||
rd.set("roleName", SysCache.getRoleName(user.getRoleid()));
|
||||
mm.put("user", rd);
|
||||
mm.put("code", CODE);
|
||||
return BASE_PATH + "user_edit.html";
|
||||
|
|
@ -96,7 +97,7 @@ public class UserController extends BaseController implements ConstShiro{
|
|||
public String editMySelf(@PathVariable String id, ModelMap mm) {
|
||||
User user = Blade.create(User.class).findById(id);
|
||||
Paras rd = Paras.parse(user);
|
||||
rd.set("roleName", Func.getRoleName(user.getRoleid()));
|
||||
rd.set("roleName", SysCache.getRoleName(user.getRoleid()));
|
||||
mm.put("user", rd);
|
||||
mm.put("code", CODE);
|
||||
mm.put("methodName", "editMySelf");
|
||||
|
|
@ -135,9 +136,9 @@ public class UserController extends BaseController implements ConstShiro{
|
|||
public String view(@PathVariable String id, ModelMap mm) {
|
||||
User user = Blade.create(User.class).findById(id);
|
||||
Paras rd = Paras.parse(user);
|
||||
rd.set("deptName", Func.getDeptName(user.getDeptid()))
|
||||
.set("roleName", Func.getRoleName(user.getRoleid()))
|
||||
.set("sexName", Func.getDictName(101, user.getSex()));
|
||||
rd.set("deptName", SysCache.getDeptName(user.getDeptid()))
|
||||
.set("roleName", SysCache.getRoleName(user.getRoleid()))
|
||||
.set("sexName", SysCache.getDictName(101, user.getSex()));
|
||||
mm.put("user", rd);
|
||||
mm.put("code", CODE);
|
||||
return BASE_PATH + "user_view.html";
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import java.io.File;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.smallchill.common.tool.SysCache;
|
||||
import com.smallchill.core.aop.AopContext;
|
||||
import com.smallchill.core.constant.Cst;
|
||||
import com.smallchill.core.meta.MetaIntercept;
|
||||
|
|
@ -39,8 +40,8 @@ public class AttachIntercept extends MetaIntercept {
|
|||
List<Map<String, Object>> list = page.getRows();
|
||||
for (Map<String, Object> map : list) {
|
||||
map.put("ATTACHURL", Cst.me().getContextPath() + "/kindeditor/renderFile/" + map.get("ID"));
|
||||
map.put("STATUSNAME", Func.getDictName(902, map.get("STATUS")));
|
||||
map.put("CREATERNAME", Func.getUserName(map.get("CREATER")));
|
||||
map.put("STATUSNAME", SysCache.getDictName(902, map.get("STATUS")));
|
||||
map.put("CREATERNAME", SysCache.getUserName(map.get("CREATER")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -53,8 +54,8 @@ public class AttachIntercept extends MetaIntercept {
|
|||
Paras rd = (Paras) ac.getObject();
|
||||
rd
|
||||
.set("attachUrl", Cst.me().getContextPath() + "/kindeditor/renderFile/" + rd.get("id"))
|
||||
.set("statusName", Func.getDictName(902, rd.get("status")))
|
||||
.set("createrName", Func.getUserName(rd.get("creater")));
|
||||
.set("statusName", SysCache.getDictName(902, rd.get("status")))
|
||||
.set("createrName", SysCache.getUserName(rd.get("creater")));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package com.smallchill.system.meta.intercept;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.smallchill.common.tool.SysCache;
|
||||
import com.smallchill.core.aop.AopContext;
|
||||
import com.smallchill.core.constant.ConstCache;
|
||||
import com.smallchill.core.meta.MetaIntercept;
|
||||
|
|
@ -39,7 +40,7 @@ public class LogIntercept extends MetaIntercept {
|
|||
for (Map<String, Object> map : list) {
|
||||
String succeedName = (Func.toInt(map.get("SUCCEED"), 1) == 1) ? "成功" : "失败";
|
||||
map.put("SUCCEEDNAME", succeedName);
|
||||
map.put("USERNAME", Func.getUserName(map.get("USERID")));
|
||||
map.put("USERNAME", SysCache.getUserName(map.get("USERID")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -51,7 +52,7 @@ public class LogIntercept extends MetaIntercept {
|
|||
public void renderViewBefore(AopContext ac) {
|
||||
Paras rd = (Paras) ac.getObject();
|
||||
String succeedName = (rd.getInt("succeed") == 1) ? "成功" : "失败";
|
||||
rd.set("succeedName", succeedName).set("userName", Func.getUserName(rd.get("userid")));
|
||||
rd.set("succeedName", succeedName).set("userName", SysCache.getUserName(rd.get("userid")));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import java.util.Map;
|
|||
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.smallchill.common.tool.SysCache;
|
||||
import com.smallchill.core.aop.AopContext;
|
||||
import com.smallchill.core.base.controller.BladeController;
|
||||
import com.smallchill.core.constant.ConstCache;
|
||||
|
|
@ -27,7 +28,6 @@ import com.smallchill.core.constant.ConstShiro;
|
|||
import com.smallchill.core.meta.MetaIntercept;
|
||||
import com.smallchill.core.plugins.dao.Blade;
|
||||
import com.smallchill.core.shiro.ShiroKit;
|
||||
import com.smallchill.core.toolbox.Func;
|
||||
import com.smallchill.core.toolbox.Paras;
|
||||
import com.smallchill.core.toolbox.ajax.AjaxResult;
|
||||
import com.smallchill.core.toolbox.kit.CacheKit;
|
||||
|
|
@ -58,7 +58,7 @@ public class ParameterIntercept extends MetaIntercept {
|
|||
BladePage<Map<String, Object>> page = (BladePage<Map<String, Object>>) ac.getObject();
|
||||
List<Map<String, Object>> list = page.getRows();
|
||||
for (Map<String, Object> map : list) {
|
||||
map.put("STATUSNAME", Func.getDictName(901, map.get("STATUS")));
|
||||
map.put("STATUSNAME", SysCache.getDictName(901, map.get("STATUS")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@
|
|||
*/
|
||||
package com.smallchill.system.meta.intercept;
|
||||
|
||||
import com.smallchill.common.vo.User;
|
||||
import com.smallchill.core.aop.Invocation;
|
||||
import com.smallchill.core.intercept.BladeValidator;
|
||||
import com.smallchill.core.plugins.dao.Blade;
|
||||
import com.smallchill.core.shiro.ShiroKit;
|
||||
import com.smallchill.core.toolbox.kit.StrKit;
|
||||
import com.smallchill.system.model.User;
|
||||
|
||||
public class PasswordValidator extends BladeValidator {
|
||||
|
||||
|
|
|
|||
|
|
@ -15,11 +15,11 @@
|
|||
*/
|
||||
package com.smallchill.system.meta.intercept;
|
||||
|
||||
import com.smallchill.common.tool.SysCache;
|
||||
import com.smallchill.core.aop.Invocation;
|
||||
import com.smallchill.core.constant.ConstShiro;
|
||||
import com.smallchill.core.intercept.BladeValidator;
|
||||
import com.smallchill.core.plugins.dao.Db;
|
||||
import com.smallchill.core.toolbox.Func;
|
||||
import com.smallchill.core.toolbox.Paras;
|
||||
import com.smallchill.core.toolbox.kit.CollectionKit;
|
||||
import com.smallchill.core.toolbox.kit.StrKit;
|
||||
|
|
@ -37,7 +37,7 @@ public class RoleValidator extends BladeValidator {
|
|||
addError("请选择权限!");
|
||||
}
|
||||
String roleId = request.getParameter(field1);
|
||||
String roleAlias = Func.getRoleAlias(roleId);
|
||||
String roleAlias = SysCache.getRoleAlias(roleId);
|
||||
if(roleAlias.equals(ConstShiro.ADMINISTRATOR)){
|
||||
String[] id = ids.split(",");
|
||||
String authority = Db.queryStr("select id from tfw_menu where code = #{code}", Paras.create().set("code", "role_authority"));
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ package com.smallchill.system.meta.intercept;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.smallchill.common.tool.SysCache;
|
||||
import com.smallchill.core.aop.AopContext;
|
||||
import com.smallchill.core.meta.PageIntercept;
|
||||
import com.smallchill.core.toolbox.Func;
|
||||
import com.smallchill.core.toolbox.support.BladePage;
|
||||
|
||||
public class UserIntercept extends PageIntercept {
|
||||
|
|
@ -35,10 +35,10 @@ public class UserIntercept extends PageIntercept {
|
|||
BladePage<Map<String, Object>> page = (BladePage<Map<String, Object>>) ac.getObject();
|
||||
List<Map<String, Object>> list = page.getRows();
|
||||
for (Map<String, Object> map : list) {
|
||||
map.put("ROLENAME", Func.getRoleName(map.get("ROLEID")));
|
||||
map.put("STATUSNAME", Func.getDictName(901, map.get("STATUS")));
|
||||
map.put("SEXNAME", Func.getDictName(101, map.get("SEX")));
|
||||
map.put("DEPTNAME", Func.getDeptName(map.get("DEPTID")));
|
||||
map.put("ROLENAME", SysCache.getRoleName(map.get("ROLEID")));
|
||||
map.put("STATUSNAME", SysCache.getDictName(901, map.get("STATUS")));
|
||||
map.put("SEXNAME", SysCache.getDictName(101, map.get("SEX")));
|
||||
map.put("DEPTNAME", SysCache.getDeptName(map.get("DEPTID")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@
|
|||
*/
|
||||
package com.smallchill.system.meta.intercept;
|
||||
|
||||
import com.smallchill.common.vo.User;
|
||||
import com.smallchill.core.aop.Invocation;
|
||||
import com.smallchill.core.intercept.BladeValidator;
|
||||
import com.smallchill.core.plugins.dao.Blade;
|
||||
import com.smallchill.core.toolbox.Paras;
|
||||
import com.smallchill.core.toolbox.kit.StrKit;
|
||||
import com.smallchill.system.model.User;
|
||||
|
||||
public class UserValidator extends BladeValidator {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package com.smallchill.common.vo;
|
||||
package com.smallchill.system.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
|
@ -25,17 +25,11 @@
|
|||
colModel:_colmodel,
|
||||
jsonReader:{id:"F_IT_XL"},
|
||||
pager : pager_selector,
|
||||
ondblClickRow : page_add,
|
||||
postData: {sort: "F_IT_XL", order: "desc"}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
function page_add(){
|
||||
$("#${code}_add").click();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user