mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 12:56:28 +08:00
5.0
This commit is contained in:
@@ -2,18 +2,20 @@ package com.gitee.sop.adminbackend.controller.isv;
|
||||
|
||||
import com.gitee.fastmybatis.core.PageInfo;
|
||||
import com.gitee.fastmybatis.core.query.LambdaQuery;
|
||||
import com.gitee.fastmybatis.core.query.Query;
|
||||
import com.gitee.fastmybatis.core.query.param.PageParam;
|
||||
import com.gitee.sop.adminbackend.common.RSATool;
|
||||
import com.gitee.sop.adminbackend.common.dto.StatusUpdateDTO;
|
||||
import com.gitee.sop.adminbackend.common.req.StatusUpdateParam;
|
||||
import com.gitee.sop.adminbackend.common.resp.Result;
|
||||
import com.gitee.sop.adminbackend.controller.isv.req.IsvGroupSettingParam;
|
||||
import com.gitee.sop.adminbackend.controller.isv.req.IsvInfoAddParam;
|
||||
import com.gitee.sop.adminbackend.controller.isv.req.IsvInfoUpdateKeysParam;
|
||||
import com.gitee.sop.adminbackend.controller.isv.req.IsvInfoUpdateParam;
|
||||
import com.gitee.sop.adminbackend.controller.isv.req.IsvKeysGenParam;
|
||||
import com.gitee.sop.adminbackend.dao.entity.IsvInfo;
|
||||
import com.gitee.sop.adminbackend.service.isv.IsvInfoService;
|
||||
import com.gitee.sop.adminbackend.service.isv.PermIsvGroupService;
|
||||
import com.gitee.sop.adminbackend.service.isv.dto.IsvGroupSettingDTO;
|
||||
import com.gitee.sop.adminbackend.service.isv.dto.IsvInfoAddDTO;
|
||||
import com.gitee.sop.adminbackend.service.isv.dto.IsvInfoDTO;
|
||||
import com.gitee.sop.adminbackend.service.isv.dto.IsvInfoUpdateDTO;
|
||||
@@ -39,6 +41,8 @@ public class IsvInfoController {
|
||||
|
||||
@Resource
|
||||
private IsvInfoService isvInfoService;
|
||||
@Resource
|
||||
private PermIsvGroupService permIsvGroupService;
|
||||
|
||||
|
||||
/**
|
||||
@@ -130,4 +134,5 @@ public class IsvInfoController {
|
||||
return Result.ok(isvInfoService.updateStatus(statusUpdateDTO));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,92 @@
|
||||
package com.gitee.sop.adminbackend.controller.isv;
|
||||
|
||||
import com.gitee.fastmybatis.core.PageInfo;
|
||||
import com.gitee.fastmybatis.core.query.LambdaQuery;
|
||||
import com.gitee.sop.adminbackend.common.req.IdParam;
|
||||
import com.gitee.sop.adminbackend.common.resp.Result;
|
||||
import com.gitee.sop.adminbackend.controller.isv.req.PermGroupParam;
|
||||
import com.gitee.sop.adminbackend.dao.entity.PermGroup;
|
||||
import com.gitee.sop.adminbackend.service.isv.PermGroupService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
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.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 权限分组
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("perm/group")
|
||||
public class PermGroupController {
|
||||
|
||||
@Resource
|
||||
private PermGroupService permGroupService;
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @return 返回分页结果
|
||||
*/
|
||||
@GetMapping("/listAll")
|
||||
public Result<List<PermGroup>> listAll() {
|
||||
List<PermGroup> list = permGroupService.listAll();
|
||||
return Result.ok(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return 返回分页结果
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public Result<PageInfo<PermGroup>> page(PermGroupParam param) {
|
||||
LambdaQuery<PermGroup> query = param.toLambdaQuery(PermGroup.class);
|
||||
PageInfo<PermGroup> pageInfo = permGroupService.doPage(query);
|
||||
return Result.ok(pageInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增记录
|
||||
*
|
||||
* @param permGroup 表单参数
|
||||
* @return 返回添加后的主键值
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Result<Long> add(@Validated @RequestBody PermGroup permGroup) {
|
||||
permGroupService.save(permGroup);
|
||||
// 返回添加后的主键值
|
||||
return Result.ok(permGroup.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改记录
|
||||
*
|
||||
* @param permGroup 表单数据
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public Result<Integer> update(@Validated @RequestBody PermGroup permGroup) {
|
||||
return Result.ok(permGroupService.update(permGroup));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除记录
|
||||
*
|
||||
* @param param 参数
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public Result<Integer> delete(@Validated @RequestBody IdParam param) {
|
||||
return Result.ok(permGroupService.deleteById(param.getId()));
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
package com.gitee.sop.adminbackend.controller.isv;
|
||||
|
||||
import com.gitee.sop.adminbackend.common.resp.Result;
|
||||
import com.gitee.sop.adminbackend.controller.isv.req.IsvGroupSettingParam;
|
||||
import com.gitee.sop.adminbackend.dao.entity.PermGroup;
|
||||
import com.gitee.sop.adminbackend.service.isv.PermIsvGroupService;
|
||||
import com.gitee.sop.adminbackend.service.isv.dto.IsvGroupSettingDTO;
|
||||
import com.gitee.sop.adminbackend.util.CopyUtil;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
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.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("perm/isv/group")
|
||||
public class PermIsvGroupController {
|
||||
|
||||
@Resource
|
||||
private PermIsvGroupService permIsvGroupService;
|
||||
|
||||
/**
|
||||
* 查询isv分组
|
||||
*
|
||||
* @param isvId isvId
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
@GetMapping("listIsvCode")
|
||||
public Result<List<String>> listIsvGroup(Long isvId) {
|
||||
List<String> permGroups = permIsvGroupService.listIsvGroup(isvId);
|
||||
return Result.ok(permGroups);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置分组
|
||||
*
|
||||
* @param param 表单数据
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
@PostMapping("setting")
|
||||
public Result<Integer> updateIsvGroup(@Validated @RequestBody IsvGroupSettingParam param) {
|
||||
IsvGroupSettingDTO isvGroupSettingDTO = CopyUtil.copyBean(param, IsvGroupSettingDTO::new);
|
||||
int i = permIsvGroupService.updateIsvGroup(isvGroupSettingDTO);
|
||||
return Result.ok(i);
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
package com.gitee.sop.adminbackend.controller.isv.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
public class IsvGroupSettingParam {
|
||||
|
||||
@NotNull
|
||||
private Long isvId;
|
||||
|
||||
private List<String> groupCodeList;
|
||||
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
package com.gitee.sop.adminbackend.controller.isv.req;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.gitee.fastmybatis.core.query.Operator;
|
||||
import com.gitee.fastmybatis.core.query.annotation.Condition;
|
||||
import com.gitee.fastmybatis.core.query.param.PageParam;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 备注:分组表
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class PermGroupParam extends PageParam {
|
||||
|
||||
/**
|
||||
* 分组代码
|
||||
*/
|
||||
@Condition(operator = Operator.like)
|
||||
private String groupCode;
|
||||
|
||||
/**
|
||||
* 分组描述
|
||||
*/
|
||||
@Condition(operator = Operator.like)
|
||||
private String groupName;
|
||||
|
||||
}
|
@@ -4,10 +4,12 @@ import com.gitee.fastmybatis.core.query.Operator;
|
||||
import com.gitee.fastmybatis.core.query.annotation.Condition;
|
||||
import com.gitee.fastmybatis.core.query.param.PageParam;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class ApiInfoParam extends PageParam {
|
||||
|
||||
|
@@ -19,6 +19,9 @@ import lombok.Data;
|
||||
@Data
|
||||
public class ApiInfo {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
@@ -77,12 +80,18 @@ public class ApiInfo {
|
||||
private Integer regSource;
|
||||
|
||||
/**
|
||||
* 1启用,2禁用
|
||||
* 1启用,0禁用
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 添加时间
|
||||
*/
|
||||
private LocalDateTime addTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
|
||||
|
@@ -1,11 +1,12 @@
|
||||
package com.gitee.sop.adminbackend.dao.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.PkStrategy;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
@@ -18,6 +19,9 @@ import java.time.LocalDateTime;
|
||||
@Data
|
||||
public class IsvInfo {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
@@ -35,8 +39,14 @@ public class IsvInfo {
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 添加时间
|
||||
*/
|
||||
private LocalDateTime addTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
|
||||
|
@@ -1,11 +1,12 @@
|
||||
package com.gitee.sop.adminbackend.dao.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.PkStrategy;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
@@ -18,6 +19,9 @@ import java.time.LocalDateTime;
|
||||
@Data
|
||||
public class IsvKeys {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
@@ -50,8 +54,14 @@ public class IsvKeys {
|
||||
*/
|
||||
private String privateKeyPlatform;
|
||||
|
||||
/**
|
||||
* 添加时间
|
||||
*/
|
||||
private LocalDateTime addTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
|
||||
|
@@ -0,0 +1,54 @@
|
||||
package com.gitee.sop.adminbackend.dao.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.PkStrategy;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
* 表名:perm_group
|
||||
* 备注:分组表
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@Table(name = "perm_group", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
|
||||
@Data
|
||||
public class PermGroup {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 分组代码
|
||||
*/
|
||||
private String groupCode;
|
||||
|
||||
/**
|
||||
* 角色描述
|
||||
*/
|
||||
private String groupName;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
@com.gitee.fastmybatis.annotation.Column(logicDelete = true)
|
||||
private Integer isDeleted;
|
||||
|
||||
/**
|
||||
* 添加时间
|
||||
*/
|
||||
private LocalDateTime addTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
|
||||
}
|
@@ -10,29 +10,38 @@ import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
* 表名:perm_role
|
||||
* 备注:角色表
|
||||
* 表名:perm_group_permission
|
||||
* 备注:组权限表
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@Table(name = "perm_role", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
|
||||
@Table(name = "perm_group_permission", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
|
||||
@Data
|
||||
public class PermRole {
|
||||
public class PermGroupPermission {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 角色代码
|
||||
* 分组表code
|
||||
*/
|
||||
private String roleCode;
|
||||
private String groupCode;
|
||||
|
||||
/**
|
||||
* 角色描述
|
||||
* api_info.id
|
||||
*/
|
||||
private String description;
|
||||
private String apiId;
|
||||
|
||||
/**
|
||||
* 添加时间
|
||||
*/
|
||||
private LocalDateTime addTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
|
@@ -10,14 +10,14 @@ import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
* 表名:perm_isv_role
|
||||
* 备注:isv角色
|
||||
* 表名:perm_isv_group
|
||||
* 备注:isv分组
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@Table(name = "perm_isv_role", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
|
||||
@Table(name = "perm_isv_group", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
|
||||
@Data
|
||||
public class PermIsvRole {
|
||||
public class PermIsvGroup {
|
||||
|
||||
private Long id;
|
||||
|
||||
@@ -27,9 +27,9 @@ public class PermIsvRole {
|
||||
private Long isvId;
|
||||
|
||||
/**
|
||||
* 角色code
|
||||
* 组code
|
||||
*/
|
||||
private String roleCode;
|
||||
private String groupCode;
|
||||
|
||||
private LocalDateTime addTime;
|
||||
|
@@ -1,39 +0,0 @@
|
||||
package com.gitee.sop.adminbackend.dao.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.PkStrategy;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
* 表名:perm_role_permission
|
||||
* 备注:角色权限表
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@Table(name = "perm_role_permission", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
|
||||
@Data
|
||||
public class PermRolePermission {
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 角色表code
|
||||
*/
|
||||
private String roleCode;
|
||||
|
||||
/**
|
||||
* api_id
|
||||
*/
|
||||
private String routeId;
|
||||
|
||||
private LocalDateTime addTime;
|
||||
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
|
||||
}
|
@@ -19,6 +19,9 @@ import lombok.Data;
|
||||
@Data
|
||||
public class SysAdminUser {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
@@ -47,17 +50,23 @@ public class SysAdminUser {
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 状态,1:启用,0:禁用
|
||||
* 状态,1:启用,2:禁用
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 注册类型
|
||||
* 注册类型,1-系统,2-手动
|
||||
*/
|
||||
private String regType;
|
||||
|
||||
/**
|
||||
* 添加时间
|
||||
*/
|
||||
private LocalDateTime addTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
|
||||
|
@@ -1,11 +1,11 @@
|
||||
package com.gitee.sop.adminbackend.dao.mapper;
|
||||
|
||||
import com.gitee.fastmybatis.core.mapper.BaseMapper;
|
||||
import com.gitee.sop.adminbackend.dao.entity.PermRole;
|
||||
import com.gitee.sop.adminbackend.dao.entity.PermGroup;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
public interface PermRoleMapper extends BaseMapper<PermRole> {
|
||||
public interface PermGroupMapper extends BaseMapper<PermGroup> {
|
||||
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
package com.gitee.sop.adminbackend.dao.mapper;
|
||||
|
||||
import com.gitee.fastmybatis.core.mapper.BaseMapper;
|
||||
import com.gitee.sop.adminbackend.dao.entity.PermGroupPermission;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
public interface PermGroupPermissionMapper extends BaseMapper<PermGroupPermission> {
|
||||
|
||||
}
|
@@ -1,11 +1,11 @@
|
||||
package com.gitee.sop.adminbackend.dao.mapper;
|
||||
|
||||
import com.gitee.fastmybatis.core.mapper.BaseMapper;
|
||||
import com.gitee.sop.adminbackend.dao.entity.PermIsvRole;
|
||||
import com.gitee.sop.adminbackend.dao.entity.PermIsvGroup;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
public interface PermIsvRoleMapper extends BaseMapper<PermIsvRole> {
|
||||
public interface PermIsvGroupMapper extends BaseMapper<PermIsvGroup> {
|
||||
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
package com.gitee.sop.adminbackend.dao.mapper;
|
||||
|
||||
import com.gitee.fastmybatis.core.mapper.BaseMapper;
|
||||
import com.gitee.sop.adminbackend.dao.entity.PermRolePermission;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
public interface PermRolePermissionMapper extends BaseMapper<PermRolePermission> {
|
||||
|
||||
}
|
@@ -9,8 +9,9 @@ import com.gitee.sop.adminbackend.common.enums.StatusEnum;
|
||||
import com.gitee.sop.adminbackend.common.enums.YesOrNoEnum;
|
||||
import com.gitee.sop.adminbackend.dao.entity.IsvInfo;
|
||||
import com.gitee.sop.adminbackend.dao.entity.IsvKeys;
|
||||
import com.gitee.sop.adminbackend.dao.entity.PermIsvRole;
|
||||
import com.gitee.sop.adminbackend.dao.entity.PermIsvGroup;
|
||||
import com.gitee.sop.adminbackend.dao.mapper.IsvInfoMapper;
|
||||
import com.gitee.sop.adminbackend.service.isv.dto.IsvGroupSettingDTO;
|
||||
import com.gitee.sop.adminbackend.service.isv.dto.IsvInfoAddDTO;
|
||||
import com.gitee.sop.adminbackend.service.isv.dto.IsvInfoDTO;
|
||||
import com.gitee.sop.adminbackend.service.isv.dto.IsvInfoUpdateDTO;
|
||||
@@ -20,6 +21,7 @@ import com.gitee.sop.adminbackend.service.isv.dto.IsvKeysGenDTO;
|
||||
import com.gitee.sop.adminbackend.util.CopyUtil;
|
||||
import com.gitee.sop.adminbackend.util.IdGen;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -29,6 +31,7 @@ import java.util.stream.Collectors;
|
||||
import javax.annotation.Resource;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
|
||||
@@ -42,7 +45,7 @@ public class IsvInfoService implements LambdaService<IsvInfo, IsvInfoMapper> {
|
||||
@Resource
|
||||
private IsvKeysService isvKeysService;
|
||||
@Resource
|
||||
private PermIsvRoleService permIsvRoleService;
|
||||
private PermIsvGroupService permIsvGroupService;
|
||||
|
||||
public PageInfo<IsvInfoDTO> doPage(LambdaQuery<IsvInfo> query) {
|
||||
query.orderByDesc(IsvInfo::getId);
|
||||
@@ -58,6 +61,8 @@ public class IsvInfoService implements LambdaService<IsvInfo, IsvInfoMapper> {
|
||||
.in(IsvKeys::getIsvId, idList)
|
||||
.map(IsvKeys::getIsvId, Function.identity());
|
||||
|
||||
Map<Long, List<String>> isvGroupMap = permIsvGroupService.getIsvGroupNameMap(idList);
|
||||
|
||||
// 格式转换
|
||||
return page.convert(isvInfo -> {
|
||||
IsvInfoDTO isvInfoDTO = CopyUtil.copyBean(isvInfo, IsvInfoDTO::new);
|
||||
@@ -73,6 +78,8 @@ public class IsvInfoService implements LambdaService<IsvInfo, IsvInfoMapper> {
|
||||
);
|
||||
}
|
||||
isvInfoDTO.setHasKeys(YesOrNoEnum.of(hasKey).getValue());
|
||||
List<String> groupNames = isvGroupMap.getOrDefault(isvInfo.getId(), Collections.emptyList());
|
||||
isvInfoDTO.setGroupNames(String.join("/", groupNames));
|
||||
return isvInfoDTO;
|
||||
});
|
||||
}
|
||||
@@ -115,18 +122,18 @@ public class IsvInfoService implements LambdaService<IsvInfo, IsvInfoMapper> {
|
||||
|
||||
private void saveIsvRole(IsvInfo isvInfo, List<String> roleCodeList) {
|
||||
Long isvId = isvInfo.getId();
|
||||
permIsvRoleService.deleteByColumn(PermIsvRole::getIsvId, isvId);
|
||||
permIsvGroupService.deleteByColumn(PermIsvGroup::getIsvId, isvId);
|
||||
|
||||
List<PermIsvRole> tobeSaveList = roleCodeList.stream()
|
||||
.map(roleCode -> {
|
||||
PermIsvRole rec = new PermIsvRole();
|
||||
List<PermIsvGroup> tobeSaveList = roleCodeList.stream()
|
||||
.map(groupCode -> {
|
||||
PermIsvGroup rec = new PermIsvGroup();
|
||||
rec.setIsvId(isvId);
|
||||
rec.setRoleCode(roleCode);
|
||||
rec.setGroupCode(groupCode);
|
||||
return rec;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
permIsvRoleService.saveBatch(tobeSaveList);
|
||||
permIsvGroupService.saveBatch(tobeSaveList);
|
||||
|
||||
// TODO:同步到网关
|
||||
// try {
|
||||
|
@@ -0,0 +1,29 @@
|
||||
package com.gitee.sop.adminbackend.service.isv;
|
||||
|
||||
import com.gitee.fastmybatis.core.PageInfo;
|
||||
import com.gitee.fastmybatis.core.query.LambdaQuery;
|
||||
import com.gitee.fastmybatis.core.support.LambdaService;
|
||||
import com.gitee.sop.adminbackend.dao.entity.PermGroupPermission;
|
||||
import com.gitee.sop.adminbackend.dao.mapper.PermGroupPermissionMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Service
|
||||
public class PermGroupPermissionService implements LambdaService<PermGroupPermission, PermGroupPermissionMapper> {
|
||||
|
||||
public PageInfo<PermGroupPermission> doPage(LambdaQuery<PermGroupPermission> query) {
|
||||
query.orderByDesc(PermGroupPermission::getId);
|
||||
PageInfo<PermGroupPermission> page = this.page(query);
|
||||
|
||||
// 格式转换
|
||||
return page.convert(isvInfo -> {
|
||||
|
||||
return isvInfo;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
package com.gitee.sop.adminbackend.service.isv;
|
||||
|
||||
import com.gitee.fastmybatis.core.PageInfo;
|
||||
import com.gitee.fastmybatis.core.query.LambdaQuery;
|
||||
import com.gitee.fastmybatis.core.support.LambdaService;
|
||||
import com.gitee.sop.adminbackend.dao.entity.PermGroup;
|
||||
import com.gitee.sop.adminbackend.dao.mapper.PermGroupMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Service
|
||||
public class PermGroupService implements LambdaService<PermGroup, PermGroupMapper> {
|
||||
|
||||
public PageInfo<PermGroup> doPage(LambdaQuery<PermGroup> query) {
|
||||
query.orderByDesc(PermGroup::getId);
|
||||
PageInfo<PermGroup> page = this.page(query);
|
||||
|
||||
// 格式转换
|
||||
return page.convert(isvInfo -> {
|
||||
|
||||
return isvInfo;
|
||||
});
|
||||
}
|
||||
|
||||
public Map<String, String> getCodeNameMap(Collection<String> codeList) {
|
||||
return this.query()
|
||||
.in(PermGroup::getGroupCode, codeList)
|
||||
.map(PermGroup::getGroupCode, PermGroup::getGroupName);
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,85 @@
|
||||
package com.gitee.sop.adminbackend.service.isv;
|
||||
|
||||
import com.gitee.fastmybatis.core.PageInfo;
|
||||
import com.gitee.fastmybatis.core.query.LambdaQuery;
|
||||
import com.gitee.fastmybatis.core.support.LambdaService;
|
||||
import com.gitee.sop.adminbackend.dao.entity.PermIsvGroup;
|
||||
import com.gitee.sop.adminbackend.dao.mapper.PermIsvGroupMapper;
|
||||
import com.gitee.sop.adminbackend.service.isv.dto.IsvGroupSettingDTO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Service
|
||||
public class PermIsvGroupService implements LambdaService<PermIsvGroup, PermIsvGroupMapper> {
|
||||
|
||||
@Resource
|
||||
private PermGroupService permGroupService;
|
||||
|
||||
public PageInfo<PermIsvGroup> doPage(LambdaQuery<PermIsvGroup> query) {
|
||||
query.orderByDesc(PermIsvGroup::getId);
|
||||
PageInfo<PermIsvGroup> page = this.page(query);
|
||||
|
||||
// 格式转换
|
||||
return page.convert(isvInfo -> {
|
||||
|
||||
return isvInfo;
|
||||
});
|
||||
}
|
||||
|
||||
public Map<Long, List<String>> getIsvGroupNameMap(Collection<Long> isvIds) {
|
||||
List<PermIsvGroup> list = this.list(PermIsvGroup::getIsvId, isvIds);
|
||||
if (list.isEmpty()) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
Set<String> codes = list.stream().map(PermIsvGroup::getGroupCode).collect(Collectors.toSet());
|
||||
Map<String, String> groupCodeMap = permGroupService.getCodeNameMap(codes);
|
||||
return this.query()
|
||||
.in(PermIsvGroup::getIsvId, isvIds)
|
||||
.group(PermIsvGroup::getIsvId,
|
||||
permIsvGroup -> groupCodeMap.getOrDefault(permIsvGroup.getGroupCode(), ""));
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int updateIsvGroup(IsvGroupSettingDTO isvGroupSettingDTO) {
|
||||
// 先删除所有
|
||||
int i = this.deleteByColumn(PermIsvGroup::getIsvId, isvGroupSettingDTO.getIsvId());
|
||||
List<String> groupCodeList = isvGroupSettingDTO.getGroupCodeList();
|
||||
if (CollectionUtils.isEmpty(groupCodeList)) {
|
||||
return i;
|
||||
}
|
||||
List<PermIsvGroup> saveList = groupCodeList
|
||||
.stream()
|
||||
.map(groupCode -> {
|
||||
PermIsvGroup permIsvGroup = new PermIsvGroup();
|
||||
permIsvGroup.setIsvId(isvGroupSettingDTO.getIsvId());
|
||||
permIsvGroup.setGroupCode(groupCode);
|
||||
return permIsvGroup;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
return this.saveBatch(saveList);
|
||||
}
|
||||
|
||||
public List<String> listIsvGroup(Long isvId) {
|
||||
List<PermIsvGroup> list = this.list(PermIsvGroup::getIsvId, isvId);
|
||||
if (list.isEmpty()) {
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
return list.stream().map(PermIsvGroup::getGroupCode).distinct().collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
package com.gitee.sop.adminbackend.service.isv;
|
||||
|
||||
import com.gitee.fastmybatis.core.support.LambdaService;
|
||||
import com.gitee.sop.adminbackend.dao.entity.PermIsvRole;
|
||||
import com.gitee.sop.adminbackend.dao.mapper.PermIsvRoleMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Service
|
||||
public class PermIsvRoleService implements LambdaService<PermIsvRole, PermIsvRoleMapper> {
|
||||
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
package com.gitee.sop.adminbackend.service.isv;
|
||||
|
||||
import com.gitee.fastmybatis.core.support.LambdaService;
|
||||
import com.gitee.sop.adminbackend.dao.entity.PermRolePermission;
|
||||
import com.gitee.sop.adminbackend.dao.mapper.PermRolePermissionMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Service
|
||||
public class PermRolePermissionService implements LambdaService<PermRolePermission, PermRolePermissionMapper> {
|
||||
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
package com.gitee.sop.adminbackend.service.isv;
|
||||
|
||||
import com.gitee.fastmybatis.core.support.LambdaService;
|
||||
import com.gitee.sop.adminbackend.dao.entity.PermRole;
|
||||
import com.gitee.sop.adminbackend.dao.mapper.PermRoleMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Service
|
||||
public class PermRoleService implements LambdaService<PermRole, PermRoleMapper> {
|
||||
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
package com.gitee.sop.adminbackend.service.isv.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
public class IsvGroupSettingDTO {
|
||||
|
||||
@NotNull
|
||||
private Long isvId;
|
||||
|
||||
@NotEmpty
|
||||
private List<String> groupCodeList;
|
||||
|
||||
}
|
@@ -37,6 +37,8 @@ public class IsvInfoDTO {
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
private String groupNames;
|
||||
|
||||
private LocalDateTime addTime;
|
||||
|
||||
private LocalDateTime updateTime;
|
||||
|
@@ -35,6 +35,14 @@ const apiRouters = [
|
||||
title: "ISV列表",
|
||||
roles: ["admin"]
|
||||
}
|
||||
},
|
||||
{
|
||||
path: "/isv/perm/permGroup",
|
||||
name: "PermGroup",
|
||||
meta: {
|
||||
title: "分组管理",
|
||||
roles: ["admin"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@@ -17,7 +17,7 @@
|
||||
"Stretch": false,
|
||||
"SidebarStatus": true,
|
||||
"EpThemeColor": "#409EFF",
|
||||
"ShowLogo": true,
|
||||
"ShowLogo": false,
|
||||
"ShowModel": "smart",
|
||||
"MenuArrowIconNoTransition": false,
|
||||
"CachingAsyncRoutes": false,
|
||||
|
@@ -10,7 +10,9 @@ const apiUrl: any = createUrl({
|
||||
getKeys: "/isv/getKeys",
|
||||
updateStatus: "/isv/updateStatus",
|
||||
createKeys: "/isv/createKeys",
|
||||
updateKeys: "/isv/updateKeys"
|
||||
updateKeys: "/isv/updateKeys",
|
||||
listGroup: "perm/isv/group/listIsvCode",
|
||||
updateGroup: "perm/isv/group/setting"
|
||||
});
|
||||
|
||||
/*
|
||||
@@ -84,5 +86,30 @@ export const api: any = {
|
||||
*/
|
||||
updateKeys(data: object): Promise<Result<KeyStore>> {
|
||||
return http.post<Result<any>, any>(apiUrl.updateKeys, { data });
|
||||
},
|
||||
/**
|
||||
* 修改秘钥
|
||||
* @param data 表单内容
|
||||
*/
|
||||
listGroup(isvId: Number): Promise<Result<string>> {
|
||||
const data = {
|
||||
isvId: isvId
|
||||
};
|
||||
return http.get<Result<string>, any>(apiUrl.listGroup, { params: data });
|
||||
},
|
||||
/**
|
||||
* 设置分组
|
||||
* @param isvId isvId
|
||||
* @param groupCodes groupCodes
|
||||
*/
|
||||
updateGroup(
|
||||
isvId: Number,
|
||||
groupCodes: Array<string>
|
||||
): Promise<Result<KeyStore>> {
|
||||
const data = {
|
||||
isvId: isvId,
|
||||
groupCodeList: groupCodes
|
||||
};
|
||||
return http.post<Result<any>, any>(apiUrl.updateGroup, { data });
|
||||
}
|
||||
};
|
||||
|
51
sop-admin/sop-admin-frontend/src/api/permGroup.ts
Normal file
51
sop-admin/sop-admin-frontend/src/api/permGroup.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import { createUrl, http } from "@/utils/http";
|
||||
import type { PageResult, Result } from "@/model";
|
||||
|
||||
// 后端请求接口
|
||||
const apiUrl: any = createUrl({
|
||||
page: "/perm/group/page",
|
||||
add: "/perm/group/add",
|
||||
update: "/perm/group/update",
|
||||
del: "/perm/group/delete",
|
||||
listAll: "/perm/group/listAll"
|
||||
});
|
||||
|
||||
/**
|
||||
* 接口管理
|
||||
*/
|
||||
export const api: any = {
|
||||
/**
|
||||
* 分页查询
|
||||
* @param params 查询参数
|
||||
*/
|
||||
page(params: object): Promise<PageResult> {
|
||||
return http.get<PageResult, any>(apiUrl.page, { params });
|
||||
},
|
||||
/**
|
||||
* 查询全部
|
||||
*/
|
||||
listAll(): Promise<Result<any>> {
|
||||
return http.get<Result<any>, any>(apiUrl.listAll, {});
|
||||
},
|
||||
/**
|
||||
* 新增
|
||||
* @param data 表单内容
|
||||
*/
|
||||
add(data: object) {
|
||||
return http.post<Result<any>, any>(apiUrl.add, { data });
|
||||
},
|
||||
/**
|
||||
* 修改
|
||||
* @param data 表单内容
|
||||
*/
|
||||
update(data: object) {
|
||||
return http.post<Result<any>, any>(apiUrl.update, { data });
|
||||
},
|
||||
/**
|
||||
* 删除
|
||||
* @param data 表单内容
|
||||
*/
|
||||
del(data: object) {
|
||||
return http.post<Result<any>, any>(apiUrl.del, { data });
|
||||
}
|
||||
};
|
@@ -10,6 +10,7 @@ import { ElMessage } from "element-plus";
|
||||
import { KeyFormatEnum, StatusEnum } from "@/model/enums";
|
||||
import { api } from "@/api/isvList";
|
||||
import { settingKeys } from "@/views/isv/list/isvKeys";
|
||||
import { settingGroup } from "@/views/isv/list/isvGroup";
|
||||
|
||||
const isAdd = ref(false);
|
||||
|
||||
@@ -73,9 +74,12 @@ export const tableColumns: PlusColumn[] = [
|
||||
width: 80
|
||||
},
|
||||
{
|
||||
label: "角色",
|
||||
prop: "roleNames",
|
||||
width: 200
|
||||
label: "所属分组",
|
||||
prop: "groupNames",
|
||||
width: 200,
|
||||
tableColumnProps: {
|
||||
showOverflowTooltip: true
|
||||
}
|
||||
},
|
||||
{
|
||||
label: "状态",
|
||||
@@ -97,7 +101,10 @@ export const tableColumns: PlusColumn[] = [
|
||||
},
|
||||
{
|
||||
label: "备注",
|
||||
prop: "remark"
|
||||
prop: "remark",
|
||||
tableColumnProps: {
|
||||
showOverflowTooltip: true
|
||||
}
|
||||
},
|
||||
{
|
||||
label: "添加时间",
|
||||
@@ -136,6 +143,16 @@ actionButtons.value = [
|
||||
settingKeys(params.row);
|
||||
}
|
||||
},
|
||||
{
|
||||
text: "设置分组",
|
||||
code: "edit",
|
||||
props: {
|
||||
type: "primary"
|
||||
},
|
||||
onClick(params: ButtonsCallBackParams) {
|
||||
settingGroup(params.row);
|
||||
}
|
||||
},
|
||||
{
|
||||
// 启用/禁用
|
||||
text: row => (row.status === StatusEnum.ENABLE ? "禁用" : "启用"),
|
||||
@@ -195,29 +212,6 @@ export const editFormColumns: PlusColumn[] = [
|
||||
placeholder: "自动生成"
|
||||
}
|
||||
},
|
||||
// {
|
||||
// label: "秘钥格式",
|
||||
// prop: "keyFormat",
|
||||
// valueType: "radio",
|
||||
// options: [
|
||||
// {
|
||||
// label: "PKCS8(Java适用)",
|
||||
// value: KeyFormatEnum.PKCS8
|
||||
// },
|
||||
// {
|
||||
// label: "PKCS1(非Java适用)",
|
||||
// value: KeyFormatEnum.PKCS1
|
||||
// }
|
||||
// ]
|
||||
// },
|
||||
// {
|
||||
// label: "角色",
|
||||
// prop: "roleCodes",
|
||||
// valueType: "checkbox",
|
||||
// // options推荐写法
|
||||
// // 3. 用 computed 返回 ref 的 value
|
||||
// options: computed(() => roleList.value)
|
||||
// },
|
||||
{
|
||||
label: "状态",
|
||||
prop: "status",
|
||||
|
@@ -34,6 +34,12 @@ import {
|
||||
settingKeysFormData,
|
||||
settingKeysFormRules
|
||||
} from "@/views/isv/list/isvKeys";
|
||||
import {
|
||||
dlgGroupSetting,
|
||||
groupColumns,
|
||||
handleUpdateGroup,
|
||||
settingGroupFormData
|
||||
} from "@/views/isv/list/isvGroup";
|
||||
</script>
|
||||
<template>
|
||||
<el-card shadow="never">
|
||||
@@ -50,7 +56,7 @@ import {
|
||||
<PlusTable
|
||||
:columns="tableColumns"
|
||||
:table-data="tableData"
|
||||
:action-bar="{ buttons: actionButtons, width: 190 }"
|
||||
:action-bar="{ buttons: actionButtons, width: 230, showNumber: 4 }"
|
||||
:pagination="{
|
||||
total,
|
||||
modelValue: pageInfo,
|
||||
@@ -129,5 +135,17 @@ import {
|
||||
</el-button>
|
||||
</template>
|
||||
</PlusDialogForm>
|
||||
<!-- 设置分组 -->
|
||||
<PlusDialogForm
|
||||
v-model:visible="dlgGroupSetting"
|
||||
v-model="settingGroupFormData"
|
||||
:dialog="{ title: '设置分组' }"
|
||||
:form="{
|
||||
columns: groupColumns,
|
||||
labelPosition: 'top'
|
||||
}"
|
||||
:hasErrorTip="false"
|
||||
@confirm="handleUpdateGroup"
|
||||
/>
|
||||
</el-card>
|
||||
</template>
|
||||
|
@@ -1,12 +1,71 @@
|
||||
// options推荐写法
|
||||
// 1. 定义一个 `ref`数组
|
||||
import { type Ref, ref } from "vue";
|
||||
import { type OptionsRow } from "plus-pro-components";
|
||||
import { computed, type Ref, ref } from "vue";
|
||||
import { type OptionsRow, type PlusColumn } from "plus-pro-components";
|
||||
import { api } from "@/api/isvList";
|
||||
import { api as groupApi } from "@/api/permGroup";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { search } from "@/views/isv/list/index";
|
||||
|
||||
// 弹窗显示
|
||||
export const dlgGroupSetting = ref(false);
|
||||
export const settingGroupFormData = ref<any>({
|
||||
isvId: 0,
|
||||
groupCodeList: []
|
||||
});
|
||||
|
||||
const groupList: Ref<OptionsRow[]> = ref([]);
|
||||
// 2. 异步函数获取到值赋值到 `ref`
|
||||
const loadGroup = async () => {
|
||||
//
|
||||
console.log(groupList);
|
||||
const loadGroup = () => {
|
||||
groupApi.listAll().then(resp => {
|
||||
const rows = resp.data;
|
||||
/*
|
||||
options.value = [
|
||||
{ label: '未解决', value: '0', color: 'red' },
|
||||
{ label: '已解决', value: '1', color: 'blue' }
|
||||
]
|
||||
*/
|
||||
groupList.value = rows.map(row => {
|
||||
return {
|
||||
label: row.groupName,
|
||||
value: row.groupCode
|
||||
};
|
||||
});
|
||||
});
|
||||
};
|
||||
loadGroup();
|
||||
|
||||
export const groupColumns: PlusColumn[] = [
|
||||
{
|
||||
label: "分组",
|
||||
width: 120,
|
||||
prop: "groupCodeList",
|
||||
valueType: "checkbox",
|
||||
// options推荐写法
|
||||
// 3. 用 computed 返回 ref 的 value
|
||||
options: computed(() => groupList.value)
|
||||
}
|
||||
];
|
||||
|
||||
export const settingGroup = (row: any) => {
|
||||
api.listGroup(row.id).then(resp => {
|
||||
settingGroupFormData.value = {
|
||||
isvId: row.id,
|
||||
groupCodeList: resp.data
|
||||
};
|
||||
dlgGroupSetting.value = true;
|
||||
});
|
||||
};
|
||||
|
||||
export const handleUpdateGroup = () => {
|
||||
const data = settingGroupFormData.value;
|
||||
|
||||
api.updateGroup(data.isvId, data.groupCodeList).then(() => {
|
||||
ElMessage({
|
||||
message: "保存成功",
|
||||
type: "success"
|
||||
});
|
||||
dlgGroupSetting.value = false;
|
||||
search();
|
||||
});
|
||||
};
|
||||
|
196
sop-admin/sop-admin-frontend/src/views/isv/perm/permGroup.ts
Normal file
196
sop-admin/sop-admin-frontend/src/views/isv/perm/permGroup.ts
Normal file
@@ -0,0 +1,196 @@
|
||||
import { computed, ref } from "vue";
|
||||
import {
|
||||
type ButtonsCallBackParams,
|
||||
type PageInfo,
|
||||
type PlusColumn,
|
||||
useTable
|
||||
} from "plus-pro-components";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { api } from "@/api/permGroup";
|
||||
|
||||
const isAdd = ref(false);
|
||||
|
||||
// ========= search form =========
|
||||
|
||||
// 查询表单对象
|
||||
export const searchFormData = ref({
|
||||
groupCode: "",
|
||||
groupName: "",
|
||||
pageIndex: 1,
|
||||
pageSize: 10
|
||||
});
|
||||
|
||||
// 查询表单字段定义
|
||||
export const searchFormColumns: PlusColumn[] = [
|
||||
{
|
||||
label: "分组代码",
|
||||
prop: "groupCode"
|
||||
},
|
||||
{
|
||||
label: "角色描述",
|
||||
prop: "groupName"
|
||||
}
|
||||
];
|
||||
|
||||
// ========= table =========
|
||||
|
||||
// 表格对象
|
||||
export const {
|
||||
tableData,
|
||||
total,
|
||||
pageInfo,
|
||||
buttons: actionButtons
|
||||
} = useTable<any[]>();
|
||||
// 默认每页条数,默认10
|
||||
pageInfo.value.pageSize = 10;
|
||||
|
||||
// 表格字段定义
|
||||
export const tableColumns: PlusColumn[] = [
|
||||
{
|
||||
label: "分组代码",
|
||||
prop: "groupCode"
|
||||
},
|
||||
{
|
||||
label: "角色描述",
|
||||
prop: "groupName"
|
||||
},
|
||||
{
|
||||
width: 160,
|
||||
label: "添加时间",
|
||||
prop: "addTime"
|
||||
},
|
||||
{
|
||||
width: 160,
|
||||
label: "修改时间",
|
||||
prop: "updateTime"
|
||||
}
|
||||
];
|
||||
// 表格按钮定义
|
||||
actionButtons.value = [
|
||||
{
|
||||
// 修改
|
||||
text: "修改",
|
||||
code: "edit",
|
||||
props: {
|
||||
type: "primary"
|
||||
},
|
||||
show: computed(() => true),
|
||||
onClick(params: ButtonsCallBackParams) {
|
||||
isAdd.value = false;
|
||||
editFormData.value = Object.assign({}, params.row);
|
||||
dlgTitle.value = "修改";
|
||||
dlgShow.value = true;
|
||||
}
|
||||
},
|
||||
{
|
||||
// 删除
|
||||
text: "删除",
|
||||
code: "delete",
|
||||
props: {
|
||||
type: "danger"
|
||||
},
|
||||
confirm: {
|
||||
options: { draggable: false }
|
||||
},
|
||||
onConfirm(params: ButtonsCallBackParams) {
|
||||
api.del(params).then(() => {
|
||||
ElMessage({
|
||||
message: "删除成功",
|
||||
type: "success"
|
||||
});
|
||||
dlgShow.value = false;
|
||||
search();
|
||||
});
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
// ========= dialog form =========
|
||||
|
||||
// 弹窗显示
|
||||
export const dlgShow = ref(false);
|
||||
export const dlgTitle = ref("");
|
||||
// 表单值
|
||||
const editFormDataGen = () => {
|
||||
return {
|
||||
groupCode: "",
|
||||
groupName: ""
|
||||
};
|
||||
};
|
||||
export const editFormData = ref<any>(editFormDataGen());
|
||||
export const editFormRules = {
|
||||
groupCode: [{ required: true, message: "请输入角色代码" }],
|
||||
groupName: [{ required: true, message: "请输入角色描述" }]
|
||||
};
|
||||
|
||||
// 表单内容
|
||||
export const editFormColumns: PlusColumn[] = [
|
||||
{
|
||||
label: "分组代码",
|
||||
prop: "groupCode",
|
||||
valueType: "input"
|
||||
},
|
||||
{
|
||||
label: "角色描述",
|
||||
prop: "groupName",
|
||||
valueType: "input"
|
||||
}
|
||||
];
|
||||
|
||||
// ========= event =========
|
||||
|
||||
// 添加按钮事件
|
||||
export const handleAdd = () => {
|
||||
isAdd.value = true;
|
||||
editFormData.value = editFormDataGen();
|
||||
dlgTitle.value = "新增";
|
||||
dlgShow.value = true;
|
||||
};
|
||||
|
||||
// 保存按钮事件,校验成功后触发
|
||||
export const handleSave = () => {
|
||||
const postData = editFormData.value;
|
||||
const pms = isAdd.value ? api.add(postData) : api.update(postData);
|
||||
pms.then(() => {
|
||||
ElMessage({
|
||||
message: "保存成功",
|
||||
type: "success"
|
||||
});
|
||||
dlgShow.value = false;
|
||||
search();
|
||||
});
|
||||
};
|
||||
|
||||
// 点击查询按钮
|
||||
export const handleSearch = () => {
|
||||
pageInfo.value.page = 1;
|
||||
search();
|
||||
};
|
||||
|
||||
// 分页事件
|
||||
export const handlePaginationChange = (_pageInfo: PageInfo): void => {
|
||||
pageInfo.value = _pageInfo;
|
||||
search();
|
||||
};
|
||||
|
||||
// 查询
|
||||
const search = async () => {
|
||||
try {
|
||||
const { data } = await doSearch();
|
||||
tableData.value = data.list;
|
||||
total.value = data.total;
|
||||
} catch (error) {}
|
||||
};
|
||||
// 请求接口
|
||||
const doSearch = async () => {
|
||||
// 查询参数
|
||||
const data = searchFormData.value;
|
||||
// 添加分页参数
|
||||
data.pageIndex = pageInfo.value.page;
|
||||
data.pageSize = pageInfo.value.pageSize;
|
||||
|
||||
return api.page(data);
|
||||
};
|
||||
|
||||
// 页面加载
|
||||
search();
|
@@ -0,0 +1,64 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
actionButtons,
|
||||
dlgShow,
|
||||
dlgTitle,
|
||||
editFormColumns,
|
||||
editFormData,
|
||||
editFormRules,
|
||||
handleAdd,
|
||||
handlePaginationChange,
|
||||
handleSave,
|
||||
handleSearch,
|
||||
pageInfo,
|
||||
searchFormColumns,
|
||||
searchFormData,
|
||||
tableColumns,
|
||||
tableData,
|
||||
total
|
||||
} from "./permGroup";
|
||||
</script>
|
||||
<template>
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<PlusSearch
|
||||
v-model="searchFormData"
|
||||
:columns="searchFormColumns"
|
||||
:show-number="2"
|
||||
label-position="right"
|
||||
:has-reset="false"
|
||||
@search="handleSearch"
|
||||
/>
|
||||
</template>
|
||||
<PlusTable
|
||||
:columns="tableColumns"
|
||||
:table-data="tableData"
|
||||
:action-bar="{ buttons: actionButtons, width: 120 }"
|
||||
:pagination="{
|
||||
total,
|
||||
modelValue: pageInfo,
|
||||
pageSizeList: [10, 20, 50, 100],
|
||||
align: 'right'
|
||||
}"
|
||||
adaptive
|
||||
@paginationChange="handlePaginationChange"
|
||||
>
|
||||
<template #title>
|
||||
<el-button type="primary" @click="handleAdd">新增</el-button>
|
||||
</template>
|
||||
</PlusTable>
|
||||
<PlusDialogForm
|
||||
v-model:visible="dlgShow"
|
||||
v-model="editFormData"
|
||||
:dialog="{ title: dlgTitle }"
|
||||
:form="{
|
||||
columns: editFormColumns,
|
||||
rules: editFormRules,
|
||||
labelWidth: '100px',
|
||||
labelPosition: 'right'
|
||||
}"
|
||||
:hasErrorTip="false"
|
||||
@confirm="handleSave"
|
||||
/>
|
||||
</el-card>
|
||||
</template>
|
Reference in New Issue
Block a user