123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- package model
- import (
- operationPb "kpt-tmr-group/proto/go/backend/operation"
- "time"
- )
- type CattleCategory struct {
- Id int64 `json:"id"`
- ParentId operationPb.CattleCategoryParent_Kind `json:"parent_id"`
- ParentName string `json:"parent_name"`
- Name string `json:"name"`
- Number string `json:"number"`
- IsShow operationPb.IsShow_Kind `json:"is_show"`
- IsDelete operationPb.IsShow_Kind `json:"is_delete"`
- CreatedAt int64 `json:"created_at"`
- UpdatedAt int64 `json:"updated_at"`
- }
- func (s *CattleCategory) TableName() string {
- return "cattle_category"
- }
- func NewCattleCategory(req *operationPb.AddCattleCategoryRequest) *CattleCategory {
- return &CattleCategory{
- ParentId: req.ParentId,
- ParentName: req.ParentName,
- Name: req.Name,
- Number: req.Number,
- IsShow: operationPb.IsShow_OK,
- IsDelete: operationPb.IsShow_OK,
- }
- }
- type CattleCategorySlice []*CattleCategory
- func (c CattleCategorySlice) ToPB() []*operationPb.AddCattleCategoryRequest {
- res := make([]*operationPb.AddCattleCategoryRequest, len(c))
- for i, v := range c {
- res[i] = &operationPb.AddCattleCategoryRequest{
- Id: v.Id,
- Name: v.Name,
- ParentId: v.ParentId,
- ParentName: v.ParentName,
- Number: v.Number,
- IsShow: v.IsShow,
- CreatedAt: v.CreatedAt,
- CreatedAtFormat: time.Unix(v.CreatedAt, 0).Format(LayoutTime),
- }
- }
- return res
- }
- func (c *CattleCategory) ToPb() *operationPb.AddCattleCategoryRequest {
- return &operationPb.AddCattleCategoryRequest{
- Id: c.Id,
- Name: c.Name,
- Number: c.Number,
- ParentId: c.ParentId,
- ParentName: c.ParentName,
- IsShow: c.IsShow,
- CreatedAt: c.CreatedAt,
- }
- }
- type CattleCategoryResponse struct {
- Page int32 `json:"page"`
- Total int32 `json:"total"`
- List []*operationPb.AddCattleCategoryRequest `json:"list"`
- }
- func (c *CattleCategoryResponse) ToPB() *operationPb.SearchCattleCategoryResponse {
- return &operationPb.SearchCattleCategoryResponse{
- Page: c.Page,
- Total: c.Total,
- List: c.List,
- }
- }
|