Files
service/erp/request/cost.go
kanade fce4272da9 feat(erp): 添加报销单及其费用管理功能
- 在 ERP 服务中新增 Request 模块,用于处理报销单相关逻辑
- 实现报销单的增删改查接口,支持列表、详情及编辑操作
- 新增费用管理模块 Cost,支持费用项的添加、修改、删除和列表查询
- 定义完整的请求与响应结构体,包括分页、搜索条件和返回数据格式
- 集成客户端调用逻辑,通过 RPC 方式与其他服务通信
- 引入 decimal 包处理金额字段,确保数值精度
- 添加时间戳字段用于记录创建和更新时间
2025-12-12 15:57:33 +08:00

91 lines
2.0 KiB
Go

package request
import (
"context"
"time"
"git.kumo.work/shama/service/client"
"git.kumo.work/shama/service/lib/bean"
"github.com/shopspring/decimal"
)
type cost struct {
}
type ArgsCostList struct {
Page bean.Page
Search CostSearch
}
type CostSearch struct {
RequestId int64 // 报销单ID
}
type ReplyCostList struct {
List []CostItem `json:"list"`
Total int64 `json:"total"`
}
type CostItem struct {
Id int64 `json:"id"`
RequestId int64 `json:"requestId"`
Amount decimal.Decimal `json:"amount"`
DepartmentId int64 `json:"departmentId"`
Remarks string `json:"remarks"`
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
}
// List @TITLE 列表
func (c *cost) List(ctx context.Context, args ArgsCostList) (reply ReplyCostList, err error) {
xClient, err := client.GetClient(c)
if err != nil {
return
}
err = xClient.Call(ctx, "List", args, &reply)
return
}
type ArgsCostAdd struct {
RequestId int64 // 报销单ID
Amount decimal.Decimal // 金额
DepartmentId int64 // 部门
Remarks string // 备注
}
// Add @TITLE 添加
func (c *cost) Add(ctx context.Context, args ArgsCostAdd) (err error) {
xClient, err := client.GetClient(c)
if err != nil {
return
}
reply := 0
return xClient.Call(ctx, "Add", args, &reply)
}
type ArgsCostEdit struct {
CostId int64
ArgsCostAdd
}
// Edit @TITLE 编辑
func (c *cost) Edit(ctx context.Context, args ArgsCostEdit) (err error) {
xClient, err := client.GetClient(c)
if err != nil {
return
}
reply := 0
return xClient.Call(ctx, "Edit", args, &reply)
}
type ArgsCostDelete struct {
RequestId int64 // 报销单ID
CostIds []int64
}
// Delete @TITLE 删除
func (c *cost) Delete(ctx context.Context, args ArgsCostDelete) (err error) {
xClient, err := client.GetClient(c)
if err != nil {
return
}
reply := 0
return xClient.Call(ctx, "Delete", args, &reply)
}