- 在 TemplateItem 结构中添加 DepId 字段,用于存储部门 ID - 在 ReplyTemplateList 结构中添加 DepIds 列表,用于存储模板关联的部门 ID - 在 TemplateAdd 结构中添加 DepIds 列表,用于在添加模板时指定关联的部门 ID - 在模板详情接口中添加 DepIds 字段,用于展示模板关联的部门 ID
		
			
				
	
	
		
			174 lines
		
	
	
		
			4.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			174 lines
		
	
	
		
			4.3 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    // 是否开启
 | |
| 	DepId  int64    // 部门id
 | |
| }
 | |
| 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"`
 | |
| 	FileName       string     `json:"fileName"`
 | |
| 	IsOpen         int64      `json:"isOpen"`
 | |
| 	CreatedStaffId int64      `json:"createdStaffId"`
 | |
| 	CreatedAt      *time.Time `json:"createdAt"`
 | |
| 	DepIds         []int64    `json:"depIds"`
 | |
| }
 | |
| 
 | |
| // 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配置
 | |
| 	FileName  string  // 文件名
 | |
| 	DepIds    []int64 // 部门id
 | |
| }
 | |
| 
 | |
| // 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"`
 | |
| 	FileName       string     `json:"fileName"`
 | |
| 	IsOpen         int64      `json:"isOpen"`
 | |
| 	CreatedStaffId int64      `json:"createdStaffId"`
 | |
| 	CreatedAt      *time.Time `json:"createdAt"`
 | |
| 	DepIds         []int64    `json:"depIds"`
 | |
| }
 | |
| 
 | |
| // 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
 | |
| }
 |