增加报销模块功能

This commit is contained in:
2026-07-20 17:50:47 +08:00
parent f00ba9f9cc
commit a78666177a
15 changed files with 2706 additions and 248 deletions
+91 -86
View File
@@ -1,86 +1,91 @@
package models
import (
"fmt"
"github.com/beego/beego/v2/client/orm"
beego "github.com/beego/beego/v2/server/web"
_ "github.com/go-sql-driver/mysql"
)
// Orm 全局 ORM 对象,供业务层和控制器使用
var Orm orm.Ormer
// Init 初始化模型层资源(数据库连接、模型注册等)。
func Init(_ string) {
// 从配置读取数据库连接信息
user, _ := beego.AppConfig.String("mysqluser")
pass, _ := beego.AppConfig.String("mysqlpass")
urls, _ := beego.AppConfig.String("mysqlurls")
dbname, _ := beego.AppConfig.String("mysqldb")
if user == "" || urls == "" || dbname == "" {
panic("数据库配置(mysqluser/mysqlurls/mysqldb) 未正确设置")
}
// 组装 DSNuser:pass@tcp(host:port)/dbname?charset=utf8mb4&parseTime=True&loc=Local
dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=True&loc=Local", user, pass, urls, dbname)
// 注册默认数据库
if err := orm.RegisterDataBase("default", "mysql", dsn); err != nil {
panic("注册数据库失败: " + err.Error())
}
// 注册模型
orm.RegisterModel(
new(SystemTenant),
new(SystemTenantUser),
new(BackendErpOrganization),
new(BackendErpEmployee),
new(BackendErpPosition),
new(SystemMenu),
new(AdminUser),
new(AdminRole),
new(SystemFile),
new(SystemFilesCategory),
new(SystemSMSTask),
new(SystemOperationLog),
new(SystemDomainPool),
new(SystemTenantDomain),
new(SystemModules),
new(StorageConfig),
new(TenantSiteSetting),
new(ComplaintCategory),
new(PlatformComplaint),
new(SystemSoftwareUpgrade),
new(PlatformCursorEquipment),
new(PlatformCursorActivationCode),
new(PlatformCursorEquipmentIpLog),
new(PlatformAccountPoolKiro),
new(PlatformAccountPoolWindsurf),
new(PlatformAccountPoolCursor),
new(PlatformAccountPoolCodex),
new(PlatformNotebook),
new(CmsArticleCategory),
new(CmsArticle),
new(SystemReminderList),
new(SystemNormalSetting),
new(PlatformNormalSetting),
new(BackendNormalSetting),
new(PlatformSchedule),
new(PlatformScheduleReminder),
new(PlatformScheduleReminderSendLog),
new(BackendNotebook),
new(BackendSchedule),
new(BackendScheduleReminder),
new(BackendScheduleReminderSendLog),
)
// 创建全局 Ormer
Orm = orm.NewOrm()
}
package models
import (
"fmt"
"github.com/beego/beego/v2/client/orm"
beego "github.com/beego/beego/v2/server/web"
_ "github.com/go-sql-driver/mysql"
)
// Orm 全局 ORM 对象,供业务层和控制器使用
var Orm orm.Ormer
// Init 初始化模型层资源(数据库连接、模型注册等)。
func Init(_ string) {
// 从配置读取数据库连接信息
user, _ := beego.AppConfig.String("mysqluser")
pass, _ := beego.AppConfig.String("mysqlpass")
urls, _ := beego.AppConfig.String("mysqlurls")
dbname, _ := beego.AppConfig.String("mysqldb")
if user == "" || urls == "" || dbname == "" {
panic("数据库配置(mysqluser/mysqlurls/mysqldb) 未正确设置")
}
// 组装 DSNuser:pass@tcp(host:port)/dbname?charset=utf8mb4&parseTime=True&loc=Local
dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=True&loc=Local", user, pass, urls, dbname)
// 注册默认数据库
if err := orm.RegisterDataBase("default", "mysql", dsn); err != nil {
panic("注册数据库失败: " + err.Error())
}
// 注册模型
orm.RegisterModel(
new(SystemTenant),
new(SystemTenantUser),
new(BackendErpOrganization),
new(BackendErpEmployee),
new(BackendErpPosition),
new(BackendApprovalFlow),
new(BackendApprovalRecord),
new(BackendReimbursement),
new(BackendReimbursementItem),
new(BackendReimbursementExpenseType),
new(SystemMenu),
new(AdminUser),
new(AdminRole),
new(SystemFile),
new(SystemFilesCategory),
new(SystemSMSTask),
new(SystemOperationLog),
new(SystemDomainPool),
new(SystemTenantDomain),
new(SystemModules),
new(StorageConfig),
new(TenantSiteSetting),
new(ComplaintCategory),
new(PlatformComplaint),
new(SystemSoftwareUpgrade),
new(PlatformCursorEquipment),
new(PlatformCursorActivationCode),
new(PlatformCursorEquipmentIpLog),
new(PlatformAccountPoolKiro),
new(PlatformAccountPoolWindsurf),
new(PlatformAccountPoolCursor),
new(PlatformAccountPoolCodex),
new(PlatformNotebook),
new(CmsArticleCategory),
new(CmsArticle),
new(SystemReminderList),
new(SystemNormalSetting),
new(PlatformNormalSetting),
new(BackendNormalSetting),
new(PlatformSchedule),
new(PlatformScheduleReminder),
new(PlatformScheduleReminderSendLog),
new(BackendNotebook),
new(BackendSchedule),
new(BackendScheduleReminder),
new(BackendScheduleReminderSendLog),
)
// 创建全局 Ormer
Orm = orm.NewOrm()
}
+113
View File
@@ -0,0 +1,113 @@
package models
import "time"
// BackendApprovalFlow 审批流程配置表 yz_backend_approval_flows
type BackendApprovalFlow struct {
ID uint64 `orm:"column(id);pk;auto" json:"id"`
Tid uint64 `orm:"column(tid)" json:"tid"`
UID *uint64 `orm:"column(uid);null" json:"uid"`
FlowName string `orm:"column(flow_name);size(100)" json:"flow_name"`
StepOrder int8 `orm:"column(step_order);default(0)" json:"step_order"`
ApproverRole string `orm:"column(approver_role);size(50)" json:"approver_role"`
ApproverRule string `orm:"column(approver_rule);size(200)" json:"approver_rule"`
TimeoutHours int `orm:"column(timeout_hours);default(48)" json:"timeout_hours"`
IsActive int8 `orm:"column(is_active);default(1)" json:"is_active"`
IsDeleted int8 `orm:"column(is_deleted);default(0)" json:"is_deleted"`
CreateTime time.Time `orm:"column(create_time);auto_now_add;type(datetime)" json:"create_time"`
UpdateTime *time.Time `orm:"column(update_time);null;type(datetime)" json:"update_time"`
DeleteTime *time.Time `orm:"column(delete_time);null;type(datetime)" json:"delete_time"`
}
func (m *BackendApprovalFlow) TableName() string {
return "yz_backend_approval_flows"
}
// BackendApprovalRecord 审批记录表 yz_backend_approval_records
type BackendApprovalRecord struct {
ID uint64 `orm:"column(id);pk;auto" json:"id"`
Tid uint64 `orm:"column(tid)" json:"tid"`
UID *uint64 `orm:"column(uid);null" json:"uid"`
ReimbursementID uint64 `orm:"column(reimbursement_id)" json:"reimbursement_id"`
ApproverID uint64 `orm:"column(approver_id)" json:"approver_id"`
ApproverName string `orm:"column(approver_name);size(100)" json:"approver_name"`
Action int8 `orm:"column(action);default(0)" json:"action"`
Comment *string `orm:"column(comment);null;type(text)" json:"comment"`
Step int8 `orm:"column(step);default(0)" json:"step"`
PrevStep int8 `orm:"column(prev_step);default(0)" json:"prev_step"`
IsDeleted int8 `orm:"column(is_deleted);default(0)" json:"is_deleted"`
CreateTime time.Time `orm:"column(create_time);auto_now_add;type(datetime)" json:"create_time"`
UpdateTime *time.Time `orm:"column(update_time);null;type(datetime)" json:"update_time"`
DeleteTime *time.Time `orm:"column(delete_time);null;type(datetime)" json:"delete_time"`
}
func (m *BackendApprovalRecord) TableName() string {
return "yz_backend_approval_records"
}
// BackendReimbursement 报销单主表 yz_backend_reimbursements
type BackendReimbursement struct {
ID uint64 `orm:"column(id);pk;auto" json:"id"`
Tid uint64 `orm:"column(tid)" json:"tid"`
UID *uint64 `orm:"column(uid);null" json:"uid"`
UserID uint64 `orm:"column(user_id)" json:"user_id"`
DepartmentID *uint64 `orm:"column(department_id);null" json:"department_id"`
Title string `orm:"column(title);size(200)" json:"title"`
TotalAmount float64 `orm:"column(total_amount);type(decimal);digits(10);decimals(2)" json:"total_amount"`
Status int8 `orm:"column(status);default(0)" json:"status"`
ExpenseType string `orm:"column(expense_type);size(50)" json:"expense_type"`
ApplyDate time.Time `orm:"column(apply_date);type(date)" json:"apply_date"`
Description *string `orm:"column(description);null;type(text)" json:"description"`
CurrentApproverID uint64 `orm:"column(current_approver_id);default(0)" json:"current_approver_id"`
CurrentStep int8 `orm:"column(current_step);default(0)" json:"current_step"`
IsDeleted int8 `orm:"column(is_deleted);default(0)" json:"is_deleted"`
CreateTime time.Time `orm:"column(create_time);auto_now_add;type(datetime)" json:"create_time"`
UpdateTime *time.Time `orm:"column(update_time);null;type(datetime)" json:"update_time"`
DeleteTime *time.Time `orm:"column(delete_time);null;type(datetime)" json:"delete_time"`
}
func (m *BackendReimbursement) TableName() string {
return "yz_backend_reimbursements"
}
// BackendReimbursementItem 报销费用明细表 yz_backend_reimbursement_items
type BackendReimbursementItem struct {
ID uint64 `orm:"column(id);pk;auto" json:"id"`
Tid uint64 `orm:"column(tid)" json:"tid"`
UID *uint64 `orm:"column(uid);null" json:"uid"`
ReimbursementID uint64 `orm:"column(reimbursement_id)" json:"reimbursement_id"`
ExpenseType string `orm:"column(expense_type);size(50)" json:"expense_type"`
ExpenseDate time.Time `orm:"column(expense_date);type(date)" json:"expense_date"`
Amount float64 `orm:"column(amount);type(decimal);digits(10);decimals(2)" json:"amount"`
Quantity int `orm:"column(quantity);default(1)" json:"quantity"`
UnitPrice float64 `orm:"column(unit_price);type(decimal);digits(10);decimals(2)" json:"unit_price"`
Description string `orm:"column(description);size(200)" json:"description"`
ReceiptFlag int8 `orm:"column(receipt_flag);default(0)" json:"receipt_flag"`
ReceiptURL string `orm:"column(receipt_url);size(500)" json:"receipt_url"`
IsDeleted int8 `orm:"column(is_deleted);default(0)" json:"is_deleted"`
CreateTime time.Time `orm:"column(create_time);auto_now_add;type(datetime)" json:"create_time"`
UpdateTime *time.Time `orm:"column(update_time);null;type(datetime)" json:"update_time"`
DeleteTime *time.Time `orm:"column(delete_time);null;type(datetime)" json:"delete_time"`
}
func (m *BackendReimbursementItem) TableName() string {
return "yz_backend_reimbursement_items"
}
// BackendReimbursementExpenseType 报销费用类型表 yz_backend_reimbursement_expense_types
type BackendReimbursementExpenseType struct {
ID uint64 `orm:"column(id);pk;auto" json:"id"`
Tid uint64 `orm:"column(tid)" json:"tid"`
UID *uint64 `orm:"column(uid);null" json:"uid"`
Name string `orm:"column(name);size(50)" json:"name"`
SortOrder int `orm:"column(sort_order);default(0)" json:"sort_order"`
IsActive int8 `orm:"column(is_active);default(1)" json:"is_active"`
IsDeleted int8 `orm:"column(is_deleted);default(0)" json:"is_deleted"`
CreateTime time.Time `orm:"column(create_time);auto_now_add;type(datetime)" json:"create_time"`
UpdateTime *time.Time `orm:"column(update_time);null;type(datetime)" json:"update_time"`
DeleteTime *time.Time `orm:"column(delete_time);null;type(datetime)" json:"delete_time"`
}
func (m *BackendReimbursementExpenseType) TableName() string {
return "yz_backend_reimbursement_expense_types"
}