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