diff --git a/src/main/java/com/smart/module/pay/entity/AppPayConfig.java b/src/main/java/com/smart/module/pay/entity/AppPayConfig.java new file mode 100644 index 0000000..f33d1e8 --- /dev/null +++ b/src/main/java/com/smart/module/pay/entity/AppPayConfig.java @@ -0,0 +1,63 @@ +package com.smart.module.pay.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.smart.common.model.PageBean; +import lombok.Data; + +import javax.persistence.*; +import java.io.Serializable; +import java.sql.Timestamp; + +/** + * 支付配置 + */ +@Data +@Entity +@Table(name = "app_pay_config") // 指定数据库表名 +public class AppPayConfig extends PageBean implements Serializable { + + // 实体类属性与数据库表字段一一对应 + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id", nullable = false, length = 20) // 使用@Column注解指定对应的数据库字段名 + private Long id; + + /** + * 停车场 + */ + @Column(name = "car_park_id") + private Long carParkId; + + /** + * 商户号 + */ + @Column(name = "mch_id ", length = 500) + private String mchId; + + /** + * 秘钥 + */ + @Column(name = "secret_key", length = 500) + private String secretKey; + + /** + * 创建时间 + */ + @Column(name = "gmt_create") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Timestamp gmtCreate; + + /** + * 修改时间 + */ + @Column(name = "gmt_modified") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Timestamp gmtModified; + + /** + * 创建用户id + */ + @Column(name = "user_id_create") + private Long userIdCreate; + +} diff --git a/src/main/java/com/smart/module/pay/repository/PayConfigRepository.java b/src/main/java/com/smart/module/pay/repository/PayConfigRepository.java new file mode 100644 index 0000000..3665295 --- /dev/null +++ b/src/main/java/com/smart/module/pay/repository/PayConfigRepository.java @@ -0,0 +1,15 @@ +package com.smart.module.pay.repository; + +import com.smart.module.pay.entity.AppPayConfig; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +/** + * 支付配置数据访问层接口 + */ +@Repository//提供了基本的CRUD +public interface PayConfigRepository extends JpaRepository { + + AppPayConfig findByCarParkId(Long carParkId); + +} diff --git a/src/main/java/com/smart/module/pay/service/PayConfigService.java b/src/main/java/com/smart/module/pay/service/PayConfigService.java new file mode 100644 index 0000000..4b8e962 --- /dev/null +++ b/src/main/java/com/smart/module/pay/service/PayConfigService.java @@ -0,0 +1,18 @@ +package com.smart.module.pay.service; + +import com.smart.common.model.Result; +import com.smart.module.pay.entity.AppPayConfig; + +/** + * 支付配置 + */ +public interface PayConfigService { + + /** + * 保存支付配置 + * @param entity 支付配置实体对象 + * @return 保存结果 + */ + Result save(AppPayConfig entity); + +} diff --git a/src/main/java/com/smart/module/pay/service/impl/PayConfigServiceImpl.java b/src/main/java/com/smart/module/pay/service/impl/PayConfigServiceImpl.java new file mode 100644 index 0000000..9c63d49 --- /dev/null +++ b/src/main/java/com/smart/module/pay/service/impl/PayConfigServiceImpl.java @@ -0,0 +1,33 @@ +package com.smart.module.pay.service.impl; + +import com.smart.common.model.Result; +import com.smart.common.util.DateUtils; +import com.smart.common.util.ShiroUtils; +import com.smart.module.pay.entity.AppPayConfig; +import com.smart.module.pay.repository.PayConfigRepository; +import com.smart.module.pay.service.PayConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +public class PayConfigServiceImpl implements PayConfigService { + + @Autowired + private PayConfigRepository payConfigRepository; // 注入支付配置数据访问层接口的实例 + + @Override + @Transactional(rollbackFor=Exception.class) // 声明事务管理,并指定回滚异常类型为Exception + public Result save(AppPayConfig entity) { + entity.setUserIdCreate(ShiroUtils.getUserId()); // 设置创建用户的ID,使用ShiroUtils获取当前登录用户的ID + if(entity.getId()==null){ // 判断支付配置ID是否为空,若为空表示新增 + entity.setGmtCreate(DateUtils.getTimestamp()); // 设置创建时间为当前时间 + entity.setGmtModified(entity.getGmtCreate()); // 设置修改时间为创建时间 + }else{ // 否则表示更新支付配置 + entity.setGmtModified(DateUtils.getTimestamp()); // 设置修改时间为当前时间 + } + payConfigRepository.saveAndFlush(entity); // 调用数据访问层接口的方法保存或更新支付配置信息并立即刷新到数据库 + return Result.ok("保存成功"); // 返回保存成功的结果 + } + +} diff --git a/src/main/resources/templates/car/parkManage/payConfig.html b/src/main/resources/templates/car/parkManage/payConfig.html deleted file mode 100644 index f5e1f3f..0000000 --- a/src/main/resources/templates/car/parkManage/payConfig.html +++ /dev/null @@ -1,82 +0,0 @@ - - - - -
- -
-
- - - \ No newline at end of file