自定义报表 目录功能 联调完成

yun-zuoyi
wei.peng 6 years ago
parent 3390abe23e
commit 584de18633

@ -101,6 +101,9 @@ public interface ISysRoleService {
@ApiOperation(value = "查信角色信息",notes = "查询所有角色信息")
List<SysRole> findSysRoleAll();
@ApiOperation(value = "查信角色信息",notes = "查询指定角色信息")
List<SysRole> findSysRoleByInId(Long[] ids);
/**
* id
*
@ -118,4 +121,5 @@ public interface ISysRoleService {
*/
@ApiOperation(value = "查信角色信息",notes = "查询角色信息(分页/组合)")
ListPager<SysRole> querySysRole(SysRole role, Pager pager);
}

@ -115,6 +115,19 @@ public class SysRoleController extends CoreBaseController{
}
}
@GetMapping(value = "/find-id-list")
@ApiOperation(value = "查询所有角色", notes = "查询所有系统角色")
public ResultBean findIdList(String[] ids) {
try {
List<SysRole> list = sysRoleService.findSysRoleAll();
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultList(list);
} catch (ImppBusiException busExcep) {
return ResultBean.fail(busExcep);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
@GetMapping(value = "/find-ref-menu/{roleId}")
@ApiOperation(value = "查询角色的所有角色权限关系", notes = "查询角色的所有角色权限关系")
public ResultBean findRefRoleMenu(@PathVariable("roleId") String roleId) {

@ -1,21 +1,27 @@
package cn.estsh.i3plus.core.apiservice.controller.report;
import cn.estsh.i3plus.core.api.iservice.busi.ISysRoleService;
import cn.estsh.i3plus.platform.common.tool.ClassTool;
import cn.estsh.i3plus.platform.common.tool.StringTool;
import cn.estsh.i3plus.platform.common.util.PlatformConstWords;
import cn.estsh.i3plus.pojo.base.bean.BaseResultBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
import cn.estsh.i3plus.pojo.model.common.ClassFieldModel;
import cn.estsh.i3plus.pojo.model.common.ClassModel;
import cn.estsh.i3plus.pojo.platform.bean.SysRole;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.util.ResultBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.persistence.Transient;
import java.lang.reflect.Field;
@ -23,7 +29,7 @@ import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping("/impp/cloud/report")
@RequestMapping(PlatformConstWords.BASE_URL + "/cloud/report")
@Api(description="报表服务")
public class CoreReportController {
@ -32,6 +38,54 @@ public class CoreReportController {
@Value("${impp.app.pojo-packages}.bean")
public String pojoPackagePath;
@Autowired
private ISysRoleService sysRoleService;
@GetMapping(value = "/role/list")
@ApiOperation(value = "查询所有角色", notes = "查询所有系统角色")
public ResultBean findAll() {
try {
List<SysRole> list = sysRoleService.findSysRoleAll();
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultList(list);
} catch (ImppBusiException busExcep) {
return ResultBean.fail(busExcep);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
@PostMapping(value = "/role/list/ids")
@ApiOperation(value = "查询所有角色", notes = "查询所有系统角色")
public ResultBean findRoleByIdList(@RequestBody String[] ids) {
try {
List<SysRole> list = sysRoleService.findSysRoleByInId(StringTool.getArrayLong(ids));
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultList(list);
} catch (ImppBusiException busExcep) {
return ResultBean.fail(busExcep);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
@GetMapping(value="/list-clz-model")
@ApiOperation(value="查询管理后台所有类",notes = "根据核心包路径列出所有类")
public BaseResultBean<ClassModel> listClzModel() {
LOGGER.info("【类路径:{}】",pojoPackagePath);
List<String> clzNameList = ClassTool.getClassName(pojoPackagePath, true);
List<ClassModel> clzList = new ArrayList<>(clzNameList.size());
for(String clzName : clzNameList){
ClassModel model = getClassModel(clzName);
if(model != null){
if(StringUtils.isNotBlank(model.getClzFullName())){
List<ClassFieldModel> list = getClassFieldModel(model.getClzFullName());
model.setFieldList(list);
}
clzList.add(model);
}
}
return ResultBean.success("获取类:" + clzList.size()).setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultList(clzList);
}
@GetMapping(value="/list-clz")
@ApiOperation(value="查询管理后台所有类",notes = "根据核心包路径列出所有类")
public BaseResultBean<ClassModel> listClz() {
@ -66,8 +120,8 @@ public class CoreReportController {
}
return ResultBean.success("获取类:" + clzList.size())
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode())
.setResultList(clzList);
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode())
.setResultList(clzList);
}
@GetMapping(value="/pojo-property")
@ -108,10 +162,67 @@ public class CoreReportController {
} catch (ClassNotFoundException e) {
LOGGER.error("【类:{}实例化出错】",clzFullName,e);
}
return ResultBean.success("获取属性:" + fieldModelList.size())
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode())
.setResultList(fieldModelList);
}
private ClassModel getClassModel(String clzName){
try {
//注册类
Class tmpClz = Class.forName(clzName);
ClassModel classModel = new ClassModel();
classModel.setServerId(CommonEnumUtil.SOFT_TYPE.CORE.getValue());
classModel.setServerName(CommonEnumUtil.SOFT_TYPE.CORE.getCode());
classModel.setPackageName(pojoPackagePath);
classModel.setClzFullName(clzName);
classModel.setClzSimpleName(tmpClz.getSimpleName());
Api api = (Api) tmpClz.getAnnotation(Api.class);
if(api != null) {
classModel.setClzDesc(api.value());
return classModel;
}else{
LOGGER.warn("不添加类:{},因为没有添加api描述", tmpClz);
}
} catch (ClassNotFoundException e) {
LOGGER.error("【类:{}注册出错】",clzName,clzName,e);
}
return null;
}
private List<ClassFieldModel> getClassFieldModel(String clzFullName){
List<ClassFieldModel> fieldModelList = new ArrayList<>();
try {
Class tmpClz = Class.forName(clzFullName);
List<Field> fields = ClassTool.getAllFieldsList(tmpClz);
ClassFieldModel fieldModel = null;
for(Field f : fields){
Transient tran = f.getAnnotation(Transient.class);
if(tran == null) {
// 临时对象不需要处理
fieldModel = new ClassFieldModel();
fieldModel.setPackageName(pojoPackagePath);
fieldModel.setClzFullName(clzFullName);
fieldModel.setClzSimpleName(tmpClz.getSimpleName());
fieldModel.setFieldName(f.getName());
ApiParam apiParam = f.getAnnotation(ApiParam.class);
if(apiParam != null){
fieldModel.setFieldDesc(apiParam.value());
fieldModelList.add(fieldModel);
}else{
LOGGER.warn("不添加属性:{},因为没有添加api描述", f.getName());
}
}else{
LOGGER.info("【临时属性:{}】",f.getName());
}
}
} catch (ClassNotFoundException e) {
LOGGER.error("【类:{}实例化出错】",clzFullName,e);
}
return fieldModelList;
}
}

@ -2,7 +2,6 @@ package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
import cn.estsh.i3plus.core.api.iservice.busi.IPersonnelService;
import cn.estsh.i3plus.core.api.iservice.busi.ISysRoleService;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.common.PagerHelper;
@ -41,7 +40,7 @@ public class SysRoleService implements ISysRoleService {
public static final Logger LOGGER = LoggerFactory.getLogger(SysRoleService.class);
@Autowired
private SysRoleRepository sysRoleRDao;
private SysRoleRepository roleRDao;
@Autowired
private SysMenuRepository sysMenuRDao;
@ -56,7 +55,7 @@ public class SysRoleService implements ISysRoleService {
@ApiOperation(value = "更新角色信息",notes = "更新角色信息")
public void updateSysRole(SysRole sysRole) {
LOGGER.info("系统角色 SYS_ROLE :{}", sysRole);
sysRoleRDao.update(sysRole);
roleRDao.update(sysRole);
// 更新冗余信息
personnelService.refreshUpdateSysRoleRdd(sysRole.getId());
}
@ -65,10 +64,10 @@ public class SysRoleService implements ISysRoleService {
@ApiOperation(value = "更新角色信息",notes = "更新角色状态信息")
public void updateSysRoleStatus(Long id, int status, SessionUser user) {
LOGGER.info("系统角色 SYS_MENU id:{} status:{} user:{}", id,status,user);
SysRole role = sysRoleRDao.getById(id);
SysRole role = roleRDao.getById(id);
role.setRoleStatus(status);
role.setModifyUser(user.getUserName());
sysRoleRDao.update(role);
roleRDao.update(role);
}
@Override
@ -78,7 +77,7 @@ public class SysRoleService implements ISysRoleService {
StringBuffer where = new StringBuffer();
HqlPack.getInPack(StringUtils.join( ids,","), "id", where);
sysRoleRDao.updateByHqlWhere(where.toString(), "roleStatus", status);
roleRDao.updateByHqlWhere(where.toString(), "roleStatus", status);
}
@Override
@ -86,14 +85,14 @@ public class SysRoleService implements ISysRoleService {
public void deleteSysRoleById(Long id) {
LOGGER.info("系统角色 SYS_ROLE Key:{}", id);
refRoleMenuRDao.deleteByProperty("roleId",id);
sysRoleRDao.deleteById(id);
roleRDao.deleteById(id);
}
@Override
@ApiOperation(value = "删除角色信息",notes = "根据ID 批量删除角色信息")
public void deleteSysRoleByIds(Long[] ids) {
LOGGER.info("系统角色 SYS_ROLE ids :{}", ids);
long positionCount = sysRoleRDao.findByHqlWhereCount(CoreHqlPack.packHqlIds("parentId",ids));
long positionCount = roleRDao.findByHqlWhereCount(CoreHqlPack.packHqlIds("parentId",ids));
if (positionCount >= 1) {
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
@ -103,7 +102,7 @@ public class SysRoleService implements ISysRoleService {
.build();
}else {
refRoleMenuRDao.deleteByPropertyIn("roleId",ids);
sysRoleRDao.deleteByIds(ids);
roleRDao.deleteByIds(ids);
}
}
@ -111,7 +110,7 @@ public class SysRoleService implements ISysRoleService {
@ApiOperation(value = "新增角色信息")
public SysRole insertSysRole(SysRole sysRole) {
LOGGER.info("系统角色 SYS_ROLE :{}", sysRole);
return sysRoleRDao.insert(sysRole);
return roleRDao.insert(sysRole);
}
@Override
@ -130,7 +129,7 @@ public class SysRoleService implements ISysRoleService {
LOGGER.info("系统角色 List<SysMenu> :{}", ids);
String roleWhere = CoreHqlPack.packHqlIds("id", roleIds);
List<SysRole> roleList = sysRoleRDao.findByHqlWhere(roleWhere);
List<SysRole> roleList = roleRDao.findByHqlWhere(roleWhere);
if(roleList != null && roleList.size() > 0){
List<String> moduleListRdd = new ArrayList<>();
@ -190,7 +189,7 @@ public class SysRoleService implements ISysRoleService {
}
refRoleMenuRDao.saveAll(refs);
sysRoleRDao.saveAll(roleList);
roleRDao.saveAll(roleList);
}else {
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
@ -215,14 +214,23 @@ public class SysRoleService implements ISysRoleService {
@ApiOperation(value = "查信角色信息",notes = "查询所有角色信息")
public List<SysRole> findSysRoleAll() {
LOGGER.info("系统角色 SYS_ROLE find All");
return sysRoleRDao.findByProperty(new String[]{"roleStatus"},new Object[]{CommonEnumUtil.DATA_STATUS.ENABLE.getValue()});
return roleRDao.findByProperty(new String[]{"roleStatus"},new Object[]{CommonEnumUtil.DATA_STATUS.ENABLE.getValue()});
}
@Override
@ApiOperation(value = "查信角色信息",notes = "查询指定角色信息")
public List<SysRole> findSysRoleByInId(Long[] ids) {
LOGGER.info("系统角色 SYS_ROLE find In Id");
StringBuffer findWhere = new StringBuffer();
HqlPack.getInPack(StringUtils.join(ids,","),"id",findWhere);
return roleRDao.findByHqlWhere(findWhere.toString());
}
@Override
@ApiOperation(value = "查信角色信息",notes = "根据 ID 查询角色信息")
public SysRole getSysRoleById(Long id) {
LOGGER.info("系统角色 SYS_ROLE find id:{}", id);
return sysRoleRDao.getOne(id);
return roleRDao.getOne(id);
}
@Override
@ -232,14 +240,14 @@ public class SysRoleService implements ISysRoleService {
if (role == null) {
//不传入实体对象,查询所有
int count = sysRoleRDao.listCount();
int count = roleRDao.listCount();
pager = PagerHelper.getPager(pager, count);
return new ListPager(sysRoleRDao.listPager(pager), pager);
return new ListPager(roleRDao.listPager(pager), pager);
} else {
//生成hql查询语句
String hqlPack = CoreHqlPack.packHqlSysRole(role);
pager = PagerHelper.getPager(pager, sysRoleRDao.findByHqlWhereCount(hqlPack));
return new ListPager(sysRoleRDao.findByHqlWherePage(hqlPack + role.orderBy(), pager), pager);
pager = PagerHelper.getPager(pager, roleRDao.findByHqlWhereCount(hqlPack));
return new ListPager(roleRDao.findByHqlWherePage(hqlPack + role.orderBy(), pager), pager);
}
}
}

Loading…
Cancel
Save