liu_lake 6 місяців тому
батько
коміт
567a596e4f

+ 17 - 0
web/admin-api/src/main/java/pay/platform/api/system/controller/PayAgentController.java

@@ -1,14 +1,18 @@
 package pay.platform.api.system.controller;
 
+import cn.hutool.core.util.StrUtil;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.Parameters;
 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.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import pay.platform.api.system.model.query.PayAgentQuery;
 import pay.platform.api.system.model.vo.PayAgentVO;
+import pay.platform.api.system.model.vo.RestPasswdVO;
 import pay.platform.api.system.servcie.PayAgentService;
 import pay.platform.core.common.Result;
 import pay.platform.core.common.domain.BasePage;
@@ -113,4 +117,17 @@ public class PayAgentController {
     public Result<BasePage<PayAgentVO>> page(@ParameterObject PayAgentQuery query) {
         return Result.OK(payAgentService.queryPage(query));
     }
+
+    @PutMapping("/reset/passwd/{username}")
+    @Operation(summary = "重置密码")
+    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 payAgentService.resetPassword(username, vo.getConfirmPassword());
+    }
 }

+ 13 - 0
web/admin-api/src/main/java/pay/platform/api/system/servcie/PayAgentService.java

@@ -2,8 +2,10 @@ package pay.platform.api.system.servcie;
 
 
 import com.mybatisflex.core.service.IService;
+import jakarta.annotation.Nonnull;
 import pay.platform.api.system.model.query.PayAgentQuery;
 import pay.platform.api.system.model.vo.PayAgentVO;
+import pay.platform.core.common.Result;
 import pay.platform.core.common.domain.BasePage;
 import pay.platform.domain.PayAgent;
 
@@ -18,4 +20,15 @@ public interface PayAgentService extends IService<PayAgent> {
     boolean saveAgent(PayAgent payAgent);
 
     BasePage<PayAgentVO> queryPage(PayAgentQuery query);
+
+
+    /**
+     * 重置密码
+     *
+     * @param username .
+     * @param passwd   .
+     * @return .
+     */
+
+    public Result<String> resetPassword(@Nonnull String username, @Nonnull String passwd);
 }

+ 16 - 0
web/admin-api/src/main/java/pay/platform/api/system/servcie/impl/PayAgentServiceImpl.java

@@ -5,10 +5,12 @@ import cn.hutool.core.bean.BeanUtil;
 import com.mybatisflex.core.paginate.Page;
 import com.mybatisflex.core.query.QueryWrapper;
 import com.mybatisflex.core.util.StringUtil;
+import jakarta.annotation.Nonnull;
 import org.springframework.stereotype.Service;
 import pay.platform.api.system.model.query.PayAgentQuery;
 import pay.platform.api.system.model.vo.PayAgentVO;
 import pay.platform.api.system.servcie.PayAgentService;
+import pay.platform.core.common.Result;
 import pay.platform.core.common.domain.BasePage;
 import pay.platform.core.common.domain.BaseService;
 import pay.platform.core.util.PasswordUtil;
@@ -44,4 +46,18 @@ public class PayAgentServiceImpl extends BaseService<PayAgentMapper, PayAgent> i
         List<PayAgentVO> vos = BeanUtil.copyToList(page.getRecords(), PayAgentVO.class);
         return new BasePage<>(page.getPageNumber(), page.getPageSize(), page.getTotalRow(), vos);
     }
+
+    /**
+     * 重置密码
+     *
+     * @param username .
+     * @param passwd   .
+     * @return .
+     */
+
+    public Result<String> resetPassword(@Nonnull String username, @Nonnull String passwd) {
+        String newPassword = PasswordUtil.encoder(passwd);
+        mapper.resetPassword(username, newPassword);
+        return Result.OK();
+    }
 }

+ 18 - 0
web/agent-api/src/main/java/pay/platform/api/system/controller/PayMerchantController.java

@@ -1,14 +1,18 @@
 package pay.platform.api.system.controller;
 
+import cn.hutool.core.util.StrUtil;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.Parameters;
 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.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import pay.platform.api.system.model.query.PayMerchantQuery;
 import pay.platform.api.system.model.vo.PayMerchantVO;
+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.common.domain.BasePage;
@@ -113,4 +117,18 @@ public class PayMerchantController {
     public Result<BasePage<PayMerchantVO>> page(@ParameterObject PayMerchantQuery query) {
         return Result.OK(PayMerchantService.queryPage(query));
     }
+
+
+    @PutMapping("/reset/passwd/{username}")
+    @Operation(summary = "重置密码")
+    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 PayMerchantService.resetPassword(username, vo.getConfirmPassword());
+    }
 }

+ 4 - 0
web/agent-api/src/main/java/pay/platform/api/system/servcie/PayMerchantService.java

@@ -2,8 +2,10 @@ package pay.platform.api.system.servcie;
 
 
 import com.mybatisflex.core.service.IService;
+import jakarta.annotation.Nonnull;
 import pay.platform.api.system.model.query.PayMerchantQuery;
 import pay.platform.api.system.model.vo.PayMerchantVO;
+import pay.platform.core.common.Result;
 import pay.platform.core.common.domain.BasePage;
 import pay.platform.domain.PayMerchant;
 
@@ -17,4 +19,6 @@ public interface PayMerchantService extends IService<PayMerchant> {
     boolean saveMerchant(PayMerchant payMerchant);
 
     BasePage<PayMerchantVO> queryPage(PayMerchantQuery query);
+
+    Result<String> resetPassword(@Nonnull String username, @Nonnull String passwd);
 }

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

@@ -6,6 +6,7 @@ import cn.hutool.core.util.RandomUtil;
 import com.mybatisflex.core.paginate.Page;
 import com.mybatisflex.core.query.QueryWrapper;
 import com.mybatisflex.core.util.StringUtil;
+import jakarta.annotation.Nonnull;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -13,6 +14,7 @@ import pay.platform.api.system.model.query.PayMerchantQuery;
 import pay.platform.api.system.model.vo.PayMerchantVO;
 import pay.platform.api.system.servcie.PayMerchantAppKeyService;
 import pay.platform.api.system.servcie.PayMerchantService;
+import pay.platform.core.common.Result;
 import pay.platform.core.common.domain.BasePage;
 import pay.platform.core.common.domain.BaseService;
 import pay.platform.core.security.util.SecurityUtil;
@@ -63,4 +65,19 @@ public class PayMerchantServiceImpl extends BaseService<PayMerchantMapper, PayMe
         List<PayMerchantVO> vos = BeanUtil.copyToList(page.getRecords(), PayMerchantVO.class);
         return new BasePage<>(page.getPageNumber(), page.getPageSize(), page.getTotalRow(), vos);
     }
+
+
+    /**
+     * 重置密码
+     *
+     * @param username .
+     * @param passwd   .
+     * @return .
+     */
+
+    public Result<String> resetPassword(@Nonnull String username, @Nonnull String passwd) {
+        String newPassword = PasswordUtil.encoder(passwd);
+        mapper.resetPassword(username, newPassword);
+        return Result.OK();
+    }
 }