models

package
v0.0.0-...-7313388 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTag

func AddTag(name string, state int, createdBy string) error

添加一个标签

func CheckAuth

func CheckAuth(username, password string) (bool, error)

CheckAuth 检查身份验证信息是否存在

func CleanAllTag

func CleanAllTag() (bool, error)

清除所有标记

func CloseDB

func CloseDB()

CloseDB关闭数据库连接

func DeleteTag

func DeleteTag(id int) error

删除标签

func DeleteUser

func DeleteUser(id int) error

DeleteUser 删除用户

func EditTag

func EditTag(id int, data interface{}) error

EditTag修改单个标签

func ExistRoleByID

func ExistRoleByID(id int) (bool, error)

ExistRoleByID根据该ID确定是否存在标记

func ExistTagByID

func ExistTagByID(id int) (bool, error)

ExistTagByID根据该ID确定是否存在标记

func ExistTagByName

func ExistTagByName(name string) (bool, error)

ExistTagByName检查是否存在具有相同名称的标记

func ExistUserByID

func ExistUserByID(id int) (bool, error)

ExistUserByID根据该ID确定是否存在标记

func ExistUserByUserName

func ExistUserByUserName(username string) (bool, error)

ExistUserByID根据该ID确定是否存在标记

func GetRoleName

func GetRoleName(id int) (string, error)

GetRole 通过ID获取单个角色

func GetTagTotal

func GetTagTotal(maps interface{}) (int, error)

GetTagTotal根据约束计算标签的总数

func GetUserTotal

func GetUserTotal(search string) (int, error)

GetUserTotal 获取用户总条数

func Setup

func Setup()

安装程序初始化数据库实例

func UpdateUser

func UpdateUser(id int, data interface{}) error

UpdateUser 修改用户信息

Types

type AddUserParam

type AddUserParam struct {
	UserName string `valid:"required,length(3|36)~仅允许3-36个字符的用户名"`
	Password string `valid:"required,length(3|36)~仅允许3-36个字符的密码"`
	Name     string `valid:"runelength(2|36)~仅允许2-36个字符的姓名"`
	Phone    string `valid:"phone~电话号码格式不正确"`
	Remarks  string `valid:"runelength(0|200)"`
	Role     int    `valid:"required~角色ID不能为空"`
}

type Area

type Area struct {
	BaseModel
	Name        string `gorm:"column:name;size:47" json:"name"`
	Description string `gorm:"column:description;size:200" json:"description"`
	Sort        int    `gorm:"column:sort;default:0" json:"sort"`
}

type Auth

type Auth struct {
	Username string `json:"username" valid:"Required; MaxSize(50)" binding:"required"`
	Password string `json:"password" valid:"Required; MaxSize(50)" binding:"required"`
}

type BaseModel

type BaseModel struct {
	ID         int           `gorm:"column:id;primary_key;AUTO_INCREMENT" json:"id"`
	Status     int8          `gorm:"column:status;default:1" json:"status"`
	IsDel      bool          `gorm:"column:is_del;default:false" json:"is_del"`
	CreateTime util.JSONTime `gorm:"column:create_time" json:"create_time"`
	UpdateTime util.JSONTime `gorm:"column:update_time" json:"update_time"`
	DelTime    time.Time     `gorm:"column:del_time;default:null" json:"del_time"`
}

type Device

type Device struct {
	BaseModel
	Name        string `gorm:"column:name;not null;unique;type:varchar(47);index" json:"name"`
	Description string `gorm:"column:description;default:'';type:text(200)" json:"description"`
	GatherType  string `gorm:"column:gather_type;not null;type:varchar(64)" json:"gather_type"`
	AreaID      uint   `gorm:"column:gather_type;not null;" json:"area_id"`
	GatherWay   string `gorm:"column:gather_way;not null;type:varchar(64)" json:"gather_way"`
	GatewayID   uint   `gorm:"column:gather_type;not null;" json:"gateway_id"`
	DeviceID    string `gorm:"column:device_id;not null;type:varchar(36)" json:"device_id"`
	DeviceIntId int32  `gorm:"column:device_int_id;not null;default:0" json:"device_int_id"`
	//	# 最大负载(告警负载)(不于小零的整数,为0表示不告警)
	MaxLoad                  float32 `gorm:"column:max_load;not null;default:0;" json:"max_load"`
	WaitLoad                 bool    `gorm:"column:wait_load;not null;default:false;not null;" json:"wait_load"`
	IsHeadMeter              bool    `gorm:"column:is_head_meter;not null;default:false" json:"is_head_meter"`
	Type                     string  `gorm:"column:type;not null;type:varchar(64)" json:"type"`
	ProductId                string  `gorm:"column:product_id;not null;default:'';type:varchar(64)" json:"product_id"`
	IsShow                   bool    `gorm:"column:is_show;not null;default:true" json:"is_show"`
	ManualReadmeterThreshold float32 `gorm:"column:manual_readmeter_threshold;not null;default:0;" json:"manual_readmeter_threshold"`
	BusinessRulesId          int32   `gorm:"column:business_rules_id;not null;default:0" json:"business_rules_id"`
	ModbusIndex              int32   `gorm:"column:modbus_index;default:0" json:"modbus_index"`
	RxcelLocation            string  `gorm:"column:excel_location;default:'';unique;type:varchar(32)" json:"excel_location"`
	WorkLoad                 int32   `gorm:"column:work_load;not null;default:0" json:"work_load"`
	LoadValue                float32 `gorm:"column:load_value;not null;default:0" json:"load_value"`
	Magnification            float32 `gorm:"column:magnification;not null;default:1" json:"magnification"`
	Blocked                  int32   `gorm:"column:sort_num;not null;default:0" json:"sort_num" valid:"Range(0,1)"`
	SortNum                  int32   `gorm:"column:blocked;default:0" json:"blocked"`
	NormalLoad               float32 `gorm:"column:normal_load;default:0" json:"normal_load"`
}

Device 仪表model

type EditUserParam

type EditUserParam struct {
	Password string `valid:"length(3|36)~仅允许3-36个字符的密码“`
	Name     string `valid:"runelength(2|36)~仅允许2-36个字符的姓名"`
	Phone    string `valid:"phone~电话号码格式不正确"`
	Remarks  string `valid:"runelength(0|200)"`
	Role     int
}

type Role

type Role struct {
	BaseModel
	Name          string `gorm:"column:name;not null;unique;type:varchar(47);" json:"name"`
	Remarks       string `gorm:"column:remarks;type:varchar(200);" json:"remarks"`
	Menus         string `gorm:"column:menus;not null;type:varchar(200);" json:"menus"`
	IsSystemRole  bool   `gorm:"column:is_system_role;default:false;" json:"is_system_role"`
	IsAppletLogin bool   `gorm:"column:is_applet_login;default:false;" json:"is_applet_login"`
	// 区域为空时,默认是所有区域
	Area    string `gorm:"column:areas;" json:"areas"`
	Devices string `gorm:"column:devices;" json:"devices"`
}

func AddRole

func AddRole(name, remarks, area, menus, devices string, isSystemRole, isAppletLogin bool) (*Role, error)

func AddRole(Rolename, password, name, phone, remarks string, role int) (*Roleprofile, error) {

func GetRole

func GetRole(id int) (*Role, error)

GetRole 通过ID获取单个角色

type RoleDetails

type RoleDetails struct {
	ID            int      `json:"id"`
	Name          string   `json:"name"`
	Remarks       string   `json:"remarks"`
	Menus         []string `json:"menus"`
	IsSystemRole  bool     `json:"is_system_role"`
	IsAppletLogin bool     `json:"is_applet_login"`
	// 区域为空时,默认是所有区域
	Area       []map[string]interface{} `json:"areas"`
	Devices    []int                    `json:"devices"`
	CreateTime util.JSONTime            `json:"create_time"`
	UpdateTime util.JSONTime            `json:"update_time“`
}

type Tag

type Tag struct {
	BaseModel

	Name       string `json:"name"`
	CreatedBy  string `json:"created_by"`
	ModifiedBy string `json:"modified_by"`
	State      int    `json:"state"`
}

func GetTags

func GetTags(pageNum int, pageSize int, maps interface{}) ([]Tag, error)

GetTags根据分页和约束获取标记列表

type UserDetails

type UserDetails struct {
	ID          int           `json:"id"`
	Username    string        `json:"username"`
	Name        string        `json:"name"`
	Phone       string        `json:"phone"`
	IsSuperuser bool          `json:"is_superuser"`
	Remarks     string        `json:"remarks"`
	Role        int           `json:"role"`
	RoleName    string        `json:"role_name"`
	CreateTime  util.JSONTime `json:"create_time"`
	UpdateTime  util.JSONTime `json:"update_time"`
}

User 用户详情

type Userprofile

type Userprofile struct {
	BaseModel
	Username    string        `gorm:"column:username;not null;unique;type:varchar(47)" json:"username"`
	Password    string        `gorm:"column:password;not null;type:varchar(128)" json:"password"`
	FirstName   string        `gorm:"column:first_name;not null;type:varchar(30)" json:"-"`
	LastName    string        `gorm:"column:last_name;not null;type:varchar(150)" json:"-"`
	Email       string        `gorm:"column:email;not null;type:varchar(254)" json:"email"`
	IsSuperuser bool          `gorm:"column:is_superuser;not null;" json:"is_superuser"`
	IsStaff     bool          `gorm:"column:is_staff;not null;" json:"-"`
	IsActive    bool          `gorm:"column:is_active;default:true;not null;" json:"-"`
	LastLogin   util.JSONTime `gorm:"column:last_login" json:"-"`
	DateJoined  util.JSONTime `gorm:"column:date_joined";not null; json:"-"`
	Name        string        `gorm:"column:name;not null;type:varchar(47)" json:"name"`
	Phone       string        `gorm:"column:phone;not null;type:varchar(18)" json:"phone"`
	Remarks     string        `gorm:"column:remarks;type:varchar(200)" json:"remarks"`
	RoleID      int           `gorm:"column:role_id;not null;default:1" json:"role_id"`
}

func AddUser

func AddUser(user AddUserParam) (*Userprofile, error)

AddUser 添加用户 func AddUser(username, password, name, phone, remarks string, role int) (*Userprofile, error) {

func GetUser

func GetUser(id int) (*Userprofile, error)

GetUser 获取单个用户

func GetUsers

func GetUsers(pageNum int, pageSize int, search string) ([]Userprofile, error)

GetUsers 获取所有用户

type Userslist

type Userslist struct {
	ID          int    `json:"id"`
	Username    string `json:"username"`
	Name        string `json:"name"`
	Phone       string `json:"phone"`
	IsSuperuser bool   `json:"is_superuser"`
	Remarks     string `json:"remarks"`
	RoleName    string `json:"role_name"`
}

Users 返回前端的用户列表

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL