12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- package model
- import (
- "kpt-tmr-group/pkg/tool"
- operationPb "kpt-tmr-group/proto/go/backend/operation"
- )
- type GroupPasture struct {
- Id int64 `json:"id,omitempty"`
- Name string `json:"name,omitempty"`
- ManagerUser string `json:"manager_user"`
- ManagerPassword string `json:"manager_password"`
- ManagerPhone string `json:"manager_phone"`
- IsShow operationPb.IsShow_Kind `json:"is_show,omitempty"`
- Address string `json:"address"`
- CreatedAt int64 `json:"created_at,omitempty"`
- UpdatedAt int64 `json:"updated_at,omitempty"`
- }
- func (s *GroupPasture) TableName() string {
- return "group_pasture"
- }
- const InitManagerPassword = "123456"
- func NewGroupPasture(req *operationPb.AddPastureRequest) *GroupPasture {
- groupPasture := &GroupPasture{
- Name: req.Name,
- ManagerUser: req.ManagerUser,
- ManagerPassword: tool.Md5String(InitManagerPassword),
- ManagerPhone: req.ManagerPhone,
- IsShow: operationPb.IsShow_OK,
- Address: req.Address,
- }
- return groupPasture
- }
- type GroupPastureSlice []*GroupPasture
- func (g GroupPastureSlice) ToPB() []*operationPb.AddPastureRequest {
- res := make([]*operationPb.AddPastureRequest, len(g))
- for i, v := range g {
- res[i] = &operationPb.AddPastureRequest{
- Id: v.Id,
- Name: v.Name,
- ManagerUser: v.ManagerUser,
- ManagerPhone: v.ManagerPhone,
- Address: v.Address,
- IsShow: v.IsShow,
- CreatedAt: v.CreatedAt,
- }
- }
- return res
- }
- func (g GroupPastureSlice) ToPermissionsPB() []*operationPb.AddPastureRequest {
- res := make([]*operationPb.AddPastureRequest, len(g))
- for i, v := range g {
- res[i] = &operationPb.AddPastureRequest{
- Id: v.Id,
- Name: v.Name,
- }
- }
- return res
- }
- func (g *GroupPasture) ToPb() *operationPb.AddPastureRequest {
- return &operationPb.AddPastureRequest{
- Id: g.Id,
- Name: g.Name,
- ManagerUser: g.ManagerUser,
- ManagerPhone: g.ManagerPhone,
- Address: g.Address,
- IsShow: g.IsShow,
- CreatedAt: g.CreatedAt,
- }
- }
- type GroupPastureResponse struct {
- Page int32 `json:"page"`
- Total int32 `json:"total"`
- List []*operationPb.AddPastureRequest `json:"list"`
- }
- func (g *GroupPastureResponse) ToPB() *operationPb.SearchPastureResponse {
- return &operationPb.SearchPastureResponse{
- Page: g.Page,
- Total: g.Total,
- List: g.List,
- }
- }
|