diff --git a/gov-access-lb/gov-access-lb-client/pom.xml b/gov-access-lb/gov-access-lb-client/pom.xml new file mode 100644 index 0000000000..1861f2e625 --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/pom.xml @@ -0,0 +1,27 @@ + + + + gov-access-lb + com.epmet + 2.0.0 + + 4.0.0 + + gov-access-lb-client + + + + com.epmet + epmet-commons-tools + 2.0.0 + + + io.swagger + swagger-annotations + 1.5.20 + compile + + + \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/GovLanguageDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/GovLanguageDTO.java new file mode 100644 index 0000000000..ed7f5924db --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/GovLanguageDTO.java @@ -0,0 +1,61 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; + + +/** + * 国际化 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@Data +public class GovLanguageDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 表名 + */ + private String tableName; + + /** + * 表主键 + */ + private String tableId; + + /** + * 字段名 + */ + private String fieldName; + + /** + * 字段值 + */ + private String fieldValue; + + /** + * 语言 + */ + private String language; + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/GovMenuDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/GovMenuDTO.java new file mode 100644 index 0000000000..fb130e9c65 --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/GovMenuDTO.java @@ -0,0 +1,124 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import com.epmet.commons.tools.utils.TreeStringNode; +import com.epmet.dto.result.MenuResourceDTO; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + + +/** + * 菜单管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@Data +public class GovMenuDTO extends TreeStringNode implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * id + */ + private String id; + + /** + * 上级ID,一级菜单为0 + */ + private String pid; + + /** + * 菜单名称 + */ + private String name; + + /** + * 菜单URL + */ + private String url; + + /** + * 类型 0:菜单 1:按钮 + */ + private Integer type; + + /** + * 菜单图标 + */ + private String icon; + + /** + * 权限标识,如:sys:menu:save + */ + private String permissions; + + /** + * 排序 + */ + private Integer sort; + + /** + * 删除标识:0.未删除 1.已删除 + */ + private Integer delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + + /** + * 菜单资源 + */ + private List resourceList; + + /** + * 上级菜单名称 + */ + private String parentName; + + /** + * 是否显示,1:显示 0不显示 + */ + private Integer showFlag; +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/GovResourceDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/GovResourceDTO.java new file mode 100644 index 0000000000..59a9576598 --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/GovResourceDTO.java @@ -0,0 +1,102 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 资源管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@Data +public class GovResourceDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * id + */ + private String id; + + /** + * 资源编码,如菜单ID + */ + private String resourceCode; + + /** + * 资源名称 + */ + private String resourceName; + + /** + * 资源URL + */ + private String resourceUrl; + + /** + * 请求方式(如:GET、POST、PUT、DELETE) + */ + private String resourceMethod; + + /** + * 菜单标识 0:非菜单资源 1:菜单资源 + */ + private Integer menuFlag; + + /** + * 认证等级 0:权限认证 1:登录认证 2:无需认证 + */ + private Integer authLevel; + + /** + * 删除标识:0.未删除 1.已删除 + */ + private Integer delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/GovRoleDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/GovRoleDTO.java new file mode 100644 index 0000000000..efe6643df6 --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/GovRoleDTO.java @@ -0,0 +1,93 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + + +/** + * 角色管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@Data +public class GovRoleDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * id + */ + private String id; + + /** + * 角色名称 + */ + private String name; + + /** + * 备注 + */ + private String remark; + + /** + * 部门ID + */ + private Long deptId; + + /** + * 删除标识:0.未删除 1.已删除 + */ + private Integer delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + + /** + * 菜单ID列表 + */ + private List menuIdList; + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/GovRoleMenuDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/GovRoleMenuDTO.java new file mode 100644 index 0000000000..eacde30cf3 --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/GovRoleMenuDTO.java @@ -0,0 +1,82 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 角色菜单关系 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@Data +public class GovRoleMenuDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * id + */ + private String id; + + /** + * 角色ID + */ + private String roleId; + + /** + * 菜单ID + */ + private String menuId; + + /** + * 删除标识:0.未删除 1.已删除 + */ + private Integer delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/GovRoleUserDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/GovRoleUserDTO.java new file mode 100644 index 0000000000..d3881edeb2 --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/GovRoleUserDTO.java @@ -0,0 +1,82 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 角色用户关系 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@Data +public class GovRoleUserDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * id + */ + private String id; + + /** + * 角色ID + */ + private String roleId; + + /** + * 用户ID + */ + private String userId; + + /** + * 删除标识:0.未删除 1.已删除 + */ + private Integer delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/OperationScopeDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/OperationScopeDTO.java new file mode 100644 index 0000000000..35885d7f8c --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/OperationScopeDTO.java @@ -0,0 +1,86 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 权限范围表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-24 + */ +@Data +public class OperationScopeDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * id + */ + private String id; + + /** + * 范围key + */ + private String scopeKey; + + /** + * 范围名称 + */ + private String scopeName; + + /** + * 范围序号 + */ + private String scopeIndex; + + /** + * 是否删除,0:未删除,1:已删除 + */ + private Integer delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建者id + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新者id + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/RoleOperationDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/RoleOperationDTO.java new file mode 100644 index 0000000000..bda4931386 --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/RoleOperationDTO.java @@ -0,0 +1,82 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 角色能进行那些操作 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Data +public class RoleOperationDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * + */ + private String id; + + /** + * 角色ID + */ + private String roleId; + + /** + * 操作key + */ + private String operationKey; + + /** + * 是否删除,0:未删除,1:已删除 + */ + private Integer delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建者id + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新者id + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/RoleScopeDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/RoleScopeDTO.java new file mode 100644 index 0000000000..17f8866215 --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/RoleScopeDTO.java @@ -0,0 +1,86 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 角色能操作哪些范围 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-24 + */ +@Data +public class RoleScopeDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * + */ + private String id; + + /** + * 角色ID + */ + private String roleId; + + /** + * 操作key + */ + private String operationKey; + + /** + * 范围Key + */ + private String scopeKey; + + /** + * 是否删除,0:未删除,1:已删除 + */ + private Integer delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建者id + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新者id + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/AccessConfigAdd4RoletFormDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/AccessConfigAdd4RoletFormDTO.java new file mode 100644 index 0000000000..85b9e9d68d --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/AccessConfigAdd4RoletFormDTO.java @@ -0,0 +1,17 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.util.List; + +@Data +public class AccessConfigAdd4RoletFormDTO { + @NotBlank(message = "角色Key不能为空") + private String roleKey; + + @NotBlank(message = "操作Key不能为空") + private String operationKey; + + private List scopeKeys; +} diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/AccessConfigOpeDefaultScopesFormDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/AccessConfigOpeDefaultScopesFormDTO.java new file mode 100644 index 0000000000..86dad3a7a3 --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/AccessConfigOpeDefaultScopesFormDTO.java @@ -0,0 +1,26 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * 权限配置-操作默认范围form dto + */ +@Data +public class AccessConfigOpeDefaultScopesFormDTO { + + public interface ListOpeDefaultScopesGroup {} + public interface SaveOpeDefaultScopesGroup {} + + @NotBlank(message = "角色Key不能为空", groups = { ListOpeDefaultScopesGroup.class, SaveOpeDefaultScopesGroup.class }) + private String roleKey; + + @NotBlank(message = "操作Key不能为空", groups = { ListOpeDefaultScopesGroup.class, SaveOpeDefaultScopesGroup.class }) + private String operationKey; + + private List scopeKeys; +} diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/AccessConfigOpesFormDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/AccessConfigOpesFormDTO.java new file mode 100644 index 0000000000..8a84ddf960 --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/AccessConfigOpesFormDTO.java @@ -0,0 +1,16 @@ +package com.epmet.dto.form; + +import com.epmet.dto.result.AccessConfigOpesResultDTO; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.util.List; + +@Data +public class AccessConfigOpesFormDTO { + + @NotBlank(message = "角色ID不能为空") + private String roleId; + private List opes; + +} diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/AccessConfigOptionsFormDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/AccessConfigOptionsFormDTO.java new file mode 100644 index 0000000000..b96e438e0b --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/AccessConfigOptionsFormDTO.java @@ -0,0 +1,16 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +@Data +public class AccessConfigOptionsFormDTO { + + @NotBlank(message = "角色ID不能为空") + private String roleId; + + @NotBlank(message = "操作的Key不能为空") + private String operationKey; + +} diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/AccessConfigRoleDefaultOpesFormDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/AccessConfigRoleDefaultOpesFormDTO.java new file mode 100644 index 0000000000..cb6f196403 --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/AccessConfigRoleDefaultOpesFormDTO.java @@ -0,0 +1,18 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.util.List; + +/** + * 角色默认操作权限列表from DTO + */ +@Data +public class AccessConfigRoleDefaultOpesFormDTO { + + @NotBlank(message = "角色Key不能为空") + private String roleKey; + + private List operationKeys; +} diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/AccessConfigSaveConfigDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/AccessConfigSaveConfigDTO.java new file mode 100644 index 0000000000..6a918b5bb2 --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/AccessConfigSaveConfigDTO.java @@ -0,0 +1,18 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.util.Set; + +@Data +public class AccessConfigSaveConfigDTO { + + @NotBlank(message = "角色ID不能为空") + private String roleId; + @NotBlank(message = "操作Key不能为空") + private String operationKey; + private Set scopeKeys; + private Set settingKeys; + +} diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/AccessSettingFormDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/AccessSettingFormDTO.java new file mode 100644 index 0000000000..ecd5e6b99f --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/AccessSettingFormDTO.java @@ -0,0 +1,12 @@ +package com.epmet.dto.form; + +import lombok.Data; + +/** + * 查询拥有的权限的DTO,非后台配置用 + */ +@Data +public class AccessSettingFormDTO { + private String roleId; + private String operationKey; +} diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/GetSQLFilterFormDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/GetSQLFilterFormDTO.java new file mode 100644 index 0000000000..4901eca2bb --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/GetSQLFilterFormDTO.java @@ -0,0 +1,29 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.util.Set; + +@Data +public class GetSQLFilterFormDTO { + + @NotBlank + private String operationKey; + + @NotBlank + private String userId; + + @NotBlank + private String app; + + @NotBlank + private String client; + + private String tableAlias; + + private Set gridIds; + + private Set departmentIds; + +} diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/HasSpecifiedPermissionFormDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/HasSpecifiedPermissionFormDTO.java new file mode 100644 index 0000000000..4dabc98dd0 --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/HasSpecifiedPermissionFormDTO.java @@ -0,0 +1,22 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +@Data +public class HasSpecifiedPermissionFormDTO { + + @NotBlank + private String operationKey; + + @NotBlank + private String userId; + + @NotBlank + private String app; + + @NotBlank + private String client; + +} diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/InitDefaultOperationsFormDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/InitDefaultOperationsFormDTO.java new file mode 100644 index 0000000000..d7b487ad67 --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/InitDefaultOperationsFormDTO.java @@ -0,0 +1,20 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.util.List; + +@Data +public class InitDefaultOperationsFormDTO { + + private List roles; + + @Data + public static class InitDefaultOpesRoleDTO { + public InitDefaultOpesRoleDTO() { + } + + private String roleId; + private String roleKey; + } +} diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/ListOpePermsFormDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/ListOpePermsFormDTO.java new file mode 100644 index 0000000000..a7b1b2a7df --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/ListOpePermsFormDTO.java @@ -0,0 +1,18 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +@Data +public class ListOpePermsFormDTO { + + @NotBlank(message = "用户ID不能为空") + private String staffId; + @NotBlank(message = "当前单位不能为空") + private String currAgencyId; + + private String currGridId; + + private String currDeptId; +} diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/OperationScopeFormDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/OperationScopeFormDTO.java new file mode 100644 index 0000000000..af992b7d51 --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/OperationScopeFormDTO.java @@ -0,0 +1,18 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +@Data +public class OperationScopeFormDTO { + + public interface ListOperationScopeGroup {} + + @NotBlank(message = "角色ID不能为空", groups = {ListOperationScopeGroup.class}) + private String roleId; + + @NotBlank(message = "操作的key不能为空", groups = {ListOperationScopeGroup.class}) + private String operationKey; + +} diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/StaffPermCacheFormDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/StaffPermCacheFormDTO.java new file mode 100644 index 0000000000..a35af017c9 --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/form/StaffPermCacheFormDTO.java @@ -0,0 +1,59 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.util.Set; + +@Data +public class StaffPermCacheFormDTO { + + /** + * 更新权限缓存分组 + */ + public interface UpdatePermissionCache {} + + /** + * 查询当前权限列表 + */ + public interface GetStaffCurrPermissions {} + + /** + * 工作人员 id + */ + @NotBlank(message = "工作人员ID不能为空", groups = {UpdatePermissionCache.class, GetStaffCurrPermissions.class}) + private String staffId; + + /** + * 登录头信息app + */ + @NotBlank(message = "登录头信息app不能为空", groups = {UpdatePermissionCache.class, GetStaffCurrPermissions.class}) + private String app; + + /** + * 登录头信息client + */ + @NotBlank(message = "登录头信息client不能为空", groups = {UpdatePermissionCache.class, GetStaffCurrPermissions.class}) + private String client; + + /** + * 组织ID路径 + */ + private String orgIdPath; + + /** + * 权限列表 + */ + private Set permissions; + + /** + * 角色列表 + */ + private Set roleIdList; + + /** + * 当前所在网格id + */ + private String gridId; + +} diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/AccessConfigOpeDefaultScopesResultDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/AccessConfigOpeDefaultScopesResultDTO.java new file mode 100644 index 0000000000..53023bd459 --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/AccessConfigOpeDefaultScopesResultDTO.java @@ -0,0 +1,16 @@ +package com.epmet.dto.result; + +import lombok.Data; + +/** + * 权限配置-操作的默认范围result dto + */ +@Data +public class AccessConfigOpeDefaultScopesResultDTO { + private String scopeKey; + private String scopeName; + private String scopeIndex; + private String operationKey; + private String roleKey; + private Boolean assigned; +} diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/AccessConfigOpesResultDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/AccessConfigOpesResultDTO.java new file mode 100644 index 0000000000..bf24f851d2 --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/AccessConfigOpesResultDTO.java @@ -0,0 +1,13 @@ +package com.epmet.dto.result; + +import lombok.Data; + +@Data +public class AccessConfigOpesResultDTO { + + private String operationKey; + private String operationName; + private String brief; + private Boolean assigned; + +} diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/AccessConfigOptionsResultDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/AccessConfigOptionsResultDTO.java new file mode 100644 index 0000000000..4959a3af40 --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/AccessConfigOptionsResultDTO.java @@ -0,0 +1,10 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.util.List; + +@Data +public class AccessConfigOptionsResultDTO { + private List scopeOptions; +} diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/AccessConfigScopeResultDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/AccessConfigScopeResultDTO.java new file mode 100644 index 0000000000..e1eb02e9fb --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/AccessConfigScopeResultDTO.java @@ -0,0 +1,15 @@ +package com.epmet.dto.result; + +import lombok.Data; + +@Data +public class AccessConfigScopeResultDTO { + + private String scopeKey; + private String scopeName; + private String scopeIndex; + private String operationKey; + private String roleId; + private Boolean assigned; + +} diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/AccessSettingResultDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/AccessSettingResultDTO.java new file mode 100644 index 0000000000..d00d440e63 --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/AccessSettingResultDTO.java @@ -0,0 +1,58 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.result; + +import lombok.Data; + +/** + * 权限配置 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-29 + */ +@Data +public class AccessSettingResultDTO { + + private static final long serialVersionUID = 1L; + + /** + * 角色ID + */ + private String roleId; + + /** + * 操作key + */ + private String operationKey; + + /** + * 配置KEY + */ + private String settingKey; + + /** + * 配置值 + */ + private String settingValue; + + /** + * 配置名称 + */ + private String settingName; + +} diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/LoginUserDetailsResultDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/LoginUserDetailsResultDTO.java new file mode 100644 index 0000000000..2a14ada3fd --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/LoginUserDetailsResultDTO.java @@ -0,0 +1,59 @@ +package com.epmet.dto.result; + +import com.epmet.commons.tools.security.dto.GovTokenDto; +import lombok.Data; + +import java.util.List; +import java.util.Set; + +@Data +public class LoginUserDetailsResultDTO { + + /** + * 政府端:gov、居民端:resi、运营端:oper + */ + private String app; + + /** + * PC端:web、微信小程序:wxmp + */ + private String client; + + /** + * 用户ID + */ + private String userId; + + /** + * 角色列表 + */ + //private Set roleIdList; + private List roleList; + + /** + * 部门id列表 + */ + private Set deptIdList; + + /** + * 当前登录的组织id(顶级) + */ + private String agencyId; + + /** + * 组织ID + */ + private String orgIdPath; + + /** + * 网格ID列表 + */ + private Set gridIdList; + + /** + * 当前工作人员进入的客户id + */ + private String customerId; + + +} diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/MenuResourceDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/MenuResourceDTO.java new file mode 100644 index 0000000000..86df7d55ca --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/MenuResourceDTO.java @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.dto.result; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 菜单资源 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Data +@ApiModel(value = "菜单资源") +public class MenuResourceDTO { + @ApiModelProperty(value = "资源URL") + private String resourceUrl; + @ApiModelProperty(value = "请求方式(如:GET、POST、PUT、DELETE)") + private String resourceMethod; + +} diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/OperationScopeDefaultResultDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/OperationScopeDefaultResultDTO.java new file mode 100644 index 0000000000..4c1f593712 --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/OperationScopeDefaultResultDTO.java @@ -0,0 +1,20 @@ +package com.epmet.dto.result; + +import lombok.Data; + +@Data +public class OperationScopeDefaultResultDTO { + + private String roleKey; + + /** + * 操作key + */ + private String operationKey; + + /** + * 范围key + */ + private String scopeKey; + +} diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/RoleOpeScopeResultDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/RoleOpeScopeResultDTO.java new file mode 100644 index 0000000000..d950f7dc85 --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/RoleOpeScopeResultDTO.java @@ -0,0 +1,36 @@ +package com.epmet.dto.result; + +import lombok.Data; + +@Data +public class RoleOpeScopeResultDTO { + + /** + * 角色ID + */ + private String roleId; + + /** + * 操作key + */ + private String operationKey; + + /** + * 范围key + */ + private String scopeKey; + + /** + * 范围名称 + */ + private String scopeName; + + /** + * 范围序号 + */ + private String scopeIndex; + + private String series; + private Integer sort; + +} diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/RoleOperationDefaultResultDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/RoleOperationDefaultResultDTO.java new file mode 100755 index 0000000000..6961dad6ca --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/RoleOperationDefaultResultDTO.java @@ -0,0 +1,60 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.result; + +import java.io.Serializable; +import lombok.Data; + + +/** + * 角色默认的可操作功能列表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-05-21 + */ +@Data +public class RoleOperationDefaultResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * + */ + private String id; + + /** + * 角色KEY + */ + private String roleKey; + + /** + * 操作key + */ + private String operationKey; + + /** + * 操作名称 + */ + private String operationName; + + /** + * 是否已经具有该操作权限 + */ + private Boolean assigned; + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/RoleOperationResultDTO.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/RoleOperationResultDTO.java new file mode 100644 index 0000000000..dc7fc1559e --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/dto/result/RoleOperationResultDTO.java @@ -0,0 +1,87 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 角色能进行那些操作 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Data +public class RoleOperationResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * + */ + private String id; + + /** + * 角色ID + */ + private String roleId; + + /** + * 操作key + */ + private String operationKey; + + /** + * 操作名称 + */ + private String operationName; + + /** + * 是否删除,0:未删除,1:已删除 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建者id + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新者id + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/enums/MenuFlagEnum.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/enums/MenuFlagEnum.java new file mode 100644 index 0000000000..2a880a728a --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/enums/MenuFlagEnum.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.enums; + +/** + * 菜单资源标识 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +public enum MenuFlagEnum { + /** + * 菜单资源 + */ + YES(1), + /** + * 非菜单资源 + */ + NO(0); + + private int value; + + MenuFlagEnum(int value) { + this.value = value; + } + + public int value() { + return this.value; + } +} diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/enums/MenuTypeEnum.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/enums/MenuTypeEnum.java new file mode 100644 index 0000000000..7132fa2ce3 --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/enums/MenuTypeEnum.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.enums; + +/** + * 菜单类型枚举 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +public enum MenuTypeEnum { + /** + * 菜单 + */ + MENU(0), + /** + * 按钮 + */ + BUTTON(1); + + private int value; + + MenuTypeEnum(int value) { + this.value = value; + } + + public int value() { + return this.value; + } +} diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/enums/RegionLeafEnum.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/enums/RegionLeafEnum.java new file mode 100644 index 0000000000..36300e201f --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/enums/RegionLeafEnum.java @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2019 人人开源 All rights reserved. + *

+ * https://www.renren.io + *

+ * 版权所有,侵权必究! + */ + +package com.epmet.enums; + +/** + * 叶子节点枚举 + * + * @author Mark sunlightcs@gmail.com + */ +public enum RegionLeafEnum { + YES(1), + NO(0); + + private int value; + + RegionLeafEnum(int value) { + this.value = value; + } + + public int value() { + return this.value; + } +} diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/enums/RegionLevelEnum.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/enums/RegionLevelEnum.java new file mode 100644 index 0000000000..b29c456897 --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/enums/RegionLevelEnum.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2019 人人开源 All rights reserved. + *

+ * https://www.renren.io + *

+ * 版权所有,侵权必究! + */ + +package com.epmet.enums; + +/** + * 行政区域 级别枚举 + * + * @author Mark sunlightcs@gmail.com + */ +public enum RegionLevelEnum { + ONE(1), + TWO(2), + THREE(3); + + private int value; + + RegionLevelEnum(int value) { + this.value = value; + } + + public int value() { + return this.value; + } +} diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/enums/UserStatusEnum.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/enums/UserStatusEnum.java new file mode 100644 index 0000000000..dbc043f529 --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/enums/UserStatusEnum.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.enums; + +/** + * 用户状态 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +public enum UserStatusEnum { + DISABLE(0), + ENABLED(1); + + private int value; + + UserStatusEnum(int value) { + this.value = value; + } + + public int value() { + return this.value; + } +} diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/feign/GovAccessFeignClient.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/feign/GovAccessFeignClient.java new file mode 100644 index 0000000000..1af72f3d72 --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/feign/GovAccessFeignClient.java @@ -0,0 +1,35 @@ +package com.epmet.feign; + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.InitDefaultOperationsFormDTO; +import com.epmet.dto.form.ListOpePermsFormDTO; +import com.epmet.feign.fallback.GovAccessFeignClientFallBack; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.Set; + +//@FeignClient(name = ServiceConstant.GOV_ACCESS_SERVER, fallback = GovAccessFeignClientFallBack.class, url = "http://localhost:8099") +@FeignClient(name = "lb-server", fallback = GovAccessFeignClientFallBack.class) +public interface GovAccessFeignClient { + + /** + * 批量为角色ID初始化操作权限列表 + * @param formDTO + * @return + */ + @PostMapping("/gov/access/role/initdefaultoperationsforroles") + Result initDefaultOperationsForRoles(@RequestBody InitDefaultOperationsFormDTO formDTO); + + /** + * 列出觉得的功能权限列表 + * @return + */ + @PostMapping("/gov/access/access/listoperationpermissions") + Result> listOperationPermissions(@RequestBody ListOpePermsFormDTO listOpePermsFormDTO); + + @PostMapping("/lb/get-host") + Result getHost(); +} diff --git a/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/feign/fallback/GovAccessFeignClientFallBack.java b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/feign/fallback/GovAccessFeignClientFallBack.java new file mode 100644 index 0000000000..4dab49c910 --- /dev/null +++ b/gov-access-lb/gov-access-lb-client/src/main/java/com/epmet/feign/fallback/GovAccessFeignClientFallBack.java @@ -0,0 +1,35 @@ +package com.epmet.feign.fallback; + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.ModuleUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.InitDefaultOperationsFormDTO; +import com.epmet.dto.form.ListOpePermsFormDTO; +import com.epmet.feign.GovAccessFeignClient; +import org.springframework.stereotype.Component; + +import java.util.Set; + +/** + * @Description + * @Author sun + */ +@Component +public class GovAccessFeignClientFallBack implements GovAccessFeignClient { + + + @Override + public Result initDefaultOperationsForRoles(InitDefaultOperationsFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ACCESS_SERVER, "initDefaultOperationsForRoles", formDTO); + } + + @Override + public Result> listOperationPermissions(ListOpePermsFormDTO listOpePermsFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ACCESS_SERVER, "listOperationPermissions", listOpePermsFormDTO); + } + + @Override + public Result getHost() { + return ModuleUtils.feignConError("lb-server", "getHost", null); + } +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/Dockerfile b/gov-access-lb/gov-access-lb-server/Dockerfile new file mode 100644 index 0000000000..a2e8d5d488 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/Dockerfile @@ -0,0 +1,11 @@ +FROM java:8 + +RUN export LANG="zh_CN.UTF-8" +RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime +RUN echo 'Asia/Shanghai' > /etc/timezone + +COPY ./target/*.jar ./gov-access-lb.jar + +EXPOSE 9999 + +ENTRYPOINT ["sh", "-c", "$RUN_INSTRUCT"] \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/deploy/docker-compose-dev.yml b/gov-access-lb/gov-access-lb-server/deploy/docker-compose-dev.yml new file mode 100644 index 0000000000..58de243d08 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/deploy/docker-compose-dev.yml @@ -0,0 +1,18 @@ +version: "3.7" +services: + gov-access-lb-server: + container_name: gov-access-lb-server-dev + image: 192.168.1.130:10080/epmet-cloud-dev/gov-access-lb-server:version_placeholder + ports: + - "9999:9999" + network_mode: host # 使用现有网络 + volumes: + - "/opt/epmet-cloud-logs/dev:/logs" + environment: + RUN_INSTRUCT: "java -Xms32m -Xmx200m -jar ./gov-access-lb.jar" + restart: "unless-stopped" + deploy: + resources: + limits: + cpus: '0.1' + memory: 250M \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/deploy/docker-compose-prod.yml b/gov-access-lb/gov-access-lb-server/deploy/docker-compose-prod.yml new file mode 100644 index 0000000000..ababaa4a99 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/deploy/docker-compose-prod.yml @@ -0,0 +1,18 @@ +version: "3.7" +services: + gov-access-server: + container_name: gov-access-server-prod + image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/gov-access-server:0.3.39 + ports: + - "8099:8099" + network_mode: host # 使用现有网络 + volumes: + - "/opt/epmet-cloud-logs/prod:/logs" + environment: + RUN_INSTRUCT: "java -Xms256m -Xmx512m -jar ./gov-access.jar" + restart: "unless-stopped" + deploy: + resources: + limits: + cpus: '0.1' + memory: 600M \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/deploy/docker-compose-test.yml b/gov-access-lb/gov-access-lb-server/deploy/docker-compose-test.yml new file mode 100644 index 0000000000..e28e5d30f0 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/deploy/docker-compose-test.yml @@ -0,0 +1,18 @@ +version: "3.7" +services: + gov-access-server: + container_name: gov-access-server-test + image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/gov-access-server:version_placeholder + ports: + - "8099:8099" + network_mode: host # 使用现有网络 + volumes: + - "/opt/epmet-cloud-logs/test:/logs" + environment: + RUN_INSTRUCT: "java -Xms32m -Xmx300m -jar ./gov-access.jar" + restart: "unless-stopped" + deploy: + resources: + limits: + cpus: '0.1' + memory: 400M \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/pom.xml b/gov-access-lb/gov-access-lb-server/pom.xml new file mode 100644 index 0000000000..b5e2005cc3 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/pom.xml @@ -0,0 +1,137 @@ + + + 0.3.41 + + gov-access-lb + com.epmet + 2.0.0 + + 4.0.0 + + gov-access-lb-server + jar + + + + com.epmet + gov-access-client + 2.0.0 + + + com.epmet + gov-org-client + 2.0.0 + compile + + + com.epmet + epmet-user-client + 2.0.0 + compile + + + com.epmet + epmet-commons-tools + 2.0.0 + + + com.epmet + epmet-commons-mybatis + 2.0.0 + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework + spring-context-support + + + org.springframework.boot + spring-boot-starter-actuator + + + de.codecentric + spring-boot-admin-starter-client + ${spring.boot.admin.version} + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + io.github.openfeign + feign-httpclient + 10.3.0 + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + ${project.basedir}/src/main/java + + + true + ${basedir}/src/main/resources + + + + + + + dev + + true + + + 9999 + dev + + + + + + epmet_gov_access_user + EpmEt-db-UsEr + + 0 + 192.168.1.130 + 6379 + 123456 + + true + 192.168.1.130:8848 + 6ceab336-d004-4acf-89c6-e121d06f4988 + + + false + + + + false + + + + + \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/GovAccessLbApplication.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/GovAccessLbApplication.java new file mode 100644 index 0000000000..9a3714756e --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/GovAccessLbApplication.java @@ -0,0 +1,20 @@ +package com.epmet; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.openfeign.EnableFeignClients; + +/** + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@SpringBootApplication +@EnableDiscoveryClient +@EnableFeignClients +//@EnableConfigurationProperties(value = {DatabaseProperties.class}) +public class GovAccessLbApplication { + public static void main(String[] args) { + SpringApplication.run(GovAccessLbApplication.class, args); + } +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/aspect/RequestLogAspect.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/aspect/RequestLogAspect.java new file mode 100644 index 0000000000..49581cf63c --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/aspect/RequestLogAspect.java @@ -0,0 +1,40 @@ +package com.epmet.aspect; + +import com.epmet.commons.tools.aspect.BaseRequestLogAspect; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; + +/** + * 日志/异常处理切面实现,调用父类方法完成日志记录和异常处理。 + */ +@Aspect +@Component +@Order(0) +public class RequestLogAspect extends BaseRequestLogAspect { + + @Override + @Around(value = "execution(* com.epmet.controller.*Controller*.*(..)) ") + public Object proceed(ProceedingJoinPoint point) throws Throwable { + return super.proceed(point, getRequest()); + } + + /** + * 获取Request对象 + * + * @return + */ + private HttpServletRequest getRequest() { + RequestAttributes ra = RequestContextHolder.getRequestAttributes(); + ServletRequestAttributes sra = (ServletRequestAttributes) ra; + return sra.getRequest(); + } + +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/bean/OpeScopeFilterResultBean.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/bean/OpeScopeFilterResultBean.java new file mode 100644 index 0000000000..fbe1b38052 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/bean/OpeScopeFilterResultBean.java @@ -0,0 +1,15 @@ +package com.epmet.bean; + +import lombok.Data; + +import java.util.HashSet; +import java.util.Set; + +@Data +public class OpeScopeFilterResultBean { + + private HashSet orgLevelScopes; + private Set switchScopes; + private boolean allScopes; + +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/config/DatabaseProperties.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/config/DatabaseProperties.java new file mode 100644 index 0000000000..e9282216d8 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/config/DatabaseProperties.java @@ -0,0 +1,15 @@ +//package com.epmet.config; +// +//import lombok.Data; +//import org.springframework.boot.context.properties.ConfigurationProperties; +// +//@ConfigurationProperties(prefix = "spring.datasource.druid") +//@Data +//public class DatabaseProperties { +// +// private String driverClassName; +// private String url; +// private String username; +// private String password; +// +//} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/config/DbMigrationConfig.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/config/DbMigrationConfig.java new file mode 100644 index 0000000000..b9fcdfb160 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/config/DbMigrationConfig.java @@ -0,0 +1,29 @@ +//package com.epmet.config; +// +//import org.flywaydb.core.Flyway; +//import org.springframework.beans.factory.annotation.Autowired; +// +//import javax.annotation.PostConstruct; +// +///** +// * 数据库迁移配置 +// */ +//@Configuration +//public class DbMigrationConfig { +// +// @Autowired +// private DatabaseProperties databaseProperties; +// +// @PostConstruct +// public void migrate() { +// Flyway flyway = Flyway.configure().dataSource( +// databaseProperties.getUrl(), +// databaseProperties.getUsername(), +// databaseProperties.getPassword()) +// .baselineOnMigrate(true) +// .load(); +// +// flyway.migrate(); +// } +// +//} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/config/ModuleConfigImpl.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/config/ModuleConfigImpl.java new file mode 100644 index 0000000000..128f1060ef --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/config/ModuleConfigImpl.java @@ -0,0 +1,26 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + *

+ * https://www.renren.io + *

+ * 版权所有,侵权必究! + */ + +package com.epmet.config; + +import com.epmet.commons.tools.config.ModuleConfig; +import org.springframework.stereotype.Service; + +/** + * 模块配置信息-新闻公告模块 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Service +public class ModuleConfigImpl implements ModuleConfig { + @Override + public String getName() { + return "govaccess"; + } +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/config/PermissionInitializer.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/config/PermissionInitializer.java new file mode 100644 index 0000000000..5196bd2c8c --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/config/PermissionInitializer.java @@ -0,0 +1,69 @@ +package com.epmet.config; + +import com.epmet.commons.tools.enums.RequirePermissionEnum; +import com.epmet.entity.OperationEntity; +import com.epmet.service.OperationService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.util.CollectionUtils; + +import javax.annotation.PostConstruct; +import java.util.*; + +@Configuration +public class PermissionInitializer { + + @Autowired + private OperationService operationService; + + /** + * 初始化操作权限 + */ + @PostConstruct + public void initOpePermissions() { + final Map existsOpesMap = new HashMap<>(); + List allExistsOpeEntities = operationService.listAllOperations(); + allExistsOpeEntities.stream().forEach(ope -> existsOpesMap.put(ope.getOperationKey(), ope)); + + ArrayList operations2Create = new ArrayList<>(); + ArrayList operations2Update = new ArrayList<>(); + + // 1.收集需要添加的 + List permEnums = Arrays.asList(RequirePermissionEnum.values()); + for (RequirePermissionEnum perm : permEnums) { + String key = perm.getKey(); + if (!existsOpesMap.containsKey(key)) { + OperationEntity operationEntity = new OperationEntity(); + operationEntity.setOperationKey(key); + operationEntity.setBrief(perm.getBrief()); + operationEntity.setOperationName(perm.getName()); + operations2Create.add(operationEntity); + } + } + + //2.收集需要修改的 + for (RequirePermissionEnum perm : permEnums) { + String key = perm.getKey(); + String name = perm.getName(); + String brief = perm.getBrief(); + if (existsOpesMap.containsKey(key)) { + OperationEntity ope = existsOpesMap.get(key); + if (!name.equals(ope.getOperationName()) || !brief.equals(ope.getBrief())) { + // name或者brief发生过变化的,需要更新 + ope.setBrief(brief); + ope.setOperationName(name); + operations2Update.add(ope); + } + } + } + + //3.批量添加和修改 + if (!CollectionUtils.isEmpty(operations2Create)) { + operationService.createBatch(operations2Create); + } + + if (!CollectionUtils.isEmpty(operations2Update)) { + operationService.updateBatch(operations2Update); + } + } +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/constant/OperationScopeConstant.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/constant/OperationScopeConstant.java new file mode 100644 index 0000000000..f4aba15fbc --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/constant/OperationScopeConstant.java @@ -0,0 +1,53 @@ +package com.epmet.constant; + +/** + * 操作范围系列常量 + */ +public class OperationScopeConstant { + + /** + * ===================系列=================== + */ + public static final String SERIES_ORG_LEVEL = "org_level"; + public static final String SERIES_SWITCH = "switch"; + public static final String SERIES_ALL = "all"; + + /** + * ===================范围=================== + */ + // 无任何范围限制 + public static final String SCOPE_ALL = "all"; + + // 覆盖机构下的所有范围 + public static final String SCOPE_ORG_ALL = "org_all"; + + //"同级组织的下级" + public static final String SCOPE_ORG_EQUAL_SUB = "org_equal_sub"; + //"同级组织及下级" + public static final String SCOPE_ORG_EQUAL_AND_SUB = "org_equal_and_sub"; + // 同级组织的上级 + public static final String SCOPE_ORG_EQUAL_SUP = "org_equal_sup"; + // 同级组织及上级 + public static final String SCOPE_ORG_EQUAL_AND_SUP = "org_equal_and_sup"; + //"同级组织" + public static final String SCOPE_ORG_EQUAL = "org_equal"; + + //"本组织的下级" + public static final String SCOPE_ORG_CURR_SUB = "org_curr_sub"; + //"本组织及下级" + public static final String SCOPE_ORG_CURR_AND_SUB = "org_curr_and_sub"; + //"本组织" + public static final String SCOPE_ORG_CURR = "org_curr"; + + //"本组织的上级" + public static final String SCOPE_ORG_CURR_SUP = "org_curr_sup"; + //"本组织及上级" + public static final String SCOPE_ORG_CURR_AND_SUP = "org_curr_and_sup"; + + //我创建的 + public static final String SCOPE_I_CREATED = "i_created"; + //网格内 + public static final String SCOPE_IN_GRID = "in_grid"; + // 部门内 + public static final String SCOPE_IN_DEPARTMENT = "in_department"; +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/AccessConfigController.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/AccessConfigController.java new file mode 100644 index 0000000000..76a7886947 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/AccessConfigController.java @@ -0,0 +1,138 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.form.*; +import com.epmet.dto.result.AccessConfigOpeDefaultScopesResultDTO; +import com.epmet.dto.result.AccessConfigOpesResultDTO; +import com.epmet.dto.result.AccessConfigOptionsResultDTO; +import com.epmet.dto.result.RoleOperationDefaultResultDTO; +import com.epmet.service.AccessConfigService; +import oracle.jdbc.proxy.annotation.Post; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.validation.constraints.NotBlank; +import java.util.List; +import java.util.Set; + +@RestController +@RequestMapping("config") +public class AccessConfigController { + + @Autowired + private AccessConfigService accessConfigService; + + /** + * 根据roleKey查询角色默认操作列表(包括assigned字段,标识该角色是否已经具有该操作权限) + * @param roleKey + * @return + */ + @PostMapping("roledefaultops/{roleKey}") + public Result listRoleDefaultOps(@PathVariable("roleKey") String roleKey) { + List defaultOps = accessConfigService.listRoleDefaultOpsByRoleKey(roleKey); + return new Result().ok(defaultOps); + } + + /** + * 根据角色ID列出角色的操作列表(及该操作的scope范围) + * @param roleId + * @return + */ + @PostMapping("roleopes/{roleId}") + public Result listRoleOperations(@PathVariable("roleId") String roleId) { + List opes = accessConfigService.listOpesByRole(roleId); + return new Result().ok(opes); + } + + /** + * 保存角色的操作权限列表 + * @return + */ + @PostMapping("saveroleopes") + public Result saveRoleOpes(@RequestBody AccessConfigOpesFormDTO formDTO) { + accessConfigService.saveRoleOpes(formDTO.getRoleId(), formDTO.getOpes()); + return new Result(); + } + + /** + * 查询可配置项列表 + * @return + */ + @PostMapping("configoptions") + public Result listConfigOptions(@RequestBody AccessConfigOptionsFormDTO accessConfigFormDTO) { + ValidatorUtils.validateEntity(accessConfigFormDTO); + AccessConfigOptionsResultDTO options = accessConfigService.listScopeOptionsForAccessConfig(accessConfigFormDTO.getRoleId(), accessConfigFormDTO.getOperationKey()); + return new Result().ok(options); + } + + /** + * 保存设置 + * @param config + * @return + */ + @PostMapping("saveconfig") + public Result saveSettings(@RequestBody AccessConfigSaveConfigDTO config) { + ValidatorUtils.validateEntity(config); + String roleId = config.getRoleId(); + String operationKey = config.getOperationKey(); + Set scopeKeys = config.getScopeKeys(); + accessConfigService.saveConfig(roleId, operationKey, scopeKeys); + return new Result(); + } + + /** + * 保存角色默认操作权限列表 + * @param form + * @return + */ + @PostMapping("roledefaultopes/save") + public Result saveRoleDefaultOperations(@RequestBody AccessConfigRoleDefaultOpesFormDTO form) { + ValidatorUtils.validateEntity(form); + accessConfigService.saveRoleDefaultOperations(form.getRoleKey(), form.getOperationKeys()); + return new Result(); + } + + /** + * 查询操作的默认范围列表 + * @param form + * @return + */ + @PostMapping("opedefaultscopes/list") + public Result listOpeDefaultScopes(@RequestBody AccessConfigOpeDefaultScopesFormDTO form) { + ValidatorUtils.validateEntity(form, AccessConfigOpeDefaultScopesFormDTO.ListOpeDefaultScopesGroup.class); + List scopes = accessConfigService.listOpeDefaultScopes4Role(form.getRoleKey(), form.getOperationKey()); + return new Result().ok(scopes); + } + + /** + * 保存操作的默认范围配置 + * @param form + * @return + */ + @PostMapping("opedefaultscopes/save") + public Result saveOpeDefaultScopes(@RequestBody AccessConfigOpeDefaultScopesFormDTO form) { + ValidatorUtils.validateEntity(form, AccessConfigOpeDefaultScopesFormDTO.SaveOpeDefaultScopesGroup.class); + accessConfigService.saveOpeDefaultScopes(form.getRoleKey(), form.getOperationKey(), form.getScopeKeys()); + return new Result(); + } + + /** + * @Description 给角色添加操作权限和操作范围 + * @return + * @author wxz + * @date 2020.11.17 17:41 + */ + @PostMapping("add-ope-and-scopes-4role") + public Result addOpeAndScopes4Role(@RequestBody AccessConfigAdd4RoletFormDTO form) { + ValidatorUtils.validateEntity(form); + String roleKey = form.getRoleKey(); + String operationKey = form.getOperationKey(); + List scopeKeys = form.getScopeKeys(); + + accessConfigService.addOpeAndScopes4Role(roleKey, operationKey, scopeKeys); + return new Result(); + } + + +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/AccessController.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/AccessController.java new file mode 100644 index 0000000000..dad8f7e095 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/AccessController.java @@ -0,0 +1,60 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.form.*; +import com.epmet.service.AccessService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Set; + +/** + * 权限相关Api + * @Author wxz + * @Description + * @Date 2020/4/23 17:54 + **/ +@RestController +@RequestMapping("access") +public class AccessController { + + @Autowired + private AccessService accessService; + + /** + * 用户是否具有指定功能权限 + * @return + */ + @PostMapping("hasspecifiedpermission") + public Result hasSpecifiedPermission(@RequestBody HasSpecifiedPermissionFormDTO form) { + ValidatorUtils.validateEntity(form); + Boolean hasPermission = accessService.hasPermission(form.getOperationKey(), form.getUserId(), form.getApp(), form.getClient()); + return new Result().ok(hasPermission); + } + + /** + * 列出功能权限列表 + * @return + */ + @PostMapping("listoperationpermissions") + public Result> listOperationPermissions(@RequestBody ListOpePermsFormDTO listOpePermsFormDTO) { + ValidatorUtils.validateEntity(listOpePermsFormDTO); + String currAgencyId = listOpePermsFormDTO.getCurrAgencyId(); + String staffId = listOpePermsFormDTO.getStaffId(); + Set operationPermissions = accessService.listOperationPermissions(staffId, currAgencyId); + return new Result>().ok(operationPermissions); + } + + /** + * 查询sql过滤片段 + * @param form + * @return + */ + @PostMapping("getSqlFilterSegment") + public Result getSqlFilterSegment(@RequestBody GetSQLFilterFormDTO form) { + ValidatorUtils.validateEntity(form); + String sqlFilterSegment = accessService.getSqlFilterSegment(form); + return new Result().ok(sqlFilterSegment); + } +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/DemoController.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/DemoController.java new file mode 100644 index 0000000000..357ea2c9af --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/DemoController.java @@ -0,0 +1,64 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.constraints.NotBlank; + +@RestController +@RequestMapping("demo") +public class DemoController { + + @PostMapping("adduser") + public Result addUser(@RequestBody UserFormDTO form) { + ValidatorUtils.validateEntity(form, UserFormDTO.AddUserShowGroup.class, UserFormDTO.AddUserInternalGroup.class); + System.out.println(form); + return new Result(); + } + +} + +@Data +class UserFormDTO { + //>>>>>>>>>>>>>>>>>校验分组开始>>>>>>>>>>>>>>>>>>>>> + /** + * 添加用户操作的内部异常分组 + * 出现错误会提示给前端7000错误码,返回信息为:服务器开小差... + */ + public interface AddUserInternalGroup {} + + /** + * 添加用户操作的用户可见异常分组 + * 该分组用于校验需要返回给前端错误信息提示的列,需要继承CustomerClientShowGroup + * 返回错误码为8999,提示信息为DTO中具体的列的校验注解message的内容 + */ + public interface AddUserShowGroup extends CustomerClientShowGroup {} + + // <<<<<<<<<<<<<<<<<<<校验分组结束<<<<<<<<<<<<<<<<<<<<<<<< + + /** + * 该字段在查询用户和添加用户的时候都要校验,所以在groups中会添加2个分组,校验器会优先校验继承了CustomerClientShowGroup + * 的分组 + * 1.该分组校验出错,直接将信息返回客户端,(多个字段有错误,多个字段的错误信息 + * 拼接起来,逗号分隔,详见ValidatorUtils#validadtorEntity()方法) + * 2.该分组校验成功,则继续往下,校验内部错误,若出现内部错误,则返回7000,服务器开小差... + */ + @NotBlank(message = "请输入姓名信息", groups = { AddUserInternalGroup.class, AddUserShowGroup.class }) + private String name; + + /** + * 用户别名,只在内部传输,因此它所属的分组不能继承CustomerClientShowGroup + */ + @NotBlank(message = "用户别名不能为空", groups = { AddUserInternalGroup.class }) + private String alias; + + @NotBlank(message = "请输入地址信息", groups = { AddUserShowGroup.class }) + private String address; + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/GovLanguageController.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/GovLanguageController.java new file mode 100644 index 0000000000..85e8bce73d --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/GovLanguageController.java @@ -0,0 +1,85 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.controller; + +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.dto.GovLanguageDTO; +import com.epmet.service.GovLanguageService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + + +/** + * 国际化 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@RestController +@RequestMapping("operlanguage") +public class GovLanguageController { + + @Autowired + private GovLanguageService govLanguageService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = govLanguageService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + GovLanguageDTO data = govLanguageService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody GovLanguageDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + govLanguageService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody GovLanguageDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + govLanguageService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + govLanguageService.delete(ids); + return new Result(); + } + + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/GovMenuController.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/GovMenuController.java new file mode 100644 index 0000000000..d3a67c889f --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/GovMenuController.java @@ -0,0 +1,156 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.exception.ErrorCode; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.dto.GovMenuDTO; +import com.epmet.dto.result.MenuResourceDTO; +import com.epmet.service.GovMenuService; +import com.epmet.service.GovResourceService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * + * 菜单管理 + * + * @author zhaoqifeng + * @date 2020/3/17 16:35 + */ +@RestController +@RequestMapping("menu") +public class GovMenuController { + + @Autowired + private GovMenuService govMenuService; + + @Autowired + private GovResourceService govResourceService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = govMenuService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + GovMenuDTO data = govMenuService.get(id); + + //菜单资源列表 + List resourceList = govResourceService.getMenuResourceList(id); + + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody GovMenuDTO dto, @LoginUser TokenDto tokenDto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + govMenuService.save(dto,tokenDto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody GovMenuDTO dto, @LoginUser TokenDto tokenDto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + govMenuService.update(dto,tokenDto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + govMenuService.delete(ids); + return new Result(); + } + + @DeleteMapping("{id}") + public Result delete(@PathVariable("id") String id, @LoginUser TokenDto tokenDto){ + //效验数据 + AssertUtils.isNull(id, "id"); + + //判断是否有子菜单或按钮 + List list = govMenuService.getListPid(id); + if(list.size() > 0){ + return new Result().error(ErrorCode.SUB_MENU_EXIST); + } + + govMenuService.delete(id, tokenDto); + + return new Result(); + } + + + /** + * 获取菜单列表 + * @param type 类型 + * @return Result> + */ + @GetMapping("list") + public Result> list(Integer type){ + List list = govMenuService.getMenuList(type); + + return new Result>().ok(list); + } + + /** + * 导航 + * @param tokenDto token + * @return List + */ + @GetMapping("nav") + public Result> nav(@LoginUser TokenDto tokenDto){ + List list = govMenuService.getUserMenuNavList(tokenDto); + return new Result>().ok(list); + } + + /** + * 权限标识 + * @param tokenDto token + * @return Set + */ + @GetMapping("permissions") + public Result> permissions(@LoginUser TokenDto tokenDto){ + Set set = govMenuService.getUserPermissions(tokenDto); + return new Result>().ok(set); + } + + /** + * 角色菜单权限 + * @param tokenDto token + * @return + */ + @GetMapping("select") + public Result> select(@LoginUser TokenDto tokenDto){ + List list = govMenuService.getUserMenuList(tokenDto, null); + + return new Result>().ok(list); + } + + /** + * @param tokenDto + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 运营端用户退出系统,清空菜单和操作权限 + * @Date 2020/5/21 18:07 + **/ + @GetMapping("cleargovuseraccess") + public Result clearGovUserAccess(@LoginUser TokenDto tokenDto) { + govMenuService.clearOperUserAccess(tokenDto.getApp(), tokenDto.getClient(), tokenDto.getUserId()); + return new Result(); + } +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/GovResourceController.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/GovResourceController.java new file mode 100644 index 0000000000..72193db454 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/GovResourceController.java @@ -0,0 +1,84 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.controller; + +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.dto.GovResourceDTO; +import com.epmet.service.GovResourceService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + + +/** + * 资源管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@RestController +@RequestMapping("govresource") +public class GovResourceController { + + @Autowired + private GovResourceService govResourceService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = govResourceService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + GovResourceDTO data = govResourceService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody GovResourceDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + govResourceService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody GovResourceDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + govResourceService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + govResourceService.delete(ids); + return new Result(); + } + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/GovRoleController.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/GovRoleController.java new file mode 100644 index 0000000000..7a1ded893c --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/GovRoleController.java @@ -0,0 +1,104 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.controller; + +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.dto.GovRoleDTO; +import com.epmet.service.GovRoleMenuService; +import com.epmet.service.GovRoleService; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +/** + * 角色管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@RestController +@RequestMapping("govrole") +public class GovRoleController { + + @Autowired + private GovRoleService govRoleService; + @Autowired + private GovRoleMenuService govRoleMenuService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = govRoleService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + GovRoleDTO data = govRoleService.get(id); + + //查询角色对应的菜单 + List menuIdList = govRoleMenuService.getMenuIdList(id); + data.setMenuIdList(menuIdList); + + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody GovRoleDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + govRoleService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody GovRoleDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + govRoleService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + govRoleService.delete(ids); + return new Result(); + } + + + @GetMapping("list") + @ApiOperation("列表") + public Result> list(){ + List data = govRoleService.list(new HashMap<>(1)); + + return new Result>().ok(data); + } + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/GovRoleMenuController.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/GovRoleMenuController.java new file mode 100644 index 0000000000..8b8a7d8aed --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/GovRoleMenuController.java @@ -0,0 +1,85 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.controller; + +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.dto.GovRoleMenuDTO; +import com.epmet.service.GovRoleMenuService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + + +/** + * 角色菜单关系 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@RestController +@RequestMapping("govrolemenu") +public class GovRoleMenuController { + + @Autowired + private GovRoleMenuService govRoleMenuService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = govRoleMenuService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + GovRoleMenuDTO data = govRoleMenuService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody GovRoleMenuDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + govRoleMenuService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody GovRoleMenuDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + govRoleMenuService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + govRoleMenuService.delete(ids); + return new Result(); + } + + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/GovRoleUserController.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/GovRoleUserController.java new file mode 100644 index 0000000000..fcd5733a4d --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/GovRoleUserController.java @@ -0,0 +1,132 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.controller; + +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.dto.GovRoleUserDTO; +import com.epmet.service.GovRoleUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + + +/** + * 角色用户关系 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@RestController +@RequestMapping("govroleuser") +public class GovRoleUserController { + + @Autowired + private GovRoleUserService govRoleUserService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = govRoleUserService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + GovRoleUserDTO data = govRoleUserService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody GovRoleUserDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + govRoleUserService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody GovRoleUserDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + govRoleUserService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + govRoleUserService.delete(ids); + return new Result(); + } + + + /** + * 获取权限id列表 + * @param id 用户id + * @return List + * @author zhaoqifeng + */ + @GetMapping("getRoleIdList/{id}") + public Result>getRoleIdList(@PathVariable("id") String id) { + List list = govRoleUserService.getRoleIdList(id); + return new Result>().ok(list); + } + + /** + * 保存更新权限 + * @param userId 用户id + * @param roleIdList 权限列表 + * @author zhaoqifeng + */ + @PostMapping("saveOrUpdateRole") + public Result saveOrUpdate(@RequestParam("userId") String userId, @RequestBody List roleIdList) { + govRoleUserService.saveOrUpdate(userId, roleIdList); + return new Result(); + } + + /** + * 根据用户id,删除角色用户关系 + * @param id 用户id + * @return Result + */ + @PostMapping("deleteByUserId") + public Result deleteByUserId(String id) { + govRoleUserService.deleteByUserId(id); + return new Result(); + } + + /** + * 根据用户ids,删除角色用户关系 + * @param ids 用户ids + * @return Result + */ + @PostMapping("deleteByUserIds") + public Result deleteByUserIds(@RequestBody String[] ids) { + govRoleUserService.deleteByUserIds(ids); + return new Result(); + } + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/RoleController.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/RoleController.java new file mode 100644 index 0000000000..5b7c01e23e --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/RoleController.java @@ -0,0 +1,41 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.InitDefaultOperationsFormDTO; +import com.epmet.dto.result.RoleOperationResultDTO; +import com.epmet.service.RoleOperationService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@RestController +@RequestMapping("role") +public class RoleController { + + @Autowired + private RoleOperationService roleOperationService; + + /** + * 查询角色对应的操作列表 + * @param roleId + * @return + */ + @PostMapping("operations/{roleId}") + public Result> listOperationsByRoleId(@PathVariable("roleId") String roleId) { + List roleOperationResultDTOS = roleOperationService.listOperationsByRoleId(roleId); + return new Result>().ok(roleOperationResultDTOS); + } + + /** + * 批量为角色ID初始化操作权限列表 + * @param formDTO + * @return + */ + @PostMapping("initdefaultoperationsforroles") + public Result initDefaultOperationsForRoles(@RequestBody InitDefaultOperationsFormDTO formDTO) { + List roles = formDTO.getRoles(); + roleOperationService.initDefaultOperationsForRoles(roles); + return new Result(); + } +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/TestController.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/TestController.java new file mode 100644 index 0000000000..b8ab2dbda6 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/controller/TestController.java @@ -0,0 +1,25 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.annotation.ExternalRequestAuth; +import com.epmet.service.TestService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("test") +public class TestController { + + @Autowired + private TestService testService; + + @ExternalRequestAuth + @GetMapping("test") + public void test() { + System.out.println("TestController -> test()"); + testService.test(); + } + +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/GovLanguageDao.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/GovLanguageDao.java new file mode 100644 index 0000000000..acd505c019 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/GovLanguageDao.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.GovLanguageEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 国际化 + * + * @author Mark sunlightcs@gmail.com + */ +@Mapper +public interface GovLanguageDao extends BaseDao { + + GovLanguageEntity getLanguage(GovLanguageEntity entity); + + void updateLanguage(GovLanguageEntity entity); + + void insertOperLanguageEntity(GovLanguageEntity entity); +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/GovMenuDao.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/GovMenuDao.java new file mode 100644 index 0000000000..1e36bff758 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/GovMenuDao.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.GovMenuEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 菜单管理 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Mapper +public interface GovMenuDao extends BaseDao { + + GovMenuEntity getById(@Param("id") String id, @Param("language") String language); + + /** + * 查询所有菜单列表 + * + * @param type 菜单类型 + * @param language 语言 + */ + List getMenuList(@Param("type") Integer type, @Param("language") String language); + + /** + * 查询用户菜单列表 + * + * @param userId 用户ID + * @param type 菜单类型 + * @param language 语言 + */ + List getUserMenuList(@Param("userId") String userId, @Param("type") Integer type, @Param("language") String language); + + + /** + * 根据父菜单,查询子菜单 + * @param pid 父菜单ID + */ + List getListPid(String pid); +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/GovResourceDao.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/GovResourceDao.java new file mode 100644 index 0000000000..4970d56e9c --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/GovResourceDao.java @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.GovResourceEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 资源管理 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Mapper +public interface GovResourceDao extends BaseDao { + /** + * 根据资源编码,删除对应的资源 + * @param code 资源编码 + */ + void deleteByCode(String code); + + /** + * 获取资源列表 + * @param menuId 菜单ID + */ + List getMenuResourceList(String menuId); + + /** + * 获取所有资源列表 + */ + List getResourceList(); + + /** + * 获取用户资源列表 + * @param userId 用户ID + */ + List getUserResourceList(@Param("userId") String userId); +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/GovRoleDao.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/GovRoleDao.java new file mode 100644 index 0000000000..768fc42792 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/GovRoleDao.java @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.GovRoleEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 角色管理 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Mapper +public interface GovRoleDao extends BaseDao { + +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/GovRoleMenuDao.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/GovRoleMenuDao.java new file mode 100644 index 0000000000..dc0559acb3 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/GovRoleMenuDao.java @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.GovRoleMenuEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 角色菜单关系 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Mapper +public interface GovRoleMenuDao extends BaseDao { + + /** + * 根据角色ID,获取菜单ID列表 + */ + List getMenuIdList(String roleId); + + /** + * 根据角色id,删除角色菜单关系 + * @param roleId 角色id + */ + void deleteByRoleId(String roleId); + + /** + * 根据菜单id,删除角色菜单关系 + * @param menuId 菜单id + */ + void deleteByMenuId(String menuId); + + + /** + * 根据角色ids,删除角色菜单关系 + * @param roleIds 角色ids + */ + void deleteByRoleIds(String[] roleIds); +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/GovRoleUserDao.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/GovRoleUserDao.java new file mode 100644 index 0000000000..bf400e0584 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/GovRoleUserDao.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.GovRoleUserEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 角色用户关系 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Mapper +public interface GovRoleUserDao extends BaseDao { + + /** + * 根据角色ids,删除角色用户关系 + * @param roleIds 角色ids + */ + void deleteByRoleIds(String[] roleIds); + + /** + * 根据用户ids,删除角色用户关系 + * @param userIds 用户ids + */ + void deleteByUserIds(String[] userIds); + + /** + * 根据角色id,删除角色用户关系 + * @param roleId 角色id + */ + void deleteByRoleId(String roleId); + + /** + * 根据用户id,删除角色用户关系 + * @param userId 用户id + */ + void deleteByUserId(String userId); + + /** + * 角色ID列表 + * @param userId 用户ID + * + * @return + */ + List getRoleIdList(String userId); +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/OperationDao.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/OperationDao.java new file mode 100644 index 0000000000..6b34908dde --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/OperationDao.java @@ -0,0 +1,38 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.OperationEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 操作类型表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-30 + */ +@Mapper +public interface OperationDao extends BaseDao { + + List listAllOperationEntities(); + + List listAllValidOperationEntities(); +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/OperationScopeDao.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/OperationScopeDao.java new file mode 100644 index 0000000000..98a455f052 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/OperationScopeDao.java @@ -0,0 +1,57 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.result.RoleOpeScopeResultDTO; +import com.epmet.entity.OperationScopeEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.springframework.context.annotation.Scope; + +import java.util.List; +import java.util.Set; + +/** + * 权限范围表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-24 + */ +@Mapper +public interface OperationScopeDao extends BaseDao { + + /** + * 查询角色的操作key对应操作范围列表 + * @param roleId 角色id + * @param operationKey 操作key + * @return + */ + Set listOperationScopesByRoleId(@Param("roleId") String roleId, + @Param("operationKey") String operationKey); + + /** + * 查询角色所有operation及其范围 + * @param roleId + */ + List listAllRoleOperationScopesByRoleId(String roleId); + + String getDefaultScopeKeyForOperation(@Param("operationKey") String operationKey); + + String getScopeIndexByScopeKey(@Param("scopeKey") String scopeKey); +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/OperationScopeDefaultDao.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/OperationScopeDefaultDao.java new file mode 100755 index 0000000000..2c9a049e83 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/OperationScopeDefaultDao.java @@ -0,0 +1,64 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.result.AccessConfigOpeDefaultScopesResultDTO; +import com.epmet.dto.result.OperationScopeDefaultResultDTO; +import com.epmet.entity.OperationScopeDefaultEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 默认操作范围表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-06-17 + */ +@Mapper +public interface OperationScopeDefaultDao extends BaseDao { + List listAllValid(); + + /** + * 根据角色key和操作key查询默认操作权限列表 + * @param roleKey + * @return + */ + List listDefaultOpeScopes(@Param("roleKey") String roleKey); + + /** + * 查询操作的默认范围 + * @param roleKey + * @param operationKey + * @return + */ + List listOpeDefaultScopes4Config( + @Param("roleKey") String roleKey, + @Param("operationKey") String operationKey); + + List listOpeDefaultScopesByRoleAndOpeKey( + @Param("roleKey") String roleKey, + @Param("operationKey") String operationKey); + + int delete( + @Param("roleKey") String roleKey, + @Param("operationKey") String operationKey, + @Param("scopeKey") String scopeKey); +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/RoleOperationDao.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/RoleOperationDao.java new file mode 100644 index 0000000000..46a159e3b6 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/RoleOperationDao.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.result.AccessConfigOpesResultDTO; +import com.epmet.dto.result.RoleOperationResultDTO; +import com.epmet.entity.RoleOperationEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 角色能进行那些操作 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Mapper +public interface RoleOperationDao extends BaseDao { + + List listOperationsByRoleId(@Param("roleId") String roleId); + + List listOpesForAccessConfig(@Param("roleId") String roleId); + + void deleteRoleOpe(@Param("roleId") String roleId, @Param("opeKey") String opeKey); + + RoleOperationEntity getRoleOpe(@Param("roleId") String roleId, @Param("opeKey") String opeKey); + + int enableRoleOpe(@Param("roleId") String roleId, @Param("opeKey") String opeKey); +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/RoleOperationDefaultDao.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/RoleOperationDefaultDao.java new file mode 100755 index 0000000000..19ccbf901e --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/RoleOperationDefaultDao.java @@ -0,0 +1,57 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.result.AccessConfigOpeDefaultScopesResultDTO; +import com.epmet.dto.result.RoleOperationDefaultResultDTO; +import com.epmet.entity.RoleOperationDefaultEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.HashMap; +import java.util.List; + +/** + * 角色默认的可操作功能列表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-05-21 + */ +@Mapper +public interface RoleOperationDefaultDao extends BaseDao { + + /** + * 查询可用 + * @return + */ + List listAllValid(); + + /** + * 查询某个roleKey的所有默认操作权限 + * @param roleKey + * @return + */ + List listByRoleKey(@Param("roleKey") String roleKey); + + List listRoleDefaultOpsByRoleKey(@Param("roleKey") String roleKey); + + int deleteByRoleKeyAndOpeKey( + @Param("roleKey") String roleKey, + @Param("operationKey") String operationKey); +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/RoleScopeDao.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/RoleScopeDao.java new file mode 100644 index 0000000000..3199a78e3d --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/dao/RoleScopeDao.java @@ -0,0 +1,85 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.result.AccessConfigScopeResultDTO; +import com.epmet.entity.RoleScopeEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Set; + +/** + * 角色能操作哪些范围 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-24 + */ +@Mapper +public interface RoleScopeDao extends BaseDao { + + /** + * 权限配置:列出可选项 + * @param roleId + * @param operationKey + * @return + */ + List listScopeOptionsForAccessConfig(@Param("roleId") String roleId, @Param("operationKey") String operationKey); + + /** + * + * @param roleId + * @param operationKey + * @return + */ + List listScopeEntities(@Param("roleId") String roleId, @Param("operationKey") String operationKey); + + /** + * 使用roleId+OperationKey+ScopeKey删除 + * @param roleId + * @param operationKey + * @param scopeKeys2Remove + * @return + */ + int deleteByRoleIdAndOpeKey(@Param("roleId") String roleId, + @Param("operationKey") String operationKey, + @Param("scopeKeys2Remove") Set scopeKeys2Remove); + + /** + * 启用 + * @param roleId + * @param operationKey + * @param scopeKey + * @return + */ + int enableByRoleIdAndOpeKey(@Param("roleId") String roleId, + @Param("operationKey") String operationKey, + @Param("scopeKey") String scopeKey); + + /** + * 使用RoleId + operationKey + scopeKey + * @param roleId + * @param operationKey + * @param scopeKey + */ + RoleScopeEntity getByRoleIdAndOpeKey(@Param("roleId") String roleId, + @Param("operationKey") String operationKey, + @Param("scopeKey") String scopeKey); +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/GovLanguageEntity.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/GovLanguageEntity.java new file mode 100644 index 0000000000..ee84f846d9 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/GovLanguageEntity.java @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * 国际化 + * + * @author Mark sunlightcs@gmail.com + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("gov_language") +public class GovLanguageEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 表名 + */ + private String tableName; + /** + * 表主键 + */ + private String tableId; + /** + * 字段名 + */ + private String fieldName; + /** + * 字段值 + */ + private String fieldValue; + /** + * 语言 + */ + private String language; + +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/GovMenuEntity.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/GovMenuEntity.java new file mode 100644 index 0000000000..fcb8a5fa38 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/GovMenuEntity.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 菜单管理 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("gov_menu") +public class GovMenuEntity extends BaseEpmetEntity { + private static final long serialVersionUID = 1L; + + /** + * 上级ID,一级菜单为0 + */ + private String pid; + /** + * 菜单名称 + */ + @TableField(exist = false) + private String name; + /** + * 菜单URL + */ + private String url; + /** + * 类型 0:菜单 1:按钮 + */ + private Integer type; + /** + * 菜单图标 + */ + private String icon; + /** + * 权限标识,如:sys:menu:save + */ + private String permissions; + /** + * 排序 + */ + private Integer sort; + /** + * 上级菜单名称 + */ + @TableField(exist = false) + private String parentName; + + /** + * 是否显示,1:显示 0不显示 + */ + private Integer showFlag; + +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/GovResourceEntity.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/GovResourceEntity.java new file mode 100644 index 0000000000..1d5d716c22 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/GovResourceEntity.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 资源管理 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("gov_resource") +public class GovResourceEntity extends BaseEpmetEntity { + private static final long serialVersionUID = 1L; + + /** + * 资源编码,如菜单ID + */ + private String resourceCode; + /** + * 资源名称 + */ + private String resourceName; + /** + * 资源URL + */ + private String resourceUrl; + /** + * 请求方式(如:GET、POST、PUT、DELETE) + */ + private String resourceMethod; + /** + * 菜单标识 0:非菜单资源 1:菜单资源 + */ + private Integer menuFlag; + /** + * 认证等级 0:权限认证 1:登录认证 2:无需认证 + */ + private Integer authLevel; + +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/GovRoleEntity.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/GovRoleEntity.java new file mode 100644 index 0000000000..4bc4575836 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/GovRoleEntity.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 角色管理 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("gov_role") +public class GovRoleEntity extends BaseEpmetEntity { + private static final long serialVersionUID = 1L; + + /** + * 角色名称 + */ + private String name; + /** + * 备注 + */ + private String remark; + /** + * 部门ID + */ + @TableField(fill = FieldFill.INSERT) + private Long deptId; + +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/GovRoleMenuEntity.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/GovRoleMenuEntity.java new file mode 100644 index 0000000000..6ea4d1f2a5 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/GovRoleMenuEntity.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 角色菜单关系 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("gov_role_menu") +public class GovRoleMenuEntity extends BaseEpmetEntity { + private static final long serialVersionUID = 1L; + /** + * 角色ID + */ + private String roleId; + /** + * 菜单ID + */ + private String menuId; + +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/GovRoleUserEntity.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/GovRoleUserEntity.java new file mode 100644 index 0000000000..599ca7f3e2 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/GovRoleUserEntity.java @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 角色用户关系 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("gov_role_user") +public class GovRoleUserEntity extends BaseEpmetEntity { + private static final long serialVersionUID = 1L; + + /** + * 角色ID + */ + private String roleId; + /** + * 用户ID + */ + private String userId; + +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/OperationEntity.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/OperationEntity.java new file mode 100644 index 0000000000..e599d8c28f --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/OperationEntity.java @@ -0,0 +1,56 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 操作类型表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-30 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("operation") +public class OperationEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * + */ + private String operationKey; + + /** + * + */ + private String operationName; + + /** + * 操作简介 + */ + private String brief; + +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/OperationScopeDefaultEntity.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/OperationScopeDefaultEntity.java new file mode 100755 index 0000000000..6ec89eb12b --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/OperationScopeDefaultEntity.java @@ -0,0 +1,53 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 默认操作范围表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-06-17 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("operation_scope_default") +public class OperationScopeDefaultEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + private String roleKey; + + /** + * 操作key + */ + private String operationKey; + + /** + * 范围key + */ + private String scopeKey; + +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/OperationScopeEntity.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/OperationScopeEntity.java new file mode 100644 index 0000000000..2c7223d97d --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/OperationScopeEntity.java @@ -0,0 +1,55 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 权限范围表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-24 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("operation_scope") +public class OperationScopeEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 范围key + */ + private String scopeKey; + + /** + * 范围名称 + */ + private String scopeName; + + private String scopeIndex; + private String series; + private Integer sort; + +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/RoleOperationDefaultEntity.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/RoleOperationDefaultEntity.java new file mode 100755 index 0000000000..8ea82b13b9 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/RoleOperationDefaultEntity.java @@ -0,0 +1,42 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("role_operation_default") +public class RoleOperationDefaultEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 角色KEY + */ + private String roleKey; + + /** + * 操作key + */ + private String operationKey; + +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/RoleOperationEntity.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/RoleOperationEntity.java new file mode 100644 index 0000000000..96f70de1be --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/RoleOperationEntity.java @@ -0,0 +1,51 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 角色能进行那些操作 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("role_operation") +public class RoleOperationEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 角色ID + */ + private String roleId; + + /** + * 操作key + */ + private String operationKey; + +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/RoleScopeEntity.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/RoleScopeEntity.java new file mode 100644 index 0000000000..2c3c6f21dc --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/entity/RoleScopeEntity.java @@ -0,0 +1,56 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 角色能操作哪些范围 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-24 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("role_scope") +public class RoleScopeEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 角色ID + */ + private String roleId; + + /** + * 操作key + */ + private String operationKey; + + /** + * 范围Key + */ + private String scopeKey; + +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/excel/RoleOperationExcel.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/excel/RoleOperationExcel.java new file mode 100644 index 0000000000..4b0c4ee373 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/excel/RoleOperationExcel.java @@ -0,0 +1,62 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.util.Date; + +/** + * 角色能进行那些操作 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Data +public class RoleOperationExcel { + + @Excel(name = "") + private String id; + + @Excel(name = "角色ID") + private String roleId; + + @Excel(name = "操作key") + private String operationKey; + + @Excel(name = "是否删除,0:未删除,1:已删除") + private Integer delFlag; + + @Excel(name = "乐观锁") + private Integer revision; + + @Excel(name = "创建者id") + private String createdBy; + + @Excel(name = "创建时间") + private Date createdTime; + + @Excel(name = "更新者id") + private String updatedBy; + + @Excel(name = "更新时间") + private Date updatedTime; + + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java new file mode 100644 index 0000000000..d88b8358a3 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java @@ -0,0 +1,77 @@ +package com.epmet.feign; + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.GovStaffRoleDTO; +import com.epmet.dto.OperUserDTO; +import com.epmet.dto.form.LatestGridFormDTO; +import com.epmet.dto.form.StaffGridVisitedFormDTO; +import com.epmet.dto.form.StaffRoleFormDTO; +import com.epmet.dto.result.CustomerGridByUserIdResultDTO; +import com.epmet.dto.result.LatestCustomerResultDTO; +import com.epmet.feign.fallback.EpmetUserFeignClientFallback; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.List; + + +/** + * @Description + * @Author sun + */ +//, url = "localhost:8087" +@FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallback = EpmetUserFeignClientFallback.class) +public interface EpmetUserFeignClient { + /** + * 获取最近一次登录的客户信息 + * + * @param userId + * @return + */ + @GetMapping("/epmetuser/staffagencyvisited/getlatestcustomer/{userId}") + Result getLatestCustomer(@PathVariable("userId") String userId); + + /** + * @Description 查询工作人员上次登录的网格 + * @Param customerId ; staffId + * @return Result + * @Author wangc + * @Date 2020.04.23 10:44 + **/ + @PostMapping(value = "/epmetuser/staffgridvisited/getstafflatestgrid") + Result getStaffLatestGrid(LatestGridFormDTO latestGridFormDTO); + + /** + * @param staffGridVisitedFormDTO + * @return com.epmet.commons.tools.utils.Result + * @Author yinzuomei + * @Description 保存网格访问记录 + * @Date 2020/4/23 13:27 + **/ + @PostMapping(value = "/epmetuser/staffgridvisited/savestaffgridvisitedrecord", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) + Result saveStaffGridVisitedRecord(@RequestBody StaffGridVisitedFormDTO staffGridVisitedFormDTO); + /** + * 查询工作人员的角色 + * @return + */ + @PostMapping("/epmetuser/staffrole/staffroles") + Result> getRolesOfStaff(StaffRoleFormDTO staffRoleFormDTO); + + /** + * + * 根据id查询运营人员详情 + * + * @param operUserId oper_user表主键 + * @return com.epmet.commons.tools.utils.Result> + * @author zhaoqifeng + * @date 2020/3/19 09:28 + **/ + @GetMapping("/operuser/queryOperUserDtoById/{operUserId}") + Result info(@PathVariable("operUserId") String operUserId); +} + diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java new file mode 100644 index 0000000000..c9f2e3eada --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java @@ -0,0 +1,34 @@ +package com.epmet.feign; + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.CustomerAgencyDTO; +import com.epmet.feign.fallback.GovOrgFeignClientFallBack; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; + +/** + * @Description + * @Author sun + */ +//@FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallback = GovOrgFeignClientFallBack.class, url = "localhost:8092") +@FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallback = GovOrgFeignClientFallBack.class) +public interface GovOrgFeignClient { + + /** + * 根据Id查询agency + * @param agencyId + * @return + */ + @PostMapping("/gov/org/agency/agencybyid/{agencyId}") + Result getAgencyById(@PathVariable("agencyId") String agencyId); + + /** + * 根据staffId查询所属的组织机构 + * @param staffId + * @return + */ + @PostMapping("/gov/org/agency/agencybystaff/{staffId}") + Result getAgencyByStaff(@PathVariable("staffId") String staffId); +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java new file mode 100644 index 0000000000..cd39c87452 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java @@ -0,0 +1,49 @@ +package com.epmet.feign.fallback; + + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.ModuleUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.GovStaffRoleDTO; +import com.epmet.dto.OperUserDTO; +import com.epmet.dto.form.LatestGridFormDTO; +import com.epmet.dto.form.StaffGridVisitedFormDTO; +import com.epmet.dto.form.StaffRoleFormDTO; +import com.epmet.dto.result.CustomerGridByUserIdResultDTO; +import com.epmet.dto.result.LatestCustomerResultDTO; +import com.epmet.feign.EpmetUserFeignClient; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * @Description + * @Author sun + */ +@Component +public class EpmetUserFeignClientFallback implements EpmetUserFeignClient { + + @Override + public Result getLatestCustomer(String userId) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getLatestCustomer", userId); + } + + @Override + public Result> getRolesOfStaff(StaffRoleFormDTO staffRoleFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getRolesOfStaff"); + } + + @Override + public Result info(String operUserId) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "info", operUserId); + } + + @Override + public Result getStaffLatestGrid(LatestGridFormDTO latestGridFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getStaffLatestGrid",latestGridFormDTO); + } + @Override + public Result saveStaffGridVisitedRecord(StaffGridVisitedFormDTO staffGridVisitedFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "saveStaffGridVisitedRecord", staffGridVisitedFormDTO); + } +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java new file mode 100644 index 0000000000..f418de95e0 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java @@ -0,0 +1,31 @@ +package com.epmet.feign.fallback; + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.ModuleUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.CustomerAgencyDTO; +import com.epmet.dto.form.LatestGridFormDTO; +import com.epmet.dto.result.CustomerGridByUserIdResultDTO; +import com.epmet.dto.result.LatestCustomerResultDTO; +import com.epmet.feign.GovOrgFeignClient; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * @Description + * @Author sun + */ +@Component +public class GovOrgFeignClientFallBack implements GovOrgFeignClient { + + @Override + public Result getAgencyById(String agencyId) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getAgencyById", agencyId); + } + + @Override + public Result getAgencyByStaff(String staffId) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getAgencyByStaff", staffId); + } +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/redis/GovLanguageRedis.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/redis/GovLanguageRedis.java new file mode 100644 index 0000000000..8f9595582b --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/redis/GovLanguageRedis.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 国际化 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@Component +public class GovLanguageRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/redis/GovMenuRedis.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/redis/GovMenuRedis.java new file mode 100644 index 0000000000..361d6c3014 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/redis/GovMenuRedis.java @@ -0,0 +1,74 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.redis; + +import com.epmet.commons.tools.redis.RedisKeys; +import com.epmet.commons.tools.redis.RedisUtils; +import com.epmet.commons.tools.utils.HttpContextUtils; +import com.epmet.dto.GovMenuDTO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.Set; + +/** + * 菜单管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@Component +public class GovMenuRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(String userId, String app, String client) { + redisUtils.deleteByPattern(RedisKeys.getUserMenuNavKey(userId, app, client, HttpContextUtils.getLanguage())); + redisUtils.delete(RedisKeys.getUserPermissionsKey(userId, app, client)); + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + + public void setUserMenuNavList(String userId, String app, String client, List menuList){ + String key = RedisKeys.getUserMenuNavKey(userId, app, client, HttpContextUtils.getLanguage()); + redisUtils.set(key, menuList); + } + + public List getUserMenuNavList(String userId, String app, String client){ + String key = RedisKeys.getUserMenuNavKey(userId, app, client, HttpContextUtils.getLanguage()); + return (List)redisUtils.get(key); + } + + public void setUserPermissions(String userId, String app, String client, Set permsSet){ + String key = RedisKeys.getUserPermissionsKey(userId, app, client); + redisUtils.set(key, permsSet); + } + + public Set getUserPermissions(String userId, String app, String client){ + String key = RedisKeys.getUserPermissionsKey(userId, app, client); + return (Set)redisUtils.get(key); + } + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/redis/GovResourceRedis.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/redis/GovResourceRedis.java new file mode 100644 index 0000000000..e21bd5095c --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/redis/GovResourceRedis.java @@ -0,0 +1,50 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.redis; + +import com.epmet.commons.tools.redis.RedisKeys; +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 资源管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@Component +public class GovResourceRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete() { + String key = RedisKeys.getSysResourceKey(); + + redisUtils.delete(key); + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/redis/GovRoleMenuRedis.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/redis/GovRoleMenuRedis.java new file mode 100644 index 0000000000..c778d22c7d --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/redis/GovRoleMenuRedis.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 角色菜单关系 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@Component +public class GovRoleMenuRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/redis/GovRoleRedis.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/redis/GovRoleRedis.java new file mode 100644 index 0000000000..3e87e447dd --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/redis/GovRoleRedis.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 角色管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@Component +public class GovRoleRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/redis/GovRoleUserRedis.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/redis/GovRoleUserRedis.java new file mode 100644 index 0000000000..7a7aad6c8c --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/redis/GovRoleUserRedis.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 角色用户关系 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@Component +public class GovRoleUserRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/redis/RoleOpeScopeRedis.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/redis/RoleOpeScopeRedis.java new file mode 100644 index 0000000000..af82f0f8b5 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/redis/RoleOpeScopeRedis.java @@ -0,0 +1,74 @@ +package com.epmet.redis; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; +import com.epmet.commons.tools.redis.RedisKeys; +import com.epmet.commons.tools.redis.RedisUtils; +import com.epmet.dto.result.RoleOpeScopeResultDTO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.Set; + +/** + * 角色的操作权限对应的操作范围Redis + */ +@Component +public class RoleOpeScopeRedis { + + @Autowired + private RedisUtils redisUtils; + + /** + * 缓存角色操作范围 + * @param roleId + * @param opeKey + * @param scopes + */ + public void setRoleOpeScopes(String roleId, String opeKey, Set scopes) { + String roleOpeScopesKey = RedisKeys.getRoleOpeScopesKey(roleId, opeKey); + redisUtils.set(roleOpeScopesKey, scopes); + } + + /** + * 缓存角色所有的操作范围 + * @param roleId + * @param scopes + */ + public void setRoleAllOpeScopes(String roleId, List scopes) { + String roleAllOpeScopesKey = RedisKeys.getRoleAllOpeScopesKey(roleId); + redisUtils.setString(roleAllOpeScopesKey, JSON.toJSONString(scopes)); + } + + /** + * 查询角色操作范围 + * @param roleId + * @param opeKey + * @return + */ + public Set getRoleOpeScopes(String roleId, String opeKey) { + String roleOpeScopesKey = RedisKeys.getRoleOpeScopesKey(roleId, opeKey); + return (Set)redisUtils.get(roleOpeScopesKey); + } + + /** + * 查询角色所有操作范围 + * @param roleId + * @return + */ + public List getRoleAllOpeScopes(String roleId) { + String roleOpeScopesKey = RedisKeys.getRoleAllOpeScopesKey(roleId); + String stringValue = redisUtils.getString(roleOpeScopesKey); + return JSON.parseObject(stringValue, new TypeReference>(){}); + } + + /** + * 删除缓存 + * @param roleId + */ + public void delRoleAllOpeScopes(String roleId) { + redisUtils.delete(RedisKeys.getRoleAllOpeScopesKey(roleId)); + } + +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/AccessConfigService.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/AccessConfigService.java new file mode 100644 index 0000000000..508f3ad45f --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/AccessConfigService.java @@ -0,0 +1,30 @@ +package com.epmet.service; + +import com.epmet.dto.form.AccessConfigRoleDefaultOpesFormDTO; +import com.epmet.dto.result.AccessConfigOpeDefaultScopesResultDTO; +import com.epmet.dto.result.AccessConfigOpesResultDTO; +import com.epmet.dto.result.AccessConfigOptionsResultDTO; +import com.epmet.dto.result.RoleOperationDefaultResultDTO; + +import java.util.List; +import java.util.Set; + +public interface AccessConfigService { + List listOpesByRole(String roleId); + + void saveRoleOpes(String roleId, List opes); + + AccessConfigOptionsResultDTO listScopeOptionsForAccessConfig(String roleId, String operationKey); + + void saveConfig(String roleId, String operationKey, Set scopeKeys); + + List listRoleDefaultOpsByRoleKey(String roleKey); + + void saveRoleDefaultOperations(String roleKey, List operationKeys); + + List listOpeDefaultScopes4Role(String roleKey, String operationKey); + + void saveOpeDefaultScopes(String roleKey, String operationKey, List scopeKeys); + + void addOpeAndScopes4Role(String roleKey, String operationKey, List scopeKeys); +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/AccessService.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/AccessService.java new file mode 100644 index 0000000000..7b365fa21b --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/AccessService.java @@ -0,0 +1,44 @@ +package com.epmet.service; + +import com.epmet.dto.form.GetSQLFilterFormDTO; +import com.epmet.dto.result.LoginUserDetailsResultDTO; +import com.epmet.dto.result.RoleOpeScopeResultDTO; + +import java.util.List; +import java.util.Set; + +public interface AccessService { + + /** + * 查询登陆用户登陆信息 + * @return + */ + LoginUserDetailsResultDTO getLoginUserDetails(String app, String client, String staffId); + + /** + * 查询角色所有operation及其范围(缓存) + * @param roleId + * @return + */ + List listAllRoleOperationScopesByRoleId(String roleId); + + /** + * 角色 + * @param operationKey + * @param userId + * @return + */ + Boolean hasPermission(String operationKey, String userId, String app, String client); + + /** + * 生成sql过滤脚本 + * @param form + */ + String getSqlFilterSegment(GetSQLFilterFormDTO form); + + /** + * 列出角色的功能权限 + * @return + */ + Set listOperationPermissions(String staffId, String currAgencyId); +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/GovLanguageService.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/GovLanguageService.java new file mode 100644 index 0000000000..1f4a5e65e3 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/GovLanguageService.java @@ -0,0 +1,105 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.GovLanguageDTO; +import com.epmet.entity.GovLanguageEntity; + +import java.util.List; +import java.util.Map; + +/** + * 国际化 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +public interface GovLanguageService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-03-18 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-03-18 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return GovLanguageDTO + * @author generator + * @date 2020-03-18 + */ + GovLanguageDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-03-18 + */ + void save(GovLanguageDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-03-18 + */ + void update(GovLanguageDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-03-18 + */ + void delete(String[] ids); + + /** + * 保存或更新 + * @param tableName 表名 + * @param tableId 表主键 + * @param fieldName 字段名 + * @param fieldValue 字段值 + * @param language 语言 + */ + void saveOrUpdate(String tableName, String tableId, String fieldName, String fieldValue, String language); +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/GovMenuService.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/GovMenuService.java new file mode 100644 index 0000000000..b5c0cf12a3 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/GovMenuService.java @@ -0,0 +1,144 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.dto.GovMenuDTO; +import com.epmet.entity.GovMenuEntity; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * 菜单管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +public interface GovMenuService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-03-18 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-03-18 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return GovMenuDTO + * @author generator + * @date 2020-03-18 + */ + GovMenuDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-03-18 + */ + void save(GovMenuDTO dto, TokenDto tokenDto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-03-18 + */ + void update(GovMenuDTO dto, TokenDto tokenDto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-03-18 + */ + void delete(String[] ids); + + /** + * 删除 + * + * @param id id + * @author generator + * @date 2020-03-18 + */ + void delete(String id, TokenDto tokenDto); + + /** + * 用户菜单列表 + * + * @param tokenDto 用户信息 + * @param type 菜单类型 + * @return java.util.List + */ + List getUserMenuList(TokenDto tokenDto, Integer type); + + /** + * 菜单列表 + * + * @param type 菜单类型 + */ + List getMenuList(Integer type); + + /** + * 用户菜单导航 + * @param tokenDto 用户信息 + * @return java.util.List + */ + List getUserMenuNavList(TokenDto tokenDto); + + /** + * 获取用户权限标识 + * @param tokenDto 用户信息 + * @return java.util.Set + */ + Set getUserPermissions(TokenDto tokenDto); + + /** + * 根据父菜单,查询子菜单 + * @param pid 父菜单ID + */ + List getListPid(String pid); + + void clearOperUserAccess(String app, String client, String userId); +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/GovResourceService.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/GovResourceService.java new file mode 100644 index 0000000000..8b6b8f5e6d --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/GovResourceService.java @@ -0,0 +1,110 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.GovResourceDTO; +import com.epmet.dto.result.MenuResourceDTO; +import com.epmet.entity.GovResourceEntity; + +import java.util.List; +import java.util.Map; + +/** + * 资源管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +public interface GovResourceService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-03-18 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-03-18 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return GovResourceDTO + * @author generator + * @date 2020-03-18 + */ + GovResourceDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-03-18 + */ + void save(GovResourceDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-03-18 + */ + void update(GovResourceDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-03-18 + */ + void delete(String[] ids); + + /** + * 保存菜单资源 + * @param menuId 菜单ID + * @param menuName 菜单名称 + * @param resourceList 资源列表 + */ + void saveMenuResource(String menuId, String menuName, List resourceList); + + /** + * 获取菜单资源列表 + * @param menuId 菜单ID + */ + List getMenuResourceList(String menuId); +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/GovRoleMenuService.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/GovRoleMenuService.java new file mode 100644 index 0000000000..7b0d2af34a --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/GovRoleMenuService.java @@ -0,0 +1,125 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.GovRoleMenuDTO; +import com.epmet.entity.GovRoleMenuEntity; + +import java.util.List; +import java.util.Map; + +/** + * 角色菜单关系 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +public interface GovRoleMenuService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-03-18 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-03-18 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return GovRoleMenuDTO + * @author generator + * @date 2020-03-18 + */ + GovRoleMenuDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-03-18 + */ + void save(GovRoleMenuDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-03-18 + */ + void update(GovRoleMenuDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-03-18 + */ + void delete(String[] ids); + + /** + * 根据角色ID,获取菜单ID列表 + */ + List getMenuIdList(String roleId); + + /** + * 保存或修改 + * @param roleId 角色ID + * @param menuIdList 菜单ID列表 + */ + void saveOrUpdate(String roleId, List menuIdList); + + /** + * 根据角色id,删除角色菜单关系 + * @param roleId 角色id + */ + void deleteByRoleId(String roleId); + + /** + * 根据角色ids,删除角色菜单关系 + * @param roleIds + */ + void deleteByRoleIds(String[] roleIds); + + /** + * 根据菜单id,删除角色菜单关系 + * @param menuId 菜单id + */ + void deleteByMenuId(String menuId); +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/GovRoleService.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/GovRoleService.java new file mode 100644 index 0000000000..4fbf7e0f58 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/GovRoleService.java @@ -0,0 +1,95 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.GovRoleDTO; +import com.epmet.entity.GovRoleEntity; + +import java.util.List; +import java.util.Map; + +/** + * 角色管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +public interface GovRoleService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-03-18 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-03-18 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return GovRoleDTO + * @author generator + * @date 2020-03-18 + */ + GovRoleDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-03-18 + */ + void save(GovRoleDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-03-18 + */ + void update(GovRoleDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-03-18 + */ + void delete(String[] ids); +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/GovRoleUserService.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/GovRoleUserService.java new file mode 100644 index 0000000000..ff67c7d239 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/GovRoleUserService.java @@ -0,0 +1,133 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.GovRoleUserDTO; +import com.epmet.entity.GovRoleUserEntity; + +import java.util.List; +import java.util.Map; + +/** + * 角色用户关系 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +public interface GovRoleUserService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-03-18 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-03-18 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return GovRoleUserDTO + * @author generator + * @date 2020-03-18 + */ + GovRoleUserDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-03-18 + */ + void save(GovRoleUserDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-03-18 + */ + void update(GovRoleUserDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-03-18 + */ + void delete(String[] ids); + + /** + * 保存或修改 + * @param userId 用户ID + * @param roleIdList 角色ID列表 + */ + void saveOrUpdate(String userId, List roleIdList); + + /** + * 根据角色id,删除角色用户关系 + * @param roleId 角色id + */ + void deleteByRoleId(String roleId); + + /** + * 根据用户id,删除角色用户关系 + * @param userId 用户id + */ + void deleteByUserId(String userId); + + /** + * 角色ID列表 + * @param userId 用户ID + * @return List + */ + List getRoleIdList(String userId); + + /** + * 根据角色ids,删除角色用户关系 + * @param roleIds 角色ids + */ + void deleteByRoleIds(String[] roleIds); + + /** + * 根据用户ids,删除角色用户关系 + * @param userIds 用户ids + */ + void deleteByUserIds(String[] userIds); +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/OperationScopeService.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/OperationScopeService.java new file mode 100644 index 0000000000..cb24b913c0 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/OperationScopeService.java @@ -0,0 +1,95 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.OperationScopeDTO; +import com.epmet.entity.OperationScopeEntity; + +import java.util.List; +import java.util.Map; + +/** + * 权限范围表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-24 + */ +public interface OperationScopeService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-04-24 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-04-24 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return OperationScopeDTO + * @author generator + * @date 2020-04-24 + */ + OperationScopeDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-04-24 + */ + void save(OperationScopeDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-04-24 + */ + void update(OperationScopeDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-04-24 + */ + void delete(String[] ids); +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/OperationService.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/OperationService.java new file mode 100644 index 0000000000..edfaa41473 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/OperationService.java @@ -0,0 +1,14 @@ +package com.epmet.service; + +import com.epmet.entity.OperationEntity; + +import java.util.ArrayList; +import java.util.List; + +public interface OperationService { + + List listAllOperations(); + + void createBatch(ArrayList operations2Create); + void updateBatch(ArrayList operations2Update); +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/RoleOperationService.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/RoleOperationService.java new file mode 100644 index 0000000000..109cdf7a51 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/RoleOperationService.java @@ -0,0 +1,106 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.RoleOperationDTO; +import com.epmet.dto.form.InitDefaultOperationsFormDTO; +import com.epmet.dto.result.RoleOperationResultDTO; +import com.epmet.entity.RoleOperationEntity; + +import java.util.List; +import java.util.Map; + +/** + * 角色能进行那些操作 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +public interface RoleOperationService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-04-22 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-04-22 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return RoleOperationDTO + * @author generator + * @date 2020-04-22 + */ + RoleOperationDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-04-22 + */ + void save(RoleOperationDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-04-22 + */ + void update(RoleOperationDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-04-22 + */ + void delete(String[] ids); + + /** + * 查询角色对应的操作列表 + * @param roleId + * @return + */ + List listOperationsByRoleId(String roleId); + + void initDefaultOperationsForRoles(List roles); +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/RoleScopeService.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/RoleScopeService.java new file mode 100644 index 0000000000..34cdd6e07f --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/RoleScopeService.java @@ -0,0 +1,95 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.RoleScopeDTO; +import com.epmet.entity.RoleScopeEntity; + +import java.util.List; +import java.util.Map; + +/** + * 角色能操作哪些范围 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-24 + */ +public interface RoleScopeService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-04-24 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-04-24 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return RoleScopeDTO + * @author generator + * @date 2020-04-24 + */ + RoleScopeDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-04-24 + */ + void save(RoleScopeDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-04-24 + */ + void update(RoleScopeDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-04-24 + */ + void delete(String[] ids); +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/TestService.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/TestService.java new file mode 100644 index 0000000000..587690221c --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/TestService.java @@ -0,0 +1,7 @@ +package com.epmet.service; + +public interface TestService { + + void test(); + +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/AccessConfigServiceImpl.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/AccessConfigServiceImpl.java new file mode 100644 index 0000000000..06f391eada --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/AccessConfigServiceImpl.java @@ -0,0 +1,264 @@ +package com.epmet.service.impl; + +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dao.*; +import com.epmet.dto.result.*; +import com.epmet.entity.OperationScopeDefaultEntity; +import com.epmet.entity.RoleOperationDefaultEntity; +import com.epmet.entity.RoleOperationEntity; +import com.epmet.entity.RoleScopeEntity; +import com.epmet.feign.EpmetUserOpenFeignClient; +import com.epmet.redis.RoleOpeScopeRedis; +import com.epmet.service.AccessConfigService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +@Service +public class AccessConfigServiceImpl implements AccessConfigService { + + protected static final Logger logger = LoggerFactory.getLogger(AccessConfigServiceImpl.class); + + @Autowired + private RoleOpeScopeRedis roleOpeScopeRedis; + + @Autowired + private RoleOperationDao roleOperationDao; + + @Autowired + private RoleOperationDefaultDao roleOperationDefaultDao; + + @Autowired + private RoleScopeDao roleScopeDao; + + @Autowired + private OperationScopeDefaultDao operationScopeDefaultDao; + + @Autowired + private EpmetUserOpenFeignClient epmetUserOpenFeignClient; + + @Override + public List listOpesByRole(String roleId) { + return roleOperationDao.listOpesForAccessConfig(roleId); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void saveRoleOpes(String roleId, List opes) { + List operationsDB = roleOperationDao.listOperationsByRoleId(roleId); + Set opeKeysDB = operationsDB.stream().map(opeDB -> opeDB.getOperationKey()).collect(Collectors.toSet()); + Set opeKeysForm = opes.stream().map(opeForm -> opeForm.getOperationKey()).collect(Collectors.toSet()); + + for (String s : opeKeysDB) { + if (!opeKeysForm.contains(s)) { + // 说明这个已经被取消 + roleOperationDao.deleteRoleOpe(roleId, s); + } + } + + for (String s : opeKeysForm) { + if (!opeKeysDB.contains(s)) { + // 说明这个是新勾选的 + if (roleOperationDao.getRoleOpe(roleId, s) != null) { + if (roleOperationDao.enableRoleOpe(roleId, s) == 0) { + logger.error("权限配置:启用权限失败,roleId:{}", roleId); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } + continue; + } + + RoleOperationEntity newRoleOpe = new RoleOperationEntity(); + newRoleOpe.setRoleId(roleId); + newRoleOpe.setOperationKey(s); + roleOperationDao.insert(newRoleOpe); + } + } + + // 失效Redis缓存 + roleOpeScopeRedis.delRoleAllOpeScopes(roleId); + } + + @Override + public AccessConfigOptionsResultDTO listScopeOptionsForAccessConfig(String roleId, String operationKey) { + List scopeOptions = roleScopeDao.listScopeOptionsForAccessConfig(roleId, operationKey); + //List settingOptions = accessSettingDao.listSettingOptionsForAccessConfig(roleId, operationKey); + AccessConfigOptionsResultDTO options = new AccessConfigOptionsResultDTO(); + options.setScopeOptions(scopeOptions); + //options.setSettingOptions(settingOptions); + return options; + } + + @Override + @Transactional + public void saveConfig(String roleId, String operationKey, Set scopeKeys) { + List scopesDB = roleScopeDao.listScopeEntities(roleId, operationKey); + // 数据库中已有的scopeKey列表 + Set scopeKeysDB = scopesDB.stream().map(scope -> scope.getScopeKey()).collect(Collectors.toSet()); + + Set scopeKeys2Add = scopeKeys.stream().filter(scopeKey -> !scopeKeysDB.contains(scopeKey)).collect(Collectors.toSet()); + Set scopeKeys2Remove = scopeKeysDB.stream().filter(scopeKeyDB -> !scopeKeys.contains(scopeKeyDB)).collect(Collectors.toSet()); + + // 添加/重新启用 + if (!CollectionUtils.isEmpty(scopeKeys2Add)) { + scopeKeys2Add.forEach(scopeKey -> { + RoleScopeEntity rsDB = roleScopeDao.getByRoleIdAndOpeKey(roleId, operationKey, scopeKey); + if (rsDB != null) { + roleScopeDao.enableByRoleIdAndOpeKey(roleId, operationKey, scopeKey); + } else { + RoleScopeEntity rs2Add = new RoleScopeEntity(); + rs2Add.setRoleId(roleId); + rs2Add.setOperationKey(operationKey); + rs2Add.setScopeKey(scopeKey); + roleScopeDao.insert(rs2Add); + } + }); + } + + // 删除 + if (!CollectionUtils.isEmpty(scopeKeys2Remove)) { + roleScopeDao.deleteByRoleIdAndOpeKey(roleId, operationKey, scopeKeys2Remove); + } + + // 清空redis缓存 + roleOpeScopeRedis.delRoleAllOpeScopes(roleId); + } + + @Override + public List listRoleDefaultOpsByRoleKey(String roleKey) { + return roleOperationDefaultDao.listRoleDefaultOpsByRoleKey(roleKey); + } + + /** + * + * @param roleKey + * @param operationKeys + */ + @Transactional(rollbackFor = Exception.class) + @Override + public void saveRoleDefaultOperations(String roleKey, List operationKeys) { + + List opesExists = roleOperationDefaultDao.listByRoleKey(roleKey); + Set opeKeysExists = opesExists.stream().map(ope -> ope.getOperationKey()).collect(Collectors.toSet()); + + // 过滤出删掉的 + Set deletedOpes = opeKeysExists.stream().filter(oke -> !operationKeys.contains(oke)).collect(Collectors.toSet()); + // 过滤出新增的 + Set newOpes = operationKeys.stream().filter(okn -> !opeKeysExists.contains(okn)).collect(Collectors.toSet()); + + for (String deletedOpe : deletedOpes) { + roleOperationDefaultDao.deleteByRoleKeyAndOpeKey(roleKey, deletedOpe); + } + + for (String newOpe : newOpes) { + RoleOperationDefaultEntity entity = new RoleOperationDefaultEntity(); + entity.setRoleKey(roleKey); + entity.setOperationKey(newOpe); + roleOperationDefaultDao.insert(entity); + } + } + + /** + * 查询默认的 + * @param roleKey + * @param operationKey + * @return + */ + @Override + public List listOpeDefaultScopes4Role(String roleKey, String operationKey) { + return operationScopeDefaultDao.listOpeDefaultScopes4Config(roleKey, operationKey); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void saveOpeDefaultScopes(String roleKey, String operationKey, List submitScopeKeys) { + List exists = operationScopeDefaultDao.listOpeDefaultScopesByRoleAndOpeKey(roleKey, operationKey); + + Set existsScopeKeys = exists.stream().map(ope -> ope.getScopeKey()).collect(Collectors.toSet()); + + // 删掉的 + Set deleteds = existsScopeKeys.stream().filter(esk -> !submitScopeKeys.contains(esk)).collect(Collectors.toSet()); + // 新增的 + Set addeds = submitScopeKeys.stream().filter(ssk -> !existsScopeKeys.contains(ssk)).collect(Collectors.toSet()); + + for (String scopeKey : deleteds) { + operationScopeDefaultDao.delete(roleKey, operationKey, scopeKey); + } + + for (String scopeKey : addeds) { + OperationScopeDefaultEntity entity = new OperationScopeDefaultEntity(); + entity.setOperationKey(operationKey); + entity.setRoleKey(roleKey); + entity.setScopeKey(scopeKey); + operationScopeDefaultDao.insert(entity); + } + } + + /** + * @Description 给角色添加操作权限和操作范围 + * @return + * @author wxz + * @date 2020.11.17 17:41 + */ + @Override + public void addOpeAndScopes4Role(String roleKey, String operationKey, List scopeKeys) { + Result> rolesResult = epmetUserOpenFeignClient.listRolesByRoleKey(roleKey); + if (!rolesResult.success()) { + String msg = "调用user服务,根据key查询角色列表失败"; + throw new RenException(EpmetErrorCode.USER_LIST_ROLES_BY_KEY_FAIL.getCode(), msg, msg, + RenException.MessageMode.CODE_INTERNAL_EXTERNAL.CODE_INTERNAL_EXTERNAL); + } + + List roles = rolesResult.getData(); + List roleIds2Add = roles.stream().map(GovStaffRoleResultDTO::getRoleId).collect(Collectors.toList()); + addOpeAndScopes4Role(roleIds2Add, operationKey, scopeKeys); + } + + /** + * @Description 将默认的角色操作和范围同步给具体的角色 + * @return + * @author wxz + * @date 2020.11.17 17:38 + */ + @Transactional(rollbackFor = Exception.class) + public void addOpeAndScopes4Role(List roleIds, String operationKey, List scopeKeys) { + for (String roleId : roleIds) { + // 只给没有添加该权限的用户赋予该权限,已经添加了和添加了又取消的不操作 + RoleOperationEntity roleOpe = roleOperationDao.getRoleOpe(roleId, operationKey); + boolean needRefreshCache = false; + if (roleOpe == null) { + // 没有该操作,则添加 + RoleOperationEntity roleOperation = new RoleOperationEntity(); + roleOperation.setOperationKey(operationKey); + roleOperation.setRoleId(roleId); + roleOperationDao.insert(roleOperation); + needRefreshCache = true; + } + for (String scopeKey : scopeKeys) { + // 没有的话则添加 + RoleScopeEntity roleScopeInDb = roleScopeDao.getByRoleIdAndOpeKey(roleId, operationKey, scopeKey); + if (roleScopeInDb == null) { + RoleScopeEntity roleScopeEntity = new RoleScopeEntity(); + roleScopeEntity.setOperationKey(operationKey); + roleScopeEntity.setRoleId(roleId); + roleScopeEntity.setScopeKey(scopeKey); + roleScopeDao.insert(roleScopeEntity); + needRefreshCache = true; + } + } + + // 清空角色的权限缓存 + if (needRefreshCache) { + roleOpeScopeRedis.delRoleAllOpeScopes(roleId); + } + } + } +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java new file mode 100644 index 0000000000..25afa314fa --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java @@ -0,0 +1,597 @@ +package com.epmet.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import com.epmet.bean.OpeScopeFilterResultBean; +import com.epmet.commons.tools.constant.AppClientConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.security.dto.GovTokenDto; +import com.epmet.commons.tools.security.user.LoginUserUtil; +import com.epmet.commons.tools.utils.CpUserDetailRedis; +import com.epmet.commons.tools.utils.Result; +import com.epmet.constant.OperationScopeConstant; +import com.epmet.dao.OperationScopeDao; +import com.epmet.dto.CustomerAgencyDTO; +import com.epmet.dto.GovStaffRoleDTO; +import com.epmet.dto.form.GetSQLFilterFormDTO; +import com.epmet.dto.form.StaffRoleFormDTO; +import com.epmet.dto.result.LoginUserDetailsResultDTO; +import com.epmet.dto.result.RoleOpeScopeResultDTO; +import com.epmet.feign.EpmetUserFeignClient; +import com.epmet.feign.GovOrgFeignClient; +import com.epmet.redis.RoleOpeScopeRedis; +import com.epmet.service.AccessService; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.*; +import java.util.stream.Collectors; + +@Service +public class AccessServiceImpl implements AccessService { + + private static Logger logger = LoggerFactory.getLogger(AccessServiceImpl.class); + + /** + * 线程变量,记录是否已经添加了至少一个过滤条件 + */ + private static final ThreadLocal hasConditions = new ThreadLocal(); + + @Autowired + private CpUserDetailRedis cpUserDetailRedis; + + @Autowired + private OperationScopeDao operationScopeDao; + + @Autowired + private RoleOpeScopeRedis roleOpeScopeRedis; + + @Autowired + private GovOrgFeignClient govOrgFeignClient; + + @Autowired + private EpmetUserFeignClient userFeignClient; + + @Autowired + private LoginUserUtil loginUserUtil; + + public static final String ORG_RELATION_SAME = "same"; + public static final String ORG_RELATION_SUB = "sub"; + public static final String ORG_RELATION_SUP = "sup"; + public static final String ORG_PATH_SEPARATOR = ":"; + + @Override + public LoginUserDetailsResultDTO getLoginUserDetails(String app, String client, String staffId) { + return cpUserDetailRedis.get(app, client, staffId, LoginUserDetailsResultDTO.class); + } + + @Override + public List listAllRoleOperationScopesByRoleId(String roleId) { + List roleAllOpeScopes = roleOpeScopeRedis.getRoleAllOpeScopes(roleId); + if (roleAllOpeScopes == null) { + roleAllOpeScopes = operationScopeDao.listAllRoleOperationScopesByRoleId(roleId); + roleOpeScopeRedis.setRoleAllOpeScopes(roleId, roleAllOpeScopes); + } + return roleAllOpeScopes; + } + + @Override + public Boolean hasPermission(String operationKey, String userId, String app, String client) { + if (!AppClientConstant.APP_GOV.equals(app)) { + // 如果不是gov,那么不判断权限,放行 + return true; + } + + LoginUserDetailsResultDTO userDetails = getLoginUserDetails(app, client, userId); + if (userDetails == null) { + return false; + } + List roleList = userDetails.getRoleList(); + if (CollectionUtils.isEmpty(roleList)) { + return false; + } + + final Set operationKeys = new HashSet<>(); + + roleList.stream().forEach(role -> { + List opeAndScopes = listAllRoleOperationScopesByRoleId(role.getId()); + operationKeys.addAll(opeAndScopes.stream().map(opeAndScope -> opeAndScope.getOperationKey()).collect(Collectors.toSet())); + }); + + if (operationKeys.contains(operationKey)) { + return true; + } + return false; + } + + @Override + public String getSqlFilterSegment(GetSQLFilterFormDTO form) { + hasConditions.set(false); + LoginUserDetailsResultDTO userDetails = getLoginUserDetails(form.getApp(), form.getClient(), form.getUserId()); + if (userDetails == null) { + logger.error("查询SQL过滤脚本:没有找到用户的登陆信息:app: {}, client: {}, userId:{}", form.getApp(), form.getClient(), form.getUserId()); + throw new RenException(EpmetErrorCode.ERR10006.getCode()); + } + + StringBuilder sb = new StringBuilder(); + + if (CollectionUtils.isEmpty(userDetails.getRoleList())) { + //logger.warn("用户{}没有配置任何角色,无法执行{}操作", form.getUserId(), form.getOperationKey()); + throw new RenException(String.format("用户%s没有配置任何角色,无法执行%s操作", form.getUserId(), form.getOperationKey())); + } + + OpeScopeFilterResultBean effectiveOpeScopes = getEffectiveOpeScopes(userDetails.getRoleList(), form.getOperationKey()); + if (effectiveOpeScopes.isAllScopes()) { + return sb.toString(); + } + + HashSet orgLevelScopes = effectiveOpeScopes.getOrgLevelScopes(); + Set switchScopes = effectiveOpeScopes.getSwitchScopes(); + + // 生成组织上下级关系系列的sql过滤片段 + if (!CollectionUtil.isEmpty(orgLevelScopes) && !orgLevelScopes.contains(OperationScopeConstant.SCOPE_ORG_ALL)) { + genOrgLevelScopeSqlFilter(sb, orgLevelScopes, userDetails.getOrgIdPath(), form.getTableAlias()); + } + + // 生成开关范围的sql过滤器 + if (!CollectionUtil.isEmpty(switchScopes)) { + genSwitchScopeSqlFilter(switchScopes, sb, form.getTableAlias(), userDetails.getUserId(), form.getGridIds(), form.getDepartmentIds()); + } + + return sb.toString(); + } + + /** + * 生成开关系列范围sql过滤片段 + * @param switchScopes + */ + private void genSwitchScopeSqlFilter(Set switchScopes, + StringBuilder sb, + String tableAlias, + String userId, + Set gridIds, + Set departmentIds) { + + if (switchScopes.contains(OperationScopeConstant.SCOPE_I_CREATED)) { + genICreatedSql(sb, userId, tableAlias); + } + + if (switchScopes.contains(OperationScopeConstant.SCOPE_IN_GRID)) { + if (gridIds == null) { + String error = String.format("DataFilter:拼接SQL语句出错:需要in grid权限,但是代码中没有获取到gridIds"); + logger.error(error); + throw new RenException(error); + } + if (gridIds.size() != 0) { + genInGrid(sb, gridIds, tableAlias); + } + } + + if (switchScopes.contains(OperationScopeConstant.SCOPE_IN_DEPARTMENT)) { + if (departmentIds == null) { + String error = String.format("DataFilter:拼接SQL语句出错:需要in department权限,但是代码中没有获取到, departmentIds"); + logger.error(error); + throw new RenException(error); + } + if (departmentIds.size() != 0) { + genDepartmentFilterSql(sb, departmentIds, tableAlias); + } + } + } + + /** + * sql:我发起的 + * + * @param userId + */ + private void genICreatedSql(StringBuilder sb, String userId, String tableAlias) { + if (StringUtils.isBlank(tableAlias)) { + sb.append(hasConditions.get() ? " OR " : " ").append(" CREATED_BY ='").append(userId).append("'"); + } else { + sb.append(hasConditions.get() ? " OR " : " ").append(tableAlias).append(".CREATED_BY ='").append(userId).append("'"); + } + hasConditions.set(true); + } + + /** + * 网格sql + * + * @param sb + * @param tableAlias + */ + private void genInGrid(StringBuilder sb, Set gridIds, String tableAlias) { + if (hasConditions.get()) { + // 之前没有条件 + sb.append(" OR "); + } + + // OR GRID_ID = 'XXX' OR GRID_ID = 'QQQ' OR + + for (String gridId : gridIds) { + if (StringUtils.isBlank(tableAlias)) { + sb.append(" GRID_ID = '").append(gridId).append("' OR "); + } else { + sb.append(" ").append(tableAlias).append(".GRID_ID ='").append(gridId).append("' OR "); + } + } + + int lastOrIndex = sb.lastIndexOf("OR"); + sb.replace(lastOrIndex, lastOrIndex + "OR".length(), "" ); + + hasConditions.set(true); + } + + /** + * sql语句拼接FALSE + * @param sb + */ + private void genFalseCondition(StringBuilder sb) { + if (hasConditions.get()) { + // 之前没有条件 + sb.append(" OR "); + } + + sb.append(" FALSE "); + + hasConditions.set(true); + } + + /** + * 生成部门过滤sql + * + * @param sb + */ + private void genDepartmentFilterSql(StringBuilder sb, Set deptIds, String tableAlias) { + //Result> deptListResult = govOrgFeignClient.getDepartmentListByStaffId(staffId); + if (hasConditions.get()) { + // 之前没有条件 + sb.append(" OR "); + } + + for (String deptId : deptIds) { + if (StringUtils.isBlank(tableAlias)) { + sb.append(" DEPARTMENT_ID = '").append(deptId).append("' OR "); + } else { + sb.append(" ").append(tableAlias).append(".DEPARTMENT_ID ='").append(deptId).append("' OR "); + } + } + + int lastOrIndex = sb.lastIndexOf("OR"); + sb.replace(lastOrIndex, lastOrIndex + "OR".length(), "" ); + + hasConditions.set(true); + } + + /** + * 计算有效操作范围 + */ + public OpeScopeFilterResultBean getEffectiveOpeScopes(List roles, String reqiurePermission) { + + // 根据角色列表查询操作范围列表 + Set opeAndScopesOfThisOperation = new HashSet<>(); + roles.forEach(role -> { + List opes = listAllRoleOperationScopesByRoleId(role.getId()); + if (!CollectionUtils.isEmpty(opes)) { + opes.forEach(ope -> { + if (reqiurePermission.equals(ope.getOperationKey())) { + // 拿到当前操作对应的 RoleOpeScopeResultDTO + opeAndScopesOfThisOperation.add(ope); + } + }); + } + }); + + // 过滤范围 + return filteAndGroupScopes(opeAndScopesOfThisOperation); + } + + /** + * 对范围进行过滤和分组 + * + * @param scopeDTOS + * @return + */ + private OpeScopeFilterResultBean filteAndGroupScopes(Set scopeDTOS) { + // 存储上下级关系系列范围。先放到Map是为了去重和中途判断 + HashMap orgLevelScopes = new HashMap<>(); + + // 存储开关系列范围 + Set switchScopes = new HashSet<>(); + + // 所有范围 + Boolean all = false; + + for (RoleOpeScopeResultDTO scope : scopeDTOS) { + + if (OperationScopeConstant.SCOPE_ALL.equals(scope.getScopeKey())) { + all = true; + break; + } + + if (OperationScopeConstant.SERIES_SWITCH.equals(scope.getSeries())) { + switchScopes.add(scope.getScopeKey()); + continue; + } + + String scopeIndex = scope.getScopeIndex(); + if (OperationScopeConstant.SCOPE_ORG_ALL.equals(scope.getScopeKey())) { + // 该操作具有org_all的权限,直接放入 + orgLevelScopes.put(scopeIndex, scope); + continue; + } + + String[] currArr = scopeIndex.split("_"); + if ("0".equals(currArr[1])) { + // 为0,说明没有包含关系,直接放入 + orgLevelScopes.put(scopeIndex, scope); + continue; + } + + RoleOpeScopeResultDTO tempScope = orgLevelScopes.get(currArr[0]); + if (tempScope != null) { + // 已经有ac开头的了 + String tempScopeIndex = tempScope.getScopeIndex(); + if (Integer.valueOf(currArr[1]) < Integer.valueOf(tempScopeIndex.split("_")[1])) { + orgLevelScopes.put(currArr[0], scope); + } + } else { + orgLevelScopes.put(currArr[0], scope); + } + } + HashSet scopeStrs = new HashSet<>(); + Set> entries = orgLevelScopes.entrySet(); + for (Map.Entry entry : entries) { + scopeStrs.add(entry.getValue().getScopeKey()); + } + OpeScopeFilterResultBean resultBean = new OpeScopeFilterResultBean(); + resultBean.setOrgLevelScopes(scopeStrs); + resultBean.setSwitchScopes(switchScopes); + resultBean.setAllScopes(all); + return resultBean; + } + + /** + * 生成组织上下级关系系列的sql过滤片段 + * @param sb + * @param orgIdPath + * @param tableAlias + * @return + */ + private void genOrgLevelScopeSqlFilter(StringBuilder sb, HashSet scopes, String orgIdPath, String tableAlias) { + // 取出父组织ID path 和当前组织ID + //String parentOrgIDPath = orgIdPath.substring(0, orgIdPath.lastIndexOf(orgIdPathSpliter)); + //String currOrgID = orgIdPath.substring(orgIdPath.lastIndexOf(orgIdPathSpliter) + 1); + + for (String scope : scopes) { + switch (scope) { + // 当前单位(可以用ORG_ID_PATH,也可以用ORG_ID判断) + case OperationScopeConstant.SCOPE_ORG_CURR: + if (StringUtils.isBlank(tableAlias)) { + sb.append(" ORG_ID_PATH = '").append(orgIdPath).append("' OR "); + //sb.append(" ORG_ID = '").append(currOrgID).append("' OR "); + } else { + sb.append(" ").append(tableAlias).append(".ORG_ID_PATH = '").append(orgIdPath).append("' OR "); + //sb.append(" ").append(tableAlias).append(".ORG_ID = '").append(currOrgID).append("' OR "); + } + break; + // 本单位及其子级单位 + case OperationScopeConstant.SCOPE_ORG_CURR_AND_SUB: + if (StringUtils.isBlank(tableAlias)) { + sb.append(" ORG_ID_PATH like '").append(orgIdPath).append("%' OR "); + } else { + sb.append(" ").append(tableAlias).append(".ORG_ID_PATH like '").append(orgIdPath).append("%' OR "); + } + break; + // 本单位的子级单位 + case OperationScopeConstant.SCOPE_ORG_CURR_SUB: + if (StringUtils.isBlank(tableAlias)) { + sb.append(" ORG_ID_PATH like '").append(orgIdPath).append(":%' OR "); + } else { + sb.append(" ").append(tableAlias).append(".ORG_ID_PATH like '").append(orgIdPath).append(":%' OR "); + } + break; + //当前单位的父级单位 + case OperationScopeConstant.SCOPE_ORG_CURR_SUP: + if (StringUtils.isBlank(tableAlias)) { + sb.append(" '").append(orgIdPath).append("' like CONCAT(").append("ORG_ID_PATH,':%') OR "); + } else { + sb.append(" '").append(orgIdPath).append("' like CONCAT(").append(tableAlias).append(".ORG_ID_PATH,':%') OR "); + } + break; + // 当前单位及其父级单位 + case OperationScopeConstant.SCOPE_ORG_CURR_AND_SUP: + if (StringUtils.isBlank(tableAlias)) { + sb.append(" '").append(orgIdPath).append("' like CONCAT(").append("ORG_ID_PATH,'%') OR "); + } else { + sb.append(" '").append(orgIdPath).append("' like CONCAT(").append(tableAlias).append(".ORG_ID_PATH,'%' ) OR "); + } + break; + case OperationScopeConstant.SCOPE_ORG_EQUAL: + // todo 同级 + //sb.append(" OR "); + break; + case OperationScopeConstant.SCOPE_ORG_EQUAL_AND_SUB: + // todo 同级及其子级 + //sb.append(" OR "); + break; + case OperationScopeConstant.SCOPE_ORG_EQUAL_SUB: + // todo 同级的子级 + //sb.append(" OR "); + break; + case OperationScopeConstant.SCOPE_ORG_EQUAL_AND_SUP: + // todo 同级及其上级 + //sb.append(" OR "); + break; + case OperationScopeConstant.SCOPE_ORG_EQUAL_SUP: + // todo 同级的上级 + //sb.append(" OR "); + break; + } + } + + sb.replace(sb.lastIndexOf("OR"), sb.lastIndexOf("OR") + 3, ""); + hasConditions.set(true); + } + + @Override + public Set listOperationPermissions(String staffId, String currAgencyId) { + + LoginUserDetailsResultDTO userDetails = getLoginUserDetails(loginUserUtil.getLoginUserApp(), loginUserUtil.getLoginUserClient(), loginUserUtil.getLoginUserId()); + if (userDetails == null) { + throw new RenException(EpmetErrorCode.ERR10006.getCode(), EpmetErrorCode.ERR10006.getMsg()); + } + + // 1.拿到所属组织机构信息 + String belongAgencyId = getBelongAgencyFromOrgIdPath(userDetails.getOrgIdPath()); + Result belongAgencyRst = govOrgFeignClient.getAgencyById(belongAgencyId); + if (!belongAgencyRst.success()) { + throw new RenException("查询用户的操作权限列表:调用GovOrg,根据belongAgencyId查询机构信息失败:".concat(belongAgencyRst.getInternalMsg())); + } + + CustomerAgencyDTO belongAgency = belongAgencyRst.getData(); + + //Result agencyByStaffRst = govOrgFeignClient.getAgencyByStaff(staffId); + //if (!agencyByStaffRst.success()) { + // logger.error("根据StaffId查询所属单位出错,StaffId:{}, 错误信息:{}", staffId, agencyByStaffRst.getMsg()); + // throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + //} + //CustomerAgencyDTO belongAgency = agencyByStaffRst.getData(); + //if (belongAgency == null) { + // logger.error("根据StaffId查询所属单位结果为空,StaffId:{}", staffId); + // throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + //} + + // 2.拿到当前所处机关单位信息 + Result currAgencyRst = govOrgFeignClient.getAgencyById(currAgencyId); + CustomerAgencyDTO currAgencyDto = currAgencyRst.getData(); + if (!currAgencyRst.success() || currAgencyDto == null) { + throw new RenException(String.format("根据当前机构id[%s]查询pids失败:%s", currAgencyId, currAgencyRst.getMsg())); + } + + // 获取机关单位中的角色 + // 目前一个人只在一个单位下,所以不动态查询,如果后面需要一个人在多个单位,再改这里 + //List roleDTOS = queryGovStaffRoles(staffId, belongAgency.getId()); + List roleList = userDetails.getRoleList(); + + // 当前组织和所属组织的orgId路径,以及他们的上下级关系 + String belongOrgIdPath = getOrgIdPath(belongAgency); + String currOrgIdPath = getOrgIdPath(currAgencyDto); + String currOrgRelation = getCurrOrgRelation(belongOrgIdPath, currOrgIdPath); + + Set filtedOps = new HashSet<>(); + + if (!CollectionUtils.isEmpty(roleList)) { + roleList.forEach(role -> { + List opeAndScopeDTO = listAllRoleOperationScopesByRoleId(role.getId()); + filtedOps.addAll(filterOpesByScope(currOrgRelation, opeAndScopeDTO)); + }); + } + return filtedOps; + } + + /** + * 从OrgIdPath中取所属机构(即最后一截) + * @param orgIdPath + * @return + */ + private String getBelongAgencyFromOrgIdPath(String orgIdPath) { + if (!orgIdPath.contains(ORG_PATH_SEPARATOR)) { + return orgIdPath; + } + return orgIdPath.substring(orgIdPath.lastIndexOf(ORG_PATH_SEPARATOR) + 1); + } + + /** + * 获取当前所处机关与所属机关的关系 + */ + private String getCurrOrgRelation(String belongOrgPath, String currAgencyPath) { + if (belongOrgPath.equals(currAgencyPath)) { + // 当前机关即该人员所属机关 + return ORG_RELATION_SAME; + } else if (currAgencyPath.indexOf(belongOrgPath.concat(":")) > -1) { + // 说明当前所在机关是人员所属机关子级,只取出scope为sub的 + return ORG_RELATION_SUB; + } else if (belongOrgPath.indexOf(currAgencyPath.concat(":")) > -1) { + // 说明当前所在机关是人员所属机关的上级 + return ORG_RELATION_SUP; + } + return belongOrgPath; + } + + /** + * 获取组织的orgId路径 + */ + public String getOrgIdPath(CustomerAgencyDTO agency) { + // 拼接单位ID全路径 + if ("0".equals(agency.getPid())) { + // 顶级组织 + return agency.getId(); + } else { + return agency.getPids().concat(":").concat(agency.getId()); + } + } + + public List queryGovStaffRoles(String staffId, String orgId) { + List roleDTOS = new ArrayList<>(); + StaffRoleFormDTO formDTO = new StaffRoleFormDTO(); + formDTO.setStaffId(staffId); + formDTO.setOrgId(orgId); + Result> gridResult = userFeignClient.getRolesOfStaff(formDTO); + if (!CollectionUtils.isEmpty(gridResult.getData())) { + roleDTOS.addAll(gridResult.getData()); + } + return roleDTOS; + } + + /** + * 根据上下级关系过滤出要返回的权限列表 + * + * @param currOrgRelation + * @param roleOperations + * @return + */ + private HashSet filterOpesByScope(String currOrgRelation, List roleOperations) { + HashSet opeKeys = new HashSet<>(); + for (RoleOpeScopeResultDTO opeScope : roleOperations) { + String scopeKey = opeScope.getScopeKey(); + if (OperationScopeConstant.SCOPE_ORG_ALL.equals(scopeKey) || OperationScopeConstant.SCOPE_ALL.equals(scopeKey)) { + // 如果该操作的范围是org_all或者all,不需要根据上下级关系判断,直接返回即可。 + opeKeys.add(opeScope.getOperationKey()); + continue; + } + + if (!opeScope.getSeries().equals(OperationScopeConstant.SERIES_ORG_LEVEL)) { + opeKeys.add(opeScope.getOperationKey()); + continue; + } + + switch (currOrgRelation) { + case ORG_RELATION_SAME:// 就在所在机构下 + if (OperationScopeConstant.SCOPE_ORG_CURR.equals(scopeKey) + || OperationScopeConstant.SCOPE_ORG_CURR_AND_SUB.equals(scopeKey) + || OperationScopeConstant.SCOPE_ORG_CURR_AND_SUP.equals(scopeKey)) { + opeKeys.add(opeScope.getOperationKey()); + } + break; + case ORG_RELATION_SUB:// 所在机构的子级 + if (OperationScopeConstant.SCOPE_ORG_CURR_SUB.equals(scopeKey) + || OperationScopeConstant.SCOPE_ORG_CURR_AND_SUB.equals(scopeKey)) { + opeKeys.add(opeScope.getOperationKey()); + } + break; + case ORG_RELATION_SUP:// 所在机构的上级 + if (OperationScopeConstant.SCOPE_ORG_CURR_SUP.equals(scopeKey) + || OperationScopeConstant.SCOPE_ORG_CURR_AND_SUP.equals(scopeKey)) { + opeKeys.add(opeScope.getOperationKey()); + } + break; + } + } + return opeKeys; + } + +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/GovLanguageServiceImpl.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/GovLanguageServiceImpl.java new file mode 100644 index 0000000000..43e21684ef --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/GovLanguageServiceImpl.java @@ -0,0 +1,121 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.dao.GovLanguageDao; +import com.epmet.dto.GovLanguageDTO; +import com.epmet.entity.GovLanguageEntity; +import com.epmet.redis.GovLanguageRedis; +import com.epmet.service.GovLanguageService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 国际化 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@Service +public class GovLanguageServiceImpl extends BaseServiceImpl implements GovLanguageService { + + @Autowired + private GovLanguageRedis govLanguageRedis; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, GovLanguageDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, GovLanguageDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public GovLanguageDTO get(String id) { + GovLanguageEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, GovLanguageDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(GovLanguageDTO dto) { + GovLanguageEntity entity = ConvertUtils.sourceToTarget(dto, GovLanguageEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(GovLanguageDTO dto) { + GovLanguageEntity entity = ConvertUtils.sourceToTarget(dto, GovLanguageEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public void saveOrUpdate(String tableName, String tableId, String fieldName, String fieldValue, String language) { + GovLanguageEntity entity = new GovLanguageEntity(); + entity.setTableName(tableName); + entity.setTableId(tableId); + entity.setFieldName(fieldName); + entity.setFieldValue(fieldValue); + entity.setLanguage(language); + + //判断是否有数据 + if(baseDao.getLanguage(entity) == null){ + baseDao.insertOperLanguageEntity(entity); + }else { + baseDao.updateLanguage(entity); + } + } + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/GovMenuServiceImpl.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/GovMenuServiceImpl.java new file mode 100644 index 0000000000..5a6efd43f2 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/GovMenuServiceImpl.java @@ -0,0 +1,247 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.Constant; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.exception.ErrorCode; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.HttpContextUtils; +import com.epmet.commons.tools.utils.TreeUtils; +import com.epmet.dao.GovMenuDao; +import com.epmet.dto.GovMenuDTO; +import com.epmet.entity.GovMenuEntity; +import com.epmet.enums.MenuTypeEnum; +import com.epmet.feign.EpmetUserFeignClient; +import com.epmet.redis.GovMenuRedis; +import com.epmet.service.GovLanguageService; +import com.epmet.service.GovMenuService; +import com.epmet.service.GovResourceService; +import com.epmet.service.GovRoleMenuService; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; + +/** + * 菜单管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@Service +public class GovMenuServiceImpl extends BaseServiceImpl implements GovMenuService { + protected Logger logger = LoggerFactory.getLogger(getClass()); + @Autowired + private GovMenuRedis govMenuRedis; + @Autowired + private EpmetUserFeignClient epmetUserFeignClient; + @Autowired + private GovRoleMenuService govRoleMenuService; + @Autowired + private GovResourceService govResourceService; + @Autowired + private GovLanguageService govLanguageService; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, GovMenuDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, GovMenuDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public GovMenuDTO get(String id) { + GovMenuEntity entity = baseDao.getById(id, HttpContextUtils.getLanguage()); + + return ConvertUtils.sourceToTarget(entity, GovMenuDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(GovMenuDTO dto, TokenDto tokenDto) { + GovMenuEntity entity = ConvertUtils.sourceToTarget(dto, GovMenuEntity.class); + + //保存菜单 + insert(entity); + saveLanguage(entity.getId(), "name", entity.getName()); + + //保存菜单资源 + govResourceService.saveMenuResource(entity.getId(), entity.getName(), dto.getResourceList()); + + //清空当前用户,菜单导航、权限标识 + govMenuRedis.delete(tokenDto.getUserId(), tokenDto.getApp(), tokenDto.getClient()); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(GovMenuDTO dto, TokenDto tokenDto) { + GovMenuEntity entity = ConvertUtils.sourceToTarget(dto, GovMenuEntity.class); + + //上级菜单不能为自身 + if(entity.getId().equals(entity.getPid())){ + throw new RenException(ErrorCode.SUPERIOR_MENU_ERROR); + } + + //更新菜单 + updateById(entity); + saveLanguage(entity.getId(), "name", entity.getName()); + + //更新菜单资源 + govResourceService.saveMenuResource(entity.getId(), entity.getName(), dto.getResourceList()); + + //清空当前用户,菜单导航、权限标识 + govMenuRedis.delete(tokenDto.getUserId(), tokenDto.getApp(), tokenDto.getClient()); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String id, TokenDto tokenDto) { + //逻辑删除 + baseDao.deleteBatchIds(Collections.singletonList(id)); + //删除角色菜单关系 + govRoleMenuService.deleteByMenuId(id); + + //清空当前用户,菜单导航、权限标识 + govMenuRedis.delete(tokenDto.getUserId(), tokenDto.getApp(), tokenDto.getClient()); + } + + @Override + public List getUserMenuList(TokenDto tokenDto, Integer type) { + List menuList; + +// Result govUserDTOResult = epmetUserFeignClient.info(tokenDto.getUserId()); + +// //系统管理员,拥有最高权限 +// if(govUserDTOResult.getData().getSuperAdmin() == SuperAdminEnum.YES.value()){ + menuList = baseDao.getMenuList(type, HttpContextUtils.getLanguage()); +// }else { +// menuList = baseDao.getUserMenuList(tokenDto.getUserId(), type, HttpContextUtils.getLanguage()); +// } + + List dtoList = ConvertUtils.sourceToTarget(menuList, GovMenuDTO.class); + + return TreeUtils.buildTree(dtoList); + } + + @Override + public List getMenuList(Integer type) { + List menuList = baseDao.getMenuList(type, HttpContextUtils.getLanguage()); + + List dtoList = ConvertUtils.sourceToTarget(menuList, GovMenuDTO.class); + + return TreeUtils.buildTree(dtoList, Constant.OPER_MENU_ROOT); + } + + @Override + public List getUserMenuNavList(TokenDto tokenDto) { + List menuList = govMenuRedis.getUserMenuNavList(tokenDto.getUserId(), tokenDto.getApp(), tokenDto.getClient()); + if(menuList == null){ + menuList = getUserMenuList(tokenDto, MenuTypeEnum.MENU.value()); + + govMenuRedis.setUserMenuNavList(tokenDto.getUserId(), tokenDto.getApp(), tokenDto.getClient(), menuList); + } + + return menuList; + } + + @Override + public Set getUserPermissions(TokenDto tokenDto) { + //用户权限列表 + Set permsSet = govMenuRedis.getUserPermissions(tokenDto.getUserId(), tokenDto.getApp(), tokenDto.getClient()); + if(permsSet != null){ + return permsSet; + } + +// Result govUserDTOResult = epmetUserFeignClient.info(tokenDto.getUserId()); + + //超级管理员,拥有最高权限 + List menuList; +// if(govUserDTOResult.getData().getSuperAdmin() == SuperAdminEnum.YES.value()){ + menuList = baseDao.getMenuList(MenuTypeEnum.BUTTON.value(), HttpContextUtils.getLanguage()); +// }else{ +// menuList = baseDao.getUserMenuList(tokenDto.getUserId(), MenuTypeEnum.BUTTON.value(), HttpContextUtils.getLanguage()); +// } + + permsSet = new HashSet<>(); + for(GovMenuEntity menu : menuList){ + if(StringUtils.isNotBlank(menu.getPermissions())){ + permsSet.add(menu.getPermissions()); + } + } + + //保存到缓存 + govMenuRedis.setUserPermissions(tokenDto.getUserId(), tokenDto.getApp(), tokenDto.getClient(), permsSet); + + return permsSet; + } + + @Override + public List getListPid(String pid) { + List menuList = baseDao.getListPid(pid); + + return ConvertUtils.sourceToTarget(menuList, GovMenuDTO.class); + } + + @Override + public void clearOperUserAccess(String app, String client, String userId) { + //清空当前用户,菜单导航、权限标识 + govMenuRedis.delete(userId, app, client); + logger.info(String.format("运营端用户退出系统%s,清空菜单、权限成功",userId)); + } + + private void saveLanguage(String tableId, String fieldName, String fieldValue){ + govLanguageService.saveOrUpdate("gov_menu", tableId, fieldName, fieldValue, HttpContextUtils.getLanguage()); + } + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/GovResourceServiceImpl.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/GovResourceServiceImpl.java new file mode 100644 index 0000000000..2cb1da7087 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/GovResourceServiceImpl.java @@ -0,0 +1,143 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.enums.ResourceAuthEnum; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.dao.GovResourceDao; +import com.epmet.dto.GovResourceDTO; +import com.epmet.dto.result.MenuResourceDTO; +import com.epmet.entity.GovResourceEntity; +import com.epmet.enums.MenuFlagEnum; +import com.epmet.redis.GovResourceRedis; +import com.epmet.service.GovResourceService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 资源管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@Service +public class GovResourceServiceImpl extends BaseServiceImpl implements GovResourceService { + + @Autowired + private GovResourceRedis govResourceRedis; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, GovResourceDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, GovResourceDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public GovResourceDTO get(String id) { + GovResourceEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, GovResourceDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(GovResourceDTO dto) { + GovResourceEntity entity = ConvertUtils.sourceToTarget(dto, GovResourceEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(GovResourceDTO dto) { + GovResourceEntity entity = ConvertUtils.sourceToTarget(dto, GovResourceEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public void saveMenuResource(String menuId, String menuName, List resourceList) { + //先删除菜单资源关系 + baseDao.deleteByCode(menuId+""); + + //删除缓存 + govResourceRedis.delete(); + + //菜单没有一个资源的情况 + if(CollUtil.isEmpty(resourceList)){ + return ; + } + + //保存菜单资源关系 + for(MenuResourceDTO dto : resourceList){ + GovResourceEntity entity = new GovResourceEntity(); + entity.setResourceCode(menuId+""); + entity.setResourceName(menuName); + entity.setResourceUrl(dto.getResourceUrl()); + entity.setResourceMethod(dto.getResourceMethod()); + entity.setAuthLevel(ResourceAuthEnum.PERMISSIONS_AUTH.value()); + entity.setMenuFlag(MenuFlagEnum.YES.value()); + + //保存 + insert(entity); + } + } + + @Override + public List getMenuResourceList(String menuId) { + List entityList = baseDao.getMenuResourceList(menuId+""); + + return ConvertUtils.sourceToTarget(entityList, MenuResourceDTO.class); + } + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/GovRoleMenuServiceImpl.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/GovRoleMenuServiceImpl.java new file mode 100644 index 0000000000..ec31c69146 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/GovRoleMenuServiceImpl.java @@ -0,0 +1,150 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.dao.GovRoleMenuDao; +import com.epmet.dto.GovRoleMenuDTO; +import com.epmet.entity.GovRoleMenuEntity; +import com.epmet.redis.GovRoleMenuRedis; +import com.epmet.service.GovRoleMenuService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 角色菜单关系 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@Service +public class GovRoleMenuServiceImpl extends BaseServiceImpl implements GovRoleMenuService { + + @Autowired + private GovRoleMenuRedis govRoleMenuRedis; + @Autowired + private GovRoleMenuDao govRoleMenuDao; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, GovRoleMenuDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, GovRoleMenuDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public GovRoleMenuDTO get(String id) { + GovRoleMenuEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, GovRoleMenuDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(GovRoleMenuDTO dto) { + GovRoleMenuEntity entity = ConvertUtils.sourceToTarget(dto, GovRoleMenuEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(GovRoleMenuDTO dto) { + GovRoleMenuEntity entity = ConvertUtils.sourceToTarget(dto, GovRoleMenuEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public List getMenuIdList(String roleId){ + return baseDao.getMenuIdList(roleId); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void saveOrUpdate(String roleId, List menuIdList) { + //先删除角色菜单关系 + deleteByRoleId(roleId); + + //角色没有一个菜单权限的情况 + if(CollUtil.isEmpty(menuIdList)){ + return ; + } + + //保存角色菜单关系 + for(String menuId : menuIdList){ + GovRoleMenuEntity govRoleMenuEntity = new GovRoleMenuEntity(); + govRoleMenuEntity.setMenuId(menuId); + govRoleMenuEntity.setRoleId(roleId); + + //保存 + insert(govRoleMenuEntity); + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteByRoleId(String roleId) { + baseDao.deleteByRoleId(roleId); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteByRoleIds(String[] roleIds) { + govRoleMenuDao.deleteByRoleIds(roleIds); + } + + @Override + public void deleteByMenuId(String menuId) { + baseDao.deleteByMenuId(menuId); + } +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/GovRoleServiceImpl.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/GovRoleServiceImpl.java new file mode 100644 index 0000000000..5810b420e5 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/GovRoleServiceImpl.java @@ -0,0 +1,118 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.dao.GovRoleDao; +import com.epmet.dto.GovRoleDTO; +import com.epmet.entity.GovRoleEntity; +import com.epmet.redis.GovRoleRedis; +import com.epmet.service.GovRoleMenuService; +import com.epmet.service.GovRoleService; +import com.epmet.service.GovRoleUserService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 角色管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@Service +public class GovRoleServiceImpl extends BaseServiceImpl implements GovRoleService { + + @Autowired + private GovRoleRedis govRoleRedis; + @Autowired + private GovRoleMenuService govRoleMenuService; + @Autowired + private GovRoleUserService govRoleUserService; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, GovRoleDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, GovRoleDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + String name = (String)params.get(FieldConstant.NAME_HUMP); + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id).like(StringUtils.isNotBlank(name), FieldConstant.NAME, name); + + return wrapper; + } + + @Override + public GovRoleDTO get(String id) { + GovRoleEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, GovRoleDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(GovRoleDTO dto) { + GovRoleEntity entity = ConvertUtils.sourceToTarget(dto, GovRoleEntity.class); + insert(entity); + //保存角色菜单关系 + govRoleMenuService.saveOrUpdate(entity.getId(), dto.getMenuIdList()); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(GovRoleDTO dto) { + GovRoleEntity entity = ConvertUtils.sourceToTarget(dto, GovRoleEntity.class); + updateById(entity); + //保存角色菜单关系 + govRoleMenuService.saveOrUpdate(entity.getId(), dto.getMenuIdList()); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + + govRoleMenuService.deleteByRoleIds(ids); + + govRoleUserService.deleteByRoleIds(ids); + } + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/GovRoleUserServiceImpl.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/GovRoleUserServiceImpl.java new file mode 100644 index 0000000000..21b796cc3b --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/GovRoleUserServiceImpl.java @@ -0,0 +1,156 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.dao.GovRoleUserDao; +import com.epmet.dto.GovRoleUserDTO; +import com.epmet.entity.GovRoleUserEntity; +import com.epmet.redis.GovRoleUserRedis; +import com.epmet.service.GovRoleUserService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 角色用户关系 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-18 + */ +@Service +public class GovRoleUserServiceImpl extends BaseServiceImpl implements GovRoleUserService { + + @Autowired + private GovRoleUserRedis govRoleUserRedis; + @Autowired + private GovRoleUserDao govRoleUserDao; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, GovRoleUserDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, GovRoleUserDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public GovRoleUserDTO get(String id) { + GovRoleUserEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, GovRoleUserDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(GovRoleUserDTO dto) { + GovRoleUserEntity entity = ConvertUtils.sourceToTarget(dto, GovRoleUserEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(GovRoleUserDTO dto) { + GovRoleUserEntity entity = ConvertUtils.sourceToTarget(dto, GovRoleUserEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void saveOrUpdate(String userId, List roleIdList) { + //先删除角色用户关系 + deleteByUserId(userId); + + //用户没有一个角色权限的情况 + if(CollUtil.isEmpty(roleIdList)){ + return ; + } + + //保存角色用户关系 + for(String roleId : roleIdList){ + GovRoleUserEntity govRoleUserEntity = new GovRoleUserEntity(); + govRoleUserEntity.setUserId(userId); + govRoleUserEntity.setRoleId(roleId); + + //保存 + insert(govRoleUserEntity); + } + } + + @Override + public void deleteByRoleId(String roleId) { + govRoleUserDao.deleteByRoleId(roleId); + } + + @Override + public void deleteByUserId(String userId) { + govRoleUserDao.deleteByUserId(userId); + } + + @Override + public List getRoleIdList(String userId) { + + return baseDao.getRoleIdList(userId); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteByRoleIds(String[] roleIds) { + govRoleUserDao.deleteByRoleIds(roleIds); + } + + @Override + public void deleteByUserIds(String[] userIds) { + govRoleUserDao.deleteByUserIds(userIds); + } + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/OperationScopeServiceImpl.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/OperationScopeServiceImpl.java new file mode 100644 index 0000000000..e582395fe2 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/OperationScopeServiceImpl.java @@ -0,0 +1,101 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.dao.OperationScopeDao; +import com.epmet.dto.OperationScopeDTO; +import com.epmet.entity.OperationScopeEntity; +import com.epmet.service.OperationScopeService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 权限范围表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-24 + */ +@Service +public class OperationScopeServiceImpl extends BaseServiceImpl implements OperationScopeService { + + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, OperationScopeDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, OperationScopeDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public OperationScopeDTO get(String id) { + OperationScopeEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, OperationScopeDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(OperationScopeDTO dto) { + OperationScopeEntity entity = ConvertUtils.sourceToTarget(dto, OperationScopeEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(OperationScopeDTO dto) { + OperationScopeEntity entity = ConvertUtils.sourceToTarget(dto, OperationScopeEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/OperationServiceImpl.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/OperationServiceImpl.java new file mode 100644 index 0000000000..ca28d43d0b --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/OperationServiceImpl.java @@ -0,0 +1,35 @@ +package com.epmet.service.impl; + +import com.epmet.dao.OperationDao; +import com.epmet.entity.OperationEntity; +import com.epmet.service.OperationService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.List; + +@Service +public class OperationServiceImpl implements OperationService { + + @Autowired + private OperationDao operationDao; + + @Override + public List listAllOperations() { + return operationDao.listAllOperationEntities(); + } + + @Transactional + @Override + public void createBatch(ArrayList operations2Create) { + operations2Create.forEach(ope -> operationDao.insert(ope)); + } + + @Transactional + @Override + public void updateBatch(ArrayList operations2Update) { + operations2Update.forEach(ope -> operationDao.updateById(ope)); + } +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/RoleOperationServiceImpl.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/RoleOperationServiceImpl.java new file mode 100644 index 0000000000..28943e74b8 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/RoleOperationServiceImpl.java @@ -0,0 +1,218 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.dao.OperationScopeDefaultDao; +import com.epmet.dao.RoleOperationDao; +import com.epmet.dao.RoleOperationDefaultDao; +import com.epmet.dao.RoleScopeDao; +import com.epmet.dto.RoleOperationDTO; +import com.epmet.dto.form.InitDefaultOperationsFormDTO; +import com.epmet.dto.result.OperationScopeDefaultResultDTO; +import com.epmet.dto.result.RoleOperationDefaultResultDTO; +import com.epmet.dto.result.RoleOperationResultDTO; +import com.epmet.entity.OperationScopeDefaultEntity; +import com.epmet.entity.RoleOperationEntity; +import com.epmet.entity.RoleScopeEntity; +import com.epmet.service.RoleOperationService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import java.util.*; + +/** + * 角色能进行那些操作 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-22 + */ +@Service +public class RoleOperationServiceImpl extends BaseServiceImpl implements RoleOperationService { + + @Autowired + private RoleOperationDefaultDao roleOperationDefaultDao; + + @Autowired + private RoleOperationDao roleOperationDao; + + @Autowired + private OperationScopeDefaultDao operationScopeDefaultDao; + + @Autowired + private RoleScopeDao roleScopeDao; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, RoleOperationDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, RoleOperationDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public RoleOperationDTO get(String id) { + RoleOperationEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, RoleOperationDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(RoleOperationDTO dto) { + RoleOperationEntity entity = ConvertUtils.sourceToTarget(dto, RoleOperationEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(RoleOperationDTO dto) { + RoleOperationEntity entity = ConvertUtils.sourceToTarget(dto, RoleOperationEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public List listOperationsByRoleId(String roleId) { + return baseDao.listOperationsByRoleId(roleId); + } + + @Override + @Transactional + public void initDefaultOperationsForRoles(List roles) { + for (InitDefaultOperationsFormDTO.InitDefaultOpesRoleDTO role : roles) { + String roleId = role.getRoleId(); + String roleKey = role.getRoleKey(); + List defaultOperations = roleOperationDefaultDao.listByRoleKey(roleKey); + if (!CollectionUtils.isEmpty(defaultOperations)) { + // 有的角色并没有配置默认的操作权限,应该忽略 + initDefaultOperationsForRole(roleId, defaultOperations); + initDefaultOperationScopesForRole(roleId, roleKey, defaultOperations); + } + } + } + + /** + * 为某一个角色初始化默认操作权限 + * @param roleId + * @param operations + */ + public void initDefaultOperationsForRole(String roleId, List operations) { + for (RoleOperationDefaultResultDTO operation : operations) { + RoleOperationEntity entity = new RoleOperationEntity(); + entity.setOperationKey(operation.getOperationKey()); + entity.setRoleId(roleId); + roleOperationDao.insert(entity); + } + } + + /** + * 为角色初始化操作范围 + * 传入的map为所有操作的默认操作范围,但是具体要为该角色初始化哪一些操作,是由operations参数决定的,并不是map中所有操作都会被初始化给该role + * @param roleId 角色ID + * @param operations 该角色可以做的操作列表 + */ + public void initDefaultOperationScopesForRole(String roleId, String roleKey, List operations) { + HashMap> opeScopeMap = listDefaultOpeScopesMap(roleKey); + for (RoleOperationDefaultResultDTO operation : operations) { + // 该角色,该操作的操作范围列表 + Set scopeKeys4ThisOpe = opeScopeMap.get(operation.getOperationKey()); + if (!CollectionUtils.isEmpty(scopeKeys4ThisOpe)) { + for (String scopeKey : scopeKeys4ThisOpe) { + RoleScopeEntity roleScopeEntity = new RoleScopeEntity(); + roleScopeEntity.setOperationKey(operation.getOperationKey()); + roleScopeEntity.setRoleId(roleId); + roleScopeEntity.setScopeKey(scopeKey); + roleScopeDao.insert(roleScopeEntity); + } + } + } + } + + private HashMap> listDefaultOpeScopesMap(String roleKey) { + List defaultScopes = operationScopeDefaultDao.listDefaultOpeScopes(roleKey); + return convertScopeDefaultDto2Map(defaultScopes); + } + + /** + * 将默认范围entity转换为map + * @param entities + * @return + */ + private HashMap> convertScopeDefaultEntity2Map(List entities) { + HashMap> map = new HashMap<>(); + for (OperationScopeDefaultEntity entity : entities) { + Set scopes = map.get(entity.getOperationKey()); + if (scopes == null) { + scopes = new HashSet<>(); + map.put(entity.getOperationKey(), scopes); + } + scopes.add(entity.getScopeKey()); + } + return map; + } + + /** + * 将默认范围dto转换为map + * @param dtos + * @return + */ + private HashMap> convertScopeDefaultDto2Map(List dtos) { + HashMap> map = new HashMap<>(); + for (OperationScopeDefaultResultDTO dto : dtos) { + Set scopes = map.get(dto.getOperationKey()); + if (scopes == null) { + scopes = new HashSet<>(); + map.put(dto.getOperationKey(), scopes); + } + scopes.add(dto.getScopeKey()); + } + return map; + } + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/RoleScopeServiceImpl.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/RoleScopeServiceImpl.java new file mode 100644 index 0000000000..bff52f8d64 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/RoleScopeServiceImpl.java @@ -0,0 +1,100 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.dao.RoleScopeDao; +import com.epmet.dto.RoleScopeDTO; +import com.epmet.entity.RoleScopeEntity; +import com.epmet.service.RoleScopeService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 角色能操作哪些范围 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-04-24 + */ +@Service +public class RoleScopeServiceImpl extends BaseServiceImpl implements RoleScopeService { + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, RoleScopeDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, RoleScopeDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public RoleScopeDTO get(String id) { + RoleScopeEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, RoleScopeDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(RoleScopeDTO dto) { + RoleScopeEntity entity = ConvertUtils.sourceToTarget(dto, RoleScopeEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(RoleScopeDTO dto) { + RoleScopeEntity entity = ConvertUtils.sourceToTarget(dto, RoleScopeEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + +} \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/TestServiceImpl.java b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/TestServiceImpl.java new file mode 100644 index 0000000000..99ba370525 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/java/com/epmet/service/impl/TestServiceImpl.java @@ -0,0 +1,16 @@ +package com.epmet.service.impl; + +import com.epmet.commons.tools.annotation.ExternalRequestAuth; +import com.epmet.service.TestService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class TestServiceImpl implements TestService { + + @ExternalRequestAuth + @Override + public void test() { + System.out.println("TestService -> test()"); + } +} diff --git a/gov-access-lb/gov-access-lb-server/src/main/resources/bootstrap.yml b/gov-access-lb/gov-access-lb-server/src/main/resources/bootstrap.yml new file mode 100644 index 0000000000..ba54ae13d4 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/resources/bootstrap.yml @@ -0,0 +1,125 @@ +server: + port: 9999 + servlet: + context-path: /lb + +spring: + main: + allow-bean-definition-overriding: true + application: + name: lb-server + #环境 dev|test|prod + profiles: + active: @spring.profiles.active@ + jackson: + time-zone: GMT+8 + date-format: yyyy-MM-dd HH:mm:ss + redis: + database: @spring.redis.index@ + host: @spring.redis.host@ + port: @spring.redis.port@ + password: @spring.redis.password@ + timeout: 30s + datasource: + druid: + #MySQL + driver-class-name: com.mysql.cj.jdbc.Driver + url: @spring.datasource.druid.url@ + username: @spring.datasource.druid.username@ + password: @spring.datasource.druid.password@ + cloud: + nacos: + discovery: + server-addr: 192.168.1.130:8848 + #nacos的命名空间ID,默认是public + namespace: 6ceab336-d004-4acf-89c6-e121d06f4988 + #不把自己注册到注册中心的地址 + register-enabled: true + ip: @nacos.ip@ + config: + enabled: @nacos.config-enabled@ + server-addr: @nacos.server-addr@ + namespace: @nacos.config.namespace@ + group: @nacos.config.group@ + file-extension: yaml + #指定共享配置,且支持动态刷新 +# ext-config: +# - data-id: datasource.yaml +# group: ${spring.cloud.nacos.config.group} +# refresh: true +# - data-id: common.yaml +# group: ${spring.cloud.nacos.config.group} +# refresh: true + + # 数据迁移工具flyway + flyway: + enabled: @spring.flyway.enabled@ + locations: classpath:db/migration + url: @spring.datasource.druid.url@ + user: @spring.datasource.druid.username@ + password: @spring.datasource.druid.password@ + baseline-on-migrate: true + baseline-version: 0 + + +management: + endpoints: + web: + exposure: + include: "*" + endpoint: + health: + show-details: ALWAYS + +mybatis-plus: + mapper-locations: classpath:/mapper/**/*.xml + #实体扫描,多个package用逗号或者分号分隔 + typeAliasesPackage: com.epmet.entity + global-config: + #数据库相关配置 + db-config: + #主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID"; + id-type: ID_WORKER + #字段策略 IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断" + field-strategy: NOT_NULL + #驼峰下划线转换 + column-underline: true + banner: false + #原生配置 + configuration: + map-underscore-to-camel-case: true + cache-enabled: false + call-setters-on-nulls: true + jdbc-type-for-null: 'null' + +feign: + hystrix: + enabled: true + client: + config: + default: + loggerLevel: BASIC + httpclient: + enabled: true + +hystrix: + command: + default: + execution: + isolation: + thread: + timeoutInMilliseconds: 60000 #缺省为1000 + +ribbon: + ReadTimeout: 300000 + ConnectTimeout: 300000 + +#pageHelper分页插件 +pagehelper: + helper-dialect: mysql + reasonable: false #分页合理化配置,例如输入页码为-1,则自动转化为最小页码1 + +#feign 日志需要该配置 +logging: + level: + com.epmet: debug \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/resources/db/migration/V0.0.1__init.sql b/gov-access-lb/gov-access-lb-server/src/main/resources/db/migration/V0.0.1__init.sql new file mode 100644 index 0000000000..7a51a3f595 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/resources/db/migration/V0.0.1__init.sql @@ -0,0 +1 @@ +select 0; \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/resources/db/migration/V0.0.2__add.sql b/gov-access-lb/gov-access-lb-server/src/main/resources/db/migration/V0.0.2__add.sql new file mode 100644 index 0000000000..7933982d49 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/resources/db/migration/V0.0.2__add.sql @@ -0,0 +1,91 @@ +CREATE TABLE `gov_language` ( + `table_name` varchar(32) NOT NULL COMMENT '表名', + `table_id` varchar(64) NOT NULL COMMENT '表主键', + `field_name` varchar(32) NOT NULL COMMENT '字段名', + `field_value` varchar(200) NOT NULL COMMENT '字段值', + `language` varchar(10) NOT NULL COMMENT '语言', + PRIMARY KEY (`table_name`,`table_id`,`field_name`,`language`) USING BTREE, + KEY `idx_table_id` (`table_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='国际化'; +CREATE TABLE `gov_menu` ( + `id` varchar(64) NOT NULL COMMENT 'id', + `pid` varchar(64) DEFAULT NULL COMMENT '上级ID,一级菜单为0', + `url` varchar(200) DEFAULT NULL COMMENT '菜单URL', + `type` tinyint(3) unsigned DEFAULT NULL COMMENT '类型 0:菜单 1:按钮', + `icon` varchar(50) DEFAULT NULL COMMENT '菜单图标', + `permissions` varchar(32) DEFAULT NULL COMMENT '权限标识,如:sys:menu:save', + `sort` int(11) DEFAULT NULL COMMENT '排序', + `REVISION` int(11) DEFAULT NULL COMMENT '乐观锁', + `DEL_FLAG` int(11) unsigned DEFAULT NULL COMMENT '删除标识 0:未删除 1:删除', + `CREATED_BY` varchar(32) DEFAULT NULL COMMENT '创建者', + `CREATED_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) DEFAULT NULL COMMENT '更新者', + `UPDATED_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `SHOW_FLAG` int(11) NOT NULL DEFAULT '1' COMMENT '是否显示,1:显示 0不显示', + PRIMARY KEY (`id`) USING BTREE, + KEY `idx_pid` (`pid`) USING BTREE, + KEY `idx_del_flag` (`DEL_FLAG`) USING BTREE, + KEY `idx_create_date` (`CREATED_TIME`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='菜单管理'; +CREATE TABLE `gov_resource` ( + `id` varchar(64) NOT NULL COMMENT 'id', + `resource_code` varchar(32) DEFAULT NULL COMMENT '资源编码,如菜单ID', + `resource_name` varchar(32) DEFAULT NULL COMMENT '资源名称', + `resource_url` varchar(100) DEFAULT NULL COMMENT '资源URL', + `resource_method` varchar(8) DEFAULT NULL COMMENT '请求方式(如:GET、POST、PUT、DELETE)', + `menu_flag` tinyint(3) unsigned DEFAULT NULL COMMENT '菜单标识 0:非菜单资源 1:菜单资源', + `auth_level` tinyint(3) unsigned DEFAULT NULL COMMENT '认证等级 0:权限认证 1:登录认证 2:无需认证', + `REVISION` int(11) DEFAULT NULL COMMENT '乐观锁', + `DEL_FLAG` int(11) DEFAULT NULL COMMENT '删除标识 0:未删除 1:删除', + `CREATED_BY` varchar(32) DEFAULT NULL COMMENT '创建者', + `CREATED_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) DEFAULT NULL COMMENT '更新者', + `UPDATED_TIME` datetime DEFAULT NULL COMMENT '更新时间', + PRIMARY KEY (`id`) USING BTREE, + KEY `idx_resource_code` (`resource_code`) USING BTREE, + KEY `idx_create_date` (`CREATED_TIME`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='资源管理'; +CREATE TABLE `gov_role` ( + `id` varchar(64) NOT NULL COMMENT 'id', + `name` varchar(32) DEFAULT NULL COMMENT '角色名称', + `remark` varchar(100) DEFAULT NULL COMMENT '备注', + `REVISION` int(11) DEFAULT NULL COMMENT '乐观锁', + `DEL_FLAG` int(11) unsigned DEFAULT NULL COMMENT '删除标识 0:未删除 1:删除', + `dept_id` bigint(20) DEFAULT NULL COMMENT '部门ID', + `CREATED_BY` varchar(32) DEFAULT NULL COMMENT '创建者', + `CREATED_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) DEFAULT NULL COMMENT '更新者', + `UPDATED_TIME` datetime DEFAULT NULL COMMENT '更新时间', + PRIMARY KEY (`id`) USING BTREE, + KEY `idx_dept_id` (`dept_id`) USING BTREE, + KEY `idx_del_flag` (`DEL_FLAG`) USING BTREE, + KEY `idx_create_date` (`CREATED_TIME`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='角色管理'; +CREATE TABLE `gov_role_menu` ( + `id` varchar(64) NOT NULL COMMENT 'id', + `role_id` varchar(64) DEFAULT NULL COMMENT '角色ID', + `menu_id` varchar(64) DEFAULT NULL COMMENT '菜单ID', + `REVISION` int(11) DEFAULT NULL COMMENT '乐观锁', + `DEL_FLAG` int(11) DEFAULT NULL COMMENT '删除标识 0:未删除 1:删除', + `CREATED_BY` varchar(32) DEFAULT NULL COMMENT '创建者', + `CREATED_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) DEFAULT NULL COMMENT '更新者', + `UPDATED_TIME` datetime DEFAULT NULL COMMENT '更新时间', + PRIMARY KEY (`id`) USING BTREE, + KEY `idx_role_id` (`role_id`) USING BTREE, + KEY `idx_menu_id` (`menu_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='角色菜单关系'; +CREATE TABLE `gov_role_user` ( + `id` varchar(64) NOT NULL COMMENT 'id', + `role_id` varchar(64) DEFAULT NULL COMMENT '角色ID', + `user_id` varchar(64) DEFAULT NULL COMMENT '用户ID', + `REVISION` int(11) DEFAULT NULL COMMENT '乐观锁', + `DEL_FLAG` int(11) DEFAULT NULL COMMENT '删除标识 0:未删除 1:删除', + `CREATED_BY` varchar(32) DEFAULT NULL COMMENT '创建者', + `CREATED_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) DEFAULT NULL COMMENT '更新者', + `UPDATED_TIME` datetime DEFAULT NULL COMMENT '更新时间', + PRIMARY KEY (`id`) USING BTREE, + KEY `idx_role_id` (`role_id`) USING BTREE, + KEY `idx_user_id` (`user_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='角色用户关系'; \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/resources/logback-spring.xml b/gov-access-lb/gov-access-lb-server/src/main/resources/logback-spring.xml new file mode 100644 index 0000000000..45b1ddc4e0 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/resources/logback-spring.xml @@ -0,0 +1,164 @@ + + + + + + + + + + ${appname} + + + + + + + + + debug + + + ${CONSOLE_LOG_PATTERN} + + UTF-8 + + + + + + + + ${log.path}/debug.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + + ${log.path}/debug-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + debug + ACCEPT + DENY + + + + + + + ${log.path}/info.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + + ${log.path}/info-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + info + ACCEPT + DENY + + + + + + + ${log.path}/warn.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${log.path}/warn-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + warn + ACCEPT + DENY + + + + + + + ${log.path}/error.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${log.path}/error-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + ERROR + ACCEPT + DENY + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/GovLanguageDao.xml b/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/GovLanguageDao.xml new file mode 100644 index 0000000000..5b829dc734 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/GovLanguageDao.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + INSERT INTO `gov_language` ( `table_name`, `table_id`, `field_name`, `field_value`, `language` ) + VALUES + ( #{tableName}, #{tableId}, #{fieldName}, #{fieldValue}, #{language} ) + + diff --git a/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/GovMenuDao.xml b/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/GovMenuDao.xml new file mode 100644 index 0000000000..90d0b8ee92 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/GovMenuDao.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + diff --git a/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/GovResourceDao.xml b/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/GovResourceDao.xml new file mode 100644 index 0000000000..8296d14065 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/GovResourceDao.xml @@ -0,0 +1,25 @@ + + + + + + + delete from gov_resource where resource_code = #{value} + + + + + + + + + diff --git a/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/GovRoleDao.xml b/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/GovRoleDao.xml new file mode 100644 index 0000000000..2de28e07bf --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/GovRoleDao.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/GovRoleMenuDao.xml b/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/GovRoleMenuDao.xml new file mode 100644 index 0000000000..862679b5de --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/GovRoleMenuDao.xml @@ -0,0 +1,25 @@ + + + + + + + + + update gov_role_menu set del_flag = 1 where del_flag = 0 and role_id in + + #{roleId} + + + + + update gov_role_menu set del_flag = 1 where role_id = #{value} and del_flag = 0 + + + + update gov_role_menu set del_flag = 1 where menu_id = #{value} and del_flag = 0 + + + diff --git a/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/GovRoleUserDao.xml b/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/GovRoleUserDao.xml new file mode 100644 index 0000000000..b5cb172451 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/GovRoleUserDao.xml @@ -0,0 +1,32 @@ + + + + + + + update gov_role_user set del_flag = 1 where del_flag = 0 and role_id in + + #{roleId} + + + + + update gov_role_user set del_flag = 1 where del_flag = 0 and user_id in + + #{userId} + + + + + update gov_role_user set del_flag = 1 where role_id = #{value} and del_flag = 0 + + + + update gov_role_user set del_flag = 1 where user_id = #{value} and del_flag = 0 + + + + + diff --git a/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/OperationDao.xml b/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/OperationDao.xml new file mode 100644 index 0000000000..824b7a4feb --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/OperationDao.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/OperationScopeDao.xml b/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/OperationScopeDao.xml new file mode 100644 index 0000000000..0591776c96 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/OperationScopeDao.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/OperationScopeDefaultDao.xml b/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/OperationScopeDefaultDao.xml new file mode 100755 index 0000000000..da0ae9597d --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/OperationScopeDefaultDao.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + DELETE + FROM operation_scope_default + WHERE ROLE_KEY = #{roleKey} + AND OPERATION_KEY = #{operationKey} + AND SCOPE_KEY = #{scopeKey} + + + + + + + + + + + + + + \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/RoleOperationDao.xml b/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/RoleOperationDao.xml new file mode 100644 index 0000000000..7009237115 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/RoleOperationDao.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + UPDATE role_operation + SET DEL_FLAG = 1 + WHERE ROLE_ID = #{roleId} + AND OPERATION_KEY = #{opeKey} + + + + + + + UPDATE role_operation + SET DEL_FLAG = 0 + WHERE ROLE_ID = #{roleId} + AND OPERATION_KEY = #{opeKey} + + \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/RoleOperationDefaultDao.xml b/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/RoleOperationDefaultDao.xml new file mode 100755 index 0000000000..98cd9f675b --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/RoleOperationDefaultDao.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + DELETE FROM role_operation_default WHERE ROLE_KEY = #{roleKey} AND OPERATION_KEY = #{operationKey} + + + + + + + + \ No newline at end of file diff --git a/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/RoleScopeDao.xml b/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/RoleScopeDao.xml new file mode 100644 index 0000000000..9a0337a2c7 --- /dev/null +++ b/gov-access-lb/gov-access-lb-server/src/main/resources/mapper/RoleScopeDao.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + DELETE + FROM role_scope + WHERE ROLE_ID = #{roleId} + AND OPERATION_KEY = #{operationKey} + AND SCOPE_KEY IN + + #{scopeKey} + + + + + + DELETE + FROM role_scope + WHERE ROLE_ID = #{roleId} + AND OPERATION_KEY = #{operationKey} + AND SCOPE_KEY = #{scopeKey} + + + + + + + \ No newline at end of file diff --git a/gov-access-lb/pom.xml b/gov-access-lb/pom.xml new file mode 100644 index 0000000000..c7847e4776 --- /dev/null +++ b/gov-access-lb/pom.xml @@ -0,0 +1,21 @@ + + + + epmet-module + com.epmet + 2.0.0 + + 4.0.0 + + gov-access-lb + pom + + + gov-access-lb-client + gov-access-lb-server + + + + \ No newline at end of file