支付配置moudle

master
Miku 1 year ago
parent 1e4bc50ed8
commit 6643157050

@ -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;
}

@ -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, Long> {
AppPayConfig findByCarParkId(Long carParkId);
}

@ -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);
}

@ -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("保存成功"); // 返回保存成功的结果
}
}

@ -1,82 +0,0 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="common/head :: head(links)"/>
<body>
<div class="ok-body" id="app" v-cloak>
<template>
<i-form label-colon ref="checkForm" :model="entity" :rules="ruleValidate" :label-width="140">
<form-item prop="mchId" label="支付申请">
https://dwz.cn/mPQmSPss
</form-item>
<form-item prop="mchId" label="商户号">
<i-input maxlength="20" v-model="entity.mchId" placeholder="请输入商户号"></i-input>
</form-item>
<form-item prop="secretKey" label="秘钥">
<i-input v-model="entity.secretKey" placeholder="请输秘钥"></i-input>
</form-item>
</i-form>
</template>
</div>
<div th:replace="common/foot :: foot(script)"></div>
<script th:inline="none">
var vm = new Vue({
el: '#app',
data:{
entity:{
},
ruleValidate : {
mchId: [
{ required: true, message: '不能为空', trigger: 'blur' }
],
secretKey: [
{ required: true, message: '不能为空', trigger: 'blur'}
],
},
okUtils:null,
okLayer:null
},
methods: {
load : function(){
layui.use(["okUtils", "okLayer"], function () {
vm.okUtils = layui.okUtils;
vm.okLayer = layui.okLayer;
if(vm.entity.carParkId!=undefined){
vm.okUtils.ajaxCloud({
url:"/pay/config/getByCarParkId",
param : {carParkId:vm.entity.carParkId},
close : false,
success : function(result) {
if(result.msg!=null){
vm.entity = result.msg;
}
}
});
}
});
},
acceptClick : function(dialog){
vm.$refs.checkForm.validate(function(valid){
if (valid) {
vm.okUtils.ajaxCloud({
url:"/pay/config/save",
param : vm.entity,
json:true,
success : function(result) {
vm.okLayer.msg.greenTick(result.msg)
dialog.load();
}
});
}
});
},
},
created: function() {
}
});
</script>
</body>
</html>
Loading…
Cancel
Save