Ver código fonte

生成预约资格代码

jianglw 4 anos atrás
pai
commit
5114878844

+ 36 - 0
dao/base_equipment_qualification.go

@@ -0,0 +1,36 @@
+// ============================================================================
+// This is auto-generated by gf cli tool only once. Fill this file as you wish.
+// ============================================================================
+
+package dao
+
+import (
+	"lims_adapter/dao/internal"
+)
+
+// baseEquipmentQualificationDao is the manager for logic model data accessing
+// and custom defined data operations functions management. You can define
+// methods on it to extend its functionality as you wish.
+type baseEquipmentQualificationDao struct {
+	internal.BaseEquipmentQualificationDao
+}
+
+var (
+	// BaseEquipmentQualification is globally public accessible object for table base_equipment_qualification operations.
+	BaseEquipmentQualification = baseEquipmentQualificationDao{
+		internal.BaseEquipmentQualification,
+	}
+)
+
+type BaseEquipmentQualificationDao struct {
+	internal.BaseEquipmentQualificationDao
+}
+
+func NewBaseEquipmentQualificationDao(tenant string) *BaseEquipmentQualificationDao {
+	dao := internal.NewBaseEquipmentQualificationDao(tenant)
+	return &BaseEquipmentQualificationDao{
+		dao,
+	}
+}
+
+// Fill with you ideas below.

+ 422 - 0
dao/internal/base_equipment_qualification.go

@@ -0,0 +1,422 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. DO NOT EDIT THIS FILE MANUALLY.
+// ==========================================================================
+
+package internal
+
+import (
+	"context"
+	"database/sql"
+	"github.com/gogf/gf/database/gdb"
+	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/frame/gmvc"
+	"lims_adapter/model"
+	"time"
+)
+
+// BaseEquipmentQualificationDao is the manager for logic model data accessing
+// and custom defined data operations functions management.
+type BaseEquipmentQualificationDao struct {
+	gmvc.M
+	DB      gdb.DB
+	Table   string
+	Columns baseEquipmentQualificationColumns
+}
+
+// BaseEquipmentQualificationColumns defines and stores column names for table base_equipment_qualification.
+type baseEquipmentQualificationColumns struct {
+	Id             string // 主键
+	EquipmentId    string // 设备Id
+	Qualification  string // 预约资格:1普通资格,2资深资格
+	AuthorizeTime  string // 授权时间
+	CreateOn       string //
+	CreateUserId   string //
+	CreateBy       string //
+	ModifiedOn     string //
+	ModifiedUserId string //
+	ModifiedBy     string //
+}
+
+var (
+	// BaseEquipmentQualification is globally public accessible object for table base_equipment_qualification operations.
+	BaseEquipmentQualification = BaseEquipmentQualificationDao{
+		M:     g.DB("default").Model("base_equipment_qualification").Safe(),
+		DB:    g.DB("default"),
+		Table: "base_equipment_qualification",
+		Columns: baseEquipmentQualificationColumns{
+			Id:             "Id",
+			EquipmentId:    "EquipmentId",
+			Qualification:  "Qualification",
+			AuthorizeTime:  "AuthorizeTime",
+			CreateOn:       "CreateOn",
+			CreateUserId:   "CreateUserId",
+			CreateBy:       "CreateBy",
+			ModifiedOn:     "ModifiedOn",
+			ModifiedUserId: "ModifiedUserId",
+			ModifiedBy:     "ModifiedBy",
+		},
+	}
+)
+
+func NewBaseEquipmentQualificationDao(tenant string) BaseEquipmentQualificationDao {
+	var dao BaseEquipmentQualificationDao
+	dao = BaseEquipmentQualificationDao{
+		M:     g.DB("default").Model("base_equipment_qualification").Safe(),
+		DB:    g.DB("default"),
+		Table: "base_equipment_qualification",
+		Columns: baseEquipmentQualificationColumns{
+			Id:             "Id",
+			EquipmentId:    "EquipmentId",
+			Qualification:  "Qualification",
+			AuthorizeTime:  "AuthorizeTime",
+			CreateOn:       "CreateOn",
+			CreateUserId:   "CreateUserId",
+			CreateBy:       "CreateBy",
+			ModifiedOn:     "ModifiedOn",
+			ModifiedUserId: "ModifiedUserId",
+			ModifiedBy:     "ModifiedBy",
+		},
+	}
+	return dao
+}
+
+// Ctx is a chaining function, which creates and returns a new DB that is a shallow copy
+// of current DB object and with given context in it.
+// Note that this returned DB object can be used only once, so do not assign it to
+// a global or package variable for long using.
+func (d *BaseEquipmentQualificationDao) Ctx(ctx context.Context) *BaseEquipmentQualificationDao {
+	return &BaseEquipmentQualificationDao{M: d.M.Ctx(ctx)}
+}
+
+// As sets an alias name for current table.
+func (d *BaseEquipmentQualificationDao) As(as string) *BaseEquipmentQualificationDao {
+	return &BaseEquipmentQualificationDao{M: d.M.As(as)}
+}
+
+// TX sets the transaction for current operation.
+func (d *BaseEquipmentQualificationDao) TX(tx *gdb.TX) *BaseEquipmentQualificationDao {
+	return &BaseEquipmentQualificationDao{M: d.M.TX(tx)}
+}
+
+// Master marks the following operation on master node.
+func (d *BaseEquipmentQualificationDao) Master() *BaseEquipmentQualificationDao {
+	return &BaseEquipmentQualificationDao{M: d.M.Master()}
+}
+
+// Slave marks the following operation on slave node.
+// Note that it makes sense only if there's any slave node configured.
+func (d *BaseEquipmentQualificationDao) Slave() *BaseEquipmentQualificationDao {
+	return &BaseEquipmentQualificationDao{M: d.M.Slave()}
+}
+
+// Args sets custom arguments for model operation.
+func (d *BaseEquipmentQualificationDao) Args(args ...interface{}) *BaseEquipmentQualificationDao {
+	return &BaseEquipmentQualificationDao{M: d.M.Args(args...)}
+}
+
+// LeftJoin does "LEFT JOIN ... ON ..." statement on the model.
+// The parameter <table> can be joined table and its joined condition,
+// and also with its alias name, like:
+// Table("user").LeftJoin("user_detail", "user_detail.uid=user.uid")
+// Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
+func (d *BaseEquipmentQualificationDao) LeftJoin(table ...string) *BaseEquipmentQualificationDao {
+	return &BaseEquipmentQualificationDao{M: d.M.LeftJoin(table...)}
+}
+
+// RightJoin does "RIGHT JOIN ... ON ..." statement on the model.
+// The parameter <table> can be joined table and its joined condition,
+// and also with its alias name, like:
+// Table("user").RightJoin("user_detail", "user_detail.uid=user.uid")
+// Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid")
+func (d *BaseEquipmentQualificationDao) RightJoin(table ...string) *BaseEquipmentQualificationDao {
+	return &BaseEquipmentQualificationDao{M: d.M.RightJoin(table...)}
+}
+
+// InnerJoin does "INNER JOIN ... ON ..." statement on the model.
+// The parameter <table> can be joined table and its joined condition,
+// and also with its alias name, like:
+// Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid")
+// Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid")
+func (d *BaseEquipmentQualificationDao) InnerJoin(table ...string) *BaseEquipmentQualificationDao {
+	return &BaseEquipmentQualificationDao{M: d.M.InnerJoin(table...)}
+}
+
+// Fields sets the operation fields of the model, multiple fields joined using char ','.
+// The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
+func (d *BaseEquipmentQualificationDao) Fields(fieldNamesOrMapStruct ...interface{}) *BaseEquipmentQualificationDao {
+	return &BaseEquipmentQualificationDao{M: d.M.Fields(fieldNamesOrMapStruct...)}
+}
+
+// FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
+// The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
+func (d *BaseEquipmentQualificationDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *BaseEquipmentQualificationDao {
+	return &BaseEquipmentQualificationDao{M: d.M.FieldsEx(fieldNamesOrMapStruct...)}
+}
+
+// Option sets the extra operation option for the model.
+func (d *BaseEquipmentQualificationDao) Option(option int) *BaseEquipmentQualificationDao {
+	return &BaseEquipmentQualificationDao{M: d.M.Option(option)}
+}
+
+// OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
+// the data and where attributes for empty values.
+func (d *BaseEquipmentQualificationDao) OmitEmpty() *BaseEquipmentQualificationDao {
+	return &BaseEquipmentQualificationDao{M: d.M.OmitEmpty()}
+}
+
+// Filter marks filtering the fields which does not exist in the fields of the operated table.
+func (d *BaseEquipmentQualificationDao) Filter() *BaseEquipmentQualificationDao {
+	return &BaseEquipmentQualificationDao{M: d.M.Filter()}
+}
+
+// Where sets the condition statement for the model. The parameter <where> can be type of
+// string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times,
+// multiple conditions will be joined into where statement using "AND".
+// Eg:
+// Where("uid=10000")
+// Where("uid", 10000)
+// Where("money>? AND name like ?", 99999, "vip_%")
+// Where("uid", 1).Where("name", "john")
+// Where("status IN (?)", g.Slice{1,2,3})
+// Where("age IN(?,?)", 18, 50)
+// Where(User{ Id : 1, UserName : "john"})
+func (d *BaseEquipmentQualificationDao) Where(where interface{}, args ...interface{}) *BaseEquipmentQualificationDao {
+	return &BaseEquipmentQualificationDao{M: d.M.Where(where, args...)}
+}
+
+// WherePri does the same logic as M.Where except that if the parameter <where>
+// is a single condition like int/string/float/slice, it treats the condition as the primary
+// key value. That is, if primary key is "id" and given <where> parameter as "123", the
+// WherePri function treats the condition as "id=123", but M.Where treats the condition
+// as string "123".
+func (d *BaseEquipmentQualificationDao) WherePri(where interface{}, args ...interface{}) *BaseEquipmentQualificationDao {
+	return &BaseEquipmentQualificationDao{M: d.M.WherePri(where, args...)}
+}
+
+// And adds "AND" condition to the where statement.
+func (d *BaseEquipmentQualificationDao) And(where interface{}, args ...interface{}) *BaseEquipmentQualificationDao {
+	return &BaseEquipmentQualificationDao{M: d.M.And(where, args...)}
+}
+
+// Or adds "OR" condition to the where statement.
+func (d *BaseEquipmentQualificationDao) Or(where interface{}, args ...interface{}) *BaseEquipmentQualificationDao {
+	return &BaseEquipmentQualificationDao{M: d.M.Or(where, args...)}
+}
+
+// Group sets the "GROUP BY" statement for the model.
+func (d *BaseEquipmentQualificationDao) Group(groupBy string) *BaseEquipmentQualificationDao {
+	return &BaseEquipmentQualificationDao{M: d.M.Group(groupBy)}
+}
+
+// Order sets the "ORDER BY" statement for the model.
+func (d *BaseEquipmentQualificationDao) Order(orderBy ...string) *BaseEquipmentQualificationDao {
+	return &BaseEquipmentQualificationDao{M: d.M.Order(orderBy...)}
+}
+
+// Limit sets the "LIMIT" statement for the model.
+// The parameter <limit> can be either one or two number, if passed two number is passed,
+// it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]"
+// statement.
+func (d *BaseEquipmentQualificationDao) Limit(limit ...int) *BaseEquipmentQualificationDao {
+	return &BaseEquipmentQualificationDao{M: d.M.Limit(limit...)}
+}
+
+// Offset sets the "OFFSET" statement for the model.
+// It only makes sense for some databases like SQLServer, PostgreSQL, etc.
+func (d *BaseEquipmentQualificationDao) Offset(offset int) *BaseEquipmentQualificationDao {
+	return &BaseEquipmentQualificationDao{M: d.M.Offset(offset)}
+}
+
+// Page sets the paging number for the model.
+// The parameter <page> is started from 1 for paging.
+// Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
+func (d *BaseEquipmentQualificationDao) Page(page, limit int) *BaseEquipmentQualificationDao {
+	return &BaseEquipmentQualificationDao{M: d.M.Page(page, limit)}
+}
+
+// Batch sets the batch operation number for the model.
+func (d *BaseEquipmentQualificationDao) Batch(batch int) *BaseEquipmentQualificationDao {
+	return &BaseEquipmentQualificationDao{M: d.M.Batch(batch)}
+}
+
+// Cache sets the cache feature for the model. It caches the result of the sql, which means
+// if there's another same sql request, it just reads and returns the result from cache, it
+// but not committed and executed into the database.
+//
+// If the parameter <duration> < 0, which means it clear the cache with given <name>.
+// If the parameter <duration> = 0, which means it never expires.
+// If the parameter <duration> > 0, which means it expires after <duration>.
+//
+// The optional parameter <name> is used to bind a name to the cache, which means you can later
+// control the cache like changing the <duration> or clearing the cache with specified <name>.
+//
+// Note that, the cache feature is disabled if the model is operating on a transaction.
+func (d *BaseEquipmentQualificationDao) Cache(duration time.Duration, name ...string) *BaseEquipmentQualificationDao {
+	return &BaseEquipmentQualificationDao{M: d.M.Cache(duration, name...)}
+}
+
+// Data sets the operation data for the model.
+// The parameter <data> can be type of string/map/gmap/slice/struct/*struct, etc.
+// Eg:
+// Data("uid=10000")
+// Data("uid", 10000)
+// Data(g.Map{"uid": 10000, "name":"john"})
+// Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"})
+func (d *BaseEquipmentQualificationDao) Data(data ...interface{}) *BaseEquipmentQualificationDao {
+	return &BaseEquipmentQualificationDao{M: d.M.Data(data...)}
+}
+
+// All does "SELECT FROM ..." statement for the model.
+// It retrieves the records from table and returns the result as []*model.BaseEquipmentQualification.
+// It returns nil if there's no record retrieved with the given conditions from table.
+//
+// The optional parameter <where> is the same as the parameter of M.Where function,
+// see M.Where.
+func (d *BaseEquipmentQualificationDao) All(where ...interface{}) ([]*model.BaseEquipmentQualification, error) {
+	all, err := d.M.All(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entities []*model.BaseEquipmentQualification
+	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entities, nil
+}
+
+// One retrieves one record from table and returns the result as *model.BaseEquipmentQualification.
+// It returns nil if there's no record retrieved with the given conditions from table.
+//
+// The optional parameter <where> is the same as the parameter of M.Where function,
+// see M.Where.
+func (d *BaseEquipmentQualificationDao) One(where ...interface{}) (*model.BaseEquipmentQualification, error) {
+	one, err := d.M.One(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entity *model.BaseEquipmentQualification
+	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entity, nil
+}
+
+// FindOne retrieves and returns a single Record by M.WherePri and M.One.
+// Also see M.WherePri and M.One.
+func (d *BaseEquipmentQualificationDao) FindOne(where ...interface{}) (*model.BaseEquipmentQualification, error) {
+	one, err := d.M.FindOne(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entity *model.BaseEquipmentQualification
+	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entity, nil
+}
+
+// FindAll retrieves and returns Result by by M.WherePri and M.All.
+// Also see M.WherePri and M.All.
+func (d *BaseEquipmentQualificationDao) FindAll(where ...interface{}) ([]*model.BaseEquipmentQualification, error) {
+	all, err := d.M.FindAll(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entities []*model.BaseEquipmentQualification
+	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entities, nil
+}
+
+// Struct retrieves one record from table and converts it into given struct.
+// The parameter <pointer> should be type of *struct/**struct. If type **struct is given,
+// it can create the struct internally during converting.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+//
+// Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
+// from table and <pointer> is not nil.
+//
+// Eg:
+// user := new(User)
+// err  := dao.User.Where("id", 1).Struct(user)
+//
+// user := (*User)(nil)
+// err  := dao.User.Where("id", 1).Struct(&user)
+func (d *BaseEquipmentQualificationDao) Struct(pointer interface{}, where ...interface{}) error {
+	return d.M.Struct(pointer, where...)
+}
+
+// Structs retrieves records from table and converts them into given struct slice.
+// The parameter <pointer> should be type of *[]struct/*[]*struct. It can create and fill the struct
+// slice internally during converting.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+//
+// Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
+// from table and <pointer> is not empty.
+//
+// Eg:
+// users := ([]User)(nil)
+// err   := dao.User.Structs(&users)
+//
+// users := ([]*User)(nil)
+// err   := dao.User.Structs(&users)
+func (d *BaseEquipmentQualificationDao) Structs(pointer interface{}, where ...interface{}) error {
+	return d.M.Structs(pointer, where...)
+}
+
+// Scan automatically calls Struct or Structs function according to the type of parameter <pointer>.
+// It calls function Struct if <pointer> is type of *struct/**struct.
+// It calls function Structs if <pointer> is type of *[]struct/*[]*struct.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+//
+// Note that it returns sql.ErrNoRows if there's no record retrieved and given pointer is not empty or nil.
+//
+// Eg:
+// user  := new(User)
+// err   := dao.User.Where("id", 1).Scan(user)
+//
+// user  := (*User)(nil)
+// err   := dao.User.Where("id", 1).Scan(&user)
+//
+// users := ([]User)(nil)
+// err   := dao.User.Scan(&users)
+//
+// users := ([]*User)(nil)
+// err   := dao.User.Scan(&users)
+func (d *BaseEquipmentQualificationDao) Scan(pointer interface{}, where ...interface{}) error {
+	return d.M.Scan(pointer, where...)
+}
+
+// Chunk iterates the table with given size and callback function.
+func (d *BaseEquipmentQualificationDao) Chunk(limit int, callback func(entities []*model.BaseEquipmentQualification, err error) bool) {
+	d.M.Chunk(limit, func(result gdb.Result, err error) bool {
+		var entities []*model.BaseEquipmentQualification
+		err = result.Structs(&entities)
+		if err == sql.ErrNoRows {
+			return false
+		}
+		return callback(entities, err)
+	})
+}
+
+// LockUpdate sets the lock for update for current operation.
+func (d *BaseEquipmentQualificationDao) LockUpdate() *BaseEquipmentQualificationDao {
+	return &BaseEquipmentQualificationDao{M: d.M.LockUpdate()}
+}
+
+// LockShared sets the lock in share mode for current operation.
+func (d *BaseEquipmentQualificationDao) LockShared() *BaseEquipmentQualificationDao {
+	return &BaseEquipmentQualificationDao{M: d.M.LockShared()}
+}
+
+// Unscoped enables/disables the soft deleting feature.
+func (d *BaseEquipmentQualificationDao) Unscoped() *BaseEquipmentQualificationDao {
+	return &BaseEquipmentQualificationDao{M: d.M.Unscoped()}
+}

+ 31 - 0
handler/equipment.go

@@ -0,0 +1,31 @@
+package handler
+
+import (
+	"context"
+	"dashoo.cn/common_definition/comm_def"
+	"lims_adapter/model"
+)
+
+// 设备
+type Equipment struct{}
+
+// AppointmentList 设备预约资格列表查询
+
+func (e *Equipment) AppointmentList(ctx context.Context, req *model.ListReq, rsp *comm_def.CommonMsg) error {
+	//tenant, err := micro_srv.GetTenant(ctx)
+	//if err != nil {
+	//	return err
+	//}
+	//g.Log().Info("Received Equipment.AppointmentList request @ " + tenant)
+	//if req.Size == 0 {
+	//	req.Size = DefaultPageNum
+	//}
+	//if req.Current < 0 {
+	//	req.Current = DefaultPageCurrent
+	//}
+	//list, total, err := equipment.NewSrv(tenant)
+	//rsp.Code = code
+	//rsp.Msg = msg
+	//rsp.Data = g.Map{"total": total, "list": list}
+	return nil
+}

+ 14 - 0
model/base_equipment_qualification.go

@@ -0,0 +1,14 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. Fill this file as you wish.
+// ==========================================================================
+
+package model
+
+import (
+	"lims_adapter/model/internal"
+)
+
+// BaseEquipmentQualification is the golang structure for table base_equipment_qualification.
+type BaseEquipmentQualification internal.BaseEquipmentQualification
+
+// Fill with you ideas below.

+ 23 - 0
model/internal/base_equipment_qualification.go

@@ -0,0 +1,23 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. DO NOT EDIT THIS FILE MANUALLY.
+// ==========================================================================
+
+package internal
+
+import (
+	"github.com/gogf/gf/os/gtime"
+)
+
+// BaseEquipmentQualification is the golang structure for table base_equipment_qualification.
+type BaseEquipmentQualification struct {
+	Id             int         `orm:"Id,primary"     json:"id"`             // 主键
+	EquipmentId    int         `orm:"EquipmentId"    json:"equipmentId"`    // 设备Id
+	Qualification  string      `orm:"Qualification"  json:"qualification"`  // 预约资格:1普通资格,2资深资格
+	AuthorizeTime  *gtime.Time `orm:"AuthorizeTime"  json:"authorizeTime"`  // 授权时间
+	CreateOn       *gtime.Time `orm:"CreateOn"       json:"createOn"`       //
+	CreateUserId   string      `orm:"CreateUserId"   json:"createUserId"`   //
+	CreateBy       string      `orm:"CreateBy"       json:"createBy"`       //
+	ModifiedOn     *gtime.Time `orm:"ModifiedOn"     json:"modifiedOn"`     //
+	ModifiedUserId string      `orm:"ModifiedUserId" json:"modifiedUserId"` //
+	ModifiedBy     string      `orm:"ModifiedBy"     json:"modifiedBy"`     //
+}

+ 14 - 0
service/equipment/equipment.go

@@ -0,0 +1,14 @@
+package equipment
+
+import "lims_adapter/dao"
+
+// Service 设备
+type Service struct {
+	Dao    *dao.BaseEquipmentQualificationDao
+	Tenant string
+}
+
+// NewSrv 服务初始化
+func NewSrv(tenant string) Service {
+	return Service{Dao: dao.NewBaseEquipmentQualificationDao(tenant), Tenant: tenant}
+}