소스 검색

支付宝店铺

liu_lake 6 달 전
부모
커밋
5322d3dc9e

+ 1 - 1
db/db-merchant/src/main/java/pay/platform/domain/PayAggregationStore.java

@@ -30,7 +30,7 @@ public class PayAggregationStore {
      * id
      */
     @Schema(description = "id")
-    @Id(keyType = KeyType.Auto)
+    @Id(keyType = KeyType.Generator, value = "SUID")
     private String id;
     /**
      * 代理id

+ 1 - 1
db/db-merchant/src/main/java/pay/platform/domain/PayMerchantAppKey.java

@@ -30,7 +30,7 @@ public class PayMerchantAppKey {
      * id
      */
     @Schema(description = "id")
-    @Id(keyType = KeyType.Auto)
+    @Id(keyType = KeyType.Generator, value = "SUID")
     private String id;
 
     @Column(value = "agent_id")

+ 37 - 1
web/agent-api/src/main/java/pay/platform/api/system/model/vo/PayChannelVO.java

@@ -1,5 +1,6 @@
 package pay.platform.api.system.model.vo;
 
+import com.mybatisflex.annotation.Column;
 import com.mybatisflex.annotation.Table;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.AllArgsConstructor;
@@ -7,6 +8,7 @@ import lombok.Builder;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 
+import java.math.BigDecimal;
 import java.time.LocalDateTime;
 
 /**
@@ -27,7 +29,7 @@ public class PayChannelVO {
      * id
      */
     @Schema(description = "id")
-    private Long id;
+    private String id;
 
     /**
      * 名称
@@ -41,6 +43,40 @@ public class PayChannelVO {
     @Schema(description = "编码")
     private String code;
 
+    @Schema(description = "appId")
+    private String appId;
+
+    /**
+     * 密钥
+     */
+    @Schema(description = "密钥")
+    @Column(value = "private_key")
+    private String privateKey;
+
+    /**
+     * 公钥
+     */
+    @Schema(description = "公钥")
+    @Column(value = "public_key")
+    private String publicKey;
+
+    /**
+     * 单笔限制金额
+     */
+    @Schema(description = "单笔限制金额")
+    private BigDecimal astrictAmount;
+
+    /**
+     * 限制流水
+     */
+    @Schema(description = "限制流水")
+    private BigDecimal astrictTrade;
+
+    /**
+     * 统一费率
+     */
+    @Schema(description = "统一费率")
+    private BigDecimal rate;
     /**
      * 状态
      */

+ 1 - 1
web/agent-api/src/main/java/pay/platform/api/system/model/vo/PayMerchantVO.java

@@ -28,7 +28,7 @@ public class PayMerchantVO {
      * id
      */
     @Schema(description = "id")
-    private Long id;
+    private String id;
 
     /**
      * 用户名

+ 2 - 0
web/agent-api/src/main/java/pay/platform/api/system/servcie/impl/PayChannelServiceImpl.java

@@ -43,7 +43,9 @@ public class PayChannelServiceImpl extends BaseService<PayChannelMapper, PayChan
         save(payChannel);
         List<PayAggregationStore> storeList = new ArrayList<>();
         for (int i = 0; i < 7; i++) {
+
             PayAggregationStore PayAggregationStore = new PayAggregationStore();
+            PayAggregationStore.setAgentId(payChannel.getId());
             PayAggregationStore.setChannelId(payChannel.getId());
             PayAggregationStore.setStoreId(RandomUtil.randomNumbers(13));
             PayAggregationStore.setOperatorId(RandomUtil.randomNumbers(6));

+ 1 - 2
web/agent-api/src/main/java/pay/platform/api/system/servcie/impl/PayMerchantServiceImpl.java

@@ -21,7 +21,6 @@ import pay.platform.core.security.util.SecurityUtil;
 import pay.platform.core.util.PasswordUtil;
 import pay.platform.domain.PayMerchant;
 import pay.platform.domain.PayMerchantAppKey;
-import pay.platform.domain.table.PayChannelTableDef;
 import pay.platform.mapper.PayMerchantMapper;
 
 import java.util.List;
@@ -58,7 +57,7 @@ public class PayMerchantServiceImpl extends BaseService<PayMerchantMapper, PayMe
     public BasePage<PayMerchantVO> queryPage(PayMerchantQuery query) {
         QueryWrapper queryWrapper = QueryWrapper.create().from(PAY_MERCHANT).where("1 = 1")
                 .and(PAY_MERCHANT.USER_NAME.like(query.getUserName(), StringUtil.isNotBlank(query.getUserName())))
-                .and(PayChannelTableDef.PAY_CHANNEL.AGENT_ID.eq(SecurityUtil.getCurrentUser().getUserid(), StringUtil.isNotBlank(SecurityUtil.getCurrentUser().getUserid()))
+                .and(PAY_MERCHANT.AGENT_ID.eq(SecurityUtil.getCurrentUser().getUserid(), StringUtil.isNotBlank(SecurityUtil.getCurrentUser().getUserid()))
 
                         .and(PAY_MERCHANT.STATUS.eq(query.getStatus(), query.getStatus() != null)));
         Page<PayMerchant> page = mapper.paginate(new Page<>(query.getCurrent(), query.getSize()), queryWrapper);

+ 5 - 0
web/merchant-api/pom.xml

@@ -106,6 +106,11 @@
             <version>1.0</version>
             <scope>compile</scope>
         </dependency>
+        <dependency>
+            <groupId>pay.platform</groupId>
+            <artifactId>db-system</artifactId>
+            <version>1.0.0-SNAPSHOT</version>
+        </dependency>
     </dependencies>
 
     <build>

+ 0 - 98
web/merchant-api/src/main/java/pay/platform/api/system/controller/PayAgentController.java

@@ -1,98 +0,0 @@
-package pay.platform.api.system.controller;
-
-import cn.bzvs.otp.OtpAuthUtil;
-import cn.hutool.core.util.StrUtil;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import jakarta.servlet.http.HttpServletRequest;
-import lombok.RequiredArgsConstructor;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-import pay.platform.api.system.model.vo.PayAgentVO;
-import pay.platform.api.system.model.vo.RestPasswdVO;
-import pay.platform.api.system.servcie.PayMerchantService;
-import pay.platform.core.common.Result;
-import pay.platform.core.security.model.UserInfo;
-import pay.platform.core.security.util.SecurityUtil;
-
-import java.time.LocalDateTime;
-
-/**
- * 用户管理
- */
-@RestController
-@RequestMapping("/sys/user")
-@Tag(name = "系统:用户管理")
-@RequiredArgsConstructor
-public class PayAgentController {
-
-    private final PayMerchantService sysUserService;
-
-
-    @GetMapping("/check/username")
-    @Operation(summary = "检查用户名是否存在")
-    public Result<Boolean> checkUsername(HttpServletRequest request, @RequestParam String username) {
-        return sysUserService.hashUsername(username);
-    }
-
-
-    @PutMapping("/update/{id}")
-    @Operation(summary = "修改")
-    @PreAuthorize("@permission.hashPermission('user:update')")
-    public Result<PayAgentVO> update(HttpServletRequest request, @PathVariable String id,
-                                     @Validated @RequestBody PayAgentVO userVO) {
-
-        userVO.setUpdateTime(LocalDateTime.now());
-        userVO.setUpdateUser(SecurityUtil.getCurrentUsername());
-        return sysUserService.updateById(id, userVO);
-    }
-
-    @PutMapping("/reset/passwd/{username}")
-    @Operation(summary = "重置密码")
-    @PreAuthorize("@permission.hashPermission('user:reset:passwd')")
-    public Result<String> resetPasswd(HttpServletRequest request, @PathVariable(value = "username") String username,
-                                      @Validated @RequestBody RestPasswdVO vo) {
-        if (StrUtil.isBlank(vo.getNewPassword())) {
-            return Result.NG("新密码不能为空");
-        }
-        if (!vo.getNewPassword().equals(vo.getConfirmPassword())) {
-            return Result.NG("两次密码不一致");
-        }
-        return sysUserService.resetPassword(username, vo.getConfirmPassword());
-    }
-
-    @PutMapping("/change/passwd/{username}")
-    @Operation(summary = "修改密码")
-    public Result<String> changePasswd(HttpServletRequest request,
-                                       @PathVariable("username") String username, @Validated @RequestBody RestPasswdVO vo) {
-        if (StrUtil.isBlank(vo.getNewPassword())) {
-            return Result.NG("新密码不能为空");
-        }
-        if (!vo.getNewPassword().equals(vo.getConfirmPassword())) {
-            return Result.NG("两次密码不一致");
-        }
-        if (vo.getOldPassword().equals(vo.getNewPassword())) {
-            return Result.NG("新密码不能与旧密码相同");
-        }
-        return sysUserService.changePasswd(username, vo.getOldPassword(), vo.getNewPassword());
-    }
-
-    @GetMapping("/get/google/qrcode")
-    @Operation(summary = "获取谷歌二维码")
-    public Result<String> getGoogleQrcode() {
-        UserInfo userInfo = SecurityUtil.getCurrentUser();
-        String otp = sysUserService.createGoogleOtp(userInfo.getUserid());
-        OtpAuthUtil.getOtpAuthUrl("Game-System", otp);
-        return Result.OK(otp);
-    }
-
-
-    @PostMapping("/check/google/otp")
-    @Operation(summary = "校验谷歌验证码")
-    public Result<Boolean> googleOtpCheck(String code) {
-        UserInfo userInfo = SecurityUtil.getCurrentUser();
-        boolean status = sysUserService.checkGoogleOtp(userInfo.getUserid(), code);
-        return Result.OK(status);
-    }
-}

+ 85 - 0
web/merchant-api/src/main/java/pay/platform/api/system/controller/SysPermissionController.java

@@ -0,0 +1,85 @@
+package pay.platform.api.system.controller;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.servlet.http.HttpServletRequest;
+import org.springdoc.core.annotations.ParameterObject;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import pay.platform.api.system.cache.RouteCache;
+import pay.platform.api.system.model.dto.PermissionTree;
+import pay.platform.api.system.model.query.PermissionTreeQuery;
+import pay.platform.api.system.model.vo.VueMenuRouteVO;
+import pay.platform.api.system.servcie.SysPermissionService;
+import pay.platform.core.common.Result;
+import pay.platform.core.security.model.UserInfo;
+import pay.platform.core.security.util.SecurityUtil;
+import pay.platform.domain.SysPermission;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * 系统:菜单与权限
+ */
+@RestController
+@RequestMapping("/sys/permission")
+@Tag(name = "系统:菜单与权限")
+public class SysPermissionController {
+
+    @Autowired
+    private SysPermissionService sysPermissionService;
+    @Autowired
+    private RouteCache routeCache;
+
+    /**
+     * 获取当前用户路由
+     *
+     * @param request .
+     * @return .
+     */
+    @GetMapping("/routes")
+    @Operation(summary = "获取当前用户路由")
+    public Result<List<VueMenuRouteVO>> getCurrentRoute(HttpServletRequest request) {
+        UserInfo user = SecurityUtil.getCurrentUser();
+        Optional<List<VueMenuRouteVO>> routeCacheOptional = routeCache.getCache(user.getUserid());
+        if (routeCacheOptional.isPresent()) {
+            return Result.OK(routeCacheOptional.get());
+        }
+        List<VueMenuRouteVO> menuRoute = sysPermissionService.queryRouteByUserid(user.getUserid());
+
+        routeCache.putCache(user.getUserid(), menuRoute);
+        return Result.OK(menuRoute);
+    }
+
+    /**
+     * 获取菜单与权限
+     *
+     * @return .
+     */
+    @GetMapping("/tree")
+    @Operation(summary = "获取菜单与权限树形列表")
+    @PreAuthorize("@permission.hashPermission('menu:query','role:query')")
+    public Result<List<PermissionTree>> treesPermission(@ParameterObject PermissionTreeQuery query) {
+        Optional<List<SysPermission>> permissionOpt = sysPermissionService.listPermission(query);
+        Optional<List<PermissionTree>> treeOpt = permissionOpt
+                .flatMap(e -> Optional.ofNullable(sysPermissionService.buildTree(e)));
+        List<PermissionTree> tree = treeOpt.orElse(Collections.emptyList());
+        return Result.OK(tree);
+    }
+
+    @GetMapping("/tree/menu")
+    @Operation(summary = "获取菜单树形列表")
+    public Result<List<PermissionTree>> tressMenus(@ParameterObject PermissionTreeQuery query) {
+        Optional<List<SysPermission>> permissionOpt = sysPermissionService.listMenu(query);
+        Optional<List<PermissionTree>> treeOpt = permissionOpt
+                .flatMap(e -> Optional.ofNullable(sysPermissionService.buildTree(e)));
+        List<PermissionTree> tree = treeOpt.orElse(Collections.emptyList());
+        return Result.OK(tree);
+    }
+
+}

+ 66 - 0
web/merchant-api/src/main/java/pay/platform/api/system/model/dto/PermissionTree.java

@@ -0,0 +1,66 @@
+package pay.platform.api.system.model.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+import pay.platform.core.common.domain.TreeData;
+import pay.platform.core.enums.MenuTypeEnums;
+import pay.platform.core.enums.ValueEnum;
+import pay.platform.domain.SysPermission;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 权限树
+ */
+@Getter
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString
+public class PermissionTree extends SysPermission implements TreeData<PermissionTree> {
+
+    @Schema(description = "子菜单")
+    private List<PermissionTree> children = new ArrayList<>();
+
+    public PermissionTree setChildren(List<PermissionTree> children) {
+        this.children = children;
+        return this;
+    }
+
+
+    @Schema(description = "是否显示")
+    public boolean isShowLink() {
+        return getShowLink() == 1;
+    }
+
+    @Schema(description = "是否显示父类")
+    public boolean isShowParent() {
+        return getShowParent() == 1;
+    }
+
+    @Schema(description = "是否缓存")
+    public boolean isKeepAlive() {
+        return getKeepAlive() == 1;
+    }
+
+    @Schema(description = "是否iframe")
+    public boolean isFrame() {
+        return getIsFrame() == 1;
+    }
+
+    @Schema(description = "菜单类型名称")
+    public String getMenuTypeName() {
+        if (ValueEnum.hash(MenuTypeEnums.class, getMenuType())) {
+            return ValueEnum.valueToEnum(MenuTypeEnums.class, getMenuType()).getName();
+        }
+        return null;
+    }
+
+    @Schema(description = "是否启用")
+    public boolean isEnable() {
+        return getEnable() == 1;
+    }
+}

+ 321 - 0
web/merchant-api/src/main/java/pay/platform/api/system/servcie/SysPermissionService.java

@@ -0,0 +1,321 @@
+package pay.platform.api.system.servcie;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.StrUtil;
+import com.mybatisflex.core.query.QueryWrapper;
+import jakarta.annotation.Nonnull;
+import jakarta.annotation.Nullable;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import pay.platform.api.system.model.dto.PermissionTree;
+import pay.platform.api.system.model.query.PermissionTreeQuery;
+import pay.platform.api.system.model.vo.PermissionVO;
+import pay.platform.api.system.model.vo.VueMenuRouteMetaVO;
+import pay.platform.api.system.model.vo.VueMenuRouteVO;
+import pay.platform.core.common.Result;
+import pay.platform.core.common.domain.BaseService;
+import pay.platform.core.enums.MenuTypeEnums;
+import pay.platform.domain.SysPermission;
+import pay.platform.domain.table.SysPermissionTableDef;
+import pay.platform.mapper.SysPermissionMapper;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * 系统 - 菜单与权限 服务层实现。
+ *
+ * @author ADMIN
+ * @since 1.0
+ */
+@Slf4j
+@Service
+public class SysPermissionService extends BaseService<SysPermissionMapper, SysPermission> {
+
+
+    /**
+     * 获取权限ID集合 BY 角色ID结合
+     *
+     * @param roleIds 角色ID集合
+     * @return 权限ID集合
+     */
+    @Nonnull
+    public Set<String> listPermissionIdsByRoleIds(@Nonnull List<String> roleIds) {
+        List<SysPermission> permissions = mapper.listByRoleIds(roleIds, true);
+        if (null == permissions) {
+            return Collections.emptySet();
+        }
+        return permissions.stream().map(SysPermission::getId).collect(Collectors.toSet());
+    }
+
+    /**
+     * 根据ID查询已启用的权限code
+     *
+     * @param permissionIds ID
+     * @return 已启用的权限code
+     */
+    @Nonnull
+    public Set<String> listPermissionPreByIds(@Nonnull List<String> permissionIds) {
+        List<SysPermission> permissions = mapper.listPermission(permissionIds, true);
+        if (permissions == null) {
+            return Collections.emptySet();
+        }
+        return permissions.stream().map(SysPermission::getPerms).collect(Collectors.toSet());
+    }
+
+    /**
+     * 获取全部的权限信息
+     *
+     * @return .
+     */
+    @Nonnull
+    public Set<String> allPermissionPre() {
+        List<SysPermission> permissions = mapper.listPermission(null, true);
+        if (null == permissions) {
+            return Collections.emptySet();
+        }
+        return permissions.stream().map(SysPermission::getPerms).collect(Collectors.toSet());
+    }
+
+    /**
+     * 获取全部的ID
+     *
+     * @return .
+     */
+    @Nonnull
+    public Set<String> allPermissionIds() {
+        List<SysPermission> permissions = mapper.list(true);
+        if (null == permissions) {
+            return Collections.emptySet();
+        }
+        return permissions.stream().map(SysPermission::getId).collect(Collectors.toSet());
+    }
+
+    /**
+     * 根据用户获取菜单路由
+     *
+     * @param userid 用户ID
+     * @return 菜单路由
+     */
+    public List<VueMenuRouteVO> queryRouteByUserid(String userid) {
+        Set<String> roleIds = new HashSet<>();
+        roleIds.add("151837087910940672380017");
+        Set<String> permissionsIds = listPermissionIdsByRoleIds(List.copyOf(roleIds));
+        return queryRouteByIds(List.copyOf(permissionsIds));
+    }
+
+    /**
+     * 根据ID查询已启用的路由信息
+     *
+     * @param ids ID
+     * @return 路由信息
+     */
+    @Nonnull
+    public List<VueMenuRouteVO> queryRouteByIds(@Nonnull List<String> ids) {
+        List<SysPermission> sysPermissions = mapper.listMenuByIds(ids, true);
+        if (null == sysPermissions) {
+            return Collections.emptyList();
+        }
+        List<PermissionTree> trees = buildTree(sysPermissions);
+        return buildRoute(trees);
+    }
+
+    /**
+     * 将菜单路由权限集合构建为树形
+     *
+     * @param permissions 菜单路由权限
+     * @return .
+     */
+    public List<PermissionTree> buildTree(@Nonnull List<SysPermission> permissions) {
+        List<PermissionTree> permissionTrees = BeanUtil.copyToList(permissions, PermissionTree.class);
+        List<PermissionTree> trees = new ArrayList<>();
+        Set<String> ids = new HashSet<>();
+        for (PermissionTree permissionTree : permissionTrees) {
+            if (StrUtil.isBlank(permissionTree.getParentId())) {
+                trees.add(permissionTree);
+            }
+            for (PermissionTree tree : permissionTrees) {
+                if (permissionTree.getId().equals(tree.getParentId())) {
+                    if (permissionTree.getChildren() == null) {
+                        permissionTree.setChildren(new ArrayList<>());
+                    }
+                    permissionTree.getChildren().add(tree);
+
+                    ids.add(tree.getId());
+                }
+            }
+        }
+        if (trees.isEmpty()) {
+            trees = permissionTrees.stream().filter(s -> !ids.contains(s.getId())).collect(Collectors.toList());
+        }
+        return trees;
+    }
+
+    /**
+     * 构建菜单路由
+     *
+     * @param permissionTrees 菜单路由权限树集合
+     * @return 菜单路由
+     */
+    public List<VueMenuRouteVO> buildRoute(@Nonnull List<PermissionTree> permissionTrees) {
+        List<VueMenuRouteVO> menuRouteList = new ArrayList<>();
+        for (PermissionTree permissionTree : permissionTrees) {
+            menuRouteList.add(buildRoute(permissionTree));
+        }
+        return menuRouteList;
+    }
+
+
+    /**
+     * 构建菜单路由
+     *
+     * @param permissionTree 菜单路由权限树
+     * @return 菜单路由
+     */
+    public VueMenuRouteVO buildRoute(PermissionTree permissionTree) {
+        VueMenuRouteVO menuRoute = new VueMenuRouteVO();
+        Integer menuType = permissionTree.getMenuType();
+        //  路由地址 必须有个 `/`
+        menuRoute.setPath(StrUtil.addPrefixIfNot(permissionTree.getPath(), "/"));
+        // 路由名字(必须保持唯一)
+        menuRoute.setName(permissionTree.getName());
+        // 元信息
+        VueMenuRouteMetaVO vo = new VueMenuRouteMetaVO();
+        // 菜单名称
+        vo.setTitle(permissionTree.getTitle());
+        // 菜单图标
+        vo.setIcon(permissionTree.getIcon());
+        // 是否显示
+        vo.setShowLink(permissionTree.getShowLink() == 1);
+        // 目录
+        if (MenuTypeEnums.dir.getValue().equals(menuType)) {
+            // 菜单排序,值越高排的越后(只针对顶级路由)
+            // TODO 其实这里已经时有序取出了,所以可以不需要给RouteMeta设置rank
+            vo.setRank(permissionTree.getRank());
+        }
+        //菜单
+        else if (MenuTypeEnums.menu.getValue().equals(menuType)) {
+            // 按需加载需要展示的页面 不需要 '/'
+            menuRoute.setComponent(StrUtil.removePrefix(permissionTree.getComponent(), "/"));
+            //  是否显示父级菜单
+            vo.setShowParent(permissionTree.getShowParent() == 1);
+            // 是否缓存该路由页面
+            vo.setKeepAlive(permissionTree.getKeepAlive() == 1);
+            // 需要内嵌的iframe链接地址
+            if (permissionTree.getIsFrame() == 1) {
+                vo.setFrameSrc(permissionTree.getPath());
+            }
+        }
+        menuRoute.setMeta(vo);
+
+        if (CollectionUtil.isNotEmpty(permissionTree.getChildren())) {
+            menuRoute.setChildren(buildRoute(permissionTree.getChildren()));
+        }
+        return menuRoute;
+    }
+    /*==============================================================================*/
+
+
+    /**
+     * 查询菜单与权限列表
+     *
+     * @param query .
+     * @return .
+     */
+
+    public Optional<List<SysPermission>> listPermission(PermissionTreeQuery query) {
+        QueryWrapper queryWrapper = buildQuery(query);
+        return Optional.ofNullable(list(queryWrapper));
+    }
+
+    /**
+     * 只查询菜单列表
+     *
+     * @param query .
+     * @return .
+     */
+    public Optional<List<SysPermission>> listMenu(PermissionTreeQuery query) {
+        QueryWrapper queryWrapper = buildQuery(query);
+        queryWrapper.ne(SysPermission::getMenuType, MenuTypeEnums.permission.getValue());
+        return Optional.ofNullable(list(queryWrapper));
+    }
+
+    /**
+     * 保存
+     *
+     * @param vo .
+     * @return .
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public Optional<PermissionTree> save(PermissionVO vo) {
+        SysPermission permission = BeanUtil.toBean(vo, SysPermission.class);
+        log.info("【菜单与权限】新增菜单与权限,参数: {}", permission);
+        save(permission);
+        PermissionTree bean = BeanUtil.toBean(permission, PermissionTree.class);
+        return Optional.of(bean);
+    }
+
+    /**
+     * 根据ID更新
+     *
+     * @param vo .
+     * @param id .
+     * @return ,
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public Optional<PermissionTree> updateById(PermissionVO vo, @Nonnull String id) {
+        SysPermission permission = BeanUtil.toBean(vo, SysPermission.class);
+        permission.setId(id);
+        log.info("【菜单与权限】根据ID更新菜单与权限,参数: id--->{} data:---> {}", id, permission);
+        updateById(permission);
+        PermissionTree bean = BeanUtil.toBean(permission, PermissionTree.class);
+        return Optional.of(bean);
+    }
+
+    /**
+     * 根据ID删除
+     *
+     * @param query 查询条件
+     * @return .
+     */
+    public QueryWrapper buildQuery(@Nullable PermissionTreeQuery query) {
+        QueryWrapper queryWrapper = QueryWrapper.create().from(SysPermissionTableDef.SYS_PERMISSION);
+        queryWrapper.orderBy(SysPermission::getRank, true);
+        if (null == query) {
+            return queryWrapper;
+        }
+        queryWrapper.like(SysPermission::getTitle, query.getTitle(), StrUtil.isNotBlank(query.getTitle()));
+        queryWrapper.eq(SysPermission::getEnable, query.getEnable(), null != query.getEnable());
+        return queryWrapper;
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids ID集合
+     * @return .
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Result<String> deleteByIds(List<String> ids) {
+        if (CollectionUtil.isEmpty(ids)) {
+            return Result.NG("删除失败");
+        }
+        QueryWrapper queryWrapper = QueryWrapper.create().from(SysPermissionTableDef.SYS_PERMISSION);
+        queryWrapper.in(SysPermission::getParentId, ids);
+        List<SysPermission> sysPermissionList = mapper.selectListByQuery(queryWrapper);
+        if (CollectionUtil.isNotEmpty(sysPermissionList)) {
+            List<String> list = sysPermissionList.stream().map(SysPermission::getId).toList();
+            ids = new ArrayList<>(ids);
+            ids.addAll(list);
+        }
+        boolean remove = removeByIds(ids);
+        if (remove) {
+            return Result.OK("删除成功");
+        }
+        return Result.NG("删除失败");
+
+    }
+}

+ 1 - 2
web/merchant-api/src/main/java/pay/platform/api/system/servcie/impl/PayMerchantServiceImpl.java

@@ -15,7 +15,6 @@ import pay.platform.core.common.Result;
 import pay.platform.core.common.domain.BaseService;
 import pay.platform.core.util.PasswordUtil;
 import pay.platform.domain.PayMerchant;
-import pay.platform.domain.table.PayAgentTableDef;
 import pay.platform.domain.table.PayMerchantTableDef;
 import pay.platform.mapper.PayMerchantMapper;
 
@@ -38,7 +37,7 @@ public class PayMerchantServiceImpl extends BaseService<PayMerchantMapper, PayMe
      * @return .
      */
     public Optional<PayMerchant> loadUserByUsername(String username) {
-        QueryWrapper queryWrapper = QueryWrapper.create().from(PayMerchantTableDef.PAY_MERCHANT).where(PayAgentTableDef.PAY_AGENT.USER_NAME.eq(username));
+        QueryWrapper queryWrapper = QueryWrapper.create().from(PayMerchantTableDef.PAY_MERCHANT).where(PayMerchantTableDef.PAY_MERCHANT.USER_NAME.eq(username));
         PayMerchant sysUser = mapper.selectOneByQuery(queryWrapper);
         return Optional.ofNullable(sysUser);
     }