Commit dce43812 by 周海峰

no message

parent 56654bbe
......@@ -9,3 +9,12 @@ ALTER TABLE `platform_auth`.`platform_applications`
ALTER TABLE `platform_auth`.`platform_applications`
ADD COLUMN `wechat_url` varchar(255) NULL COMMENT '企业微信入口' AFTER `group_code`;
CREATE TABLE `platform_role_application_app`
(
`id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`roleid` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
`applicationid` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='角色的三方应用app权限';
\ No newline at end of file
package com.metro.auth.platform.controller;
import com.metro.auth.platform.domain.ResultJson;
import com.metro.auth.platform.domain.auth.PlatformApplications;
import com.metro.auth.platform.service.PlatformRoleApplicationAppService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
@RestController
@RequestMapping("/PlatformRoleApplicationAppController")
public class PlatformRoleApplicationAppController {
@Resource
PlatformRoleApplicationAppService platformRoleApplicationAppService;
@GetMapping("/platformapplications/listallApp")
public ResultJson listallApp(){
List<PlatformApplications> list = platformRoleApplicationAppService.getPlatformApplicationsListApp();
return ResultJson.ok(list);
}
@GetMapping("/platformapplications/listbyroleApp/{roleid}")
public ResultJson listbyroleApp(@PathVariable String roleid){
List<PlatformApplications> list = platformRoleApplicationAppService.getPlatformApplicationsListByRoleApp(roleid);
return ResultJson.ok(list);
}
}
package com.metro.auth.platform.domain.auth;
import java.io.Serializable;
public class PlatformRoleApplicationApp implements Serializable {
private String id;
private String roleid;
private String applicationid;
private static final long serialVersionUID = 1L;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getRoleid() {
return roleid;
}
public void setRoleid(String roleid) {
this.roleid = roleid;
}
public String getApplicationid() {
return applicationid;
}
public void setApplicationid(String applicationid) {
this.applicationid = applicationid;
}
}
......@@ -65,6 +65,9 @@ public class PlatformSysRole implements Serializable {
@Transient
private String group;
@Transient
private String groupApp;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table platform_sys_role
......
......@@ -105,9 +105,13 @@ public interface PlatformApplicationsMapper {
List<PlatformApplications> getPlatformApplicationsListByRole(String roleid);
List<PlatformApplications> getPlatformApplicationsListByRoleApp(String roleid);
List<PlatformApplications> selectByExample(String userid );
int deleteByRoleid(String roleid);
int insertRoleApplication(PlatformRoleApplication platformRoleApplication);
}
......@@ -111,9 +111,9 @@
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
<!-- <if test="orderByClause != null">-->
<!-- order by ${orderByClause}-->
<!-- </if>-->
<!-- <if test="orderByClause != null">-->
<!-- order by ${orderByClause}-->
<!-- </if>-->
order by num + 0
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
......@@ -331,6 +331,11 @@
select distinct T.* from platform_applications T left join platform_role_application R on T.id=R.applicationid
where T.qyflag='1' and R.roleid = #{roleid,jdbcType=VARCHAR} order by T.num + 0
</select>
<select id="getPlatformApplicationsListByRoleApp" parameterType="java.lang.String" resultMap="BaseResultMap">
select distinct T.* from platform_applications T left join platform_role_application_app R on T.id=R.applicationid
where T.qyflag='1' and R.roleid = #{roleid,jdbcType=VARCHAR} order by T.num + 0
</select>
<select id="getPlatformApplicationsListByRoleList" resultMap="BaseResultMap">
select distinct T.* from platform_applications T left join platform_role_application R on T.id=R.applicationid
where T.qyflag='1' and R.roleid in
......@@ -348,10 +353,6 @@
</delete>
<insert id="insertRoleApplication" parameterType="com.metro.auth.platform.domain.auth.PlatformRoleApplication">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into platform_role_application (id, roleid, applicationid)
values (#{id,jdbcType=VARCHAR}, #{roleid,jdbcType=VARCHAR}, #{applicationid,jdbcType=VARCHAR})
</insert>
......
package com.metro.auth.platform.mapper;
import com.metro.auth.platform.domain.auth.PlatformRoleApplicationApp;
public interface PlatformRoleApplicationAppMapper {
int deleteByRoleid(String roleid);
int insertRoleApplicationApp(PlatformRoleApplicationApp platformRoleApplicationApp);
}
<?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.metro.auth.platform.mapper.PlatformRoleApplicationAppMapper">
<delete id="deleteByRoleid" parameterType="java.lang.String">
delete from platform_role_application_app where roleid = #{roleid,jdbcType=VARCHAR}
</delete>
<insert id="insertRoleApplicationApp" parameterType="com.metro.auth.platform.domain.auth.PlatformRoleApplicationApp">
insert into platform_role_application_app (id, roleid, applicationid)
values (#{id,jdbcType=VARCHAR}, #{roleid,jdbcType=VARCHAR}, #{applicationid,jdbcType=VARCHAR})
</insert>
</mapper>
......@@ -154,6 +154,13 @@ public class PlatformApplicationsServiceImpl implements PlatformApplicationsServ
List<PlatformApplications> alllist = platformApplicationsMapper.selectByExample(platformApplicationsExample);
//当前角色可见应用
List<PlatformApplications> rolelist = platformApplicationsMapper.getPlatformApplicationsListByRole(roleid);
// 首先将所有应用的 roleUseStatue 设置为 0(不可见)
alllist.stream().forEach(t -> {
t.setRoleUseStatue(0);
});
// 然后将可见应用的 roleUseStatue 设置为该应用的ID
if (rolelist != null && rolelist.size() > 0) {
for (int i = 0; i < rolelist.size(); i++) {
int finalI = i;
......@@ -163,10 +170,6 @@ public class PlatformApplicationsServiceImpl implements PlatformApplicationsServ
}
});
}
} else {
alllist.stream().forEach(t -> {
t.setRoleUseStatue(0);
});
}
return alllist;
}
......
package com.metro.auth.platform.service;
import com.metro.auth.platform.domain.auth.PlatformApplications;
import com.metro.auth.platform.domain.auth.PlatformRoleApplicationApp;
import java.util.List;
public interface PlatformRoleApplicationAppService {
List<PlatformApplications> getPlatformApplicationsListApp();
List<PlatformApplications> getPlatformApplicationsListByRoleApp(String roleid);
int deleteByRoleid(String roleid);
int insertRoleApplicationApp(PlatformRoleApplicationApp platformRoleApplicationApp);
}
package com.metro.auth.platform.service;
import com.metro.auth.platform.domain.auth.PlatformApplications;
import com.metro.auth.platform.domain.auth.PlatformApplicationsExample;
import com.metro.auth.platform.domain.auth.PlatformRoleApplicationApp;
import com.metro.auth.platform.mapper.PlatformApplicationsMapper;
import com.metro.auth.platform.mapper.PlatformRoleApplicationAppMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class PlatformRoleApplicationAppServiceImpl implements PlatformRoleApplicationAppService {
@Resource
PlatformApplicationsMapper platformApplicationsMapper;
@Resource
PlatformRoleApplicationAppMapper platformRoleApplicationAppMapper;
@Override
public List<PlatformApplications> getPlatformApplicationsListApp() {
return platformApplicationsMapper.getPlatformApplicationsList();
}
@Override
public List<PlatformApplications> getPlatformApplicationsListByRoleApp(String roleid) {
PlatformApplicationsExample platformApplicationsExample = new PlatformApplicationsExample();
//所有应用
List<PlatformApplications> alllist = platformApplicationsMapper.selectByExample(platformApplicationsExample);
// 查询当前角色的 App 应用权限关联
List<PlatformApplications> roleApps = platformApplicationsMapper.getPlatformApplicationsListByRoleApp(roleid);
// 首先将所有应用的 roleUseStatue 设置为 0(不可见)
alllist.stream().forEach(t -> {
t.setRoleUseStatue(0);
});
// 然后将可见应用的 roleUseStatue 设置为该应用的ID
if (roleApps != null && roleApps.size() > 0) {
for (PlatformApplications roleApp : roleApps) {
alllist.stream().forEach(t -> {
if (t.getId().equals(roleApp.getId())) {
t.setRoleUseStatue(t.getId());
}
});
}
}
return alllist;
}
@Override
public int deleteByRoleid(String roleid) {
return platformRoleApplicationAppMapper.deleteByRoleid(roleid);
}
@Override
public int insertRoleApplicationApp(PlatformRoleApplicationApp platformRoleApplicationApp) {
return platformRoleApplicationAppMapper.insertRoleApplicationApp(platformRoleApplicationApp);
}
}
......@@ -28,6 +28,7 @@ import com.metro.auth.platform.domain.dto.RoleFunctionDTO;
import com.metro.auth.platform.mapper.PlatformApplicationsMapper;
import com.metro.auth.platform.mapper.PlatformRoleMenuMapper;
import com.metro.auth.platform.mapper.PlatformSysRoleMapper;
import com.metro.auth.platform.service.PlatformRoleApplicationAppService;
import com.metro.auth.platform.utils.EmptyUtilHelper;
import com.metro.auth.platform.utils.StrUtil;
import org.springframework.stereotype.Service;
......@@ -55,6 +56,9 @@ public class PlatformRoleServiceImpl implements PlatformRoleService{
@Resource
PlatformApplicationsMapper platformApplicationsMapper;
@Resource
PlatformRoleApplicationAppService platformRoleApplicationAppService;
/**
* 功能描述: <br>查询权限列表
* 〈〉
......@@ -103,6 +107,7 @@ public class PlatformRoleServiceImpl implements PlatformRoleService{
if(platformSysRole!=null&& !EmptyUtilHelper.isEmpty(platformSysRole.getId())){
//更新
platformApplicationsMapper.deleteByRoleid(platformSysRole.getId());
platformRoleApplicationAppService.deleteByRoleid(platformSysRole.getId());
PlatformSysRoleExample platformSysRoleExample =new PlatformSysRoleExample();
platformSysRoleExample.createCriteria().andIdEqualTo(platformSysRole.getId());
count =platformSysRoleMapper.updateByExample(platformSysRole,platformSysRoleExample);
......@@ -111,6 +116,8 @@ public class PlatformRoleServiceImpl implements PlatformRoleService{
platformSysRole.setId(StrUtil.makePramykey());
count =platformSysRoleMapper.insert(platformSysRole);
}
// 处理PC端应用权限
if(platformSysRole.getGroup() != null && !platformSysRole.getGroup().isEmpty()) {
String[] appid = platformSysRole.getGroup().split(",");
//不选者可见菜单权限时的处理
if(appid!=null&&appid.length>0){
......@@ -122,12 +129,28 @@ public class PlatformRoleServiceImpl implements PlatformRoleService{
platformApplicationsMapper.insertRoleApplication(platformRoleApplication);
});
}
}
// 处理App端应用权限
if(platformSysRole.getGroupApp() != null && !platformSysRole.getGroupApp().isEmpty()) {
String[] appidApp = platformSysRole.getGroupApp().split(",");
if(appidApp!=null&&appidApp.length>0){
Arrays.stream(appidApp).forEach(t->{
com.metro.auth.platform.domain.auth.PlatformRoleApplicationApp platformRoleApplicationApp =
new com.metro.auth.platform.domain.auth.PlatformRoleApplicationApp();
platformRoleApplicationApp.setId(StrUtil.makePramykey());
platformRoleApplicationApp.setRoleid(platformSysRole.getId());
platformRoleApplicationApp.setApplicationid(t);
platformRoleApplicationAppService.insertRoleApplicationApp(platformRoleApplicationApp);
});
}
}
return count;
}
@Override
public int deleRole(String id) {
platformApplicationsMapper.deleteByRoleid(id);
platformRoleApplicationAppService.deleteByRoleid(id);
int count = platformSysRoleMapper.deleteByPrimaryKey(id);
return count;
}
......@@ -137,6 +160,7 @@ public class PlatformRoleServiceImpl implements PlatformRoleService{
String[] id = ids.split(",");
Arrays.stream(id).forEach(t->{
platformApplicationsMapper.deleteByRoleid(t);
platformRoleApplicationAppService.deleteByRoleid(t);
platformSysRoleMapper.deleteByPrimaryKey(t);
});
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论