20 changed files with 61 additions and 1023 deletions
@ -1,218 +0,0 @@ |
|||
package com.yxt.portal.apiadmin; |
|||
|
|||
import cn.hutool.core.bean.BeanUtil; |
|||
import com.yxt.portal.biz.sysfunction.*; |
|||
import com.yxt.portal.biz.syssource.SysSource; |
|||
import com.yxt.portal.biz.syssource.SysSourceVo; |
|||
//import com.yxt.user.biz.syssourcefunction.SysSourceFunction;
|
|||
import com.yxt.portal.biz.syssource.SysSourceService; |
|||
//import com.yxt.user.biz.syssourcefunction.SysSourceFunctionService;
|
|||
import com.yxt.common.base.utils.StringUtils; |
|||
import com.yxt.common.core.query.PagerQuery; |
|||
import com.yxt.common.core.result.ResultBean; |
|||
import com.yxt.common.core.vo.PagerVo; |
|||
import io.swagger.annotations.Api; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* Project: anrui_portal(门户建设) <br/> |
|||
* File: SysFunctionFeignFallback.java <br/> |
|||
* Class: com.yxt.user.biz.sysfunction.SysFunctionRest <br/> |
|||
* Description: 功能. <br/> |
|||
* Copyright: Copyright (c) 2011 <br/> |
|||
* Company: https://gitee.com/liuzp315 <br/>
|
|||
* Makedate: 2021-08-03 00:24:28 <br/> |
|||
* |
|||
* @author liupopo |
|||
* @version 1.0 |
|||
* @since 1.0 |
|||
*/ |
|||
@Api(tags = "功能") |
|||
@RestController |
|||
@RequestMapping("apiadmin/sysfunction") |
|||
public class SysFunctionRest { |
|||
|
|||
@Autowired |
|||
private SysFunctionService sysFunctionService; |
|||
@Autowired |
|||
private SysSourceService sysSourceService; |
|||
// @Autowired
|
|||
// private SysSourceFunctionService sysSourceFunctionService;
|
|||
|
|||
|
|||
public ResultBean<PagerVo<SysFunctionVo>> listPage(@RequestBody PagerQuery<SysFunctionQuery> pq) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
PagerVo<SysFunctionVo> pv = sysFunctionService.listPageVo(pq); |
|||
return rb.success().setData(pv); |
|||
} |
|||
|
|||
|
|||
public ResultBean<List<SysFunctionVo>> listAll(@RequestBody SysFunctionQuery query) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
List<SysFunctionVo> list = sysFunctionService.listAllVo(query); |
|||
return rb.success().setData(list); |
|||
} |
|||
|
|||
|
|||
public ResultBean<List<SysFunctionVo>> listAllByRoleSid(SysFunctionQuery query) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
List<SysFunctionVo> list = sysFunctionService.listAllByRoleSid(query); |
|||
return rb.success().setData(list); |
|||
} |
|||
|
|||
|
|||
public ResultBean<List<SysFunctionTreeVo>> listAllVoForSource(@RequestBody SysFunctionQuery query) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
List<SysFunctionTreeVo> list = sysFunctionService.listAllVoForSource(query); |
|||
return rb.success().setData(list); |
|||
} |
|||
|
|||
|
|||
public ResultBean<List<SysFunctionVo>> list() { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
List<SysFunctionVo> list = sysFunctionService.listVo(); |
|||
return rb.success().setData(list); |
|||
} |
|||
|
|||
|
|||
public ResultBean save(SysFunctionDto dto) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
String sourceSid = dto.getSourceSid(); |
|||
if (StringUtils.isBlank(sourceSid)) { |
|||
return ResultBean.fireFail().setMessage("资源不能为空"); |
|||
} else { |
|||
SysSourceVo sysSourceVo = sysSourceService.fetchBySidVo(sourceSid); |
|||
if (sysSourceVo.getSid() == null) { |
|||
return ResultBean.fireFail().setMessage("资源不存在"); |
|||
} |
|||
} |
|||
String pSid = dto.getParentSid(); |
|||
if (StringUtils.isBlank(pSid)) { |
|||
return ResultBean.fireFail().setMessage("菜单父级sid不能为空"); |
|||
} else { |
|||
if (!"0".equals(pSid)) { |
|||
SysFunction sysFunction = sysFunctionService.fetchBySid(pSid); |
|||
if (StringUtils.isBlank(sysFunction.getSid())) { |
|||
return ResultBean.fireFail().setMessage("菜单父级不存在!"); |
|||
} |
|||
} |
|||
} |
|||
sysFunctionService.saveOrUpdateDto(dto); |
|||
return rb.success(); |
|||
} |
|||
|
|||
|
|||
public ResultBean update(SysFunctionDto dto, String sid) { |
|||
SysFunction sysFunction = sysFunctionService.fetchBySid(sid); |
|||
if (sysFunction.getSid() == null) { |
|||
return ResultBean.fireFail().setMessage("功能不存在!"); |
|||
} |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
sysFunctionService.updateBySid(dto.toMap(), sid); |
|||
// SysSourceFunction sysSourceFunction1 = sysSourceFunctionService.fetchByFunctionSid(sid);
|
|||
// sysSourceFunctionService.delByFunctionSid(sid);
|
|||
// SysSourceFunction sysSourceFunction = new SysSourceFunction();
|
|||
// sysSourceFunction.setFunctionRootSid(sysSourceFunction1.getFunctionRootSid());
|
|||
// sysSourceFunction.setFunctionSid(sid);
|
|||
// sysSourceFunction.setSourceSid(dto.getSourceSid());
|
|||
// sysSourceFunctionService.insert(sysSourceFunction);
|
|||
return rb.success(); |
|||
} |
|||
|
|||
|
|||
public ResultBean updateIsEnable(String sid, Integer isEnable) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
SysFunction sysFunction = sysFunctionService.fetchBySid(sid); |
|||
if (sysFunction == null) { |
|||
//查询资源是否存在
|
|||
SysSource sysSource = sysSourceService.fetchBySid(sid); |
|||
if (sysSource == null) { |
|||
return ResultBean.fireFail().setMessage("功能不存在!"); |
|||
} else { |
|||
//将该资源下的所有功能关闭
|
|||
// List<String> sids = sysSourceFunctionService.selectBySourceSid(sid);
|
|||
// if (sids.size() != 0) {
|
|||
// sysFunctionService.updateBySourceSid(isEnable, sids);
|
|||
// }
|
|||
|
|||
} |
|||
} else { |
|||
sysFunction.setIsEnable(isEnable); |
|||
sysFunctionService.updateById(sysFunction); |
|||
} |
|||
|
|||
return rb.success(); |
|||
} |
|||
|
|||
|
|||
public ResultBean del(String ids) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
sysFunctionService.delByIds(ids); |
|||
return rb.success(); |
|||
} |
|||
|
|||
|
|||
public ResultBean delBySids(String sids) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
String[] sidsArr = sids.split(","); |
|||
// for (String functionSid : sidsArr) {
|
|||
// sysSourceFunctionService.delByFunctionSid(functionSid);
|
|||
// }
|
|||
sysFunctionService.delBySids(sidsArr); |
|||
return rb.success(); |
|||
} |
|||
|
|||
|
|||
public ResultBean<SysFunctionVo> fetch(String id) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
SysFunctionVo vo = sysFunctionService.fetchByIdVo(id); |
|||
return rb.success().setData(vo); |
|||
} |
|||
|
|||
|
|||
public ResultBean<SysFunctionVo> fetchBySid(String sid) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
SysFunction entity = sysFunctionService.fetchBySid(sid); |
|||
SysFunctionVo vo = new SysFunctionVo(); |
|||
BeanUtil.copyProperties(entity, vo); |
|||
// SysSourceFunction sysSourceFunction = sysSourceFunctionService.fetchByFunctionSid(sid);
|
|||
// vo.setSourceSid(sysSourceFunction.getSourceSid());
|
|||
if ("0".equals(entity.getParentSid())) { |
|||
vo.setParentSid("0"); |
|||
vo.setParentName("顶级功能"); |
|||
} else { |
|||
SysFunction sysFunction = sysFunctionService.fetchBySid(entity.getParentSid()); |
|||
vo.setParentSid(sysFunction.getSid()); |
|||
vo.setParentName(sysFunction.getName()); |
|||
} |
|||
return rb.success().setData(vo); |
|||
} |
|||
|
|||
|
|||
public ResultBean<List<Map<String,Object>>> getFunctionAuthorization(String roleSid) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
List<Map<String,Object>> list=sysFunctionService.getFunctionAuthorization(roleSid); |
|||
return rb.success().setData(list); |
|||
} |
|||
|
|||
|
|||
public ResultBean<List<Map<String, Object>>> getFunctionAuthorizationApp(String roleSid) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
List<Map<String,Object>> list=sysFunctionService.getFunctionAuthorizationApp(roleSid); |
|||
return rb.success().setData(list); |
|||
} |
|||
|
|||
|
|||
public ResultBean<List<ButtonPermissionVo>> getButtonPermissions(ButtonPermissionQuery query) { |
|||
ResultBean<List<ButtonPermissionVo>> rb = ResultBean.fireFail(); |
|||
return rb.success().setData(sysFunctionService.getButtonPermissions(query)); |
|||
} |
|||
//getFunctionAuthorization(){
|
|||
// }
|
|||
} |
@ -1,54 +0,0 @@ |
|||
package com.yxt.portal.biz.sysfunction; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.fasterxml.jackson.annotation.JsonProperty; |
|||
import com.yxt.common.core.domain.BaseEntity; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* Project: anrui_portal(门户建设) <br/> |
|||
* File: SysFunction.java <br/> |
|||
* Class: com.yxt.anrui.portal.api.sysfunction.SysFunction <br/> |
|||
* Description: 功能. <br/> |
|||
* Copyright: Copyright (c) 2011 <br/> |
|||
* Company: https://gitee.com/liuzp315 <br/>
|
|||
* Makedate: 2021-08-03 00:24:28 <br/> |
|||
* |
|||
* @author liupopo |
|||
* @version 1.0 |
|||
* @since 1.0 |
|||
*/ |
|||
@ApiModel(value = "功能", description = "功能") |
|||
@TableName("sys_function") |
|||
@Data |
|||
public class SysFunction extends BaseEntity { |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
|
|||
@ApiModelProperty("功能名称") |
|||
private String name; |
|||
|
|||
@ApiModelProperty("层级") |
|||
private Integer level; |
|||
|
|||
@ApiModelProperty("父级sid") |
|||
private String parentSid; |
|||
|
|||
@ApiModelProperty("接口地址") |
|||
private String actionUrl; |
|||
|
|||
@ApiModelProperty("模块名称") |
|||
private String controllerName; |
|||
|
|||
@ApiModelProperty("移动端按钮id") |
|||
private String funId; |
|||
|
|||
@ApiModelProperty("前端控制按钮的id") |
|||
@JsonProperty("cId") |
|||
private String cId; |
|||
|
|||
@ApiModelProperty("是否手机端权限0否,1是") |
|||
private String phoneFunction; |
|||
} |
@ -1,54 +0,0 @@ |
|||
package com.yxt.portal.biz.sysfunction; |
|||
|
|||
|
|||
import com.fasterxml.jackson.annotation.JsonProperty; |
|||
import com.yxt.common.core.dto.Dto; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* Project: anrui_portal(门户建设) <br/> |
|||
* File: SysFunctionDto.java <br/> |
|||
* Class: com.yxt.anrui.portal.api.sysfunction.SysFunctionDto <br/> |
|||
* Description: 功能 数据传输对象. <br/> |
|||
* Copyright: Copyright (c) 2011 <br/> |
|||
* Company: https://gitee.com/liuzp315 <br/>
|
|||
* Makedate: 2021-08-03 00:24:28 <br/> |
|||
* |
|||
* @author liupopo |
|||
* @version 1.0 |
|||
* @since 1.0 |
|||
*/ |
|||
@ApiModel(value = "功能 数据传输对象", description = "功能 数据传输对象") |
|||
@Data |
|||
public class SysFunctionDto implements Dto { |
|||
|
|||
|
|||
@ApiModelProperty("功能名称") |
|||
private String name; |
|||
|
|||
@ApiModelProperty("层级") |
|||
private Integer level; |
|||
|
|||
@ApiModelProperty("父级sid") |
|||
private String parentSid; |
|||
|
|||
@ApiModelProperty("接口地址") |
|||
private String actionUrl; |
|||
|
|||
@ApiModelProperty("模块名称") |
|||
private String controllerName; |
|||
@ApiModelProperty("模块sid") |
|||
private String sourceSid; |
|||
|
|||
@ApiModelProperty("移动端按钮id") |
|||
private String funId; |
|||
@ApiModelProperty("前端控制按钮的id") |
|||
@JsonProperty("cId") |
|||
private String cId; |
|||
@ApiModelProperty("是否手机端权限0否,1是") |
|||
private String phoneFunction; |
|||
@ApiModelProperty("备注") |
|||
private String remarks ; |
|||
} |
@ -1,74 +0,0 @@ |
|||
package com.yxt.portal.biz.sysfunction; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.core.toolkit.Constants; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.apache.ibatis.annotations.Select; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* Project: anrui_portal(门户建设) <br/> |
|||
* File: SysFunctionMapper.java <br/> |
|||
* Class: com.yxt.anrui.portal.biz.sysfunction.SysFunctionMapper <br/> |
|||
* Description: 功能. <br/> |
|||
* Copyright: Copyright (c) 2011 <br/> |
|||
* Company: https://gitee.com/liuzp315 <br/>
|
|||
* Makedate: 2021-08-03 00:24:28 <br/> |
|||
* |
|||
* @author liupopo |
|||
* @version 1.0 |
|||
* @since 1.0 |
|||
*/ |
|||
@Mapper |
|||
public interface SysFunctionMapper extends BaseMapper<SysFunction> { |
|||
|
|||
//@Update("update sys_function set name=#{msg} where id=#{id}")
|
|||
//IPage<SysFunctionVo> voPage(IPage<SysFunction> page, @Param(Constants.WRAPPER) QueryWrapper<SysFunction> qw);
|
|||
|
|||
IPage<SysFunctionVo> selectPageVo(IPage<SysFunction> page, @Param(Constants.WRAPPER) Wrapper<SysFunction> qw); |
|||
|
|||
List<SysFunctionVo> selectListAllVo(@Param(Constants.WRAPPER) Wrapper<SysFunction> qw); |
|||
|
|||
@Select("select * from sys_function") |
|||
List<SysFunctionVo> selectListVo(); |
|||
|
|||
List<SysFunctionVo> listAllParentByRoleSid(String roleSid, String sid); |
|||
|
|||
List<SysFunctionTreeVo> getChildrensForFunctionTree(@Param(Constants.WRAPPER) QueryWrapper<SysFunctionTreeVo> qw); |
|||
|
|||
List<SysFunctionTreeVo> selectChildernList(String sid); |
|||
|
|||
int updateBySourceSid(@Param("isEnable") Integer isEnable, @Param("list") List<String> list); |
|||
|
|||
/** |
|||
* 该资源下的功能是否可用 状态为1的功能 |
|||
* |
|||
* @param isEnable 是否可用,1可用,0不可用 |
|||
* @param sourceSid 资源sid |
|||
* @return |
|||
*/ |
|||
int selectBySourceSid(@Param("isEnable") int isEnable, @Param("sourceSid") String sourceSid); |
|||
|
|||
List<ButtonPermissionVo> getButtonPermissions(@Param("query") ButtonPermissionQuery query); |
|||
|
|||
List<Map<String, Object>> getSourceAuthorization(@Param("roleSid") String roleSid); |
|||
|
|||
@Select("SELECT sm.name,sm.sid,sm.pageUrl FROM sys_menu sm LEFT JOIN sys_source_menu ssm ON sm.sid=ssm.menuSid where ssm.sourceSid=#{sourceSid}") |
|||
List<Map<String, Object>> getMenuAuthorization(@Param("sourceSid") String sourceSid); |
|||
|
|||
@Select("SELECT sf.name,sf.sid FROM sys_function sf WHERE sf.actionUrl= #{pageUrl}") |
|||
List<Map<String, Object>> getFunctionAuthorization(@Param("pageUrl") String pageUrl); |
|||
|
|||
@Select("SELECT sf.name,sf.sid,IF(IFNULL(srf.id,0)<=0,1,0) checked FROM sys_function sf " + |
|||
" LEFT JOIN sys_role_function srf ON srf.functionSid=sf.sid " + |
|||
" WHERE sf.actionUrl= #{pageUrl} AND srf.roleSid = #{roleSid} ") |
|||
List<Map<String, Object>> getFunctionByRoleSid(@Param("pageUrl") String pageUrl, @Param("roleSid") String roleSid); |
|||
|
|||
List<Map<String, Object>> getSourceAuthorizationApp(@Param("roleSid") String roleSid); |
|||
} |
@ -1,103 +0,0 @@ |
|||
<?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="com.yxt.portal.biz.sysfunction.SysFunctionMapper"> |
|||
<!-- <where> ${ew.sqlSegment} </where>--> |
|||
<!-- ${ew.customSqlSegment} --> |
|||
<select id="selectPageVo" resultType="com.yxt.portal.biz.sysfunction.SysFunctionVo"> |
|||
SELECT * |
|||
FROM sys_function |
|||
<where> |
|||
${ew.sqlSegment} |
|||
</where> |
|||
</select> |
|||
|
|||
<select id="selectListAllVo" resultType="com.yxt.portal.biz.sysfunction.SysFunctionVo"> |
|||
SELECT func.*, source.sourceName as sourceName |
|||
FROM sys_function func |
|||
left join sys_source_function sourceF on sourceF.functionSid = func.sid |
|||
left join sys_source source on source.sid = sourceF.sourceSid |
|||
<where> |
|||
${ew.sqlSegment} |
|||
</where> |
|||
</select> |
|||
<select id="listAllParentByRoleSid" resultType="com.yxt.portal.biz.sysfunction.SysFunctionVo"> |
|||
SELECT DISTINCT func.*, ISNULL(roleFunction.sid) AS checked |
|||
FROM sys_function func |
|||
left join sys_role_function roleFunction |
|||
on func.sid = roleFunction.functionSid and roleFunction.roleSid = #{param1} |
|||
where func.parentSid = #{param2} |
|||
</select> |
|||
<select id="getChildrensForFunctionTree" resultType="com.yxt.portal.biz.sysfunction.SysFunctionTreeVo"> |
|||
SELECT func.*, source.sourceName, sourceFunction.functionRootSid as functionRootSid |
|||
FROM sys_function func |
|||
left join sys_source_function sourceFunction on sourceFunction.functionSid = func.sid |
|||
left join sys_source source on source.sid = sourceFunction.sourceSid |
|||
<where> |
|||
${ew.sqlSegment} |
|||
</where> |
|||
</select> |
|||
|
|||
<select id="selectChildernList" resultType="com.yxt.portal.biz.sysfunction.SysFunctionTreeVo"> |
|||
SELECT func.*, source.sourceName, sourceFunction.functionRootSid as functionRootSid |
|||
FROM sys_function func |
|||
left join sys_source_function sourceFunction on sourceFunction.functionSid = func.sid |
|||
left join sys_source source on source.sid = sourceFunction.sourceSid |
|||
where func.parentSid = #{sid} |
|||
</select> |
|||
|
|||
<update id="updateBySourceSid"> |
|||
UPDATE sys_function |
|||
SET isEnable = #{isEnable} WHERE sid IN |
|||
<foreach collection="list" index="index" item="item" open="(" separator="," close=")"> |
|||
#{item} |
|||
</foreach> |
|||
</update> |
|||
|
|||
<select id="selectBySourceSid" resultType="int"> |
|||
select count(*) |
|||
from sys_function sf |
|||
left join sys_source_function ssf on sf.sid = ssf.functionSid |
|||
where sf.isEnable = #{isEnable} |
|||
and ssf.sourceSid = #{sourceSid} |
|||
</select> |
|||
<select id="getButtonPermissions" resultType="com.yxt.portal.biz.sysfunction.ButtonPermissionVo"> |
|||
SELECT sf.cId AS buttonId |
|||
FROM sys_function sf |
|||
WHERE actionUrl = #{query.url} |
|||
AND phoneFunction = #{query.type} |
|||
AND sid NOT IN |
|||
(SELECT IFNULL(srf.functionSid, "") functionSid |
|||
FROM sys_user_role sur |
|||
LEFT JOIN sys_role_function srf |
|||
ON sur.roleSid = srf.rolesid |
|||
WHERE sur.userSid = #{query.userSid}) |
|||
</select> |
|||
|
|||
<select id="getSourceAuthorization" resultType="java.util.Map"> |
|||
SELECT DISTINCT ss.sourceName, |
|||
ss.sid |
|||
FROM sys_source ss |
|||
LEFT JOIN sys_source_role ssr |
|||
ON ss.sid = ssr.sorceSid |
|||
LEFT JOIN sys_source_function ssf |
|||
ON ssr.`sorceSid` = ssf.`sourceSid` |
|||
LEFT JOIN sys_function sf |
|||
ON ssf.`functionSid` = sf.sid |
|||
WHERE ssr.rolesid = #{roleSid} |
|||
AND sf.phoneFunction = '0' |
|||
</select> |
|||
|
|||
<select id="getSourceAuthorizationApp" resultType="java.util.Map"> |
|||
SELECT DISTINCT ss.sourceName, |
|||
ss.sid |
|||
FROM sys_source ss |
|||
LEFT JOIN sys_source_role ssr |
|||
ON ss.sid = ssr.sorceSid |
|||
LEFT JOIN sys_source_function ssf |
|||
ON ssr.`sorceSid` = ssf.`sourceSid` |
|||
LEFT JOIN sys_function sf |
|||
ON ssf.`functionSid` = sf.sid |
|||
WHERE ssr.rolesid = #{roleSid} |
|||
AND sf.phoneFunction = '1' |
|||
</select> |
|||
</mapper> |
@ -1,53 +0,0 @@ |
|||
package com.yxt.portal.biz.sysfunction; |
|||
|
|||
|
|||
import com.fasterxml.jackson.annotation.JsonProperty; |
|||
import com.yxt.common.core.query.Query; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* Project: anrui_portal(门户建设) <br/> |
|||
* File: SysFunctionQuery.java <br/> |
|||
* Class: com.yxt.anrui.portal.api.sysfunction.SysFunctionQuery <br/> |
|||
* Description: 功能 查询条件. <br/> |
|||
* Copyright: Copyright (c) 2011 <br/> |
|||
* Company: https://gitee.com/liuzp315 <br/>
|
|||
* Makedate: 2021-08-03 00:24:28 <br/> |
|||
* |
|||
* @author liupopo |
|||
* @version 1.0 |
|||
* @since 1.0 |
|||
*/ |
|||
@ApiModel(value = "功能 查询条件", description = "功能 查询条件") |
|||
@Data |
|||
public class SysFunctionQuery implements Query { |
|||
|
|||
|
|||
@ApiModelProperty("功能名称") |
|||
private String name; |
|||
|
|||
@ApiModelProperty("层级") |
|||
private Integer level; |
|||
|
|||
@ApiModelProperty("父级sid") |
|||
private String parentSid; |
|||
@ApiModelProperty("角色sid") |
|||
private String roleSid; |
|||
|
|||
@ApiModelProperty("接口地址") |
|||
private String actionUrl; |
|||
|
|||
@ApiModelProperty("模块名称") |
|||
private String controllerName; |
|||
|
|||
@ApiModelProperty("移动端按钮id") |
|||
private String funId; |
|||
@ApiModelProperty("前端控制按钮的id") |
|||
@JsonProperty("cId") |
|||
private String cId; |
|||
|
|||
@ApiModelProperty("是否手机端权限0否,1是") |
|||
private String phoneFunction; |
|||
} |
@ -1,344 +0,0 @@ |
|||
package com.yxt.portal.biz.sysfunction; |
|||
|
|||
import cn.hutool.core.bean.BeanUtil; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.yxt.portal.biz.syssource.SysSourceService; |
|||
import com.yxt.common.base.service.MybatisBaseService; |
|||
import com.yxt.common.base.utils.PagerUtil; |
|||
import com.yxt.common.core.query.PagerQuery; |
|||
import com.yxt.common.core.vo.PagerVo; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* Project: anrui_portal(门户建设) <br/> |
|||
* File: SysFunctionService.java <br/> |
|||
* Class: com.yxt.user.biz.sysfunction.SysFunctionService <br/> |
|||
* Description: 功能 业务逻辑. <br/> |
|||
* Copyright: Copyright (c) 2011 <br/> |
|||
* Company: https://gitee.com/liuzp315 <br/>
|
|||
* Makedate: 2021-08-03 00:24:28 <br/> |
|||
* |
|||
* @author liupopo |
|||
* @version 1.0 |
|||
* @since 1.0 |
|||
*/ |
|||
@Service |
|||
public class SysFunctionService extends MybatisBaseService<SysFunctionMapper, SysFunction> { |
|||
@Autowired |
|||
private SysSourceService sysSourceService; |
|||
// @Autowired
|
|||
// private SysSourceFunctionService sysSourceFunctionService;
|
|||
|
|||
public PagerVo<SysFunction> listPage(PagerQuery<SysFunctionQuery> pq) { |
|||
SysFunctionQuery query = pq.getParams(); |
|||
QueryWrapper<SysFunction> qw = createQueryWrapper(query); |
|||
IPage<SysFunction> page = PagerUtil.queryToPage(pq); |
|||
IPage<SysFunction> pagging = baseMapper.selectPage(page, qw); |
|||
PagerVo<SysFunction> p = PagerUtil.pageToVo(pagging, null); |
|||
return p; |
|||
} |
|||
|
|||
public List<SysFunction> listAll(SysFunctionQuery query) { |
|||
QueryWrapper<SysFunction> qw = createQueryWrapper(query); |
|||
return baseMapper.selectList(qw); |
|||
} |
|||
|
|||
private QueryWrapper<SysFunction> createQueryWrapper(SysFunctionQuery query) { |
|||
// todo: 这里根据具体业务调整查询条件
|
|||
// 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
|||
QueryWrapper<SysFunction> qw = new QueryWrapper<>(); |
|||
|
|||
|
|||
if (StringUtils.isNotBlank(query.getName())) { |
|||
qw.eq("name", query.getName()); |
|||
} |
|||
|
|||
if (query.getLevel() != null) { |
|||
qw.eq("level", query.getLevel()); |
|||
} |
|||
|
|||
if (StringUtils.isNotBlank(query.getParentSid())) { |
|||
qw.eq("parentSid", query.getParentSid()); |
|||
} |
|||
|
|||
if (StringUtils.isNotBlank(query.getActionUrl())) { |
|||
qw.eq("actionUrl", query.getActionUrl()); |
|||
} |
|||
|
|||
if (StringUtils.isNotBlank(query.getControllerName())) { |
|||
qw.eq("controllerName", query.getControllerName()); |
|||
} |
|||
|
|||
if (StringUtils.isNotBlank(query.getFunId())) { |
|||
qw.eq("funId", query.getFunId()); |
|||
} |
|||
|
|||
if (query.getPhoneFunction() != null) { |
|||
qw.eq("phoneFunction", query.getPhoneFunction()); |
|||
} |
|||
return qw; |
|||
} |
|||
|
|||
public PagerVo<SysFunctionVo> listPageVo(PagerQuery<SysFunctionQuery> pq) { |
|||
SysFunctionQuery query = pq.getParams(); |
|||
QueryWrapper<SysFunction> qw = createQueryWrapper(query); |
|||
IPage<SysFunction> page = PagerUtil.queryToPage(pq); |
|||
IPage<SysFunctionVo> pagging = baseMapper.selectPageVo(page, qw); |
|||
PagerVo<SysFunctionVo> p = PagerUtil.pageToVo(pagging, null); |
|||
return p; |
|||
} |
|||
|
|||
public List<SysFunctionVo> listAllVo(SysFunctionQuery query) { |
|||
QueryWrapper<SysFunction> qw = new QueryWrapper<>(); |
|||
qw.eq("func.parentSid", "0"); |
|||
List<SysFunctionVo> sysFunctionVos = baseMapper.selectListAllVo(qw); |
|||
for (SysFunctionVo s : sysFunctionVos) { |
|||
getChildrens(s); |
|||
} |
|||
return sysFunctionVos; |
|||
} |
|||
|
|||
private void getChildrens(SysFunctionVo s) { |
|||
String sid = s.getSid(); |
|||
QueryWrapper<SysFunction> qw = new QueryWrapper<>(); |
|||
if (StringUtils.isNotBlank(sid)) { |
|||
qw.eq("func.parentSid", sid); |
|||
} |
|||
List<SysFunctionVo> sysFunctionVos = baseMapper.selectListAllVo(qw); |
|||
if (!sysFunctionVos.isEmpty()) { |
|||
for (SysFunctionVo sfv : sysFunctionVos) { |
|||
getChildrens(sfv); |
|||
} |
|||
} |
|||
s.setChildren(sysFunctionVos); |
|||
} |
|||
|
|||
public List<SysFunctionVo> listVo() { |
|||
return baseMapper.selectListVo(); |
|||
} |
|||
|
|||
public void saveOrUpdateDto(SysFunctionDto dto) { |
|||
SysFunction entity = new SysFunction(); |
|||
dto.fillEntity(entity); |
|||
// SysSourceFunction sysSourceFunction = new SysSourceFunction();
|
|||
// sysSourceFunction.setFunctionSid(entity.getSid());
|
|||
// sysSourceFunction.setSourceSid(dto.getSourceSid());
|
|||
// setRootSid(entity, sysSourceFunction);
|
|||
// sysSourceFunctionService.save(sysSourceFunction);
|
|||
this.saveOrUpdate(entity); |
|||
} |
|||
|
|||
// private void setRootSid(SysFunction entity, SysSourceFunction sysSourceFunction) {
|
|||
// String pSid = entity.getParentSid();
|
|||
// if ("0".equals(pSid)) {
|
|||
// sysSourceFunction.setFunctionRootSid(entity.getSid());
|
|||
// } else {
|
|||
// SysFunction sysFunction = this.fetchBySid(pSid);
|
|||
// String pSid1 = sysFunction.getParentSid();
|
|||
// if ("0".equals(pSid1)) {
|
|||
// sysSourceFunction.setFunctionRootSid(sysFunction.getSid());
|
|||
// }
|
|||
// setRootSid(sysFunction, sysSourceFunction);
|
|||
// }
|
|||
// }
|
|||
|
|||
public SysFunctionVo fetchByIdVo(String id) { |
|||
SysFunction entity = this.fetchById(id); |
|||
SysFunctionVo vo = new SysFunctionVo(); |
|||
BeanUtil.copyProperties(entity, vo); |
|||
return vo; |
|||
} |
|||
|
|||
public List<SysFunctionVo> listAllByRoleSid(SysFunctionQuery query) { |
|||
List<SysFunctionVo> sysFunctionVos = baseMapper.listAllParentByRoleSid(query.getRoleSid(), "0"); |
|||
for (SysFunctionVo s : sysFunctionVos) { |
|||
getChildrensByRoleSid(s, query.getRoleSid()); |
|||
} |
|||
return sysFunctionVos; |
|||
} |
|||
|
|||
private void getChildrensByRoleSid(SysFunctionVo s, String roleSid) { |
|||
List<SysFunctionVo> sysFunctionVos = baseMapper.listAllParentByRoleSid(roleSid, s.getSid()); |
|||
if (!sysFunctionVos.isEmpty()) { |
|||
for (SysFunctionVo sfv : sysFunctionVos) { |
|||
getChildrensByRoleSid(sfv, roleSid); |
|||
} |
|||
} |
|||
s.setChildren(sysFunctionVos); |
|||
} |
|||
|
|||
public List<SysFunctionTreeVo> listAllVoForSource(SysFunctionQuery query) { |
|||
String name = query.getName(); |
|||
List<SysFunctionTreeVo> sysSourceVos = sysSourceService.listFunctionTreeVo(name); |
|||
for (SysFunctionTreeVo s : sysSourceVos) { |
|||
// List<SysFunctionTreeVo> sysFunctionVoList = sysSourceFunctionService.fetchRootFunctionBySourceSid(s.getSourceSid());
|
|||
// for (SysFunctionTreeVo sysFunctionTreeVo : sysFunctionVoList) {
|
|||
// if (StringUtils.isNotBlank(sysFunctionTreeVo.getRemarks())){
|
|||
// sysFunctionTreeVo.setName(sysFunctionTreeVo.getName() + "(" + sysFunctionTreeVo.getRemarks() + ")");
|
|||
// }
|
|||
// }
|
|||
// s.setChildren(sysFunctionVoList);
|
|||
s.setIsSource("1"); |
|||
//判断该资源下的功能是否有可用的状态
|
|||
int isEnable = 1; |
|||
int count = baseMapper.selectBySourceSid(isEnable, s.getSourceSid()); |
|||
if (count == 0) { |
|||
s.setIsEnable("0"); |
|||
} else { |
|||
s.setIsEnable("1"); |
|||
} |
|||
// if (!sysFunctionVoList.isEmpty()) {
|
|||
//// sysFunctionVoList = getChildrensForFunctionTree(sysFunctionVoList);
|
|||
// getChildList(sysFunctionVoList);
|
|||
// }
|
|||
} |
|||
return sysSourceVos; |
|||
} |
|||
|
|||
public void getChildList(List<SysFunctionTreeVo> list) { |
|||
list.forEach(str -> { |
|||
String sid = str.getSid(); |
|||
List<SysFunctionTreeVo> listChildren = baseMapper.selectChildernList(sid); |
|||
str.setChildren(listChildren); |
|||
getChildList(listChildren); |
|||
}); |
|||
} |
|||
|
|||
private List<SysFunctionTreeVo> getChildrensForFunctionTree(List<SysFunctionTreeVo> sysFunctionVoList) { |
|||
List<SysFunctionTreeVo> list = new ArrayList<>(); |
|||
for (SysFunctionTreeVo s : sysFunctionVoList) { |
|||
SysFunction sysFunction = fetchBySid(s.getFunctionRootSid()); |
|||
SysFunctionTreeVo sysFunctionTreeVo = new SysFunctionTreeVo(); |
|||
BeanUtil.copyProperties(sysFunction, sysFunctionTreeVo); |
|||
/*sysFunctionTreeVo.setParentName("顶级功能");*/ |
|||
list.add(sysFunctionTreeVo); |
|||
} |
|||
for (SysFunctionTreeVo s : list) { |
|||
getChildrensForFunctionTree(s, s.getSid()); |
|||
} |
|||
return list; |
|||
} |
|||
|
|||
private void getChildrensForFunctionTree(SysFunctionTreeVo s, String sid) { |
|||
QueryWrapper<SysFunctionTreeVo> qw = new QueryWrapper<>(); |
|||
if (StringUtils.isNotBlank(sid)) { |
|||
qw.eq("func.parentSid", sid); |
|||
} |
|||
List<SysFunctionTreeVo> sysMenuVos = baseMapper.getChildrensForFunctionTree(qw); |
|||
if (!sysMenuVos.isEmpty()) { |
|||
for (SysFunctionTreeVo smv : sysMenuVos) { |
|||
/*SysFunction sysFunction = fetchBySid(sid); |
|||
smv.setParentName(sysFunction.getName());*/ |
|||
getChildrensForFunctionTree(smv, smv.getSid()); |
|||
} |
|||
} |
|||
s.setChildren(sysMenuVos); |
|||
} |
|||
|
|||
public int updateBySourceSid(Integer isEnable, List<String> sids) { |
|||
return baseMapper.updateBySourceSid(isEnable, sids); |
|||
} |
|||
|
|||
public List<ButtonPermissionVo> getButtonPermissions(ButtonPermissionQuery query) { |
|||
List<ButtonPermissionVo> buttonPermissions = baseMapper.getButtonPermissions(query); |
|||
return buttonPermissions; |
|||
} |
|||
|
|||
public List<Map<String, Object>> getFunctionAuthorization(String roleSid) { |
|||
List<Map<String, Object>> list = new ArrayList<>(); |
|||
List<Map<String, Object>> lsources = baseMapper.getSourceAuthorization(roleSid); |
|||
lsources.forEach(f -> { |
|||
Map<String, Object> map = new HashMap<>(); |
|||
map.put("name", f.get("sourceName").toString()); |
|||
map.put("sid", f.get("sid").toString()); |
|||
map.put("checked", "1"); |
|||
list.add(map); |
|||
}); |
|||
|
|||
list.forEach(f -> { |
|||
List<Map<String, Object>> list2 = new ArrayList<>(); |
|||
String sid = f.get("sid").toString(); |
|||
List<Map<String, Object>> lmenus = baseMapper.getMenuAuthorization(sid); |
|||
lmenus.forEach(ff -> { |
|||
Map<String, Object> map = new HashMap<>(); |
|||
if (ff.get("pageUrl") != null && com.yxt.common.base.utils.StringUtils.isNotBlank(ff.get("pageUrl").toString())) { |
|||
String pageUrl = ff.get("pageUrl").toString(); |
|||
List<Map<String, Object>> lfuncs = baseMapper.getFunctionAuthorization(pageUrl); |
|||
List<Map<String, Object>> functionByRoleSid = baseMapper.getFunctionByRoleSid(pageUrl, roleSid); |
|||
if (lfuncs.size() > 0){ |
|||
map.put("name", ff.get("name")); |
|||
String sids = ff.get("sid").toString(); |
|||
map.put("sid", sids); |
|||
map.put("checked", "1"); |
|||
map.put("children", new ArrayList<>()); |
|||
for (Map<String, Object> lfunc : lfuncs) { |
|||
for (Map<String, Object> funByRole : functionByRoleSid) { |
|||
if (lfunc.get("sid").equals(funByRole.get("sid"))) { |
|||
lfunc.put("checked", "0"); |
|||
} |
|||
} |
|||
lfunc.put("children", new ArrayList<>()); |
|||
} |
|||
map.put("children", lfuncs); |
|||
list2.add(map); |
|||
} |
|||
} |
|||
}); |
|||
f.put("children", list2); |
|||
}); |
|||
return list; |
|||
} |
|||
|
|||
public List<Map<String, Object>> getFunctionAuthorizationApp(String roleSid) { |
|||
List<Map<String, Object>> list = new ArrayList<>(); |
|||
List<Map<String, Object>> lsources = baseMapper.getSourceAuthorizationApp(roleSid); |
|||
lsources.forEach(f -> { |
|||
Map<String, Object> map = new HashMap<>(); |
|||
map.put("name", f.get("sourceName").toString()); |
|||
map.put("sid", f.get("sid").toString()); |
|||
map.put("checked", "1"); |
|||
list.add(map); |
|||
}); |
|||
|
|||
list.forEach(f -> { |
|||
List<Map<String, Object>> list2 = new ArrayList<>(); |
|||
String sid = f.get("sid").toString(); |
|||
List<Map<String, Object>> lmenus = baseMapper.getMenuAuthorization(sid); |
|||
lmenus.forEach(ff -> { |
|||
Map<String, Object> map = new HashMap<>(); |
|||
if (ff.get("pageUrl") != null && com.yxt.common.base.utils.StringUtils.isNotBlank(ff.get("pageUrl").toString())) { |
|||
String pageUrl = ff.get("pageUrl").toString(); |
|||
List<Map<String, Object>> lfuncs = baseMapper.getFunctionAuthorization(pageUrl); |
|||
List<Map<String, Object>> functionByRoleSid = baseMapper.getFunctionByRoleSid(pageUrl, roleSid); |
|||
if (lfuncs.size() > 0){ |
|||
map.put("name", ff.get("name")); |
|||
String sids = ff.get("sid").toString(); |
|||
map.put("sid", sids); |
|||
map.put("checked", "1"); |
|||
map.put("children", new ArrayList<>()); |
|||
for (Map<String, Object> lfunc : lfuncs) { |
|||
for (Map<String, Object> funByRole : functionByRoleSid) { |
|||
if (lfunc.get("sid").equals(funByRole.get("sid"))) { |
|||
lfunc.put("checked", "0"); |
|||
} |
|||
} |
|||
lfunc.put("children", new ArrayList<>()); |
|||
} |
|||
map.put("children", lfuncs); |
|||
list2.add(map); |
|||
} |
|||
} |
|||
}); |
|||
f.put("children", list2); |
|||
}); |
|||
return list; |
|||
} |
|||
} |
@ -1,50 +0,0 @@ |
|||
package com.yxt.portal.biz.sysfunction; |
|||
|
|||
|
|||
import com.yxt.common.core.vo.Vo; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* Project: anrui_portal(门户建设) <br/> |
|||
* File: SysFunctionTreeVo.java <br/> |
|||
* Description: 功能表 视图数据对象. <br/> |
|||
* Copyright: Copyright (c) 2011 <br/> |
|||
* Company: https://gitee.com/liuzp315 <br/>
|
|||
* Makedate: 2021-08-03 00:24:28 <br/> |
|||
* |
|||
* @author liupopo |
|||
* @version 1.0 |
|||
* @since 1.0 |
|||
*/ |
|||
@ApiModel(value = "功能表 视图数据对象", description = "功能表 视图数据对象") |
|||
@Data |
|||
public class SysFunctionTreeVo implements Vo { |
|||
@ApiModelProperty("功能名称") |
|||
private String name; |
|||
@ApiModelProperty("资源sid") |
|||
private String sourceSid; |
|||
@ApiModelProperty("上级sid") |
|||
private String parentSid; |
|||
@ApiModelProperty("sid") |
|||
private String sid; |
|||
@ApiModelProperty("资源名称") |
|||
private String sourceName; |
|||
@ApiModelProperty("url地址") |
|||
private String actionUrl; |
|||
@ApiModelProperty("功能根路径sid") |
|||
private String functionRootSid; |
|||
@ApiModelProperty("子功能") |
|||
private List<SysFunctionTreeVo> children; |
|||
@ApiModelProperty("是否可用") |
|||
private String isEnable; |
|||
@ApiModelProperty("功能列表用,是否是资源层级1是,0不是") |
|||
private String isSource = "0"; |
|||
@ApiModelProperty("父级名称") |
|||
private String parentName; |
|||
@ApiModelProperty("说明") |
|||
private String remarks; |
|||
} |
@ -1,59 +0,0 @@ |
|||
package com.yxt.portal.biz.sysfunction; |
|||
|
|||
|
|||
import com.fasterxml.jackson.annotation.JsonProperty; |
|||
import com.yxt.common.core.vo.Vo; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* Project: anrui_portal(门户建设) <br/> |
|||
* File: SysFunctionVo.java <br/> |
|||
* Class: com.yxt.anrui.portal.api.sysfunction.SysFunctionVo <br/> |
|||
* Description: 功能 视图数据对象. <br/> |
|||
* Copyright: Copyright (c) 2011 <br/> |
|||
* Company: https://gitee.com/liuzp315 <br/>
|
|||
* Makedate: 2021-08-03 00:24:28 <br/> |
|||
* |
|||
* @author liupopo |
|||
* @version 1.0 |
|||
* @since 1.0 |
|||
*/ |
|||
@ApiModel(value = "功能 视图数据对象", description = "功能 视图数据对象") |
|||
@Data |
|||
public class SysFunctionVo implements Vo { |
|||
@ApiModelProperty("功能名称") |
|||
private String name; |
|||
@ApiModelProperty("父级sid") |
|||
private String parentSid; |
|||
@ApiModelProperty("父级名称") |
|||
private String parentName; |
|||
@ApiModelProperty("接口地址") |
|||
private String actionUrl; |
|||
@ApiModelProperty("模块名称") |
|||
private String controllerName; |
|||
@ApiModelProperty("是否手机端权限0否,1是") |
|||
private String phoneFunction; |
|||
@ApiModelProperty("sid") |
|||
private String sid; |
|||
@ApiModelProperty("子集数据") |
|||
private List<SysFunctionVo> children; |
|||
@ApiModelProperty("是否选中 1未选中,0选中") |
|||
private String checked; |
|||
@ApiModelProperty("资源名称") |
|||
private String sourceName; |
|||
@ApiModelProperty("资源SId") |
|||
private String sourceSid; |
|||
@ApiModelProperty("是否可用") |
|||
private Integer isEnable; |
|||
@ApiModelProperty("移动端按钮id") |
|||
private String funId; |
|||
@ApiModelProperty("前端控制按钮的id") |
|||
@JsonProperty("cId") |
|||
private String cId; |
|||
@ApiModelProperty("说明") |
|||
private String remarks; |
|||
} |
@ -1,4 +1,4 @@ |
|||
package com.yxt.portal.biz.sysfunction; |
|||
package com.yxt.portal.biz.sysmenu; |
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
Loading…
Reference in new issue