审查视图

pkg/domain/company.go 2.1 KB
唐旭辉 authored
1 2
package domain
唐旭辉 authored
3 4 5 6
import (
	"fmt"
	"time"
)
唐旭辉 authored
7 8 9 10 11 12 13 14 15 16 17 18 19

// 公司的状态 1正常 2禁用
const (
	companyStatusUsable   int8 = 1
	companyStatusUnusable int8 = 2
)

//是否开启机会模块,是否有效【1:有效】【2:无效】
const (
	CompanyEnableYes int8 = 1
	CompanyEnableNo  int8 = 2
)
20
type CompanyApplets struct {
唐旭辉 authored
21 22 23 24
	Name     string `json:"name"`
	URL      string `json:"url"`
	Id       string `json:"id"`
	ImageUrl string `json:"imageUrl"`
25 26
}
唐旭辉 authored
27 28 29 30 31 32
// 公司信息
type Company struct {
	// 唯一标识
	Id int64 `json:"id"`
	// 名称
	Name string `json:"name"`
唐旭辉 authored
33 34
	//简称
	Abbreviation string `json:"abbreviation"`
唐旭辉 authored
35 36 37 38 39 40 41 42
	// 手机号码
	Phone string `json:"phone"`
	// 公司logo
	Logo string `json:"logo"`
	// 备注
	Remarks string `json:"remarks"`
	// 总后台的公司id
	AdminCompanyId int `json:"adminCompanyId"`
唐旭辉 authored
43
	//是否有效【1:有效】【2:无效】
唐旭辉 authored
44 45 46 47 48 49
	Enable int8 `json:"enable"`
	// 创建时间
	CreateAt time.Time `json:"createAt"`
	// 更新时间
	UpdateAt time.Time `json:"updateAt"`
	// 删除时间
50 51
	DeleteAt time.Time        `json:"deleteAt"`
	Applets  []CompanyApplets `json:"applets"`
唐旭辉 authored
52 53 54 55 56 57
}

func (c Company) EnableIsOk() bool {
	return c.Enable == CompanyEnableYes
}
唐旭辉 authored
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
func (c *Company) Update(m map[string]interface{}) error {
	if v, ok := m["Name"]; ok {
		c.Name = fmt.Sprint(v)
	}
	if v, ok := m["Phone"]; ok {
		c.Phone = fmt.Sprint(v)
	}
	if v, ok := m["Logo"]; ok {
		c.Logo = fmt.Sprint(v)
	}
	if v, ok := m["Remarks"]; ok {
		c.Remarks = fmt.Sprint(v)
	}
	if v, ok := m["AdminCompanyId"]; ok {
		c.AdminCompanyId = v.(int)
	}
	if v, ok := m["Remarks"]; ok {
		c.Remarks = fmt.Sprint(v)
	}
	if v, ok := m["Enable"]; ok {
		c.Enable = v.(int8)
	}
唐旭辉 authored
80 81 82
	if v, ok := m["Abbreviation"]; ok {
		c.Abbreviation = v.(string)
	}
83 84 85
	if v, ok := m["Applets"]; ok {
		c.Applets = v.([]CompanyApplets)
	}
唐旭辉 authored
86 87 88
	return nil
}
唐旭辉 authored
89
type CompanyFindOneOptions struct {
唐旭辉 authored
90 91
	Id             int64
	AdminCompanyId int64
唐旭辉 authored
92 93 94 95 96
}

type CompanyFindOptions struct {
}
唐旭辉 authored
97 98 99
type CompanyRepository interface {
	Add(*Company) error
	Edit(*Company) error
唐旭辉 authored
100 101
	FindOne(queryOptions CompanyFindOneOptions) (Company, error)
	Find(queryOptions CompanyFindOptions) (int64, []Company, error)
唐旭辉 authored
102
}