From 1bcd266b5fff859977f1d54616a00695670ab43b Mon Sep 17 00:00:00 2001 From: Miku <2634544095@qq.com> Date: Wed, 23 Aug 2023 20:48:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98web=E7=AB=AF=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=EF=BC=8CHTML=E8=AE=BE=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/pay/web/PayConfigController.java | 52 ++++++++++++ .../templates/car/parkManage/payConfig.html | 82 +++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 src/main/java/com/smart/module/pay/web/PayConfigController.java create mode 100644 src/main/resources/templates/car/parkManage/payConfig.html diff --git a/src/main/java/com/smart/module/pay/web/PayConfigController.java b/src/main/java/com/smart/module/pay/web/PayConfigController.java new file mode 100644 index 0000000..a1f1b03 --- /dev/null +++ b/src/main/java/com/smart/module/pay/web/PayConfigController.java @@ -0,0 +1,52 @@ +package com.smart.module.pay.web; + +import com.smart.common.model.Result; +import com.smart.module.pay.entity.AppPayConfig; +import com.smart.module.pay.repository.PayConfigRepository; +import com.smart.module.pay.service.PayConfigService; +import org.apache.shiro.authz.annotation.Logical; +import org.apache.shiro.authz.annotation.RequiresRoles; +import org.springframework.beans.factory.annotation.Autowired; +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; + +@RestController // 处理HTTP请求,并将结果封装为JSON格式返回 +@RequestMapping("/pay/config") +public class PayConfigController { + + @Autowired + private PayConfigService payConfigService; // 注入支付配置业务逻辑层接口的实例 + @Autowired + private PayConfigRepository payConfigRepository; // 注入支付配置数据访问层接口的实例 + + /** + * 根据停车场ID获取支付配置 + */ + @PostMapping("getByCarParkId") + @RequiresRoles(value={"admin","orgAdmin"},logical = Logical.OR) // 需要具备"admin"或"orgAdmin"角色之一 + public Result getByCarParkId(Long carParkId){ + AppPayConfig entity = payConfigRepository.findByCarParkId(carParkId); // 根据停车场ID从数据库中获取相应的支付配置 + return Result.ok(entity); // 将支付配置封装到Result对象中并返回 + } + + /** + * 保存支付配置 + */ + @PostMapping("save") + @RequiresRoles(value={"admin","orgAdmin"},logical = Logical.OR) // 需要具备"admin"或"orgAdmin"角色之一 + public Result save(@RequestBody AppPayConfig entity){ + return payConfigService.save(entity); // 调用业务逻辑层的方法保存支付配置,并返回保存结果 + } + + /** + * 删除支付配置 + */ + @PostMapping("delete") + @RequiresRoles(value={"admin","orgAdmin"},logical = Logical.OR) // 需要具备"admin"或"orgAdmin"角色之一 + public Result delete(Long id){ + payConfigRepository.deleteById(id); // 根据支付配置ID从数据库中删除相应的支付配置 + return Result.ok(); // 返回删除成功的结果 + } +} diff --git a/src/main/resources/templates/car/parkManage/payConfig.html b/src/main/resources/templates/car/parkManage/payConfig.html new file mode 100644 index 0000000..f5e1f3f --- /dev/null +++ b/src/main/resources/templates/car/parkManage/payConfig.html @@ -0,0 +1,82 @@ + + + + +
+ +
+
+ + + \ No newline at end of file