first commit

This commit is contained in:
2025-03-21 11:05:42 +08:00
commit 7dffc94035
1717 changed files with 724764 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
package dto
import (
"github.com/google/uuid"
)
type AuthorizeUser struct {
ID int32 `json:"id"`
Uuid uuid.UUID `json:"uuid"`
Email string `json:"email"`
Username string `json:"username"`
RoleID int32 `json:"role_id"`
RoleName string `json:"role_name"`
OS string `json:"os"`
IP string `json:"ip"`
Browser string `json:"browser"`
}

View File

@@ -0,0 +1,11 @@
package dto
type MenuUIDto struct {
ID string `json:"id"`
Title string `json:"title"`
Icon string `json:"icon"`
Type int `json:"type"`
OpenType string `json:"openType"`
Href string `json:"href"`
Children []*MenuUIDto `json:"children"`
}

View File

@@ -0,0 +1,65 @@
package dto
type PearConfig struct {
Logo Logo `json:"logo"`
Menu Menu `json:"menu"`
Tab Tab `json:"tab"`
Theme Theme `json:"theme"`
Colors []Colors `json:"colors"`
Other Other `json:"other"`
Header Header `json:"header"`
}
type Logo struct {
Title string `json:"title"`
Image string `json:"image"`
}
type Menu struct {
Data string `json:"data"`
Method string `json:"method"`
Accordion bool `json:"accordion"`
Collapse bool `json:"collapse"`
Control bool `json:"control"`
Select string `json:"select"`
Async bool `json:"async"`
}
type Index struct {
Id string `json:"id"`
Href string `json:"href"`
Title string `json:"title"`
}
type Tab struct {
Enable bool `json:"enable"`
KeepState bool `json:"keepState"`
Session bool `json:"session"`
Preload bool `json:"preload"`
Max string `json:"max"`
Index Index `json:"index"`
}
type Theme struct {
DefaultColor string `json:"defaultColor"`
DefaultMenu string `json:"defaultMenu"`
DefaultHeader string `json:"defaultHeader"`
AllowCustom bool `json:"allowCustom"`
Banner bool `json:"banner"`
}
type Colors struct {
Id string `json:"id"`
Color string `json:"color"`
Second string `json:"second"`
}
type Other struct {
KeepLoad string `json:"keepLoad"`
AutoHead bool `json:"autoHead"`
Footer bool `json:"footer"`
}
type Header struct {
Message string `json:"message"`
}

View File

@@ -0,0 +1,13 @@
package dto
type SearchDto struct {
SearchTimeBegin string `json:"searchTimeBegin"`
SearchTimeEnd string `json:"searchTimeEnd"`
SearchStatus int `json:"searchStatus"`
SearchName string `json:"searchName"`
SearchKey string `json:"searchKey"`
SearchParentID int `json:"searchParentId"`
SearchDepartmentID int `json:"searchDepartmentId"`
Page int `json:"page"`
Rows int `json:"rows"`
}

View File

@@ -0,0 +1,26 @@
package dto
type SetMenuDto struct {
ID int32
Name string
Link string
IsList bool
IsSelect bool
Items []*SetMenuDto
}
type OwnerMenuDto struct {
ID int32 `json:"id"`
// 显示名称
DisplayName string `json:"display_name"`
// 菜单url
Url string `json:"url"`
// 上级id
ParentID int32 `json:"parent_id"`
// 菜单图标
Avatar string `json:"avatar"`
// 菜单样式
Style string `json:"style"`
// 是否列表
IsList bool `json:"is_list"`
}

View File

@@ -0,0 +1,56 @@
package dto
import "time"
type SysDepartmentDto struct {
ID int32 `json:"id"`
// 部门名称
Name string `json:"name"`
// 上级id
ParentID int32 `json:"parent_id"`
// 树路径
ParentPath string `json:"parent_path"`
// 状态
Status int32 `json:"status"`
// 排序
Sort int32 `json:"sort"`
// 创建时间
CreatedAt time.Time `json:"created_at"`
// 更新时间
UpdatedAt time.Time `json:"updated_at"`
Children []*SysDepartmentDto `json:"children"`
}
type SysMenuDto struct {
ID int32 `json:"id"`
// 名称
Name string `json:"name"`
// 显示名称
DisplayName string `json:"display_name"`
// 菜单url
Url string `json:"url"`
// 菜单类型(node, menu, btn)
Type string `json:"type"`
// 上级id
ParentID int32 `json:"parent_id"`
// 树路径
ParentPath string `json:"parent_path"`
// 菜单图标
Avatar string `json:"avatar"`
// 菜单样式
Style string `json:"style"`
// 是否可见
Visible bool `json:"visible"`
// 是否列表
IsList bool `json:"is_list"`
// 状态
Status int32 `json:"status"`
// 排序
Sort int32 `json:"sort"`
// 创建时间
CreatedAt time.Time `json:"created_at"`
// 更新时间
UpdatedAt time.Time `json:"updated_at"`
Children []*SysMenuDto `json:"children"`
}

View File

@@ -0,0 +1,17 @@
package dto
type TreeDto struct {
ID int `json:"id"`
Title string `json:"title"`
Children []*TreeDto `json:"children"`
}
type DTreeDto struct {
ID string `json:"id"`
Title string `json:"title"`
Last bool `json:"last"`
ParentId string `json:"parentId"`
Children []*DTreeDto `json:"children"`
}

View File

@@ -0,0 +1,21 @@
package dto
type XmSelectDto struct {
Name string `json:"name"`
Value int `json:"value"`
}
type XmSelectInt64Dto struct {
Name string `json:"name"`
Value int64 `json:"value"`
}
type XmSelectInt32Dto struct {
Name string `json:"name"`
Value int32 `json:"value"`
}
type XmSelectStrDto struct {
Name string `json:"name"`
Value string `json:"value"`
}

View File

@@ -0,0 +1,53 @@
package form
import (
"time"
db "management/internal/db/sqlc"
"management/internal/pkg/convertor"
"github.com/jackc/pgx/v5/pgtype"
)
type BudgetForm struct {
ID int64 `json:"id"`
ProjectID int64 `json:"project_id"`
Name string `json:"name"`
BudgetType int32 `json:"budget_type"`
Category int32 `json:"category"`
StartAt time.Time `json:"start_at"`
EndAt time.Time `json:"end_at"`
Amount float64 `json:"amount"`
AmountF pgtype.Numeric `comment:"预算金额"`
UsedAmount float64 `json:"used_amount"`
UsedAmountF pgtype.Numeric `comment:"已支付金额"`
RemainingAmount float64 `json:"remaining_amount"`
RemainingAmountF pgtype.Numeric `comment:"剩余金额"`
Remark string `json:"remark"`
Status int16 `json:"status"`
Sort int32 `json:"sort"`
CreatedAt time.Time `json:"created_at"`
CreatedName string `comment:"创建人"`
UpdatedAt time.Time `json:"updated_at"`
UpdatedName string `comment:"更新人"`
}
func (f *BudgetForm) ToForm(p *db.Budget) *BudgetForm {
return &BudgetForm{
ID: p.ID,
ProjectID: p.ProjectID,
Name: p.Name,
BudgetType: p.BudgetType,
Category: p.Category,
StartAt: p.StartAt,
EndAt: p.EndAt,
Amount: convertor.NumericToFloat64(p.Amount),
UsedAmount: convertor.NumericToFloat64(p.UsedAmount),
RemainingAmount: convertor.NumericToFloat64(p.RemainingAmount),
Remark: p.Remark,
Status: p.Status,
Sort: p.Sort,
CreatedAt: p.CreatedAt,
UpdatedAt: p.UpdatedAt,
}
}

View File

@@ -0,0 +1,39 @@
package form
import (
"time"
db "management/internal/db/sqlc"
)
type CustomerForm struct {
ID int64 `json:"id" validate:"min=0" comment:"ID"`
Name string `json:"name" validate:"required" comment:"名称"`
Category int32 `json:"category" validate:"min=0" comment:"类别"`
Source int32 `json:"source" validate:"min=0" comment:"来源"`
Address string `json:"address" comment:"地址"`
ContactName string `json:"contact_name" comment:"联系人姓名"`
ContactPhone string `json:"contact_phone" validate:"telephone" comment:"联系人手机"`
Status int16 `json:"status" validate:"min=-1" comment:"状态"`
Sort int32 `json:"sort" validate:"min=0" comment:"排序"`
CreatedAt time.Time `json:"created_at" comment:"创建时间"`
CreatedBy string `json:"created_by" comment:"创建人"`
UpdatedAt time.Time `json:"updated_at" comment:"更新时间"`
UpdatedBy string `json:"updated_by" comment:"更新人"`
}
func (f *CustomerForm) ToForm(c *db.Customer) *CustomerForm {
return &CustomerForm{
ID: c.ID,
Name: c.Name,
Category: c.Category,
Source: c.Source,
Address: c.Address,
ContactName: c.ContactName,
ContactPhone: c.ContactPhone,
Status: c.Status,
Sort: c.Sort,
CreatedAt: c.CreatedAt,
UpdatedAt: c.UpdatedAt,
}
}

View File

@@ -0,0 +1,42 @@
package form
import (
"time"
db "management/internal/db/sqlc"
"management/internal/pkg/convertor"
"github.com/jackc/pgx/v5/pgtype"
)
type ExpenseForm struct {
ID int64 `json:"id"`
ProjectID int64 `json:"project_id"`
BudgetID int64 `json:"budget_id"`
Amount float64 `json:"amount"`
AmountF pgtype.Numeric `comment:"报销金额"`
ExpensesAt time.Time `json:"expenses_at"`
ExpensesType int32 `json:"expenses_type"`
Remark string `json:"remark"`
Status int16 `json:"status"`
CreatedAt time.Time `json:"created_at"`
CreatedName string `comment:"创建人"`
UpdatedAt time.Time `json:"updated_at"`
UpdatedName string `comment:"更新人"`
}
func (f *ExpenseForm) ToForm(p *db.Expense) *ExpenseForm {
return &ExpenseForm{
ID: p.ID,
ProjectID: p.ProjectID,
BudgetID: p.BudgetID,
Amount: convertor.NumericToFloat64(p.Amount),
AmountF: p.Amount,
ExpensesAt: p.ExpensesAt,
ExpensesType: p.ExpensesType,
Remark: p.Remark,
Status: p.Status,
CreatedAt: p.CreatedAt,
UpdatedAt: p.UpdatedAt,
}
}

View File

@@ -0,0 +1,40 @@
package form
import (
"net/http"
"management/internal/pkg/validation"
"github.com/gorilla/schema"
)
// 初始化一个解码器实例
var decoder = schema.NewDecoder()
func BindForm(r *http.Request, form any) error {
if err := r.ParseForm(); err != nil {
return err
}
// 忽略名为 "csrf_token" 的表单字段
delete(r.PostForm, "csrf_token")
// decoder.RegisterConverter(time.Time{}, func(s string) reflect.Value {
// res, err := time.ParseInLocation("2006-01-02", s, time.Local)
// if err != nil {
// panic(err)
// }
// return reflect.ValueOf(res)
// })
if err := decoder.Decode(form, r.PostForm); err != nil {
return err
}
// 校验表单规则
if err := validation.ValidateForm(form); err != nil {
return err
}
return nil
}

View File

@@ -0,0 +1,44 @@
package form
import (
"time"
db "management/internal/db/sqlc"
"management/internal/pkg/convertor"
"github.com/jackc/pgx/v5/pgtype"
)
type IncomeForm struct {
ID int64 `json:"id"`
ProjectID int64 `json:"project_id"`
BudgetID int64 `json:"budget_id"`
Amount float64 `json:"amount"`
AmountF pgtype.Numeric `comment:"收入金额"`
IncomeAt time.Time `json:"income_at"`
IncomeType int32 `json:"income_type"`
IncomeBank int32 `json:"income_bank"`
Remark string `json:"remark"`
Status int16 `json:"status"`
CreatedAt time.Time `json:"created_at"`
CreatedName string `comment:"创建人"`
UpdatedAt time.Time `json:"updated_at"`
UpdatedName string `comment:"更新人"`
}
func (f *IncomeForm) ToForm(p *db.Income) *IncomeForm {
return &IncomeForm{
ID: p.ID,
ProjectID: p.ProjectID,
BudgetID: p.BudgetID,
Amount: convertor.NumericToFloat64(p.Amount),
AmountF: p.Amount,
IncomeAt: p.IncomeAt,
IncomeType: p.IncomeType,
IncomeBank: p.IncomeBank,
Remark: p.Remark,
Status: p.Status,
CreatedAt: p.CreatedAt,
UpdatedAt: p.UpdatedAt,
}
}

View File

@@ -0,0 +1,80 @@
package form
import (
"time"
db "management/internal/db/sqlc"
"management/internal/pkg/convertor"
"github.com/jackc/pgx/v5/pgtype"
)
type ProjectFileForm struct {
Combination string `schema:"-"`
ProjectFileItems []*ProjectFileItemForm `schema:"-"`
}
type ProjectFileItemForm struct {
Name string `schema:"-"`
Path string `schema:"-"`
Combination string `schema:"-"`
}
type ProjectForm struct {
ID int64 `validate:"min=0" comment:"ID"`
Name string `validate:"required" comment:"名称"`
StartAt time.Time `validate:"required" comment:"开始时间"`
EndAt time.Time `validate:"required" comment:"结束时间"`
CustomerID int64 `validate:"required" comment:"客户ID"`
CustomerName string `comment:"客户名称"`
TotalMoney float64 `validate:"required" comment:"总金额"`
TotalMoneyF pgtype.Numeric `comment:"总金额"`
Description string `comment:"简介"`
ApplyAt time.Time `validate:"required" comment:"申请时间"`
ApplyUserID int32 `validate:"required" comment:"申请人"`
ApplyUserName string `comment:"申请人"`
ManagerID int32 `comment:"项目经理"`
ManagerName string `comment:"项目经理"`
Members string `comment:"项目成员"`
MembersName string `comment:"项目成员"`
Status int16 `validate:"min=-1" comment:"状态"`
Sort int32 `validate:"min=0" comment:"排序"`
CreatedAt time.Time `comment:"创建时间"`
CreatedName string `comment:"创建人"`
UpdatedAt time.Time `comment:"更新时间"`
UpdatedName string `comment:"更新人"`
ProjectFiles *ProjectFileForm `schema:"-"`
}
func (f *ProjectForm) ToForm(p *db.Project, pfs []*db.ProjectFile) *ProjectForm {
var allCombinationPath string
var pfi []*ProjectFileItemForm
for _, pf := range pfs {
pfi = append(pfi, &ProjectFileItemForm{
Name: pf.Name,
Path: pf.Path,
Combination: pf.Name + "|" + pf.Path,
})
allCombinationPath += pf.Name + "|" + pf.Path + ","
}
return &ProjectForm{
ID: p.ID,
Name: p.Name,
StartAt: p.StartAt,
EndAt: p.EndAt,
CustomerID: p.CustomerID,
TotalMoney: convertor.NumericToFloat64(p.TotalMoney),
Description: p.Description,
ApplyAt: p.ApplyAt,
ApplyUserID: p.ApplyUserID,
ManagerID: p.ManagerID,
Members: p.Members,
Status: p.Status,
Sort: p.Sort,
CreatedAt: p.CreatedAt,
UpdatedAt: p.UpdatedAt,
ProjectFiles: &ProjectFileForm{
Combination: allCombinationPath,
ProjectFileItems: pfi,
},
}
}

View File

@@ -0,0 +1,107 @@
package view
type DashboardProject struct {
ProjectIncome float64 `json:"project_income"` // 项目收入
ProjectExpense float64 `json:"project_expense"` // 项目支出
ProjectProfit float64 `json:"project_profit"` // 项目利润
ProjectProfitRate string `json:"project_profit_rate"` // 项目利润率
IncomeExpenseEcharts EchartsOption `json:"income_expense_echarts"` // 收支图表
IncomeEcharts EchartsOption `json:"income_echarts"` // 收入图表
ExpenseEcharts EchartsOption `json:"expense_echarts"` // 支出图表
}
type EchartsOption struct {
Title Title `json:"title"`
Color []string `json:"color"`
ToolTip ToolTip `json:"tooltip"`
Grid Grid `json:"grid"`
Legend Legend `json:"legend"`
XAxis []XAxis `json:"xAxis"`
YAxis []YAxis `json:"yAxis"`
BarMaxWidth string `json:"barMaxWidth"`
Label Label `json:"label"`
Series []Series `json:"series"`
}
type Series struct {
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
Data any `json:"data,omitempty"`
ItemStyle ItemStyle `json:"itemStyle,omitempty"`
Radius string `json:"radius,omitempty"`
Label Label `json:"label,omitempty"`
}
type ItemStyle struct {
Normal Normal `json:"normal,omitempty"`
}
type Normal struct {
Color string `json:"color,omitempty"`
}
type Title struct {
Text string `json:"text,omitempty"`
Orient string `json:"orient,omitempty"`
Left string `json:"left,omitempty"`
Top int `json:"top,omitempty"`
FontSize int `json:"fontSize,omitempty"`
TextStyle TextStyle `json:"textStyle,omitempty"`
}
type TextStyle struct {
Color string `json:"color,omitempty"`
FontWeight string `json:"fontWeight,omitempty"`
}
type ToolTip struct {
Trigger string `json:"trigger,omitempty"`
AxisPointer AxisPointer `json:"axisPointer,omitempty"`
}
type AxisPointer struct {
Type string `json:"type,omitempty"`
}
type Grid struct {
Left string `json:"left,omitempty"`
Right string `json:"right,omitempty"`
Bottom string `json:"bottom,omitempty"`
ContainLabel bool `json:"containLabel,omitempty"`
}
type Legend struct {
Left string `json:"left,omitempty"`
Top string `json:"top,omitempty"`
Data []string `json:"data,omitempty"`
}
type XAxis struct {
Type string `json:"type,omitempty"`
Data []string `json:"data,omitempty"`
AxisTick AxisTick `json:"axisTick,omitempty"`
}
type AxisTick struct {
AlignWithLabel bool `json:"alignWithLabel,omitempty"`
}
type YAxis struct {
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
}
type Label struct {
Show bool `json:"show,omitempty"`
Position string `json:"position,omitempty"`
TextStyle TextStyle `json:"textStyle,omitempty"`
Normal LableNormal `json:"normal,omitempty"`
}
type LableNormal struct {
Formatter string `json:"formatter,omitempty"`
TextStyle TextStyle `json:"textStyle,omitempty"`
}
type DataItem struct {
Name string `json:"name,omitempty"`
Value float64 `json:"value,omitempty"`
}