service/erp/template.go
2024-11-19 09:58:03 +08:00

167 lines
4.0 KiB
Go

package erp
import (
"context"
"git.kumo.work/shama/service/client"
"git.kumo.work/shama/service/lib/bean"
"time"
)
type template struct {
}
type ArgsTemplateList struct {
Page bean.Page
Search TemplateSearch
}
type TemplateSearch struct {
Name string // 模板名称
Types []string // 模板类型
IsOpen int64 // 是否开启
}
type ReplyTemplateList struct {
List []TemplateItem `json:"list"`
Total int64 `json:"total"`
}
type TemplateItem struct {
Id int64 `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Path string `json:"path"`
Sort int64 `json:"sort"`
PdfConfig string `json:"pdfConfig"`
IsOpen int64 `json:"isOpen"`
CreatedStaffId int64 `json:"createdStaffId"`
CreatedAt *time.Time `json:"createdAt"`
}
// List @TITLE 列表
func (t *template) List(ctx context.Context, args ArgsTemplateList) (reply ReplyTemplateList, err error) {
xClient, err := client.GetClient(t)
if err != nil {
return
}
err = xClient.Call(ctx, "List", args, &reply)
return
}
type ArgsTemplateAdd struct {
StaffId int64 // 员工id
TemplateAdd TemplateAdd
}
type TemplateAdd struct {
Name string // 模板名称
Type string // 模板类型
Path string // 模板文件地址
Sort int64 // 排序
PdfConfig string // pdf配置
}
// Add @TITLE 添加
func (t *template) Add(ctx context.Context, args ArgsTemplateAdd) (err error) {
xClient, err := client.GetClient(t)
if err != nil {
return
}
reply := 0
err = xClient.Call(ctx, "Add", args, &reply)
return
}
type TemplateInfo struct {
Id int64 `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Path string `json:"path"`
Sort int64 `json:"sort"`
PdfConfig string `json:"pdfConfig"`
IsOpen int64 `json:"isOpen"`
CreatedStaffId int64 `json:"createdStaffId"`
CreatedAt *time.Time `json:"createdAt"`
}
// Info @TITLE 详情
func (t *template) Info(ctx context.Context, templateId int64) (reply TemplateInfo, err error) {
xClient, err := client.GetClient(t)
if err != nil {
return
}
err = xClient.Call(ctx, "Info", templateId, &reply)
return
}
type ArgsTemplateEdit struct {
TemplateId int64 // 模板id
TemplateAdd TemplateAdd
}
// Edit @TITLE 编辑
func (t *template) Edit(ctx context.Context, args ArgsTemplateEdit) (err error) {
xClient, err := client.GetClient(t)
if err != nil {
return
}
reply := 0
err = xClient.Call(ctx, "Edit", args, &reply)
return
}
// Open @TITLE 开启
func (t *template) Open(ctx context.Context, templateIds []int64) (err error) {
xClient, err := client.GetClient(t)
if err != nil {
return
}
reply := 0
err = xClient.Call(ctx, "Open", templateIds, &reply)
return
}
// Close @TITLE 关闭
func (t *template) Close(ctx context.Context, templateIds []int64) (err error) {
xClient, err := client.GetClient(t)
if err != nil {
return
}
reply := 0
err = xClient.Call(ctx, "Close", templateIds, &reply)
return
}
// Delete @TITLE 删除
func (t *template) Delete(ctx context.Context, templateIds []int64) (err error) {
xClient, err := client.GetClient(t)
if err != nil {
return
}
reply := 0
err = xClient.Call(ctx, "Delete", templateIds, &reply)
return
}
type ArgsTemplateExportData struct {
ExportType ExportType // 导出类型
DataId int64 // 导出数据id
Search string // 筛选json
}
// ExportData @TITLE 导出数据
func (t *template) ExportData(ctx context.Context, args ArgsTemplateExportData) (reply interface{}, err error) {
xClient, err := client.GetClient(t)
if err != nil {
return
}
err = xClient.Call(ctx, "ExportData", args, &reply)
return
}
// ExportStruct @TITLE 导出数据结构
func (t *template) ExportStruct(ctx context.Context, exportType ExportType) (reply interface{}, err error) {
xClient, err := client.GetClient(t)
if err != nil {
return
}
err = xClient.Call(ctx, "ExportStruct", exportType, &reply)
return
}