bug fix
This commit is contained in:
parent
5bb328ec1f
commit
97e82ab7ed
2
pom.xml
2
pom.xml
|
|
@ -17,7 +17,7 @@
|
|||
<!-- 依赖版本 -->
|
||||
<spring.version>4.3.3.RELEASE</spring.version>
|
||||
<shiro.version>1.3.2</shiro.version>
|
||||
<log4j2.version>2.6.2</log4j2.version>
|
||||
<log4j2.version>2.7</log4j2.version>
|
||||
<beetl.version>2.5.2</beetl.version>
|
||||
<beetlsql.version>2.6.5</beetlsql.version>
|
||||
</properties>
|
||||
|
|
|
|||
|
|
@ -28,5 +28,5 @@ import java.lang.annotation.Target;
|
|||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.METHOD})
|
||||
public @interface DoLog {
|
||||
|
||||
String name();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import com.smallchill.core.annotation.DoLog;
|
|||
import com.smallchill.core.shiro.ShiroKit;
|
||||
import com.smallchill.core.toolbox.Func;
|
||||
import com.smallchill.core.toolbox.kit.HttpKit;
|
||||
import com.smallchill.core.toolbox.kit.ObjectKit;
|
||||
import com.smallchill.core.toolbox.kit.StrKit;
|
||||
import com.smallchill.core.toolbox.log.BladeLogManager;
|
||||
|
||||
|
|
@ -72,7 +73,7 @@ public class LogAop {
|
|||
}
|
||||
try {
|
||||
String msg = Func.format("[类名]:{} [方法]:{} [参数]:{}", className, methodName, StrKit.removeSuffix(sb.toString(), "&"));
|
||||
BladeLogManager.doLog(user, msg, getLogName(methodName), request, true);
|
||||
BladeLogManager.doLog(user, msg, (ObjectKit.isNull(doLog) ? getLogName(methodName) : doLog.name()), request, true);
|
||||
log.info(msg);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
|||
|
|
@ -36,9 +36,9 @@ 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.ClassKit;
|
||||
import com.smallchill.core.toolbox.kit.JsonKit;
|
||||
import com.smallchill.core.toolbox.kit.StrKit;
|
||||
import com.smallchill.core.toolbox.support.Singleton;
|
||||
import com.smallchill.system.service.CurdService;
|
||||
|
||||
public abstract class CurdController<M> extends BaseController {
|
||||
|
|
@ -66,13 +66,13 @@ public abstract class CurdController<M> extends BaseController {
|
|||
|
||||
private void init() {
|
||||
this.modelClass = getClazz();
|
||||
this.metaFactory = Singleton.create(metaFactoryClass());
|
||||
this.metaFactory = ClassKit.newInstance(metaFactoryClass());
|
||||
this.controllerKey = metaFactory.controllerKey();
|
||||
this.paraPrefix = metaFactory.paraPrefix();
|
||||
this.switchMap = metaFactory.switchMap();
|
||||
this.renderMap = metaFactory.renderMap();
|
||||
this.sourceMap = metaFactory.sourceMap();
|
||||
this.intercept = Singleton.create(metaFactory.intercept());
|
||||
this.intercept = ClassKit.newInstance(metaFactory.intercept());
|
||||
}
|
||||
|
||||
public CurdController() {
|
||||
|
|
|
|||
|
|
@ -445,7 +445,7 @@ public class Func {
|
|||
StringBuilder sb = new StringBuilder();
|
||||
for(int i = 0 ; i < roleIdArr.length; i++){
|
||||
final String roleId = roleIdArr[i];
|
||||
Role role = CacheKit.get(ConstCache.DICT_CACHE, "getRoleName" + "_" + roleId, new ILoader() {
|
||||
Role role = CacheKit.get(ConstCache.ROLE_CACHE, "getRoleName" + "_" + roleId, new ILoader() {
|
||||
@Override
|
||||
public Object load() {
|
||||
return Blade.create(Role.class).findById(roleId);
|
||||
|
|
@ -456,13 +456,37 @@ public class Func {
|
|||
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.DICT_CACHE, "getUserName" + "_" + userId, new ILoader() {
|
||||
User user = CacheKit.get(ConstCache.USER_CACHE, "getUserName" + "_" + userId, new ILoader() {
|
||||
@Override
|
||||
public Object load() {
|
||||
return Blade.create(User.class).findById(userId);
|
||||
|
|
@ -487,7 +511,7 @@ public class Func {
|
|||
StringBuilder sb = new StringBuilder();
|
||||
for(int i = 0 ; i < deptIdArr.length; i++){
|
||||
final String deptId = deptIdArr[i];
|
||||
Dept dept = CacheKit.get(ConstCache.DICT_CACHE, "getDeptName" + "_" + deptId, new ILoader() {
|
||||
Dept dept = CacheKit.get(ConstCache.DEPT_CACHE, "getDeptName" + "_" + deptId, new ILoader() {
|
||||
@Override
|
||||
public Object load() {
|
||||
return Blade.create(Dept.class).findById(deptId);
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ public class ClassKit {
|
|||
if (index < 0 || index > params.length - 1) {
|
||||
return null;
|
||||
}
|
||||
Type param = params[0];
|
||||
Type param = params[index];
|
||||
if (param instanceof Class) {
|
||||
return (Class) param;
|
||||
}
|
||||
|
|
@ -291,6 +291,8 @@ public class ClassKit {
|
|||
* @return 对象
|
||||
*/
|
||||
public static <T> T newInstance(Class<T> clazz) {
|
||||
if (null == clazz)
|
||||
return null;
|
||||
try {
|
||||
return (T) clazz.newInstance();
|
||||
} catch (Exception e) {
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ public class RoleController extends BaseController{
|
|||
CacheKit.removeAll(MENU_CACHE);
|
||||
return success("设置成功");
|
||||
}
|
||||
boolean temp = service.saveAuthority(ids, roleId);
|
||||
boolean temp = service.authority(ids, roleId);
|
||||
if (temp) {
|
||||
CacheKit.removeAll(ROLE_CACHE);
|
||||
CacheKit.removeAll(MENU_CACHE);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ 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.shiro.ShiroKit;
|
||||
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;
|
||||
|
|
@ -28,14 +28,17 @@ public class RoleValidator extends BladeValidator {
|
|||
|
||||
@Override
|
||||
protected void doValidate(Invocation inv) {
|
||||
validateRole("ids", "超级管理员不能去掉角色管理的权限!");
|
||||
validateRole("roleId", "ids", "超级管理员不能去掉角色管理的权限!");
|
||||
}
|
||||
|
||||
protected void validateRole(String field, String errorMessage) {
|
||||
String ids = request.getParameter(field);
|
||||
protected void validateRole(String field1, String field2, String errorMessage) {
|
||||
String ids = request.getParameter(field2);
|
||||
if (StrKit.isBlank(ids)) {
|
||||
addError("请选择权限!");
|
||||
} else if(ShiroKit.hasRole(ConstShiro.ADMINISTRATOR)){
|
||||
}
|
||||
String roleId = request.getParameter(field1);
|
||||
String roleAlias = Func.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"));
|
||||
if(!CollectionKit.contains(id, authority)){
|
||||
|
|
|
|||
|
|
@ -15,13 +15,15 @@
|
|||
*/
|
||||
package com.smallchill.system.service;
|
||||
|
||||
import com.smallchill.core.annotation.DoLog;
|
||||
import com.smallchill.core.base.service.IService;
|
||||
import com.smallchill.system.model.Role;
|
||||
|
||||
public interface RoleService extends IService<Role> {
|
||||
int findLastNum(String id);
|
||||
|
||||
boolean saveAuthority(String ids, String roleId);
|
||||
@DoLog(name = "设置权限")
|
||||
boolean authority(String ids, String roleId);
|
||||
|
||||
int getParentCnt(String id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class RoleServiceImpl extends BaseService<Role> implements RoleService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean saveAuthority(String ids, String roleId) {
|
||||
public boolean authority(String ids, String roleId) {
|
||||
Db.deleteByIds("TFW_RELATION", "ROLEID", roleId);
|
||||
|
||||
String sql = "";
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@ import java.util.Map;
|
|||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.jeecgframework.poi.excel.ExcelExportUtil;
|
||||
import org.jeecgframework.poi.excel.ExcelToHtmlUtil;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.params.ExcelExportEntity;
|
||||
import org.jeecgframework.poi.excel.entity.vo.MapExcelConstants;
|
||||
|
|
@ -48,5 +51,30 @@ public class ExcelTest extends BladeController {
|
|||
modelMap.put(NormalExcelConstants.PARAMS, new ExportParams("商户利润详情", "商户"));
|
||||
return MapExcelConstants.JEECG_MAP_EXCEL_VIEW;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将excel转成html
|
||||
*/
|
||||
@RequestMapping("/html")
|
||||
public String exportMerchantProfitQuery() {
|
||||
List<ExcelExportEntity> entityList = new ArrayList<ExcelExportEntity>();
|
||||
entityList.add(new ExcelExportEntity("姓名", "name"));
|
||||
entityList.add(new ExcelExportEntity("性别", "sex"));
|
||||
entityList.add(new ExcelExportEntity("国籍", "country"));
|
||||
|
||||
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
|
||||
Map<String, String> map;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
map = new HashMap<String, String>();
|
||||
map.put("name", "1" + i);
|
||||
map.put("sex", "2" + i);
|
||||
map.put("country", "大中华");
|
||||
list.add(map);
|
||||
}
|
||||
HSSFWorkbook workbook = (HSSFWorkbook) ExcelExportUtil.exportExcel(new ExportParams("人员综合信息", "人员"), entityList, list);
|
||||
String html = ExcelToHtmlUtil.toTableHtml(workbook);
|
||||
return html;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user