Просмотр исходного кода

调整项目目录结构,
添加:结算明细主表子表方法;财务账号、主从账号分页接口;充值账户添加绑定方法

jianglw 4 лет назад
Родитель
Сommit
15a24cbde1
54 измененных файлов с 1284 добавлено и 371 удалено
  1. 2 2
      config/config.toml
  2. 36 0
      dao/account/settle_account_main.go
  3. 6 6
      dao/consequent/consequent.go
  4. 6 6
      dao/consequent/consequent_detail.go
  5. 11 12
      dao/consequent/internal/consequent.go
  6. 11 12
      dao/consequent/internal/consequent_detail.go
  7. 6 6
      dao/equipment/base_equipment_advance_time.go
  8. 6 6
      dao/equipment/base_equipment_qualification.go
  9. 2 2
      dao/equipment/instrument.go
  10. 11 11
      dao/equipment/internal/base_equipment_advance_time.go
  11. 14 14
      dao/equipment/internal/base_equipment_qualification.go
  12. 11 11
      dao/equipment/internal/instrument.go
  13. 11 12
      dao/meeting/internal/meeting.go
  14. 11 12
      dao/meeting/internal/meeting_reservation.go
  15. 6 6
      dao/meeting/meeting.go
  16. 6 6
      dao/meeting/meeting_reservation.go
  17. 2 2
      dao/system/base_itemdetails.go
  18. 11 11
      dao/system/internal/base_itemdetails.go
  19. 4 4
      dao/user/base_user.go
  20. 11 11
      dao/user/internal/base_user.go
  21. 113 0
      handler/account.go
  22. 88 13
      handler/equipment.go
  23. 5 4
      handler/meeting.go
  24. 7 6
      handler/reservation.go
  25. 97 6
      handler/system.go
  26. 1 1
      main.go
  27. 3 3
      model/account/settle_account_bill.go
  28. 64 0
      model/account/settle_account_detail.go
  29. 19 0
      model/account/settle_account_main.go
  30. 0 37
      model/base_user.go
  31. 3 3
      model/consequent/consequent.go
  32. 3 3
      model/consequent/consequent_detail.go
  33. 0 0
      model/consequent/internal/consequent.go
  34. 0 0
      model/consequent/internal/consequent_detail.go
  35. 3 3
      model/equipment/base_equipment_advance_time.go
  36. 15 15
      model/equipment/base_equipment_qualification.go
  37. 64 0
      model/equipment/instrument.go
  38. 0 0
      model/equipment/internal/base_equipment_advance_time.go
  39. 1 1
      model/equipment/internal/base_equipment_qualification.go
  40. 6 0
      model/equipment/internal/instrument.go
  41. 0 0
      model/meeting/internal/meeting.go
  42. 0 0
      model/meeting/internal/meeting_reservation.go
  43. 3 3
      model/meeting/meeting.go
  44. 5 5
      model/meeting/meeting_reservation.go
  45. 3 3
      model/system/base_itemdetails.go
  46. 0 0
      model/system/internal/base_itemdetails.go
  47. 126 0
      model/user/base_user.go
  48. 0 0
      model/user/internal/base_user.go
  49. 184 0
      service/account/account.go
  50. 104 55
      service/equipment/equipment.go
  51. 18 14
      service/meeting/meeting.go
  52. 28 26
      service/reservation/reservation.go
  53. 4 4
      service/result/result.go
  54. 133 14
      service/system/system.go

+ 2 - 2
config/config.toml

@@ -46,7 +46,7 @@
 
 [gfcli]
     [[gfcli.gen.dao]]
-        link   = "mysql:root:Dashoo#190801@ali@tcp(192.168.0.252:3306)/lims_dev"
+        link   = "mysql:root:Dashoo#190801@ali@tcp(192.168.0.252:3306)/lims_test"
         group  = "default"
         prefix = ""
-        tables = "base_itemdetails"
+        tables = "base_account"

+ 36 - 0
dao/account/settle_account_main.go

@@ -0,0 +1,36 @@
+// ============================================================================
+// This is auto-generated by gf cli tool only once. Fill this file as you wish.
+// ============================================================================
+
+package account
+
+import (
+	"lims_adapter/dao/account/internal"
+)
+
+// settleAccountMainDao 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 settleAccountMainDao struct {
+	internal.SettleAccountMainDao
+}
+
+var (
+	// SettleAccountMain is globally public accessible object for table settle_account_main operations.
+	SettleAccountMain = settleAccountMainDao{
+		internal.SettleAccountMain,
+	}
+)
+
+type SettleAccountMainDao struct {
+	internal.SettleAccountMainDao
+}
+
+func NewSettleAccountMainDao(tenant string) *SettleAccountMainDao {
+	dao := internal.NewSettleAccountMainDao(tenant)
+	return &SettleAccountMainDao{
+		dao,
+	}
+}
+
+// Fill with you ideas below.

+ 6 - 6
dao/consequent.go → dao/consequent/consequent.go

@@ -2,32 +2,32 @@
 // This is auto-generated by gf cli tool only once. Fill this file as you wish.
 // ============================================================================
 
-package dao
+package consequent
 
 import (
-	"lims_adapter/dao/internal"
+	internal2 "lims_adapter/dao/consequent/internal"
 )
 
 // consequentDao 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 consequentDao struct {
-	internal.ConsequentDao
+	internal2.ConsequentDao
 }
 
 var (
 	// Consequent is globally public accessible object for table consequent operations.
 	Consequent = consequentDao{
-		internal.Consequent,
+		internal2.Consequent,
 	}
 )
 
 type ConsequentDao struct {
-	internal.ConsequentDao
+	internal2.ConsequentDao
 }
 
 func NewConsequentDao(tenant string) *ConsequentDao {
-	dao := internal.NewConsequentDao(tenant)
+	dao := internal2.NewConsequentDao(tenant)
 	return &ConsequentDao{
 		dao,
 	}

+ 6 - 6
dao/consequent_detail.go → dao/consequent/consequent_detail.go

@@ -2,32 +2,32 @@
 // This is auto-generated by gf cli tool only once. Fill this file as you wish.
 // ============================================================================
 
-package dao
+package consequent
 
 import (
-	"lims_adapter/dao/internal"
+	internal2 "lims_adapter/dao/consequent/internal"
 )
 
 // consequentDetailDao 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 consequentDetailDao struct {
-	internal.ConsequentDetailDao
+	internal2.ConsequentDetailDao
 }
 
 var (
 	// ConsequentDetail is globally public accessible object for table consequent_detail operations.
 	ConsequentDetail = consequentDetailDao{
-		internal.ConsequentDetail,
+		internal2.ConsequentDetail,
 	}
 )
 
 type ConsequentDetailDao struct {
-	internal.ConsequentDetailDao
+	internal2.ConsequentDetailDao
 }
 
 func NewConsequentDetailDao(tenant string) *ConsequentDetailDao {
-	dao := internal.NewConsequentDetailDao(tenant)
+	dao := internal2.NewConsequentDetailDao(tenant)
 	return &ConsequentDetailDao{
 		dao,
 	}

+ 11 - 12
dao/internal/consequent.go → dao/consequent/internal/consequent.go

@@ -10,9 +10,8 @@ import (
 	"github.com/gogf/gf/database/gdb"
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/frame/gmvc"
+	"lims_adapter/model/consequent"
 	"time"
-
-	"lims_adapter/model"
 )
 
 // ConsequentDao is the manager for logic model data accessing
@@ -288,12 +287,12 @@ func (d *ConsequentDao) Data(data ...interface{}) *ConsequentDao {
 //
 // The optional parameter <where> is the same as the parameter of M.Where function,
 // see M.Where.
-func (d *ConsequentDao) All(where ...interface{}) ([]*model.Consequent, error) {
+func (d *ConsequentDao) All(where ...interface{}) ([]*consequent.Consequent, error) {
 	all, err := d.M.All(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entities []*model.Consequent
+	var entities []*consequent.Consequent
 	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -305,12 +304,12 @@ func (d *ConsequentDao) All(where ...interface{}) ([]*model.Consequent, error) {
 //
 // The optional parameter <where> is the same as the parameter of M.Where function,
 // see M.Where.
-func (d *ConsequentDao) One(where ...interface{}) (*model.Consequent, error) {
+func (d *ConsequentDao) One(where ...interface{}) (*consequent.Consequent, error) {
 	one, err := d.M.One(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entity *model.Consequent
+	var entity *consequent.Consequent
 	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -319,12 +318,12 @@ func (d *ConsequentDao) One(where ...interface{}) (*model.Consequent, error) {
 
 // FindOne retrieves and returns a single Record by M.WherePri and M.One.
 // Also see M.WherePri and M.One.
-func (d *ConsequentDao) FindOne(where ...interface{}) (*model.Consequent, error) {
+func (d *ConsequentDao) FindOne(where ...interface{}) (*consequent.Consequent, error) {
 	one, err := d.M.FindOne(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entity *model.Consequent
+	var entity *consequent.Consequent
 	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -333,12 +332,12 @@ func (d *ConsequentDao) FindOne(where ...interface{}) (*model.Consequent, error)
 
 // FindAll retrieves and returns Result by by M.WherePri and M.All.
 // Also see M.WherePri and M.All.
-func (d *ConsequentDao) FindAll(where ...interface{}) ([]*model.Consequent, error) {
+func (d *ConsequentDao) FindAll(where ...interface{}) ([]*consequent.Consequent, error) {
 	all, err := d.M.FindAll(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entities []*model.Consequent
+	var entities []*consequent.Consequent
 	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -411,9 +410,9 @@ func (d *ConsequentDao) Scan(pointer interface{}, where ...interface{}) error {
 }
 
 // Chunk iterates the table with given size and callback function.
-func (d *ConsequentDao) Chunk(limit int, callback func(entities []*model.Consequent, err error) bool) {
+func (d *ConsequentDao) Chunk(limit int, callback func(entities []*consequent.Consequent, err error) bool) {
 	d.M.Chunk(limit, func(result gdb.Result, err error) bool {
-		var entities []*model.Consequent
+		var entities []*consequent.Consequent
 		err = result.Structs(&entities)
 		if err == sql.ErrNoRows {
 			return false

+ 11 - 12
dao/internal/consequent_detail.go → dao/consequent/internal/consequent_detail.go

@@ -10,9 +10,8 @@ import (
 	"github.com/gogf/gf/database/gdb"
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/frame/gmvc"
+	"lims_adapter/model/consequent"
 	"time"
-
-	"lims_adapter/model"
 )
 
 // ConsequentDetailDao is the manager for logic model data accessing
@@ -378,12 +377,12 @@ func (d *ConsequentDetailDao) Data(data ...interface{}) *ConsequentDetailDao {
 //
 // The optional parameter <where> is the same as the parameter of M.Where function,
 // see M.Where.
-func (d *ConsequentDetailDao) All(where ...interface{}) ([]*model.ConsequentDetail, error) {
+func (d *ConsequentDetailDao) All(where ...interface{}) ([]*consequent.ConsequentDetail, error) {
 	all, err := d.M.All(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entities []*model.ConsequentDetail
+	var entities []*consequent.ConsequentDetail
 	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -395,12 +394,12 @@ func (d *ConsequentDetailDao) All(where ...interface{}) ([]*model.ConsequentDeta
 //
 // The optional parameter <where> is the same as the parameter of M.Where function,
 // see M.Where.
-func (d *ConsequentDetailDao) One(where ...interface{}) (*model.ConsequentDetail, error) {
+func (d *ConsequentDetailDao) One(where ...interface{}) (*consequent.ConsequentDetail, error) {
 	one, err := d.M.One(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entity *model.ConsequentDetail
+	var entity *consequent.ConsequentDetail
 	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -409,12 +408,12 @@ func (d *ConsequentDetailDao) One(where ...interface{}) (*model.ConsequentDetail
 
 // FindOne retrieves and returns a single Record by M.WherePri and M.One.
 // Also see M.WherePri and M.One.
-func (d *ConsequentDetailDao) FindOne(where ...interface{}) (*model.ConsequentDetail, error) {
+func (d *ConsequentDetailDao) FindOne(where ...interface{}) (*consequent.ConsequentDetail, error) {
 	one, err := d.M.FindOne(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entity *model.ConsequentDetail
+	var entity *consequent.ConsequentDetail
 	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -423,12 +422,12 @@ func (d *ConsequentDetailDao) FindOne(where ...interface{}) (*model.ConsequentDe
 
 // FindAll retrieves and returns Result by by M.WherePri and M.All.
 // Also see M.WherePri and M.All.
-func (d *ConsequentDetailDao) FindAll(where ...interface{}) ([]*model.ConsequentDetail, error) {
+func (d *ConsequentDetailDao) FindAll(where ...interface{}) ([]*consequent.ConsequentDetail, error) {
 	all, err := d.M.FindAll(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entities []*model.ConsequentDetail
+	var entities []*consequent.ConsequentDetail
 	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -501,9 +500,9 @@ func (d *ConsequentDetailDao) Scan(pointer interface{}, where ...interface{}) er
 }
 
 // Chunk iterates the table with given size and callback function.
-func (d *ConsequentDetailDao) Chunk(limit int, callback func(entities []*model.ConsequentDetail, err error) bool) {
+func (d *ConsequentDetailDao) Chunk(limit int, callback func(entities []*consequent.ConsequentDetail, err error) bool) {
 	d.M.Chunk(limit, func(result gdb.Result, err error) bool {
-		var entities []*model.ConsequentDetail
+		var entities []*consequent.ConsequentDetail
 		err = result.Structs(&entities)
 		if err == sql.ErrNoRows {
 			return false

+ 6 - 6
dao/base_equipment_advance_time.go → dao/equipment/base_equipment_advance_time.go

@@ -2,32 +2,32 @@
 // This is auto-generated by gf cli tool only once. Fill this file as you wish.
 // ============================================================================
 
-package dao
+package equipment
 
 import (
-	"lims_adapter/dao/internal"
+	internal2 "lims_adapter/dao/equipment/internal"
 )
 
 // baseEquipmentAdvanceTimeDao 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 baseEquipmentAdvanceTimeDao struct {
-	internal.BaseEquipmentAdvanceTimeDao
+	internal2.BaseEquipmentAdvanceTimeDao
 }
 
 var (
 	// BaseEquipmentAdvanceTime is globally public accessible object for table base_equipment_advance_time operations.
 	BaseEquipmentAdvanceTime = baseEquipmentAdvanceTimeDao{
-		internal.BaseEquipmentAdvanceTime,
+		internal2.BaseEquipmentAdvanceTime,
 	}
 )
 
 type BaseEquipmentAdvanceTimeDao struct {
-	internal.BaseEquipmentAdvanceTimeDao
+	internal2.BaseEquipmentAdvanceTimeDao
 }
 
 func NewBaseEquipmentAdvanceTimeDao(tenant string) *BaseEquipmentAdvanceTimeDao {
-	dao := internal.NewBaseEquipmentAdvanceTimeDao(tenant)
+	dao := internal2.NewBaseEquipmentAdvanceTimeDao(tenant)
 	return &BaseEquipmentAdvanceTimeDao{
 		dao,
 	}

+ 6 - 6
dao/base_equipment_qualification.go → dao/equipment/base_equipment_qualification.go

@@ -2,32 +2,32 @@
 // This is auto-generated by gf cli tool only once. Fill this file as you wish.
 // ============================================================================
 
-package dao
+package equipment
 
 import (
-	"lims_adapter/dao/internal"
+	internal2 "lims_adapter/dao/equipment/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
+	internal2.BaseEquipmentQualificationDao
 }
 
 var (
 	// BaseEquipmentQualification is globally public accessible object for table base_equipment_qualification operations.
 	BaseEquipmentQualification = baseEquipmentQualificationDao{
-		internal.BaseEquipmentQualification,
+		internal2.BaseEquipmentQualification,
 	}
 )
 
 type BaseEquipmentQualificationDao struct {
-	internal.BaseEquipmentQualificationDao
+	internal2.BaseEquipmentQualificationDao
 }
 
 func NewBaseEquipmentQualificationDao(tenant string) *BaseEquipmentQualificationDao {
-	dao := internal.NewBaseEquipmentQualificationDao(tenant)
+	dao := internal2.NewBaseEquipmentQualificationDao(tenant)
 	return &BaseEquipmentQualificationDao{
 		dao,
 	}

+ 2 - 2
dao/instrument.go → dao/equipment/instrument.go

@@ -2,10 +2,10 @@
 // This is auto-generated by gf cli tool only once. Fill this file as you wish.
 // ============================================================================
 
-package dao
+package equipment
 
 import (
-	"lims_adapter/dao/internal"
+	"lims_adapter/dao/equipment/internal"
 )
 
 // instrumentDao is the manager for logic model data accessing

+ 11 - 11
dao/internal/base_equipment_advance_time.go → dao/equipment/internal/base_equipment_advance_time.go

@@ -10,7 +10,7 @@ import (
 	"github.com/gogf/gf/database/gdb"
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/frame/gmvc"
-	model2 "lims_adapter/model"
+	"lims_adapter/model/equipment"
 	"time"
 )
 
@@ -266,12 +266,12 @@ func (d *BaseEquipmentAdvanceTimeDao) Data(data ...interface{}) *BaseEquipmentAd
 //
 // The optional parameter <where> is the same as the parameter of M.Where function,
 // see M.Where.
-func (d *BaseEquipmentAdvanceTimeDao) All(where ...interface{}) ([]*model2.BaseEquipmentAdvanceTime, error) {
+func (d *BaseEquipmentAdvanceTimeDao) All(where ...interface{}) ([]*equipment.BaseEquipmentAdvanceTime, error) {
 	all, err := d.M.All(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entities []*model2.BaseEquipmentAdvanceTime
+	var entities []*equipment.BaseEquipmentAdvanceTime
 	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -283,12 +283,12 @@ func (d *BaseEquipmentAdvanceTimeDao) All(where ...interface{}) ([]*model2.BaseE
 //
 // The optional parameter <where> is the same as the parameter of M.Where function,
 // see M.Where.
-func (d *BaseEquipmentAdvanceTimeDao) One(where ...interface{}) (*model2.BaseEquipmentAdvanceTime, error) {
+func (d *BaseEquipmentAdvanceTimeDao) One(where ...interface{}) (*equipment.BaseEquipmentAdvanceTime, error) {
 	one, err := d.M.One(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entity *model2.BaseEquipmentAdvanceTime
+	var entity *equipment.BaseEquipmentAdvanceTime
 	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -297,12 +297,12 @@ func (d *BaseEquipmentAdvanceTimeDao) One(where ...interface{}) (*model2.BaseEqu
 
 // FindOne retrieves and returns a single Record by M.WherePri and M.One.
 // Also see M.WherePri and M.One.
-func (d *BaseEquipmentAdvanceTimeDao) FindOne(where ...interface{}) (*model2.BaseEquipmentAdvanceTime, error) {
+func (d *BaseEquipmentAdvanceTimeDao) FindOne(where ...interface{}) (*equipment.BaseEquipmentAdvanceTime, error) {
 	one, err := d.M.FindOne(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entity *model2.BaseEquipmentAdvanceTime
+	var entity *equipment.BaseEquipmentAdvanceTime
 	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -311,12 +311,12 @@ func (d *BaseEquipmentAdvanceTimeDao) FindOne(where ...interface{}) (*model2.Bas
 
 // FindAll retrieves and returns Result by by M.WherePri and M.All.
 // Also see M.WherePri and M.All.
-func (d *BaseEquipmentAdvanceTimeDao) FindAll(where ...interface{}) ([]*model2.BaseEquipmentAdvanceTime, error) {
+func (d *BaseEquipmentAdvanceTimeDao) FindAll(where ...interface{}) ([]*equipment.BaseEquipmentAdvanceTime, error) {
 	all, err := d.M.FindAll(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entities []*model2.BaseEquipmentAdvanceTime
+	var entities []*equipment.BaseEquipmentAdvanceTime
 	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -389,9 +389,9 @@ func (d *BaseEquipmentAdvanceTimeDao) Scan(pointer interface{}, where ...interfa
 }
 
 // Chunk iterates the table with given size and callback function.
-func (d *BaseEquipmentAdvanceTimeDao) Chunk(limit int, callback func(entities []*model2.BaseEquipmentAdvanceTime, err error) bool) {
+func (d *BaseEquipmentAdvanceTimeDao) Chunk(limit int, callback func(entities []*equipment.BaseEquipmentAdvanceTime, err error) bool) {
 	d.M.Chunk(limit, func(result gdb.Result, err error) bool {
-		var entities []*model2.BaseEquipmentAdvanceTime
+		var entities []*equipment.BaseEquipmentAdvanceTime
 		err = result.Structs(&entities)
 		if err == sql.ErrNoRows {
 			return false

+ 14 - 14
dao/internal/base_equipment_qualification.go → dao/equipment/internal/base_equipment_qualification.go

@@ -10,7 +10,7 @@ import (
 	"github.com/gogf/gf/database/gdb"
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/frame/gmvc"
-	"lims_adapter/model"
+	"lims_adapter/model/equipment"
 	"time"
 )
 
@@ -28,7 +28,7 @@ type baseEquipmentQualificationColumns struct {
 	Id             string // 主键
 	EquipmentId    string // 设备Id
 	Qualification  string // 预约资格:1普通资格,2资深资格
-	UserId		   string // 用户Id
+	UserId         string // 用户Id
 	AuthorizeTime  string // 授权时间
 	CreateOn       string //
 	CreateUserId   string //
@@ -48,7 +48,7 @@ var (
 			Id:             "Id",
 			EquipmentId:    "EquipmentId",
 			Qualification:  "Qualification",
-			UserId:			"UserId",
+			UserId:         "UserId",
 			AuthorizeTime:  "AuthorizeTime",
 			CreateOn:       "CreateOn",
 			CreateUserId:   "CreateUserId",
@@ -70,7 +70,7 @@ func NewBaseEquipmentQualificationDao(tenant string) BaseEquipmentQualificationD
 			Id:             "Id",
 			EquipmentId:    "EquipmentId",
 			Qualification:  "Qualification",
-			UserId:			"UserId",
+			UserId:         "UserId",
 			AuthorizeTime:  "AuthorizeTime",
 			CreateOn:       "CreateOn",
 			CreateUserId:   "CreateUserId",
@@ -275,12 +275,12 @@ func (d *BaseEquipmentQualificationDao) Data(data ...interface{}) *BaseEquipment
 //
 // 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) {
+func (d *BaseEquipmentQualificationDao) All(where ...interface{}) ([]*equipment.BaseEquipmentQualification, error) {
 	all, err := d.M.All(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entities []*model.BaseEquipmentQualification
+	var entities []*equipment.BaseEquipmentQualification
 	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -292,12 +292,12 @@ func (d *BaseEquipmentQualificationDao) All(where ...interface{}) ([]*model.Base
 //
 // 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) {
+func (d *BaseEquipmentQualificationDao) One(where ...interface{}) (*equipment.BaseEquipmentQualification, error) {
 	one, err := d.M.One(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entity *model.BaseEquipmentQualification
+	var entity *equipment.BaseEquipmentQualification
 	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -306,12 +306,12 @@ func (d *BaseEquipmentQualificationDao) One(where ...interface{}) (*model.BaseEq
 
 // 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) {
+func (d *BaseEquipmentQualificationDao) FindOne(where ...interface{}) (*equipment.BaseEquipmentQualification, error) {
 	one, err := d.M.FindOne(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entity *model.BaseEquipmentQualification
+	var entity *equipment.BaseEquipmentQualification
 	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -320,12 +320,12 @@ func (d *BaseEquipmentQualificationDao) FindOne(where ...interface{}) (*model.Ba
 
 // 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) {
+func (d *BaseEquipmentQualificationDao) FindAll(where ...interface{}) ([]*equipment.BaseEquipmentQualification, error) {
 	all, err := d.M.FindAll(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entities []*model.BaseEquipmentQualification
+	var entities []*equipment.BaseEquipmentQualification
 	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -398,9 +398,9 @@ func (d *BaseEquipmentQualificationDao) Scan(pointer interface{}, where ...inter
 }
 
 // Chunk iterates the table with given size and callback function.
-func (d *BaseEquipmentQualificationDao) Chunk(limit int, callback func(entities []*model.BaseEquipmentQualification, err error) bool) {
+func (d *BaseEquipmentQualificationDao) Chunk(limit int, callback func(entities []*equipment.BaseEquipmentQualification, err error) bool) {
 	d.M.Chunk(limit, func(result gdb.Result, err error) bool {
-		var entities []*model.BaseEquipmentQualification
+		var entities []*equipment.BaseEquipmentQualification
 		err = result.Structs(&entities)
 		if err == sql.ErrNoRows {
 			return false

+ 11 - 11
dao/internal/instrument.go → dao/equipment/internal/instrument.go

@@ -10,7 +10,7 @@ import (
 	"github.com/gogf/gf/database/gdb"
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/frame/gmvc"
-	model2 "lims_adapter/model"
+	"lims_adapter/model/equipment"
 	"time"
 )
 
@@ -374,12 +374,12 @@ func (d *InstrumentDao) Data(data ...interface{}) *InstrumentDao {
 //
 // The optional parameter <where> is the same as the parameter of M.Where function,
 // see M.Where.
-func (d *InstrumentDao) All(where ...interface{}) ([]*model2.Instrument, error) {
+func (d *InstrumentDao) All(where ...interface{}) ([]*equipment.Instrument, error) {
 	all, err := d.M.All(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entities []*model2.Instrument
+	var entities []*equipment.Instrument
 	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -391,12 +391,12 @@ func (d *InstrumentDao) All(where ...interface{}) ([]*model2.Instrument, error)
 //
 // The optional parameter <where> is the same as the parameter of M.Where function,
 // see M.Where.
-func (d *InstrumentDao) One(where ...interface{}) (*model2.Instrument, error) {
+func (d *InstrumentDao) One(where ...interface{}) (*equipment.Instrument, error) {
 	one, err := d.M.One(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entity *model2.Instrument
+	var entity *equipment.Instrument
 	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -405,12 +405,12 @@ func (d *InstrumentDao) One(where ...interface{}) (*model2.Instrument, error) {
 
 // FindOne retrieves and returns a single Record by M.WherePri and M.One.
 // Also see M.WherePri and M.One.
-func (d *InstrumentDao) FindOne(where ...interface{}) (*model2.Instrument, error) {
+func (d *InstrumentDao) FindOne(where ...interface{}) (*equipment.Instrument, error) {
 	one, err := d.M.FindOne(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entity *model2.Instrument
+	var entity *equipment.Instrument
 	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -419,12 +419,12 @@ func (d *InstrumentDao) FindOne(where ...interface{}) (*model2.Instrument, error
 
 // FindAll retrieves and returns Result by by M.WherePri and M.All.
 // Also see M.WherePri and M.All.
-func (d *InstrumentDao) FindAll(where ...interface{}) ([]*model2.Instrument, error) {
+func (d *InstrumentDao) FindAll(where ...interface{}) ([]*equipment.Instrument, error) {
 	all, err := d.M.FindAll(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entities []*model2.Instrument
+	var entities []*equipment.Instrument
 	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -497,9 +497,9 @@ func (d *InstrumentDao) Scan(pointer interface{}, where ...interface{}) error {
 }
 
 // Chunk iterates the table with given size and callback function.
-func (d *InstrumentDao) Chunk(limit int, callback func(entities []*model2.Instrument, err error) bool) {
+func (d *InstrumentDao) Chunk(limit int, callback func(entities []*equipment.Instrument, err error) bool) {
 	d.M.Chunk(limit, func(result gdb.Result, err error) bool {
-		var entities []*model2.Instrument
+		var entities []*equipment.Instrument
 		err = result.Structs(&entities)
 		if err == sql.ErrNoRows {
 			return false

+ 11 - 12
dao/internal/meeting.go → dao/meeting/internal/meeting.go

@@ -10,9 +10,8 @@ import (
 	"github.com/gogf/gf/database/gdb"
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/frame/gmvc"
+	"lims_adapter/model/meeting"
 	"time"
-
-	"lims_adapter/model"
 )
 
 // MeetingDao is the manager for logic model data accessing
@@ -288,12 +287,12 @@ func (d *MeetingDao) Data(data ...interface{}) *MeetingDao {
 //
 // The optional parameter <where> is the same as the parameter of M.Where function,
 // see M.Where.
-func (d *MeetingDao) All(where ...interface{}) ([]*model.Meeting, error) {
+func (d *MeetingDao) All(where ...interface{}) ([]*meeting.Meeting, error) {
 	all, err := d.M.All(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entities []*model.Meeting
+	var entities []*meeting.Meeting
 	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -305,12 +304,12 @@ func (d *MeetingDao) All(where ...interface{}) ([]*model.Meeting, error) {
 //
 // The optional parameter <where> is the same as the parameter of M.Where function,
 // see M.Where.
-func (d *MeetingDao) One(where ...interface{}) (*model.Meeting, error) {
+func (d *MeetingDao) One(where ...interface{}) (*meeting.Meeting, error) {
 	one, err := d.M.One(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entity *model.Meeting
+	var entity *meeting.Meeting
 	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -319,12 +318,12 @@ func (d *MeetingDao) One(where ...interface{}) (*model.Meeting, error) {
 
 // FindOne retrieves and returns a single Record by M.WherePri and M.One.
 // Also see M.WherePri and M.One.
-func (d *MeetingDao) FindOne(where ...interface{}) (*model.Meeting, error) {
+func (d *MeetingDao) FindOne(where ...interface{}) (*meeting.Meeting, error) {
 	one, err := d.M.FindOne(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entity *model.Meeting
+	var entity *meeting.Meeting
 	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -333,12 +332,12 @@ func (d *MeetingDao) FindOne(where ...interface{}) (*model.Meeting, error) {
 
 // FindAll retrieves and returns Result by by M.WherePri and M.All.
 // Also see M.WherePri and M.All.
-func (d *MeetingDao) FindAll(where ...interface{}) ([]*model.Meeting, error) {
+func (d *MeetingDao) FindAll(where ...interface{}) ([]*meeting.Meeting, error) {
 	all, err := d.M.FindAll(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entities []*model.Meeting
+	var entities []*meeting.Meeting
 	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -411,9 +410,9 @@ func (d *MeetingDao) Scan(pointer interface{}, where ...interface{}) error {
 }
 
 // Chunk iterates the table with given size and callback function.
-func (d *MeetingDao) Chunk(limit int, callback func(entities []*model.Meeting, err error) bool) {
+func (d *MeetingDao) Chunk(limit int, callback func(entities []*meeting.Meeting, err error) bool) {
 	d.M.Chunk(limit, func(result gdb.Result, err error) bool {
-		var entities []*model.Meeting
+		var entities []*meeting.Meeting
 		err = result.Structs(&entities)
 		if err == sql.ErrNoRows {
 			return false

+ 11 - 12
dao/internal/meeting_reservation.go → dao/meeting/internal/meeting_reservation.go

@@ -10,9 +10,8 @@ import (
 	"github.com/gogf/gf/database/gdb"
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/frame/gmvc"
+	"lims_adapter/model/meeting"
 	"time"
-
-	"lims_adapter/model"
 )
 
 // MeetingReservationDao is the manager for logic model data accessing
@@ -306,12 +305,12 @@ func (d *MeetingReservationDao) Data(data ...interface{}) *MeetingReservationDao
 //
 // The optional parameter <where> is the same as the parameter of M.Where function,
 // see M.Where.
-func (d *MeetingReservationDao) All(where ...interface{}) ([]*model.MeetingReservation, error) {
+func (d *MeetingReservationDao) All(where ...interface{}) ([]*meeting.MeetingReservation, error) {
 	all, err := d.M.All(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entities []*model.MeetingReservation
+	var entities []*meeting.MeetingReservation
 	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -323,12 +322,12 @@ func (d *MeetingReservationDao) All(where ...interface{}) ([]*model.MeetingReser
 //
 // The optional parameter <where> is the same as the parameter of M.Where function,
 // see M.Where.
-func (d *MeetingReservationDao) One(where ...interface{}) (*model.MeetingReservation, error) {
+func (d *MeetingReservationDao) One(where ...interface{}) (*meeting.MeetingReservation, error) {
 	one, err := d.M.One(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entity *model.MeetingReservation
+	var entity *meeting.MeetingReservation
 	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -337,12 +336,12 @@ func (d *MeetingReservationDao) One(where ...interface{}) (*model.MeetingReserva
 
 // FindOne retrieves and returns a single Record by M.WherePri and M.One.
 // Also see M.WherePri and M.One.
-func (d *MeetingReservationDao) FindOne(where ...interface{}) (*model.MeetingReservation, error) {
+func (d *MeetingReservationDao) FindOne(where ...interface{}) (*meeting.MeetingReservation, error) {
 	one, err := d.M.FindOne(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entity *model.MeetingReservation
+	var entity *meeting.MeetingReservation
 	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -351,12 +350,12 @@ func (d *MeetingReservationDao) FindOne(where ...interface{}) (*model.MeetingRes
 
 // FindAll retrieves and returns Result by by M.WherePri and M.All.
 // Also see M.WherePri and M.All.
-func (d *MeetingReservationDao) FindAll(where ...interface{}) ([]*model.MeetingReservation, error) {
+func (d *MeetingReservationDao) FindAll(where ...interface{}) ([]*meeting.MeetingReservation, error) {
 	all, err := d.M.FindAll(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entities []*model.MeetingReservation
+	var entities []*meeting.MeetingReservation
 	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -429,9 +428,9 @@ func (d *MeetingReservationDao) Scan(pointer interface{}, where ...interface{})
 }
 
 // Chunk iterates the table with given size and callback function.
-func (d *MeetingReservationDao) Chunk(limit int, callback func(entities []*model.MeetingReservation, err error) bool) {
+func (d *MeetingReservationDao) Chunk(limit int, callback func(entities []*meeting.MeetingReservation, err error) bool) {
 	d.M.Chunk(limit, func(result gdb.Result, err error) bool {
-		var entities []*model.MeetingReservation
+		var entities []*meeting.MeetingReservation
 		err = result.Structs(&entities)
 		if err == sql.ErrNoRows {
 			return false

+ 6 - 6
dao/meeting.go → dao/meeting/meeting.go

@@ -2,32 +2,32 @@
 // This is auto-generated by gf cli tool only once. Fill this file as you wish.
 // ============================================================================
 
-package dao
+package meeting
 
 import (
-	"lims_adapter/dao/internal"
+	internal2 "lims_adapter/dao/meeting/internal"
 )
 
 // meetingDao 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 meetingDao struct {
-	internal.MeetingDao
+	internal2.MeetingDao
 }
 
 var (
 	// Meeting is globally public accessible object for table meeting operations.
 	Meeting = meetingDao{
-		internal.Meeting,
+		internal2.Meeting,
 	}
 )
 
 type MeetingDao struct {
-	internal.MeetingDao
+	internal2.MeetingDao
 }
 
 func NewMeetingDao(tenant string) *MeetingDao {
-	dao := internal.NewMeetingDao(tenant)
+	dao := internal2.NewMeetingDao(tenant)
 	return &MeetingDao{
 		dao,
 	}

+ 6 - 6
dao/meeting_reservation.go → dao/meeting/meeting_reservation.go

@@ -2,32 +2,32 @@
 // This is auto-generated by gf cli tool only once. Fill this file as you wish.
 // ============================================================================
 
-package dao
+package meeting
 
 import (
-	"lims_adapter/dao/internal"
+	internal2 "lims_adapter/dao/meeting/internal"
 )
 
 // meetingReservationDao 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 meetingReservationDao struct {
-	internal.MeetingReservationDao
+	internal2.MeetingReservationDao
 }
 
 var (
 	// MeetingReservation is globally public accessible object for table meeting_reservation operations.
 	MeetingReservation = meetingReservationDao{
-		internal.MeetingReservation,
+		internal2.MeetingReservation,
 	}
 )
 
 type MeetingReservationDao struct {
-	internal.MeetingReservationDao
+	internal2.MeetingReservationDao
 }
 
 func NewMeetingReservationDao(tenant string) *MeetingReservationDao {
-	dao := internal.NewMeetingReservationDao(tenant)
+	dao := internal2.NewMeetingReservationDao(tenant)
 	return &MeetingReservationDao{
 		dao,
 	}

+ 2 - 2
dao/base_itemdetails.go → dao/system/base_itemdetails.go

@@ -2,10 +2,10 @@
 // This is auto-generated by gf cli tool only once. Fill this file as you wish.
 // ============================================================================
 
-package dao
+package system
 
 import (
-	"lims_adapter/dao/internal"
+	"lims_adapter/dao/system/internal"
 )
 
 // baseItemdetailsDao is the manager for logic model data accessing

+ 11 - 11
dao/internal/base_itemdetails.go → dao/system/internal/base_itemdetails.go

@@ -10,7 +10,7 @@ import (
 	"github.com/gogf/gf/database/gdb"
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/frame/gmvc"
-	"lims_adapter/model"
+	"lims_adapter/model/system"
 	"time"
 )
 
@@ -296,12 +296,12 @@ func (d *BaseItemdetailsDao) Data(data ...interface{}) *BaseItemdetailsDao {
 //
 // The optional parameter <where> is the same as the parameter of M.Where function,
 // see M.Where.
-func (d *BaseItemdetailsDao) All(where ...interface{}) ([]*model.BaseItemdetails, error) {
+func (d *BaseItemdetailsDao) All(where ...interface{}) ([]*system.BaseItemdetails, error) {
 	all, err := d.M.All(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entities []*model.BaseItemdetails
+	var entities []*system.BaseItemdetails
 	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -313,12 +313,12 @@ func (d *BaseItemdetailsDao) All(where ...interface{}) ([]*model.BaseItemdetails
 //
 // The optional parameter <where> is the same as the parameter of M.Where function,
 // see M.Where.
-func (d *BaseItemdetailsDao) One(where ...interface{}) (*model.BaseItemdetails, error) {
+func (d *BaseItemdetailsDao) One(where ...interface{}) (*system.BaseItemdetails, error) {
 	one, err := d.M.One(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entity *model.BaseItemdetails
+	var entity *system.BaseItemdetails
 	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -327,12 +327,12 @@ func (d *BaseItemdetailsDao) One(where ...interface{}) (*model.BaseItemdetails,
 
 // FindOne retrieves and returns a single Record by M.WherePri and M.One.
 // Also see M.WherePri and M.One.
-func (d *BaseItemdetailsDao) FindOne(where ...interface{}) (*model.BaseItemdetails, error) {
+func (d *BaseItemdetailsDao) FindOne(where ...interface{}) (*system.BaseItemdetails, error) {
 	one, err := d.M.FindOne(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entity *model.BaseItemdetails
+	var entity *system.BaseItemdetails
 	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -341,12 +341,12 @@ func (d *BaseItemdetailsDao) FindOne(where ...interface{}) (*model.BaseItemdetai
 
 // FindAll retrieves and returns Result by by M.WherePri and M.All.
 // Also see M.WherePri and M.All.
-func (d *BaseItemdetailsDao) FindAll(where ...interface{}) ([]*model.BaseItemdetails, error) {
+func (d *BaseItemdetailsDao) FindAll(where ...interface{}) ([]*system.BaseItemdetails, error) {
 	all, err := d.M.FindAll(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entities []*model.BaseItemdetails
+	var entities []*system.BaseItemdetails
 	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -419,9 +419,9 @@ func (d *BaseItemdetailsDao) Scan(pointer interface{}, where ...interface{}) err
 }
 
 // Chunk iterates the table with given size and callback function.
-func (d *BaseItemdetailsDao) Chunk(limit int, callback func(entities []*model.BaseItemdetails, err error) bool) {
+func (d *BaseItemdetailsDao) Chunk(limit int, callback func(entities []*system.BaseItemdetails, err error) bool) {
 	d.M.Chunk(limit, func(result gdb.Result, err error) bool {
-		var entities []*model.BaseItemdetails
+		var entities []*system.BaseItemdetails
 		err = result.Structs(&entities)
 		if err == sql.ErrNoRows {
 			return false

+ 4 - 4
dao/base_user.go → dao/user/base_user.go

@@ -2,23 +2,23 @@
 // This is auto-generated by gf cli tool only once. Fill this file as you wish.
 // ============================================================================
 
-package dao
+package user
 
 import (
-	internal2 "lims_adapter/dao/internal"
+	"lims_adapter/dao/user/internal"
 )
 
 // baseUserDao 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 baseUserDao struct {
-	internal2.BaseUserDao
+	internal.BaseUserDao
 }
 
 var (
 	// BaseUser is globally public accessible object for table base_user operations.
 	BaseUser = baseUserDao{
-		internal2.BaseUser,
+		internal.BaseUser,
 	}
 )
 

+ 11 - 11
dao/internal/base_user.go → dao/user/internal/base_user.go

@@ -10,7 +10,7 @@ import (
 	"github.com/gogf/gf/database/gdb"
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/frame/gmvc"
-	model2 "lims_adapter/model"
+	"lims_adapter/model/user"
 	"time"
 )
 
@@ -446,12 +446,12 @@ func (d *BaseUserDao) Data(data ...interface{}) *BaseUserDao {
 //
 // The optional parameter <where> is the same as the parameter of M.Where function,
 // see M.Where.
-func (d *BaseUserDao) All(where ...interface{}) ([]*model2.BaseUser, error) {
+func (d *BaseUserDao) All(where ...interface{}) ([]*user.BaseUser, error) {
 	all, err := d.M.All(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entities []*model2.BaseUser
+	var entities []*user.BaseUser
 	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -463,12 +463,12 @@ func (d *BaseUserDao) All(where ...interface{}) ([]*model2.BaseUser, error) {
 //
 // The optional parameter <where> is the same as the parameter of M.Where function,
 // see M.Where.
-func (d *BaseUserDao) One(where ...interface{}) (*model2.BaseUser, error) {
+func (d *BaseUserDao) One(where ...interface{}) (*user.BaseUser, error) {
 	one, err := d.M.One(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entity *model2.BaseUser
+	var entity *user.BaseUser
 	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -477,12 +477,12 @@ func (d *BaseUserDao) One(where ...interface{}) (*model2.BaseUser, error) {
 
 // FindOne retrieves and returns a single Record by M.WherePri and M.One.
 // Also see M.WherePri and M.One.
-func (d *BaseUserDao) FindOne(where ...interface{}) (*model2.BaseUser, error) {
+func (d *BaseUserDao) FindOne(where ...interface{}) (*user.BaseUser, error) {
 	one, err := d.M.FindOne(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entity *model2.BaseUser
+	var entity *user.BaseUser
 	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -491,12 +491,12 @@ func (d *BaseUserDao) FindOne(where ...interface{}) (*model2.BaseUser, error) {
 
 // FindAll retrieves and returns Result by by M.WherePri and M.All.
 // Also see M.WherePri and M.All.
-func (d *BaseUserDao) FindAll(where ...interface{}) ([]*model2.BaseUser, error) {
+func (d *BaseUserDao) FindAll(where ...interface{}) ([]*user.BaseUser, error) {
 	all, err := d.M.FindAll(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entities []*model2.BaseUser
+	var entities []*user.BaseUser
 	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -569,9 +569,9 @@ func (d *BaseUserDao) Scan(pointer interface{}, where ...interface{}) error {
 }
 
 // Chunk iterates the table with given size and callback function.
-func (d *BaseUserDao) Chunk(limit int, callback func(entities []*model2.BaseUser, err error) bool) {
+func (d *BaseUserDao) Chunk(limit int, callback func(entities []*user.BaseUser, err error) bool) {
 	d.M.Chunk(limit, func(result gdb.Result, err error) bool {
-		var entities []*model2.BaseUser
+		var entities []*user.BaseUser
 		err = result.Structs(&entities)
 		if err == sql.ErrNoRows {
 			return false

+ 113 - 0
handler/account.go

@@ -0,0 +1,113 @@
+package handler
+
+import (
+	"context"
+	"dashoo.cn/common_definition/comm_def"
+	"dashoo.cn/micro_libary/micro_srv"
+	"dashoo.cn/micro_libary/myerrors"
+	"github.com/gogf/gf/frame/g"
+	"lims_adapter/model"
+	account "lims_adapter/model/account"
+	service "lims_adapter/service/account"
+)
+
+// 结算
+type Account struct{}
+
+// 结算明细分页
+func (a *Account) SettleAccountList(ctx context.Context, req *model.ListReq, rsp *comm_def.CommonMsg) error {
+	tenant, err := micro_srv.GetTenant(ctx)
+	info, err := micro_srv.GetUserInfo(ctx)
+	if err != nil {
+		return err
+	}
+	g.Log().Info("Received Account.SettleAccountList request @ " + tenant)
+	if req.Size == 0 {
+		req.Size = DefaultPageNum
+	}
+	if req.Current < 0 {
+		req.Current = DefaultPageCurrent
+	}
+
+	var list, total, errors = service.NewSrv(tenant).SettleAccountList(*req, info)
+	_, err, code, msg := myerrors.CheckError(errors)
+	if err != nil {
+		return err
+	}
+
+	rsp.Code = code
+	rsp.Msg = msg
+	rsp.Data = g.Map{"total": total, "list": list}
+	return nil
+}
+
+// AddCountMainDetail 添加结算明细主表明细表
+func (a *Account) AddCountMainDetail(ctx context.Context, req *account.AppointInfoReq, rsp *comm_def.CommonMsg) error {
+	tenant, err := micro_srv.GetTenant(ctx)
+	if err != nil {
+		return err
+	}
+	g.Log().Info("Received Account.AddCountMainDetail request @ " + tenant)
+	err = service.NewSrv(tenant).AddCountMainDetail(*req)
+	_, err, code, _ := myerrors.CheckError(err)
+	if err != nil {
+		return err
+	}
+	rsp.Code = code
+	return nil
+}
+
+// AddAccount 添加财务账号
+func (a *Account) AddAccount(ctx context.Context, req *account.BaseAccount, rsp *comm_def.CommonMsg) error {
+	tenant, err := micro_srv.GetTenant(ctx)
+	if err != nil {
+		return err
+	}
+	g.Log().Info("Received Account.AddAccount request @ " + tenant)
+	err = service.NewSrv(tenant).AddAccount(req)
+	_, err, code, _ := myerrors.CheckError(err)
+	if err != nil {
+		rsp.Code = code
+		return err
+	}
+	rsp.Code = code
+	rsp.Msg = "添加账号成功"
+	return nil
+}
+
+// AccountList 财务账号分页查询
+func (a *Account) AccountList(ctx context.Context, req *account.AccountReq, rsp *comm_def.CommonMsg) error {
+	tenant, err := micro_srv.GetTenant(ctx)
+	if err != nil {
+		return err
+	}
+	g.Log().Info("Received Account.AccountList request @ " + tenant)
+	list, err := service.NewSrv(tenant).AccountList(req)
+	_, err, code, _ := myerrors.CheckError(err)
+	if err != nil {
+		rsp.Code = code
+		return err
+	}
+	rsp.Code = code
+	rsp.Msg = ""
+	rsp.Data = list
+	return nil
+}
+
+// DepositAccount 充值账户
+func (a *Account) DepositAccount(ctx context.Context, req *account.BaseAccountResp, rsp *comm_def.CommonMsg) error {
+	tenant, err := micro_srv.GetTenant(ctx)
+	if err != nil {
+		return err
+	}
+	g.Log().Info("Received Account.DepositAccount request @ " + tenant)
+	err = service.NewAccountSrv(tenant).DepositAccount(req)
+	_, err, code, _ := myerrors.CheckError(err)
+	if err != nil {
+		rsp.Code = code
+		return err
+	}
+	rsp.Code = code
+	rsp.Msg = ""
+	return nil
+}

+ 88 - 13
handler/equipment.go

@@ -7,16 +7,16 @@ import (
 	"dashoo.cn/micro_libary/myerrors"
 	"errors"
 	"github.com/gogf/gf/frame/g"
-	"lims_adapter/model"
+	equipment2 "lims_adapter/model/equipment"
 	"lims_adapter/service/equipment"
 	"strconv"
 )
 
-// 设备
+// Equipment 设备
 type Equipment struct{}
 
 // AppointmentQualificationList 设备预约资格列表查询
-func (e *Equipment) AppointmentQualificationList(ctx context.Context, req *model.QualificationListReq, rsp *comm_def.CommonMsg) error {
+func (e *Equipment) AppointmentQualificationList(ctx context.Context, req *equipment2.QualificationListReq, rsp *comm_def.CommonMsg) error {
 	tenant, err := micro_srv.GetTenant(ctx)
 	if err != nil {
 		return err
@@ -40,7 +40,7 @@ func (e *Equipment) AppointmentQualificationList(ctx context.Context, req *model
 }
 
 // AppointmentQualificationList 优先预约权资格列表查询
-func (e *Equipment) AdvanceList(ctx context.Context, req *model.QualificationListReq, rsp *comm_def.CommonMsg) error {
+func (e *Equipment) AdvanceList(ctx context.Context, req *equipment2.QualificationListReq, rsp *comm_def.CommonMsg) error {
 	tenant, err := micro_srv.GetTenant(ctx)
 	if err != nil {
 		return err
@@ -63,8 +63,29 @@ func (e *Equipment) AdvanceList(ctx context.Context, req *model.QualificationLis
 	return nil
 }
 
+// IsAdvance 是否有优先预约资格
+func (e *Equipment) IsAdvance(ctx context.Context, req *equipment2.QualificationListReq, rsp *comm_def.CommonMsg) error {
+	tenant, err := micro_srv.GetTenant(ctx)
+	if err != nil {
+		return err
+	}
+	info, err := micro_srv.GetUserInfo(ctx)
+	if err != nil {
+		return err
+	}
+	g.Log().Info("Received Equipment.IsAdvance request @ " + tenant)
+	isAdvance, err := equipment.NewSrv(tenant).IsAdvance(info.Id, req.InstrumentId)
+	_, err, code, _ := myerrors.CheckError(err)
+	if err != nil {
+		return err
+	}
+	rsp.Code = code
+	rsp.Data = g.Map{"isAdvance": isAdvance, "userName": info.RealName}
+	return nil
+}
+
 // AddOrUpdateQualification 新增、修改预约资格名单
-func (e *Equipment) AddOrUpdateQualification(ctx context.Context, req *model.AddOrUpdateQualification, rsp *comm_def.CommonMsg) error {
+func (e *Equipment) AddOrUpdateQualification(ctx context.Context, req *equipment2.AddOrUpdateQualification, rsp *comm_def.CommonMsg) error {
 	tenant, err := micro_srv.GetTenant(ctx)
 	if err != nil {
 		return err
@@ -91,7 +112,7 @@ func (e *Equipment) AddOrUpdateQualification(ctx context.Context, req *model.Add
 }
 
 // DeleteQualification 删除预约资格
-func(e *Equipment) DeleteQualification(ctx context.Context, req *model.IdReq, rsp *comm_def.CommonMsg) error {
+func (e *Equipment) DeleteQualification(ctx context.Context, req *equipment2.IdReq, rsp *comm_def.CommonMsg) error {
 	tenant, err := micro_srv.GetTenant(ctx)
 	if err != nil {
 		return err
@@ -118,7 +139,7 @@ func(e *Equipment) DeleteQualification(ctx context.Context, req *model.IdReq, rs
 }
 
 // DeleteAdvance 删除优先预约资格
-func(e *Equipment) DeleteAdvance(ctx context.Context, req *model.IdReq, rsp *comm_def.CommonMsg) error {
+func (e *Equipment) DeleteAdvance(ctx context.Context, req *equipment2.IdReq, rsp *comm_def.CommonMsg) error {
 	tenant, err := micro_srv.GetTenant(ctx)
 	if err != nil {
 		return err
@@ -138,7 +159,7 @@ func(e *Equipment) DeleteAdvance(ctx context.Context, req *model.IdReq, rsp *com
 }
 
 // SearchAdvanceTime 查看设备优先预约时间段
-func(e *Equipment) SearchAdvanceTime(ctx context.Context, req *model.QualificationListReq, rsp *comm_def.CommonMsg) error {
+func (e *Equipment) SearchAdvanceTime(ctx context.Context, req *equipment2.QualificationListReq, rsp *comm_def.CommonMsg) error {
 	tenant, err := micro_srv.GetTenant(ctx)
 	if err != nil {
 		return err
@@ -166,7 +187,7 @@ func(e *Equipment) SearchAdvanceTime(ctx context.Context, req *model.Qualificati
 }
 
 // AddAdvanceTime 添加设备优先预约时间段
-func(e *Equipment) AddAdvanceTime(ctx context.Context, req *model.AdvanceTimeReq, rsp *comm_def.CommonMsg) error {
+func (e *Equipment) AddAdvanceTime(ctx context.Context, req *equipment2.AdvanceTimeReq, rsp *comm_def.CommonMsg) error {
 	tenant, err := micro_srv.GetTenant(ctx)
 	if err != nil {
 		return err
@@ -191,7 +212,7 @@ func(e *Equipment) AddAdvanceTime(ctx context.Context, req *model.AdvanceTimeReq
 }
 
 // DeleteAdvanceTime 删除设备预约时间段
-func(e *Equipment) DeleteAdvanceTime(ctx context.Context, req *model.IdReq, rsp *comm_def.CommonMsg) error {
+func (e *Equipment) DeleteAdvanceTime(ctx context.Context, req *equipment2.IdReq, rsp *comm_def.CommonMsg) error {
 	tenant, err := micro_srv.GetTenant(ctx)
 	if err != nil {
 		return err
@@ -210,7 +231,7 @@ func(e *Equipment) DeleteAdvanceTime(ctx context.Context, req *model.IdReq, rsp
 }
 
 // AppointmentTime 设备预约时间段
-func(e *Equipment) AppointmentTime(ctx context.Context, req *model.IdReq, rsp *comm_def.CommonMsg) error {
+func (e *Equipment) AppointmentTime(ctx context.Context, req *equipment2.IdReq, rsp *comm_def.CommonMsg) error {
 	tenant, err := micro_srv.GetTenant(ctx)
 	if err != nil {
 		return err
@@ -228,7 +249,7 @@ func(e *Equipment) AppointmentTime(ctx context.Context, req *model.IdReq, rsp *c
 }
 
 // SearchNoAppointment 查看不能预约时间段信息
-func (e *Equipment) SearchNoAppointment(ctx context.Context, req *model.IdReq, rsp *comm_def.CommonMsg) error {
+func (e *Equipment) SearchNoAppointment(ctx context.Context, req *equipment2.IdReq, rsp *comm_def.CommonMsg) error {
 	tenant, err := micro_srv.GetTenant(ctx)
 	if err != nil {
 		return err
@@ -256,7 +277,7 @@ func (e *Equipment) SearchNoAppointment(ctx context.Context, req *model.IdReq, r
 }
 
 // ChangeInstrStauts 修改设备所属
-func(e *Equipment) ChangeBelongs(ctx context.Context, req *model.IdReq, rsp *comm_def.CommonMsg) error {
+func (e *Equipment) ChangeBelongs(ctx context.Context, req *equipment2.IdReq, rsp *comm_def.CommonMsg) error {
 	tenant, err := micro_srv.GetTenant(ctx)
 	if err != nil {
 		return err
@@ -277,3 +298,57 @@ func(e *Equipment) ChangeBelongs(ctx context.Context, req *model.IdReq, rsp *com
 	rsp.Code = code
 	return nil
 }
+
+// GetUnitCount 查询设备计费
+func (e *Equipment) GetUnitCount(ctx context.Context, req *equipment2.InstrumentId, rsp *comm_def.CommonMsg) error {
+	tenant, err := micro_srv.GetTenant(ctx)
+	if err != nil {
+		return err
+	}
+	g.Log().Info("Received Equipment.GetUnitCount request @ " + tenant)
+	if strconv.Itoa(req.InstrumentId) == "" {
+		return errors.New("请传入设备Id")
+	}
+	rspInfo, err := equipment.NewSrv(tenant).GetUnitCount(req.InstrumentId)
+	if len(rspInfo) > 0 && strconv.Itoa(rspInfo[0].Id) != "" {
+		rspInfo[0].CountType = "按时计费"
+	}
+	_, err, code, _ := myerrors.CheckError(err)
+	rsp.Code = code
+	rsp.Data = rspInfo
+	return nil
+}
+
+// UpdateUnifPrice 更新计费价格
+func (e *Equipment) UpdateUnitfPrice(ctx context.Context, req *equipment2.InstrumentId, rsp *comm_def.CommonMsg) error {
+	tenant, err := micro_srv.GetTenant(ctx)
+	if err != nil {
+		return err
+	}
+	g.Log().Info("Received Equipment.UpdateUnitfPrice request @ " + tenant)
+	if strconv.Itoa(req.InstrumentId) == "" || strconv.Itoa(req.UnitCount) == "" {
+		return errors.New("请输入完成参数!")
+	}
+	err = equipment.NewSrv(tenant).UpdateUnitfPrice(req.InstrumentId, req.UnitCount)
+	_, err, code, msg := myerrors.CheckError(err)
+	rsp.Code = code
+	rsp.Msg = msg
+	return nil
+}
+
+// RateChange 优惠比例更新
+func (e *Equipment) RateChange(ctx context.Context, req *equipment2.InstrumentId, rsp *comm_def.CommonMsg) error {
+	tenant, err := micro_srv.GetTenant(ctx)
+	if err != nil {
+		return err
+	}
+	g.Log().Info("Received Equipment.RateChange request @ " + tenant)
+	if strconv.Itoa(req.InstrumentId) == "" || strconv.Itoa(req.Rate) == "" {
+		return errors.New("请输入完成参数!")
+	}
+	err = equipment.NewSrv(tenant).RateChange(req.InstrumentId, req.Rate)
+	_, err, code, msg := myerrors.CheckError(err)
+	rsp.Code = code
+	rsp.Msg = msg
+	return nil
+}

+ 5 - 4
handler/meeting.go

@@ -8,6 +8,7 @@ import (
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/util/gvalid"
 	"lims_adapter/model"
+	meeting2 "lims_adapter/model/meeting"
 	"lims_adapter/service/meeting"
 )
 
@@ -40,7 +41,7 @@ func (m *Meeting) List(ctx context.Context, req *model.ListReq, rsp *comm_def.Co
 	return nil
 }
 
-func (m *Meeting) Add(ctx context.Context, req *model.MeetingReq, rsp *comm_def.CommonMsg) error {
+func (m *Meeting) Add(ctx context.Context, req *meeting2.MeetingReq, rsp *comm_def.CommonMsg) error {
 	tenant, err := micro_srv.GetTenant(ctx)
 	if err != nil {
 		return err
@@ -67,7 +68,7 @@ func (m *Meeting) Add(ctx context.Context, req *model.MeetingReq, rsp *comm_def.
 	return nil
 }
 
-func (m *Meeting) Update(ctx context.Context, req *model.MeetingReq, rsp *comm_def.CommonMsg) error {
+func (m *Meeting) Update(ctx context.Context, req *meeting2.MeetingReq, rsp *comm_def.CommonMsg) error {
 	tenant, err := micro_srv.GetTenant(ctx)
 	if err != nil {
 		return err
@@ -96,7 +97,7 @@ func (m *Meeting) Update(ctx context.Context, req *model.MeetingReq, rsp *comm_d
 	return nil
 }
 
-func (m *Meeting) Get(ctx context.Context, req *model.MeetingReq, rsp *comm_def.CommonMsg) error {
+func (m *Meeting) Get(ctx context.Context, req *meeting2.MeetingReq, rsp *comm_def.CommonMsg) error {
 	tenant, err := micro_srv.GetTenant(ctx)
 	if err != nil {
 		return err
@@ -118,7 +119,7 @@ func (m *Meeting) Get(ctx context.Context, req *model.MeetingReq, rsp *comm_def.
 	return nil
 }
 
-func (m *Meeting) Delete(ctx context.Context, req *model.MeetingReq, rsp *comm_def.CommonMsg) error {
+func (m *Meeting) Delete(ctx context.Context, req *meeting2.MeetingReq, rsp *comm_def.CommonMsg) error {
 	tenant, err := micro_srv.GetTenant(ctx)
 	if err != nil {
 		return err

+ 7 - 6
handler/reservation.go

@@ -8,6 +8,7 @@ import (
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/util/gvalid"
 	"lims_adapter/model"
+	"lims_adapter/model/meeting"
 	"lims_adapter/service/reservation"
 )
 
@@ -40,7 +41,7 @@ func (r *Reservation) List(ctx context.Context, req *model.ListReq, rsp *comm_de
 }
 
 // Add 添加预约
-func (r *Reservation) Add(ctx context.Context, req *model.ReservationReq, rsp *comm_def.CommonMsg) error {
+func (r *Reservation) Add(ctx context.Context, req *meeting.ReservationReq, rsp *comm_def.CommonMsg) error {
 	tenant, err := micro_srv.GetTenant(ctx)
 	if err != nil {
 		return err
@@ -71,7 +72,7 @@ func (r *Reservation) Add(ctx context.Context, req *model.ReservationReq, rsp *c
 }
 
 // Cancel 取消预约
-func (r *Reservation) Cancel(ctx context.Context, req *model.ReservationReq, rsp *comm_def.CommonMsg) error {
+func (r *Reservation) Cancel(ctx context.Context, req *meeting.ReservationReq, rsp *comm_def.CommonMsg) error {
 	tenant, err := micro_srv.GetTenant(ctx)
 	if err != nil {
 		return err
@@ -97,7 +98,7 @@ func (r *Reservation) Cancel(ctx context.Context, req *model.ReservationReq, rsp
 }
 
 // OverviewList 预约概况
-func (r *Reservation) OverviewList(ctx context.Context, req *model.OverviewReq, rsp *comm_def.CommonMsg) error {
+func (r *Reservation) OverviewList(ctx context.Context, req *meeting.OverviewReq, rsp *comm_def.CommonMsg) error {
 	tenant, err := micro_srv.GetTenant(ctx)
 	if err != nil {
 		return err
@@ -119,7 +120,7 @@ func (r *Reservation) OverviewList(ctx context.Context, req *model.OverviewReq,
 }
 
 // OverviewListByDay 预约概况
-func (r *Reservation) OverviewListByDay(ctx context.Context, req *model.OverviewReq, rsp *comm_def.CommonMsg) error {
+func (r *Reservation) OverviewListByDay(ctx context.Context, req *meeting.OverviewReq, rsp *comm_def.CommonMsg) error {
 	tenant, err := micro_srv.GetTenant(ctx)
 	if err != nil {
 		return err
@@ -141,7 +142,7 @@ func (r *Reservation) OverviewListByDay(ctx context.Context, req *model.Overview
 }
 
 // ReserveInfo 预约信息
-func (r *Reservation) ReserveInfo(ctx context.Context, req *model.ReserveReq, rsp *comm_def.CommonMsg) error {
+func (r *Reservation) ReserveInfo(ctx context.Context, req *meeting.ReserveReq, rsp *comm_def.CommonMsg) error {
 	tenant, err := micro_srv.GetTenant(ctx)
 	if err != nil {
 		return err
@@ -166,7 +167,7 @@ func (r *Reservation) ReserveInfo(ctx context.Context, req *model.ReserveReq, rs
 }
 
 // Ending 提前结束
-func (r *Reservation) Ending(ctx context.Context, req *model.EndingReq, rsp *comm_def.CommonMsg) error {
+func (r *Reservation) Ending(ctx context.Context, req *meeting.EndingReq, rsp *comm_def.CommonMsg) error {
 	tenant, err := micro_srv.GetTenant(ctx)
 	if err != nil {
 		return err

+ 97 - 6
handler/system.go

@@ -7,19 +7,20 @@ import (
 	"dashoo.cn/micro_libary/myerrors"
 	"errors"
 	"github.com/gogf/gf/frame/g"
-	"lims_adapter/model"
+	system2 "lims_adapter/model/system"
+	"lims_adapter/model/user"
 	"lims_adapter/service/system"
 )
 
 type System struct{}
 
 // DictInfo 获取字典数据
-func (s *System) DictInfo(ctx context.Context, req *model.DictReq, rsp *comm_def.CommonMsg) error {
+func (s *System) DictInfo(ctx context.Context, req *system2.DictReq, rsp *comm_def.CommonMsg) error {
 	tenant, err := micro_srv.GetTenant(ctx)
 	if err != nil {
 		return err
 	}
-	g.Log().Info("Received DictInfo request @ " + tenant)
+	g.Log().Info("Received user.DictInfo request @ " + tenant)
 	if req.DictCode == "" {
 		return errors.New("字典类型不能为空")
 	}
@@ -33,13 +34,13 @@ func (s *System) DictInfo(ctx context.Context, req *model.DictReq, rsp *comm_def
 	return nil
 }
 
-// UserList 获取用户信息
-func (s *System) UserList(ctx context.Context, req *model.UserInfoReq, rsp *comm_def.CommonMsg) error {
+// UserList 设备预约权管理:获取用户信息
+func (s *System) UserList(ctx context.Context, req *user.UserInfoReq, rsp *comm_def.CommonMsg) error {
 	tenant, err := micro_srv.GetTenant(ctx)
 	if err != nil {
 		return err
 	}
-	g.Log().Info("Received UserList request @ " + tenant)
+	g.Log().Info("Received user.UserList request @ " + tenant)
 	userList, err := system.NewSrv(tenant).UserList(req)
 	_, err, code, _ := myerrors.CheckError(err)
 	if err != nil {
@@ -50,3 +51,93 @@ func (s *System) UserList(ctx context.Context, req *model.UserInfoReq, rsp *comm
 	rsp.Data = userList
 	return nil
 }
+
+// GetProgramGroup 获取课题组信息
+func (s *System) GetProgramGroup(ctx context.Context, req *user.UserQualification, rsp *comm_def.CommonMsg) error {
+	tenant, err := micro_srv.GetTenant(ctx)
+	if err != nil {
+		return err
+	}
+	g.Log().Info("Received user.GetProgramGroup request @ " + tenant)
+	programGroup, err := system.NewSrv(tenant).GetProgramGroup(req.Id)
+	_, err, _, _ = myerrors.CheckError(err)
+	if err != nil {
+		return err
+	}
+	rsp.Data = programGroup
+	return nil
+}
+
+// GetUserList 主从用户管理:获取用户信息
+// 请求类型参数  req.ReqType 1 查询主用户 2 查询相关从用户  3 查询可添加为从主用户
+func (s *System) GetUserList(ctx context.Context, req *user.UserInfoReq, rsp *comm_def.CommonMsg) error {
+	tenant, err := micro_srv.GetTenant(ctx)
+	userInfo, err := micro_srv.GetUserInfo(ctx)
+	if err != nil {
+		return err
+	}
+	g.Log().Info("Received user.GetUserList request @ " + tenant)
+	userList, err := system.NewSrv(tenant).GetUserList(req, userInfo.Id)
+	_, err, code, _ := myerrors.CheckError(err)
+	if err != nil {
+		return err
+	}
+	rsp.Code = code
+	rsp.Msg = ""
+	rsp.Data = userList
+	return nil
+}
+
+// AddMainUserOrSubUser 添加主从用户
+// 请求类型参数 req.ReqType 1 添加主用户(只需修改base_user的IsMain字段)
+func (s *System) AddMainUserOrSubUser(ctx context.Context, req *user.AddMainOrSubReq, rsp *comm_def.CommonMsg) error {
+	tenant, err := micro_srv.GetTenant(ctx)
+	userInfo, err := micro_srv.GetUserInfo(ctx)
+	if err != nil {
+		return err
+	}
+	g.Log().Info("Received user.AddMainUserOrSubUser request @ " + tenant)
+	err = system.NewSrv(tenant).AddMainUserOrUser(req, userInfo)
+	_, err, code, _ := myerrors.CheckError(err)
+	if err != nil {
+		return err
+	}
+	rsp.Code = code
+	rsp.Msg = "添加用户成功!"
+	return nil
+}
+
+// DeleteMainUserOrSubUser 删除主从用户
+func (s *System) DeleteMainUserOrSubUser(ctx context.Context, req *user.AddMainOrSubReq, rsp *comm_def.CommonMsg) error {
+	tenant, err := micro_srv.GetTenant(ctx)
+	userInfo, err := micro_srv.GetUserInfo(ctx)
+	if err != nil {
+		return err
+	}
+	g.Log().Info("Received user.DeleteMainUserOrSubUser request @ " + tenant)
+	err = system.NewSrv(tenant).DeleteMainUserOrSubUser(req, userInfo)
+	_, err, code, msg := myerrors.CheckError(err)
+	if err != nil {
+		return err
+	}
+	rsp.Msg = msg
+	rsp.Code = code
+	return nil
+}
+
+// UserBindAccount 用户绑定
+func (s *System) UserBindAccount(ctx context.Context, req *user.UserBindAccountReq, rsp *comm_def.CommonMsg) error {
+	tenant, err := micro_srv.GetTenant(ctx)
+	if err != nil {
+		return err
+	}
+	g.Log().Info("Received user.UserBindAccount request @ " + tenant)
+	err = system.NewSrv(tenant).UserBindAccount(req)
+	_, err, code, msg := myerrors.CheckError(err)
+	if err != nil {
+		return err
+	}
+	rsp.Msg = msg
+	rsp.Code = code
+	return nil
+}

+ 1 - 1
main.go

@@ -23,7 +23,7 @@ func main() {
 	s.RegisterName("Equipment", new(handler.Equipment), "")
 	s.RegisterName("System", new(handler.System), "")
 	s.RegisterName("Result", new(handler.Result), "")
-
+	s.RegisterName("Account", new(handler.Account), "")
 	// 注册auth处理
 	s.AuthFunc = handleAuth
 	// 运行服务

+ 3 - 3
model/instrument.go → model/account/settle_account_bill.go

@@ -5,10 +5,10 @@
 package model
 
 import (
-	"lims_adapter/model/internal"
+	"lims_adapter/model/account/internal"
 )
 
-// Instrument is the golang structure for table instrument.
-type Instrument internal.Instrument
+// SettleAccountBill is the golang structure for table settle_account_bill.
+type SettleAccountBill internal.SettleAccountBill
 
 // Fill with you ideas below.

+ 64 - 0
model/account/settle_account_detail.go

@@ -0,0 +1,64 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. Fill this file as you wish.
+// ==========================================================================
+
+package model
+
+import (
+	"github.com/gogf/gf/os/gtime"
+	"lims_adapter/model/account/internal"
+	"lims_adapter/model/equipment"
+)
+
+// SettleAccountDetail is the golang structure for table settle_account_detail.
+type SettleAccountDetail internal.SettleAccountDetail
+
+// Fill with you ideas below.
+
+// 预约详细信息
+type AppointInfo struct {
+	Appoint *SearchEntity
+	User    *SearchUser
+	Instr   *equipment.SearchEntity
+}
+
+// 结算明细前端请求
+type AppointInfoReq struct {
+	Appointment       *AppointInfo
+	SettleCountDetail int // 结算明细类型 1正常结算 2违规结算
+	SignOutTime       *gtime.Time
+}
+
+// 结算明细子表信息
+
+// 返回预约列表
+type SearchEntity struct {
+	Id                 int         `orm:"Id,primary"    json:"Id"`                        //
+	Title              string      `orm:"Title"         json:"Title"`                     // 标题
+	ProjectId          int         `orm:"ProjectId"    json:"project_id"`                 // 科研项目ID
+	UserId             int         `orm:"UserId"        json:"UserId"`                    // 预约人ID
+	UserName           string      `orm:"UserName"       json:"user_name"`                // 预约人姓名
+	CreatedAt          *gtime.Time `orm:"CreatedAt"     json:"AppointTime"`               // 创建时间
+	DepartmentId       int         `orm:"DepartmentId"  json:"DepartmentId"`              // 部门,单位
+	Status             int         `orm:"Status"        json:"Status"`                    // 状态
+	Remark             string      `orm:"Remark"        json:"Remark"`                    // 备注
+	RelevanceId        int         `orm:"RelevanceId"   json:"RelevanceId"`               // 设备Id
+	StartTime          *gtime.Time `orm:"StartTime"     json:"StartTime"`                 // 开始时间
+	EndTime            *gtime.Time `orm:"EndTime"       json:"EndTime"`                   // 结束时间
+	Num                int         `orm:"Num"           json:"num"`                       // 参与人数
+	RealityUseDuration float64     `orm:"RealityUseDuration" json:"reality_use_duration"` // 实际使用时长
+	SignInTime         *gtime.Time `orm:"SignInTime"         json:"sign_in_time"`         // 签到时间
+	SignOutTime        *gtime.Time `orm:"SignOutTime"        json:"sign_out_time"`        // 签退时间
+	Reason             string      `orm:"Reason"             json:"reason"`               // 拒绝原因
+}
+
+type SearchUser struct {
+	Id             int    `orm:"Id,primary"            json:"id"`
+	Uuid           string `orm:"Uuid"                  json:"uuid"`
+	UserName       string `orm:"UserName"              json:"user_name"`
+	Realname       string `orm:"Realname"              json:"realname"`
+	Mobile         string `orm:"Mobile"                json:"mobile"`
+	DepartmentId   string `orm:"DepartmentId"          json:"department_id"`
+	DepartmentName string `orm:"DepartmentName"        json:"department_name"`
+	IsPreferential string `                            json:"isPreferential"` // 是否享有设备预约优惠 3有优惠
+}

+ 19 - 0
model/account/settle_account_main.go

@@ -0,0 +1,19 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. Fill this file as you wish.
+// ==========================================================================
+
+package model
+
+import (
+	internal2 "lims_adapter/model/account/internal"
+)
+
+// SettleAccountMain is the golang structure for table settle_account_main.
+type SettleAccountMain internal2.SettleAccountMain
+
+// Fill with you ideas below.
+
+type SettleAccountMainReq struct {
+	AppointUserId int `orm:"AppointUserId"           json:"appoint_user_id"`
+	RelevanceId   int `orm:"RelevanceId"             json:"relevance_id"`
+}

+ 0 - 37
model/base_user.go

@@ -1,37 +0,0 @@
-// ==========================================================================
-// This is auto-generated by gf cli tool. Fill this file as you wish.
-// ==========================================================================
-
-package model
-
-import (
-	"github.com/gogf/gf/os/gtime"
-	"lims_adapter/model/internal"
-)
-
-// BaseUser is the golang structure for table base_user.
-type BaseUser internal.BaseUser
-
-// Fill with you ideas below.
-
-type UserQualification struct {
-	Id            int         `orm:"Id,primary"            json:"id"`           //
-	UserName      string      `orm:"UserName"              json:"userName"`     // 用户登录名
-	RealName      string      `orm:"RealName"              json:"realName"`     // 用户名
-	Qualification int         `orm:"Qualification"		   json:"qualification"`    // 资格 1普通资格 2资深资格
-	Mobile        string      `orm:"Mobile"                json:"mobile"`       // 手机号
-	AuthorizeTime *gtime.Time `orm:"AuthorizeTime"    	   json:"authorizeTime"` // 授权时间
-}
-
-type UserInfoReq struct {
-	PageNun      int `json:"pageNum"`
-	PageSize     int `json:"pageSize"`
-	Enabled      int `json:"enabled"`
-	InstrumentId int `json:"instrument_id"`
-	DepartmentId int `json:"department_id"`
-	ReqType      int `json:"req_type"` // 请求类型 1:预约资格 2:优先预约权
-}
-type UserInfoRsp struct {
-	Records []BaseUser `json:"records"`
-	Total   int        `json:"total"'`
-}

+ 3 - 3
model/consequent.go → model/consequent/consequent.go

@@ -2,13 +2,13 @@
 // This is auto-generated by gf cli tool. Fill this file as you wish.
 // ==========================================================================
 
-package model
+package consequent
 
 import (
-	"lims_adapter/model/internal"
+	internal2 "lims_adapter/model/consequent/internal"
 )
 
 // Consequent is the golang structure for table consequent.
-type Consequent internal.Consequent
+type Consequent internal2.Consequent
 
 // Fill with you ideas below.

+ 3 - 3
model/consequent_detail.go → model/consequent/consequent_detail.go

@@ -2,13 +2,13 @@
 // This is auto-generated by gf cli tool. Fill this file as you wish.
 // ==========================================================================
 
-package model
+package consequent
 
 import (
-	"lims_adapter/model/internal"
+	internal2 "lims_adapter/model/consequent/internal"
 )
 
 // ConsequentDetail is the golang structure for table consequent_detail.
-type ConsequentDetail internal.ConsequentDetail
+type ConsequentDetail internal2.ConsequentDetail
 
 // Fill with you ideas below.

+ 0 - 0
model/internal/consequent.go → model/consequent/internal/consequent.go


+ 0 - 0
model/internal/consequent_detail.go → model/consequent/internal/consequent_detail.go


+ 3 - 3
model/base_equipment_advance_time.go → model/equipment/base_equipment_advance_time.go

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

+ 15 - 15
model/base_equipment_qualification.go → model/equipment/base_equipment_qualification.go

@@ -2,38 +2,38 @@
 // This is auto-generated by gf cli tool. Fill this file as you wish.
 // ==========================================================================
 
-package model
+package equipment
 
 import (
-	"lims_adapter/model/internal"
+	internal2 "lims_adapter/model/equipment/internal"
 )
 
 // BaseEquipmentQualification is the golang structure for table base_equipment_qualification.
-type BaseEquipmentQualification internal.BaseEquipmentQualification
+type BaseEquipmentQualification internal2.BaseEquipmentQualification
 
 // Fill with you ideas below.
 
 // 添加、修改预约资格
 type AddOrUpdateQualification struct {
-	Ids []int `json:"ids"` // 用户Id列表
-	InstrumentId int `json:"instrument_id"` // 设备Id
+	Ids               []int  `json:"ids"`                // 用户Id列表
+	InstrumentId      int    `json:"instrument_id"`      // 设备Id
 	QualificationType string `json:"qualification_type"` // 预约资格:"normal"普通资格,"senior"资深资格
 }
 
 // 预约资格分页查询
 type QualificationListReq struct {
-	Current 	 int 	`json:"current"`
-	Size 		 int 	`json:"size"`
-	Enabled 	 int 	`json:"enabled"` // 用户是否启用 0 禁用 1 启用
-	InstrumentId int 	`json:"instrument_id"` // 设备Id
-	Type 		 int	`json:"type"'` // 1、预约资格,2、优先预约权
+	Current      int `json:"current"`
+	Size         int `json:"size"`
+	Enabled      int `json:"enabled"`       // 用户是否启用 0 禁用 1 启用
+	InstrumentId int `json:"instrument_id"` // 设备Id
+	Type         int `json:"type"'`         // 1、预约资格,2、优先预约权
 }
 
 // 删除预约资格
 type IdReq struct {
-	Id          int  `json:"id"`
-	UserId  	int  `json:"user_id"`
-	EquipmentId int `json:"equipment_id"`
-	Date 		string `json:"date"`
-	Belongs   	string		`json:"belongs"`
+	Id          int    `json:"id"`
+	UserId      int    `json:"user_id"`
+	EquipmentId int    `json:"equipment_id"`
+	Date        string `json:"date"`
+	Belongs     string `json:"belongs"`
 }

+ 64 - 0
model/equipment/instrument.go

@@ -0,0 +1,64 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. Fill this file as you wish.
+// ==========================================================================
+
+package equipment
+
+import (
+	"github.com/gogf/gf/os/gtime"
+	internal2 "lims_adapter/model/equipment/internal"
+)
+
+// Instrument is the golang structure for table instrument.
+type Instrument internal2.Instrument
+
+// Fill with you ideas below.
+// 设备Id、计费单价
+type InstrumentId struct {
+	InstrumentId int `json:"instrument_id"` // 设备Id
+	UnitCount    int `json:"unit_count"`    // 计费单价
+	Rate         int `json:"rate"`          // 优惠比例
+}
+type InstrumentEntity struct {
+	Instrument Instrument
+	CountType  string `json:"countType"`
+}
+
+type SearchEntity struct {
+	Id                      int         `orm:"Id,primary"              json:"id"          excel:"设备编码"`
+	Name                    string      `orm:"Name"                    json:"name"        excel:"设备名称"`   // 设备名称
+	InstrType               int         `orm:"InstrType"               json:"instr_type"`                 // 设备类别
+	InstrTypeStr            string      `orm:"-"                       json:"-"           excel:"设备类别"`   // 设备类别
+	Brand                   string      `orm:"Brand"                   json:"brand"       excel:"设备品牌"`   // 设备品牌
+	Belongs                 int         `orm:"Belongs"  			   json:"belongs"`                             // 设备所属 1内部 2外部
+	BelongsName             string      `orm:"BelongsName"      	   json:"belongs_name"`                  // 设备所属名称
+	Rate                    int         `orm:"Rate"                    json:"rate"`                       // 优惠比例
+	UnitCount               int         `orm:"UnitCount"               json:"unit_count"`                 // 计费单价
+	FactoryNum              string      `orm:"FactoryNum"              json:"factory_num" excel:"出厂编号"`   // 出厂编号
+	Status                  int         `orm:"Status"                  json:"status"`                     // 设备状态
+	StatusStr               string      `orm:"-"                       json:"-"           excel:"设备状态"`   // 设备状态 string
+	IsAppoint               int         `orm:"IsAppoint"               json:"is_appoint"`                 // 是否需要预约
+	IsAppointStr            string      `orm:"-"                       json:"-"           excel:"是否需要预约"` // 是否需要预约 string
+	Remark                  string      `orm:"Remark"                  json:"remark"      excel:"备注"`     // 备注
+	Code                    string      `orm:"Code,unique"             json:"code"`                       // 设备编码
+	InstrImgUrl             string      `orm:"InstrImgUrl"             json:"instr_img_url"`              // 设备图片Url
+	Spec                    string      `orm:"Spec"                    json:"spec"`                       // 规格
+	PurchaseTime            *gtime.Time `orm:"PurchaseTime"            json:"purchase_time"`              // 采购日期
+	Responsible             string      `orm:"Responsible"             json:"responsible"`                // 责任人
+	Location                string      `orm:"Location"                json:"location"`                   // 设备所在位置
+	TimeNotification        int         `orm:"TimeNotification"        json:"time_notification"`          // 有效期提醒
+	CalibrationDeadline     int         `orm:"CalibrationDeadline"     json:"calibration_deadline"`       // 校准使用期限
+	CalibrationDeadlineType int         `orm:"CalibrationDeadlineType" json:"calibration_deadline_type"`  // 期限类型
+	CreatedBy               int         `orm:"CreatedBy"               json:"created_by"`                 // 创建人
+	UpdatedBy               int         `orm:"UpdatedBy"               json:"updated_by"`                 // 更新人
+	Model                   string      `orm:"Model"                   json:"model"`                      // 型号
+	SupplierId              int         `orm:"SupplierId"              json:"supplier_id"`                // 供应商
+	IsOpen                  int         `orm:"IsOpen"                  json:"is_open"`                    // 是否开启预约  1开启 2未开启
+	Weekday                 string      `orm:"Weekday"                 json:"weekday"`                    // 每周可预约日
+	BeginAt                 *gtime.Time `orm:"BeginAt"                 json:"begin_at"`                   // 预约开始时段
+	EndAt                   *gtime.Time `orm:"EndAt"                   json:"end_at"`                     // 预约结束时段
+	Terminal                string      `orm:"Terminal"                json:"terminal"`                   // 信息终端
+	TodayHour               float64     `json:"today_hour"`                                               // 今日预约剩余Mob
+	TomorrowHour            float64     `json:"tomorrow_hour"`                                            // 明日预约剩余空闲时间
+	Qualification           int         `json:"qualification"`                                            // 人员预约资格 1普通资格 2自身资格
+}

+ 0 - 0
model/internal/base_equipment_advance_time.go → model/equipment/internal/base_equipment_advance_time.go


+ 1 - 1
model/internal/base_equipment_qualification.go → model/equipment/internal/base_equipment_qualification.go

@@ -12,7 +12,7 @@ import (
 type BaseEquipmentQualification struct {
 	Id             int         `orm:"Id,primary"     json:"id"`             // 主键
 	EquipmentId    int         `orm:"EquipmentId"    json:"equipmentId"`    // 设备Id
-	UserId		   int		   `orm:"EquipmentIdUserId" json:"user_id"`     // 用户Id
+	UserId         int         `orm:"EquipmentIdUserId" json:"user_id"`     // 用户Id
 	Qualification  string      `orm:"Qualification"  json:"qualification"`  // 预约资格:1普通资格,2资深资格, 3优先使用权
 	AuthorizeTime  *gtime.Time `orm:"AuthorizeTime"  json:"authorizeTime"`  // 授权时间
 	CreateOn       *gtime.Time `orm:"CreateOn"       json:"createOn"`       //

+ 6 - 0
model/internal/instrument.go → model/equipment/internal/instrument.go

@@ -22,6 +22,11 @@ type Instrument struct {
 	Brand                   string      `orm:"Brand"                   json:"brand"`                   // 设备品牌
 	InstrType               int         `orm:"InstrType"               json:"instrType"`               // 设备类别
 	Status                  int         `orm:"Status"                  json:"status"`                  // 设备状态
+	Belongs                 int         `orm:"Belongs"                 json:"belongs"`                 // 设备所属 1内部 2外部
+	BelongsName             int         `orm:"BelongsName"             json:"belongsName"`             // 设备所属名称
+	Rate                    int         `orm:"Rate"                    json:"rate"`                    // 优惠比例
+	UnitCount               int         `orm:"UnitCount"               json:"unitCount"`               // 计费单价
+	CountType               string      `orm:"-"                       json:"countType"`               // 计费方式
 	Location                string      `orm:"Location"                json:"location"`                // 设备所在位置
 	Remark                  string      `orm:"Remark"                  json:"remark"`                  // 备注
 	IsFixedPoint            int         `orm:"IsFixedPoint"            json:"isFixedPoint"`            // 参与点检:
@@ -54,4 +59,5 @@ type Instrument struct {
 	Terminal                string      `orm:"Terminal"                json:"terminal"`                // 信息终端
 	RoleId                  int         `orm:"RoleId"                  json:"roleId"`                  // 自动审批角色
 	Sort                    int         `orm:"Sort"                    json:"sort"`                    // 排序
+	Qualification           int         `json:"qualification"`                                         // 人员预约资格 1普通资格 2自身资格
 }

+ 0 - 0
model/internal/meeting.go → model/meeting/internal/meeting.go


+ 0 - 0
model/internal/meeting_reservation.go → model/meeting/internal/meeting_reservation.go


+ 3 - 3
model/meeting.go → model/meeting/meeting.go

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

+ 5 - 5
model/meeting_reservation.go → model/meeting/meeting_reservation.go

@@ -2,15 +2,15 @@
 // This is auto-generated by gf cli tool. Fill this file as you wish.
 // ==========================================================================
 
-package model
+package meeting
 
 import (
 	"github.com/gogf/gf/os/gtime"
-	"lims_adapter/model/internal"
+	internal2 "lims_adapter/model/meeting/internal"
 )
 
 // MeetingReservation is the golang structure for table meeting_reservation.
-type MeetingReservation internal.MeetingReservation
+type MeetingReservation internal2.MeetingReservation
 
 // Fill with you ideas below.
 
@@ -85,8 +85,8 @@ type ReserveReq struct {
 
 // ReservationList 预约详情
 type ReservationList struct {
-	EntityId      int    `json:"entity_id"`		 // 会议室ID
-	Title         string `json:"title"`     		 // 会议名称
+	EntityId      int    `json:"entity_id"`      // 会议室ID
+	Title         string `json:"title"`          // 会议名称
 	ReservationId int    `json:"reservation_id"` // 预约ID
 	Day           int    `json:"day"`            // 日期
 	Dept          string `json:"dept"`           // 部门

+ 3 - 3
model/base_itemdetails.go → model/system/base_itemdetails.go

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

+ 0 - 0
model/internal/base_itemdetails.go → model/system/internal/base_itemdetails.go


+ 126 - 0
model/user/base_user.go

@@ -0,0 +1,126 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. Fill this file as you wish.
+// ==========================================================================
+
+package user
+
+import (
+	"github.com/gogf/gf/os/gtime"
+	internal2 "lims_adapter/model/user/internal"
+)
+
+// BaseUser is the golang structure for table base_user.
+type BaseUser internal2.BaseUser
+
+// Fill with you ideas below.
+
+type UserQualification struct {
+	Id            int         `orm:"Id,primary"            json:"id"`           //
+	UserName      string      `orm:"UserName"              json:"userName"`     // 用户登录名
+	RealName      string      `orm:"RealName"              json:"realName"`     // 用户名
+	Qualification int         `orm:"Qualification"		   json:"qualification"`    // 资格 1普通资格 2资深资格
+	Mobile        string      `orm:"Mobile"                json:"mobile"`       // 手机号
+	AuthorizeTime *gtime.Time `orm:"AuthorizeTime"    	   json:"authorizeTime"` // 授权时间
+}
+
+type UserInfoReq struct {
+	PageNun      int    `json:"pageNum"`
+	PageSize     int    `json:"pageSize"`
+	Enabled      int    `json:"enabled"`
+	InstrumentId int    `json:"instrument_id"`
+	DepartmentId int    `json:"department_id"`
+	UserName     string `json:"user_name"`
+	Mobile       string `json:"mobile"`
+	ReqType      int    `json:"req_type"` // 请求类型 设备预约(1:预约资格 2:优先预约权) 主从用户管理(1:主用户查询 2:从用户查询)
+}
+type UserInfoRsp struct {
+	Records []BaseUserInfo `json:"records"`
+	Total   int            `json:"total"'`
+}
+
+// 添加、删除主从用户
+type AddMainOrSubReq struct {
+	Ids     []int `json:"ids"`      // 用户Id列表
+	Id      int   `json:"id"`       // 用户Id
+	ReqType int   `json:"req_type"` // 预约资格:1 添加主用户,2添加从用户
+}
+
+// 财务账号绑定用户
+type UserBindAccountReq struct {
+	Id     int `json:"id"`
+	UserId int `json:"userId"`
+}
+
+type BaseUserInfo struct {
+	Id                    int         `orm:"Id,primary"            json:"id"`       //
+	Uuid                  string      `orm:"Uuid"                  json:"uuid"`     // 用户Id标识,不易猜出
+	AccCode               string      `orm:"AccCode"               json:"accCode"`  // 区分不同App的用户
+	Code                  string      `orm:"Code"                  json:"code"`     // 编码
+	UserName              string      `orm:"UserName"              json:"userName"` // 用户登录名
+	Realname              string      `orm:"Realname"              json:"realname"` // 用户名
+	RoleId                int         `orm:"RoleId"                json:"roleId"`   // 角色id
+	RoleInfo              string      `json:"roleInfo"`                             // 角色名称
+	AccountName           string      `json:"accountName"`                          // 账号名称
+	AccountId             int         `json:"accountId"`
+	SecurityLevel         int         `orm:"SecurityLevel"         json:"securityLevel"`         //
+	UserFrom              string      `orm:"UserFrom"              json:"userFrom"`              //
+	CompanyId             string      `orm:"CompanyId"             json:"companyId"`             // 公司id
+	CompanyName           string      `orm:"CompanyName"           json:"companyName"`           // 公司名称
+	DepartmentId          string      `orm:"DepartmentId"          json:"departmentId"`          // 部门id
+	DepartmentName        string      `orm:"DepartmentName"        json:"departmentName"`        // 部门名称
+	WorkgroupId           string      `orm:"WorkgroupId"           json:"workgroupId"`           // 工作组id
+	WorkgroupName         string      `orm:"WorkgroupName"         json:"workgroupName"`         // 工作组名称
+	WorkCategory          string      `orm:"WorkCategory"          json:"workCategory"`          //
+	Duty                  string      `orm:"Duty"                  json:"duty"`                  // 职务
+	Title                 string      `orm:"Title"                 json:"title"`                 // 头衔
+	Gender                string      `orm:"Gender"                json:"gender"`                // 性别
+	Birthday              string      `orm:"Birthday"              json:"birthday"`              //
+	Mobile                string      `orm:"Mobile"                json:"mobile"`                //
+	Telephone             string      `orm:"Telephone"             json:"telephone"`             //
+	Email                 string      `orm:"Email"                 json:"email"`                 //
+	OICQ                  string      `orm:"OICQ"                  json:"oICQ"`                  //
+	HomeAddress           string      `orm:"HomeAddress"           json:"homeAddress"`           //
+	UserPassword          string      `orm:"UserPassword"          json:"userPassword"`          //
+	ChangePasswordDate    *gtime.Time `orm:"ChangePasswordDate"    json:"changePasswordDate"`    // 改密码时间
+	CommunicationPassword string      `orm:"CommunicationPassword" json:"communicationPassword"` //
+	PublicKey             string      `orm:"PublicKey"             json:"publicKey"`             //
+	SignedPassword        string      `orm:"SignedPassword"        json:"signedPassword"`        //
+	Lang                  string      `orm:"Lang"                  json:"lang"`                  //
+	Theme                 string      `orm:"Theme"                 json:"theme"`                 //
+	AllowStartTime        *gtime.Time `orm:"AllowStartTime"        json:"allowStartTime"`        //
+	AllowEndTime          *gtime.Time `orm:"AllowEndTime"          json:"allowEndTime"`          //
+	LockStartDate         *gtime.Time `orm:"LockStartDate"         json:"lockStartDate"`         //
+	LockEndDate           *gtime.Time `orm:"LockEndDate"           json:"lockEndDate"`           //
+	FirstVisit            *gtime.Time `orm:"FirstVisit"            json:"firstVisit"`            //
+	PreviousVisit         *gtime.Time `orm:"PreviousVisit"         json:"previousVisit"`         //
+	LastVisit             *gtime.Time `orm:"LastVisit"             json:"lastVisit"`             //
+	LogOnCount            int         `orm:"LogOnCount"            json:"logOnCount"`            //
+	IsStaff               int         `orm:"IsStaff"               json:"isStaff"`               //
+	UserOnLine            int         `orm:"UserOnLine"            json:"userOnLine"`            //
+	IsVisible             int         `orm:"IsVisible"             json:"isVisible"`             // 是否可视,1为可视
+	OpenId                string      `orm:"OpenId"                json:"openId"`                //
+	IPAddress             string      `orm:"IPAddress"             json:"iPAddress"`             //
+	MACAddress            string      `orm:"MACAddress"            json:"mACAddress"`            //
+	Question              string      `orm:"Question"              json:"question"`              //
+	AnswerQuestion        string      `orm:"AnswerQuestion"        json:"answerQuestion"`        //
+	UserAddressId         int         `orm:"UserAddressId"         json:"userAddressId"`         //
+	Enabled               int         `orm:"Enabled"               json:"enabled"`               // 是否可用
+	AuditStatus           int         `orm:"AuditStatus"           json:"auditStatus"`           // 激活状态(1激活)
+	DeletionStateCode     int         `orm:"DeletionStateCode"     json:"deletionStateCode"`     // 删除状态
+	SortCode              int         `orm:"SortCode"              json:"sortCode"`              //
+	Description           string      `orm:"Description"           json:"description"`           //
+	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"`            //
+	Photo                 string      `orm:"Photo"                 json:"photo"`                 //
+	QRCode                string      `orm:"QRCode"                json:"qRCode"`                //
+	QRCodeImage           []byte      `orm:"QRCodeImage"           json:"qRCodeImage"`           //
+	IsCompanyUser         int         `orm:"IsCompanyUser"         json:"isCompanyUser"`         // 是否是企业用户(供方字段用)
+	Superior              string      `orm:"Superior"              json:"superior"`              // 上级部门
+	UnitId                int         `orm:"UnitId"                json:"unitId"`                // 二级单位ID(供方字段用)
+	Unit                  string      `orm:"Unit"                  json:"unit"`                  //
+	DeletedAt             *gtime.Time `orm:"DeletedAt"             json:"deletedAt"`             // 删除时间
+}

+ 0 - 0
model/internal/base_user.go → model/user/internal/base_user.go


+ 184 - 0
service/account/account.go

@@ -0,0 +1,184 @@
+package account
+
+import (
+	"dashoo.cn/micro_libary/request"
+	"database/sql"
+	"errors"
+	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/os/gtime"
+	"github.com/gogf/gf/util/gconv"
+	dao "lims_adapter/dao/account"
+	"lims_adapter/model"
+	account "lims_adapter/model/account"
+	"strconv"
+)
+
+// Service 账号相关
+type Service struct {
+	Dao    *dao.SettleAccountMainDao
+	Tenant string
+}
+
+type AccountService struct {
+	Dao    *dao.BaseAccountDao
+	Tenant string
+}
+
+// NewSrv 服务初始化
+func NewSrv(tenant string) Service {
+	return Service{Dao: dao.NewSettleAccountMainDao(tenant), Tenant: tenant}
+}
+
+func NewAccountSrv(tenant string) AccountService {
+	return AccountService{Dao: dao.NewBaseAccountDao(tenant), Tenant: tenant}
+}
+
+// 结算明细分页
+func (s Service) SettleAccountList(req model.ListReq, info request.UserInfo) ([]account.SettleAccountMain, int, error) {
+	entityModel := s.Dao.DB.Model("settle_account_main s").
+		LeftJoin("appointment a", "s.AppointId = a.Id").
+		LeftJoin("Instrument i").
+		Fields("s.Id, s.BillId, s.AppointUser, s.MainUser, s.FeeType, s.TotalPrice, ").
+		Where("MainUserId = ?", info.Id)
+	if req.Entity != nil {
+		entity := new(account.SettleAccountMainReq)
+		gconv.Struct(req.Entity, entity)
+		if strconv.Itoa(entity.AppointUserId) != "" {
+			entityModel = entityModel.WhereLike(s.Dao.Columns.AppointUserId, "%"+strconv.Itoa(entity.AppointUserId)+"%")
+		}
+		if strconv.Itoa(entity.RelevanceId) != "" {
+			entityModel = entityModel.WhereLike("RelevanceId", "%"+strconv.Itoa(entity.RelevanceId)+"%")
+		}
+	}
+	total, err := entityModel.Count()
+	if err != nil {
+		return nil, 0, err
+	}
+	if total == 0 {
+		return nil, 0, nil
+	}
+	return nil, 0, nil
+	res, err := entityModel.Page(req.Current, req.Size).FindAll()
+	if err != nil {
+		return nil, 0, err
+	}
+	list := make([]account.SettleAccountMain, 0)
+	res.Structs(&list)
+	return list, total, nil
+}
+
+// 新增结算明细主表、明细子表
+func (s Service) AddCountMainDetail(mobAppoint account.AppointInfoReq) error {
+	// 通过设备、用户查询优惠状态
+	var result account.AppointInfo
+	isDiscount := false
+	err := s.Dao.DB.Model("base_equipment_qualification").Fields("Qualification as IsPreferential").
+		Where("EquipmentId = " + strconv.Itoa(mobAppoint.Appointment.Instr.Id) + " and Qualification = 3 " +
+			" and UserId = " + strconv.Itoa(mobAppoint.Appointment.User.Id)).Scan(&result.User)
+	// 如果没有数据,则没有权限
+	if err == sql.ErrNoRows {
+		// TODO
+	} else {
+		if result.User.IsPreferential == "3" {
+			isDiscount = true
+		}
+	}
+	// 计算实际实验时长、费用,目前为一条明细子表数据,后期可能扩展为多条数据子表数据
+	totalMinutes := 0.0
+	//signInTime := mobAppoint.Appointment.Appoint.SignInTime
+	//hour := mobAppoint.SignOutTime.Hour() - signInTime.Hour()
+	//minute := mobAppoint.SignOutTime.Minute() - signInTime.Minute()
+	//totalMinute += hour * 60 + minute
+	totalMinutes += mobAppoint.Appointment.Appoint.RealityUseDuration * 60
+	unitCount := float64(mobAppoint.Appointment.Instr.UnitCount)
+	// 有优惠权,则按照优惠计费
+	if isDiscount {
+		unitCount = unitCount * float64(mobAppoint.Appointment.Instr.UnitCount) / 100
+	}
+	totalPrice := totalMinutes / 60 * unitCount
+
+	// 生成结算明细主表
+	now := gtime.Now()
+	var mainEntity = g.Map{
+		"AppointId":     mobAppoint.Appointment.Appoint.Id,
+		"AppointUserId": mobAppoint.Appointment.User.Id,
+		"AppointUser":   mobAppoint.Appointment.User.Realname,
+		"SettleStatus":  1,
+		"TotalPrice":    totalPrice,
+		"CreateUserId":  mobAppoint.Appointment.User.Id,
+		"CreateBy":      mobAppoint.Appointment.User.Realname,
+		"CreateOn":      now,
+	}
+	id, err := s.Dao.DB.Model("settle_account_main").InsertAndGetId(mainEntity)
+	if err != nil {
+		return err
+	} else {
+		// 生成结算明细子表
+		// TODO 判断正常支出或是违约
+		var detailEntity = g.Map{
+			"pid":            id,
+			"UnitPrice":      unitCount,
+			"Minutes":        totalMinutes,
+			"PaymentType":    1,
+			"PaymentAccount": 1,
+			"CreateUserId":   mobAppoint.Appointment.User.Id,
+			"CreateBy":       mobAppoint.Appointment.User.Realname,
+			"CreateOn":       now,
+		}
+		_, err := s.Dao.DB.Model("settle_account_detail").Insert(detailEntity)
+		if err != nil {
+			return err
+		}
+	}
+	return nil
+}
+
+// AddAccount 添加财务账号
+func (s Service) AddAccount(req *account.BaseAccount) error {
+	count, err := s.Dao.DB.Model("base_account").Where("Account = ?", req.Account).Count()
+	if err != nil {
+		return err
+	}
+	if count > 0 {
+		return errors.New("该账号已存在,请重新输入!")
+	}
+	_, err = s.Dao.DB.Model("base_account").Insert(req)
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
+// AccountList 财务账号分页查询
+func (s Service) AccountList(req *account.AccountReq) (infos account.BaseAccountRsp, err error) {
+	current := req.PageNun
+	size := req.PageSize
+	model := s.Dao.DB.Model("base_account a").
+		LeftJoin("user_account_bind b", "a.Id = b.AccountId").
+		LeftJoin("base_user c", "b.UserId = c.Id")
+	if req.Account != "" {
+		model = model.WhereLike("Account", req.Account)
+	}
+	if req.RealName != "" {
+		model = model.WhereLike("RealName", req.RealName)
+	}
+	if req.AccountName != "" {
+		model = model.Where("AccountName", req.AccountName)
+	}
+	infos.Total, err = model.Count()
+	if err != nil {
+		return infos, err
+	}
+	model.Fields("a.Id, a.Account,a.AccountName,A.Surplus,a.Available,a.Limit,a.Advance,c.Id UserId,c.RealName").
+		Page(current, size).Scan(&infos.Records)
+	return infos, nil
+}
+
+// DepositAccount 充值账户
+func (s AccountService) DepositAccount(req *account.BaseAccountResp) error {
+	_, err := s.Dao.M.Update("Surplus = "+strconv.Itoa(req.Surplus), "Id = "+strconv.Itoa(req.Id))
+	if err != nil {
+		return err
+	}
+	return nil
+}

+ 104 - 55
service/equipment/equipment.go

@@ -2,13 +2,15 @@ package equipment
 
 import (
 	"dashoo.cn/micro_libary/request"
+	"database/sql"
 	"errors"
 	"fmt"
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/os/gtime"
 	"github.com/gogf/gf/util/gconv"
-	"lims_adapter/dao"
-	"lims_adapter/model"
+	"lims_adapter/dao/equipment"
+	equipment2 "lims_adapter/model/equipment"
+	"lims_adapter/model/user"
 	"strconv"
 	"strings"
 	"time"
@@ -16,24 +18,24 @@ import (
 
 // Service 设备
 type Service struct {
-	Dao    *dao.BaseEquipmentQualificationDao
+	Dao    *equipment.BaseEquipmentQualificationDao
 	Tenant string
 }
 
 // NewSrv 服务初始化
 func NewSrv(tenant string) Service {
-	return Service{Dao: dao.NewBaseEquipmentQualificationDao(tenant), Tenant: tenant}
+	return Service{Dao: equipment.NewBaseEquipmentQualificationDao(tenant), Tenant: tenant}
 }
 
 // AppointmentQualificationList 预约资格分页查询
-func (s Service) AppointmentQualificationList(req *model.QualificationListReq) ([]model.UserQualification, int, error) {
+func (s Service) AppointmentQualificationList(req *equipment2.QualificationListReq) ([]user.UserQualification, int, error) {
 	var current = req.Current
 	var size = req.Size
 	var enabled = req.Enabled
 	var instrumentId = req.InstrumentId
 	var reqType = req.Type
 	entity := s.Dao.DB.Model("base_user a")
-	var userInfo []model.UserQualification
+	var userInfo []user.UserQualification
 	where := "a.Enabled = " + strconv.Itoa(enabled) + " and b.EquipmentId = " + strconv.Itoa(instrumentId)
 
 	if reqType == 1 { // 预约资格查询条件
@@ -43,7 +45,7 @@ func (s Service) AppointmentQualificationList(req *model.QualificationListReq) (
 	}
 	entity.LeftJoin("base_equipment_qualification b", "a.id = b.UserId").
 		Where(where)
-	count, _:= entity.Count()
+	count, _ := entity.Count()
 	err := entity.Fields("a.Id, a.UserName, a.RealName, a.Mobile, b.Qualification, b.AuthorizeTime").
 		Page(current, size).Scan(&userInfo)
 	if err != nil {
@@ -53,13 +55,13 @@ func (s Service) AppointmentQualificationList(req *model.QualificationListReq) (
 }
 
 // AdvanceList 优先预约权资格列表查询
-func (s Service) AdvanceList(req *model.QualificationListReq) ([]model.UserQualification, int, error) {
+func (s Service) AdvanceList(req *equipment2.QualificationListReq) ([]user.UserQualification, int, error) {
 	var current = req.Current
 	var size = req.Size
 	var enabled = req.Enabled
 	var instrumentId = req.InstrumentId
 	entity := s.Dao.DB.Model("base_user a")
-	var userInfo []model.UserQualification
+	var userInfo []user.UserQualification
 	entity.LeftJoin("base_equipment_qualification b", "a.id = b.UserId").
 		Where("a.Enabled = " + strconv.Itoa(enabled) + " and b.EquipmentId = " + strconv.Itoa(instrumentId))
 	count, _ := entity.Count()
@@ -72,7 +74,7 @@ func (s Service) AdvanceList(req *model.QualificationListReq) ([]model.UserQuali
 }
 
 // AddOrUpdateQualification 新增、修改预约资格名单;新增优先预约权名单
-func (s Service) AddOrUpdateQualification(req *model.AddOrUpdateQualification, userInfo request.UserInfo) (err error) {
+func (s Service) AddOrUpdateQualification(req *equipment2.AddOrUpdateQualification, userInfo request.UserInfo) (err error) {
 	entity := s.Dao.M
 	var instrumentId = req.InstrumentId
 	var ids = req.Ids
@@ -90,7 +92,7 @@ func (s Service) AddOrUpdateQualification(req *model.AddOrUpdateQualification, u
 			strconv.Itoa(v)
 		if qualification == 1 || qualification == 2 { // 预约资格
 			where += " and Qualification != 3"
-		} else if qualification ==3 { // 优先预约权
+		} else if qualification == 3 { // 优先预约权
 			// 先判断是否有预约资格,没有则不更新操作
 			count, _ := s.Dao.DB.Model("base_equipment_qualification").Where("EquipmentId = " +
 				strconv.Itoa(instrumentId) + " and Qualification != 0" + " and UserId = " +
@@ -101,9 +103,9 @@ func (s Service) AddOrUpdateQualification(req *model.AddOrUpdateQualification, u
 			}
 			where += " and Qualification = 3"
 		}
-			var qualificationInfo model.BaseEquipmentQualification
+		var qualificationInfo equipment2.BaseEquipmentQualification
 		entity.Where(where).Scan(&qualificationInfo)
-		entity.Data(g.Map{"Id": qualificationInfo.Id,"EquipmentId": instrumentId, "UserId": v, "Qualification": qualification, "CreateOn": gtime.Now(),
+		entity.Data(g.Map{"Id": qualificationInfo.Id, "EquipmentId": instrumentId, "UserId": v, "Qualification": qualification, "CreateOn": gtime.Now(),
 			"AuthorizeTime": gtime.Now(), "CreateUserId": userInfo.Id, "CreateBy": userInfo.RealName}).Save()
 
 	}
@@ -120,10 +122,10 @@ func (s Service) AddOrUpdateQualification(req *model.AddOrUpdateQualification, u
 }
 
 // DeleteQualification 删除预约资格
-func (s Service) DeleteQualification(req *model.IdReq, info request.UserInfo) error {
+func (s Service) DeleteQualification(req *equipment2.IdReq, info request.UserInfo) error {
 	_, err := s.Dao.M.Update(g.Map{"Qualification": 0, "ModifiedOn": gtime.Now(),
-		"ModifiedUserId": info.Id, "ModifiedBy": info.RealName}, "UserId = " + strconv.Itoa(req.UserId) +
-		" and EquipmentId = " + strconv.Itoa(req.EquipmentId) + " and Qualification != 3")
+		"ModifiedUserId": info.Id, "ModifiedBy": info.RealName}, "UserId = "+strconv.Itoa(req.UserId)+
+		" and EquipmentId = "+strconv.Itoa(req.EquipmentId)+" and Qualification != 3")
 	if err != nil {
 		return err
 	}
@@ -131,7 +133,7 @@ func (s Service) DeleteQualification(req *model.IdReq, info request.UserInfo) er
 }
 
 // DeleteAdvance 删除优先预约权人员
-func (s Service) DeleteAdvance(req *model.IdReq) error {
+func (s Service) DeleteAdvance(req *equipment2.IdReq) error {
 	_, err := s.Dao.M.Delete("UserId = " + strconv.Itoa(req.UserId) +
 		" and EquipmentId = " + strconv.Itoa(req.EquipmentId) + " and Qualification = 3")
 	if err != nil {
@@ -141,7 +143,7 @@ func (s Service) DeleteAdvance(req *model.IdReq) error {
 }
 
 // SearchAdvanceTime 查看设备优先预约时间段
-func (s Service) SearchAdvanceTime(req *model.QualificationListReq) (advanceTime []model.BaseEquipmentAdvanceTime, count int, err error) {
+func (s Service) SearchAdvanceTime(req *equipment2.QualificationListReq) (advanceTime []equipment2.BaseEquipmentAdvanceTime, count int, err error) {
 	entity := s.Dao.DB.Model("base_equipment_advance_time")
 	err = entity.Where("EquipmentId = " + strconv.Itoa(req.InstrumentId)).Scan(&advanceTime)
 	count, _ = entity.CountColumn("1")
@@ -153,7 +155,7 @@ func (s Service) SearchAdvanceTime(req *model.QualificationListReq) (advanceTime
 }
 
 // AddAdvanceTime 添加设备优先预约时间段
-func (s Service) AddAdvanceTime(req *model.AdvanceTimeReq, info request.UserInfo) error {
+func (s Service) AddAdvanceTime(req *equipment2.AdvanceTimeReq, info request.UserInfo) error {
 	//for _, v := range domains {
 	//	count, err := s.Dao.DB.Model("base_equipment_advance_time").Where("Week = '" + v.Week +
 	//		"' and StartTime = '" + v.StartTime + "' and EndTime = '" + v.EndTime + "'").Count()
@@ -177,24 +179,24 @@ func (s Service) AddAdvanceTime(req *model.AdvanceTimeReq, info request.UserInfo
 	count, err := s.Dao.DB.Model("base_equipment_advance_time").Where("EquipmentId = " +
 		strconv.Itoa(req.EquipmentId) + " and Week = " + req.Week +
 		" and StartTime = '" + req.StartTime + "' and EndTime = '" + req.EndTime + "'").Count()
-	if err != nil{
+	if err != nil {
 		return err
 	}
 	if count > 0 {
 		return errors.New("该时间段已存在,请重新输入!")
 	}
 	week, _ := strconv.Atoi(req.Week)
-	saveEntity := model.BaseEquipmentAdvanceTime{
-		EquipmentId: req.EquipmentId,
-		Week: week,
-		StartTime: req.StartTime,
-		EndTime: req.EndTime,
-		CreateOn: gtime.Now(),
+	saveEntity := equipment2.BaseEquipmentAdvanceTime{
+		EquipmentId:  req.EquipmentId,
+		Week:         week,
+		StartTime:    req.StartTime,
+		EndTime:      req.EndTime,
+		CreateOn:     gtime.Now(),
 		CreateUserId: gconv.Int(info.Id),
-		CreateBy: info.RealName,
+		CreateBy:     info.RealName,
 	}
 	_, err = s.Dao.DB.Model("base_equipment_advance_time").Insert(saveEntity)
-	if err != nil{
+	if err != nil {
 		return err
 	}
 	return nil
@@ -210,9 +212,9 @@ func (s Service) DeleteAdvanceTime(id int) error {
 }
 
 // AppointmentTime 设备预约时间段
-func (s Service) AppointmentTime(req *model.IdReq) error{
+func (s Service) AppointmentTime(req *equipment2.IdReq) error {
 	// 先查该人员的预约资格、优先使用权
-	var qualificationInfo []model.BaseEquipmentQualification
+	var qualificationInfo []equipment2.BaseEquipmentQualification
 	s.Dao.DB.Model("base_equipment_qualification").Where("EquipmentId = " +
 		strconv.Itoa(req.EquipmentId)).Order("Qualification").Scan(&qualificationInfo)
 	// 如果是普通预约资格,筛选出周末时间段
@@ -220,8 +222,8 @@ func (s Service) AppointmentTime(req *model.IdReq) error{
 		// TODO 时间获取
 	}
 	// 如果有预约资格但没有优先使用权,查询优先使用权时间段
-	if len(qualificationInfo) ==2 && qualificationInfo[1].Qualification == "3"{
-		var appointmentInfo []model.BaseEquipmentAdvanceTime
+	if len(qualificationInfo) == 2 && qualificationInfo[1].Qualification == "3" {
+		var appointmentInfo []equipment2.BaseEquipmentAdvanceTime
 		s.Dao.DB.Model("base_equipment_advance_time").Where("EquipmentId = " +
 			strconv.Itoa(req.EquipmentId) + " and UserId").Scan(&appointmentInfo)
 	}
@@ -229,16 +231,16 @@ func (s Service) AppointmentTime(req *model.IdReq) error{
 }
 
 // SearchNoAppointment 查看不能预约时间段信息
-func (s Service) SearchNoAppointment(req *model.IdReq, info request.UserInfo) ([]model.NoReservationInfo, error) {
+func (s Service) SearchNoAppointment(req *equipment2.IdReq, info request.UserInfo) ([]equipment2.NoReservationInfo, error) {
 	// 普通资格限制周末时间
-	var qualificationInfo []model.BaseEquipmentQualification
-	var noAppointmentInfos []model.NoReservationInfo
+	var qualificationInfo []equipment2.BaseEquipmentQualification
+	var noAppointmentInfos []equipment2.NoReservationInfo
 	s.Dao.DB.Model("base_equipment_qualification").Where("EquipmentId = " +
 		strconv.Itoa(req.EquipmentId) + " and UserId = " +
 		strconv.Itoa(gconv.Int(info.Id))).Order("Qualification").Scan(&qualificationInfo)
 	if len(qualificationInfo) >= 1 && qualificationInfo[0].Qualification == "1" { // 只有普通预约资格,限制周末预约时间段
 		// 查询设备可预约时间段
-		var equipmentInfo model.Instrument
+		var equipmentInfo equipment2.Instrument
 		s.Dao.DB.Model("instrument").Fields("BeginAt, EndAt").
 			Where("Id = " + strconv.Itoa(req.EquipmentId)).Scan(&equipmentInfo)
 		startTime := equipmentInfo.BeginAt
@@ -250,7 +252,7 @@ func (s Service) SearchNoAppointment(req *model.IdReq, info request.UserInfo) ([
 		noAppointmentInfos = append(saturdayTime, sundayTime...)
 	}
 	if len(qualificationInfo) == 1 && qualificationInfo[0].Qualification != "3" { // 没有优先预约权,限制优先预约时间段
-		var advanceTimeList []model.BaseEquipmentAdvanceTime
+		var advanceTimeList []equipment2.BaseEquipmentAdvanceTime
 		s.Dao.DB.Model("base_equipment_advance_time").
 			Where("EquipmentId = " + strconv.Itoa(req.EquipmentId)).Scan(&advanceTimeList)
 		for _, v := range advanceTimeList {
@@ -266,17 +268,57 @@ func (s Service) SearchNoAppointment(req *model.IdReq, info request.UserInfo) ([
 }
 
 // ChangeInstrStauts 修改设备所属
-func (s Service) ChangeBelongs(req *model.IdReq) error{
+func (s Service) ChangeBelongs(req *equipment2.IdReq) error {
 	_, err := s.Dao.DB.Model("Instrument").
-		Update("Belongs = " + req.Belongs, "Id = "+strconv.Itoa(req.EquipmentId))
+		Update("Belongs = "+req.Belongs, "Id = "+strconv.Itoa(req.EquipmentId))
 	if err != nil {
 		return err
 	}
 	return nil
 }
 
+// GetUnitCount 查询设备计费
+func (s Service) GetUnitCount(instrumentId int) (rspInfo []equipment2.Instrument, err error) {
+	err = s.Dao.DB.Model("Instrument").Where("Id = ?", instrumentId).Scan(&rspInfo)
+	if err != nil {
+		return rspInfo, err
+	}
+	return rspInfo, nil
+}
+
+// UpdateUnifPrice 更新计费价格
+func (s Service) UpdateUnitfPrice(instrumentId, unitCount int) error {
+	_, err := s.Dao.DB.Model("Instrument").Update("unitCount = "+strconv.Itoa(unitCount), "Id = "+
+		strconv.Itoa(instrumentId))
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
+// RateChange 优惠比例更新
+func (s Service) RateChange(InstrumentId, rate int) error {
+	_, err := s.Dao.DB.Model("Instrument").Update("Rate = "+strconv.Itoa(rate), "Id = "+
+		strconv.Itoa(InstrumentId))
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
+// IsAdvance 是否有优先预约资格
+func (s Service) IsAdvance(id int32, instrumentId int) (isAdvance int, err error) {
+	equipmentQualification := equipment2.BaseEquipmentQualification{}
+	err = s.Dao.DB.Model("base_equipment_qualification").Where("UserId", id).
+		Where("Qualification", "3").Where("EquipmentId", instrumentId).Scan(&equipmentQualification)
+	if err == sql.ErrNoRows {
+		return 0, nil
+	}
+	return 1, nil
+}
+
 // noReservationInfo 不可预约时间段处理 startTime开始时间 timeLong 时间间隔 Date 前端传入日期 week 星期几
-func noReservationInfo(startTime *gtime.Time, timeLong float64, Date string, week int) (noAppointmentInfo []model.NoReservationInfo) {
+func noReservationInfo(startTime *gtime.Time, timeLong float64, Date string, week int) (noAppointmentInfo []equipment2.NoReservationInfo) {
 	date, _ := gtime.StrToTime(Date, "Y-m-d")
 	// 获取当前星期对应的日期
 	day := GetDate(date, week)
@@ -285,29 +327,36 @@ func noReservationInfo(startTime *gtime.Time, timeLong float64, Date string, wee
 		// 开始时间
 		start_time := startTime.Add(time.Duration(i) * 30 * time.Minute)
 		//fmt.Println("day:", day, "week:", week, "start_time", fmt.Sprintf("%02d", start_time.Hour()) + ":"+fmt.Sprintf("%02d", start_time.Minute()), "status:", status)
-		noAppointmentInfo = append(noAppointmentInfo, model.NoReservationInfo{
-			Day : day,
-			Week : week,
-			StartTime : fmt.Sprintf("%02d", start_time.Hour()) + ":"+fmt.Sprintf("%02d", start_time.Minute()),
-			Status : 3,
+		noAppointmentInfo = append(noAppointmentInfo, equipment2.NoReservationInfo{
+			Day:       day,
+			Week:      week,
+			StartTime: fmt.Sprintf("%02d", start_time.Hour()) + ":" + fmt.Sprintf("%02d", start_time.Minute()),
+			Status:    3,
 		})
 	}
 	return noAppointmentInfo
 }
 
 // 获取当前星期对应的日期
-func GetDate(Date *gtime.Time, week int) int{
+func GetDate(Date *gtime.Time, week int) int {
 	weekday := Date.Weekday().String()
-	var targetDay  *gtime.Time
+	var targetDay *gtime.Time
 	switch weekday {
-		case "Monday": 		targetDay = Date.AddDate(0, 0, week - 1)
-		case "Tuesday":		targetDay = Date.AddDate(0, 0, week - 2)
-		case "Wednesday": 	targetDay = Date.AddDate(0, 0, week - 3)
-		case "Thursday": 	targetDay = Date.AddDate(0, 0, week - 4)
-		case "Friday": 		targetDay = Date.AddDate(0, 0, week - 5)
-		case "Saturday": 	targetDay = Date.AddDate(0, 0, week - 6)
-		case "Sunday": 		targetDay = Date.AddDate(0, 0, week - 7)
+	case "Monday":
+		targetDay = Date.AddDate(0, 0, week-1)
+	case "Tuesday":
+		targetDay = Date.AddDate(0, 0, week-2)
+	case "Wednesday":
+		targetDay = Date.AddDate(0, 0, week-3)
+	case "Thursday":
+		targetDay = Date.AddDate(0, 0, week-4)
+	case "Friday":
+		targetDay = Date.AddDate(0, 0, week-5)
+	case "Saturday":
+		targetDay = Date.AddDate(0, 0, week-6)
+	case "Sunday":
+		targetDay = Date.AddDate(0, 0, week-7)
 	}
 	_, _, day := targetDay.Date()
 	return day
-}
+}

+ 18 - 14
service/meeting/meeting.go

@@ -3,30 +3,32 @@ package meeting
 import (
 	"dashoo.cn/micro_libary/request"
 	"errors"
+	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/util/gconv"
 	"lims_adapter/common"
-	"lims_adapter/dao"
+	"lims_adapter/dao/meeting"
 	"lims_adapter/model"
+	meeting2 "lims_adapter/model/meeting"
 	"lims_adapter/service"
 )
 
 // Service 会议室服务
 type Service struct {
-	Dao    *dao.MeetingDao
+	Dao    *meeting.MeetingDao
 	Tenant string
 }
 
 // NewSrv 服务初始化
 func NewSrv(tenant string) Service {
-	return Service{Dao: dao.NewMeetingDao(tenant), Tenant: tenant}
+	return Service{Dao: meeting.NewMeetingDao(tenant), Tenant: tenant}
 }
 
 // List 会议室列表
-func (m Service) List(req model.ListReq) ([]model.Meeting, int, error) {
+func (m Service) List(req model.ListReq) ([]meeting2.Meeting, int, error) {
 	entityModel := m.Dao.M
 
 	if req.Entity != nil {
-		entity := new(model.MeetingReq)
+		entity := new(meeting2.MeetingReq)
 		gconv.Struct(req.Entity, entity)
 		if entity.Name != "" {
 			entityModel = entityModel.WhereLike(m.Dao.Columns.Name, "%"+entity.Name+"%")
@@ -50,7 +52,7 @@ func (m Service) List(req model.ListReq) ([]model.Meeting, int, error) {
 	}
 
 	if req.Value != "" {
-		entityModel = entityModel.Order(common.Snake2Orm(model.Meeting{}, req.Value), req.Type)
+		entityModel = entityModel.Order(common.Snake2Orm(meeting2.Meeting{}, req.Value), req.Type)
 	} else {
 		entityModel = entityModel.Order(service.DefaultSortField)
 	}
@@ -61,13 +63,13 @@ func (m Service) List(req model.ListReq) ([]model.Meeting, int, error) {
 	if res.IsEmpty() {
 		return nil, 0, nil
 	}
-	list := make([]model.Meeting, 0)
+	list := make([]meeting2.Meeting, 0)
 	res.Structs(&list)
 	return list, total, nil
 }
 
-func (m Service) Add(userInfo request.UserInfo, req model.MeetingReq) error {
-	entity := new(model.Meeting)
+func (m Service) Add(userInfo request.UserInfo, req meeting2.MeetingReq) error {
+	entity := new(meeting2.Meeting)
 	// 唯一校验
 	count, err := m.Dao.M.Fields(m.Dao.Columns.Id).Where(m.Dao.Columns.Name, req.Name).FindCount()
 	if err != nil {
@@ -94,8 +96,8 @@ func (m Service) Add(userInfo request.UserInfo, req model.MeetingReq) error {
 	return nil
 }
 
-func (m Service) Update(userInfo request.UserInfo, req model.MeetingReq) error {
-	entity := new(model.Meeting)
+func (m Service) Update(userInfo request.UserInfo, req meeting2.MeetingReq) error {
+	entity := new(meeting2.Meeting)
 	// 唯一校验
 	count, err := m.Dao.M.Fields(m.Dao.Columns.Id).
 		Where(m.Dao.Columns.Name, req.Name).WhereNot(m.Dao.Columns.Id, req.Id).
@@ -126,7 +128,7 @@ func (m Service) Update(userInfo request.UserInfo, req model.MeetingReq) error {
 	return nil
 }
 
-func (m Service) Get(id int) (*model.Meeting, error) {
+func (m Service) Get(id int) (*meeting2.Meeting, error) {
 	return m.Dao.WherePri(id).FindOne()
 }
 
@@ -169,13 +171,15 @@ func (m Service) Exists(id int) error {
 	return nil
 }
 
-func (m Service) ShortList() ([]model.ShortMeeting, error) {
-	list := make([]model.ShortMeeting, 0)
+func (m Service) ShortList() ([]meeting2.ShortMeeting, error) {
+	list := make([]meeting2.ShortMeeting, 0)
 	res, err := m.Dao.M.Order(m.Dao.Columns.Sort, "DESC, ", m.Dao.Columns.CreatedAt, "DESC").FindAll()
 	if err != nil {
 		return nil, err
+		g.Log().Info("ShortList err:", err)
 	}
 	if res.IsEmpty() {
+		g.Log().Info("ShortList IsEmpty err:", err)
 		return nil, nil
 	}
 	res.Structs(&list)

+ 28 - 26
service/reservation/reservation.go

@@ -11,8 +11,9 @@ import (
 	"github.com/gogf/gf/os/gtime"
 	"github.com/gogf/gf/util/gconv"
 	"lims_adapter/common"
-	"lims_adapter/dao"
+	meeting2 "lims_adapter/dao/meeting"
 	"lims_adapter/model"
+	meeting3 "lims_adapter/model/meeting"
 	"lims_adapter/service"
 	"lims_adapter/service/meeting"
 	"lims_adapter/service/srv"
@@ -21,21 +22,21 @@ import (
 
 // Service ReservationService 预约
 type Service struct {
-	Dao    *dao.MeetingReservationDao
+	Dao    *meeting2.MeetingReservationDao
 	Tenant string
 }
 
 // NewSrv 服务初始化
 func NewSrv(tenant string) Service {
-	return Service{Dao: dao.NewMeetingReservationDao(tenant), Tenant: tenant}
+	return Service{Dao: meeting2.NewMeetingReservationDao(tenant), Tenant: tenant}
 }
 
 // List 预约列表
-func (s Service) List(req model.ListReq) ([]model.List, int, error) {
+func (s Service) List(req model.ListReq) ([]meeting3.List, int, error) {
 	entityModel := s.Dao.M
 
 	if req.Entity != nil {
-		entity := new(model.ReservationReq)
+		entity := new(meeting3.ReservationReq)
 		gconv.Struct(req.Entity, entity)
 		tableSql := s.Dao.Table + "."
 		if entity.Title != "" {
@@ -64,7 +65,7 @@ func (s Service) List(req model.ListReq) ([]model.List, int, error) {
 		return nil, 0, nil
 	}
 	if req.Value != "" {
-		entityModel = entityModel.Order(s.Dao.Table+"."+common.Snake2Orm(model.MeetingReservation{}, req.Value), req.Type)
+		entityModel = entityModel.Order(s.Dao.Table+"."+common.Snake2Orm(meeting3.MeetingReservation{}, req.Value), req.Type)
 	} else {
 		entityModel = entityModel.Order(s.Dao.Table+"."+s.Dao.Columns.CreatedAt, "DESC")
 	}
@@ -79,14 +80,14 @@ func (s Service) List(req model.ListReq) ([]model.List, int, error) {
 	if res.IsEmpty() {
 		return nil, 0, nil
 	}
-	list := make([]model.List, 0)
+	list := make([]meeting3.List, 0)
 	res.Structs(&list)
 	return list, total, nil
 }
 
 // Add 添加预约
-func (s Service) Add(userInfo request.UserInfo, req model.ReservationReq) error {
-	entity := new(model.MeetingReservation)
+func (s Service) Add(userInfo request.UserInfo, req meeting3.ReservationReq) error {
+	entity := new(meeting3.MeetingReservation)
 	err := s.check(req)
 	if err != nil {
 		return err
@@ -133,7 +134,7 @@ func (s Service) Cancel(userInfo request.UserInfo, id int) error {
 }
 
 // OverviewList 预约概况
-func (s Service) OverviewList(req model.OverviewReq) (g.Map, error) {
+func (s Service) OverviewList(req meeting3.OverviewReq) (g.Map, error) {
 	dates := getCurrentWeekDay(req.Date)
 	meetingList, err := meeting.NewSrv(s.Tenant).ShortList()
 	if err != nil {
@@ -152,7 +153,7 @@ func (s Service) OverviewList(req model.OverviewReq) (g.Map, error) {
 }
 
 // OverviewListByDay 按天预约概况
-func (s Service) OverviewListByDay(ctx context.Context, req model.OverviewReq) (g.Map, error) {
+func (s Service) OverviewListByDay(ctx context.Context, req meeting3.OverviewReq) (g.Map, error) {
 	beginAt := g.Cfg().GetString("reservation.begin")
 	endAt := g.Cfg().GetString("reservation.end")
 	period := s.getCurrentPeriod(beginAt, endAt)
@@ -161,7 +162,7 @@ func (s Service) OverviewListByDay(ctx context.Context, req model.OverviewReq) (
 	if err != nil {
 		return nil, err
 	}
-	reservationList, err := s.getCurrentDayReservation(ctx,meetingList, req.Date)
+	reservationList, err := s.getCurrentDayReservation(ctx, meetingList, req.Date)
 	if err != nil {
 		return nil, err
 	}
@@ -175,7 +176,7 @@ func (s Service) OverviewListByDay(ctx context.Context, req model.OverviewReq) (
 }
 
 // ReserveInfo 预约信息
-func (s Service) ReserveInfo(ctx context.Context, req model.ReserveReq) (g.Map, error) {
+func (s Service) ReserveInfo(ctx context.Context, req meeting3.ReserveReq) (g.Map, error) {
 	// 常规信息
 	beginAt := g.Cfg().GetString("reservation.begin_at")
 	endAt := g.Cfg().GetString("reservation.end_at")
@@ -196,7 +197,7 @@ func (s Service) ReserveInfo(ctx context.Context, req model.ReserveReq) (g.Map,
 }
 
 // Ending 结束会议
-func (s Service) Ending(ctx context.Context, req model.EndingReq) error {
+func (s Service) Ending(ctx context.Context, req meeting3.EndingReq) error {
 	// 先查询预约记录
 	entity, err := s.Dao.WherePri(req.Id).FindOne()
 	if err != nil {
@@ -259,7 +260,7 @@ func (s Service) AutoEnding(id int) error {
 }
 
 // Check 预约校验
-func (s Service) check(req model.ReservationReq) error {
+func (s Service) check(req meeting3.ReservationReq) error {
 	// 校验开始结束时间不能跨天
 	if req.StartTime.Format("Y-m-d") != req.EndTime.Format("Y-m-d") &&
 		req.EndTime.Hour() != 0 && req.EndTime.Minute() != 0 {
@@ -306,12 +307,12 @@ func (s Service) check(req model.ReservationReq) error {
 }
 
 // getCurrentWeekDay 返回当前日期的周信息
-func getCurrentWeekDay(current *gtime.Time) []model.CurrentDate {
+func getCurrentWeekDay(current *gtime.Time) []meeting3.CurrentDate {
 	startOfWeek := common.GetCNStartOfWeek(current)
-	dates := make([]model.CurrentDate, 0)
+	dates := make([]meeting3.CurrentDate, 0)
 	for i := 0; i <= 6; i++ {
 		times := startOfWeek.AddDate(0, 0, 1*i)
-		dates = append(dates, model.CurrentDate{
+		dates = append(dates, meeting3.CurrentDate{
 			Date: times.Format("Y-m-d"),
 			Day:  times.Day(),
 		})
@@ -319,11 +320,11 @@ func getCurrentWeekDay(current *gtime.Time) []model.CurrentDate {
 	return dates
 }
 
-func (s Service) shortList(date *gtime.Time) ([]model.ShortList, error) {
+func (s Service) shortList(date *gtime.Time) ([]meeting3.ShortList, error) {
 	sTime := common.GetCNStartOfWeek(date)
 	eTime := common.GetCNEndOfWeek(date)
 
-	list := make([]model.ShortList, 0)
+	list := make([]meeting3.ShortList, 0)
 	res, err := s.Dao.M.WhereBetween(s.Dao.Columns.StartTime, sTime, eTime).
 		Where(s.Dao.Columns.Status, 1).FindAll()
 	if err != nil {
@@ -377,7 +378,7 @@ func (s Service) getCurrentPeriod(entityBeginAt, entityEndAt string) [][]string
 }
 
 // getCurrentWeekReservation 返回本周预约信息
-func (s Service) getCurrentWeekReservation(ctx context.Context, req model.ReserveReq) ([]model.ReservationList, error) {
+func (s Service) getCurrentWeekReservation(ctx context.Context, req meeting3.ReserveReq) ([]meeting3.ReservationList, error) {
 	// 获取符合条件的预约信息
 	list, err := s.Dao.Where(s.Dao.Columns.EntityId, req.EntityId).
 		Where(s.Dao.Columns.Status, 1).
@@ -404,7 +405,7 @@ func (s Service) getCurrentWeekReservation(ctx context.Context, req model.Reserv
 	for _, v := range userList {
 		usersMap[v.Id] = v
 	}
-	resultList := make([]model.ReservationList, 0)
+	resultList := make([]meeting3.ReservationList, 0)
 	for _, v := range list {
 		timeLong := v.EndTime.Sub(v.StartTime).Hours()
 		if v.SignOutTime.String() != "" && v.EndTime.Sub(v.SignOutTime) > 0 {
@@ -413,7 +414,7 @@ func (s Service) getCurrentWeekReservation(ctx context.Context, req model.Reserv
 		grid := timeLong * 2
 		for i := 0; i < int(grid); i++ {
 			startAt := v.StartTime.Add(time.Duration(i) * 30 * time.Minute)
-			resultList = append(resultList, model.ReservationList{
+			resultList = append(resultList, meeting3.ReservationList{
 				ReservationId: int(v.Id),
 				Day:           v.StartTime.Day(),
 				Dept:          usersMap[v.UserId].DepartmentName,
@@ -429,9 +430,9 @@ func (s Service) getCurrentWeekReservation(ctx context.Context, req model.Reserv
 }
 
 // getCurrentWeekReservation 返回本周预约信息
-func (s Service) getCurrentDayReservation(ctx context.Context,meetingList []model.ShortMeeting, reqDate *gtime.Time) ([]model.ReservationList, error) {
+func (s Service) getCurrentDayReservation(ctx context.Context, meetingList []meeting3.ShortMeeting, reqDate *gtime.Time) ([]meeting3.ReservationList, error) {
 	// 获取符合条件的预约信息
-	resultList := make([]model.ReservationList, 0)
+	resultList := make([]meeting3.ReservationList, 0)
 	for _, value := range meetingList {
 		list, err := s.Dao.Where(s.Dao.Columns.EntityId, value.Id).
 			Where(s.Dao.Columns.Status, 1).
@@ -439,6 +440,7 @@ func (s Service) getCurrentDayReservation(ctx context.Context,meetingList []mode
 			Where(s.Dao.Columns.EndTime+"<=", reqDate.AddDate(0, 0, 1)).
 			FindAll()
 		if err != nil {
+			g.Log().Info("getCurrentDayReservation err:", err)
 			return nil, err
 		}
 		if len(list) == 0 {
@@ -466,7 +468,7 @@ func (s Service) getCurrentDayReservation(ctx context.Context,meetingList []mode
 			grid := timeLong * 2
 			for i := 0; i < int(grid); i++ {
 				startAt := v.StartTime.Add(time.Duration(i) * 30 * time.Minute)
-				resultList = append(resultList, model.ReservationList{
+				resultList = append(resultList, meeting3.ReservationList{
 					EntityId:      value.Id,
 					ReservationId: int(v.Id),
 					Title:         v.Title,

+ 4 - 4
service/result/result.go

@@ -4,7 +4,7 @@ import (
 	"context"
 	"encoding/json"
 	"errors"
-	"lims_adapter/dao"
+	"lims_adapter/dao/consequent"
 	"log"
 
 	"dashoo.cn/common_definition/admin/result_def"
@@ -14,14 +14,14 @@ import (
 )
 
 type Service struct {
-	ConsequentDao       *dao.ConsequentDao
-	ConsequentDetailDao *dao.ConsequentDetailDao
+	ConsequentDao       *consequent.ConsequentDao
+	ConsequentDetailDao *consequent.ConsequentDetailDao
 	Tenant              string
 }
 
 // NewSrv 服务初始化
 func NewSrv(tenant string) Service {
-	return Service{ConsequentDao: dao.NewConsequentDao(tenant), ConsequentDetailDao: dao.NewConsequentDetailDao(tenant), Tenant: tenant}
+	return Service{ConsequentDao: consequent.NewConsequentDao(tenant), ConsequentDetailDao: consequent.NewConsequentDetailDao(tenant), Tenant: tenant}
 }
 
 func (s Service) GetResultList(req result_def.ResultListReq) ([]result_def.ResultList, int, error) {

+ 133 - 14
service/system/system.go

@@ -1,23 +1,28 @@
 package system
 
 import (
-	"lims_adapter/dao"
-	"lims_adapter/model"
+	"dashoo.cn/micro_libary/request"
+	"errors"
+	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/os/gtime"
+	"lims_adapter/dao/system"
+	model "lims_adapter/model/system"
+	"lims_adapter/model/user"
 	"strconv"
 )
 
 type Service struct {
-	Dao    *dao.BaseItemdetailsDao
+	Dao    *system.BaseItemdetailsDao
 	Tenant string
 }
 
 // NewSrv 服务初始化
 func NewSrv(tenant string) Service {
-	return Service{Dao: dao.NewBaseItemdetailsDao(tenant), Tenant: tenant}
+	return Service{Dao: system.NewBaseItemdetailsDao(tenant), Tenant: tenant}
 }
 
 // DictInfo 获取字典数据
-func(s Service) DictInfo(req *model.DictReq) (dictInfo []model.BaseItemdetails, err error) {
+func (s Service) DictInfo(req *model.DictReq) (dictInfo []model.BaseItemdetails, err error) {
 	where := "DictCode = '" + req.DictCode + "' and Enabled = 1"
 	if req.ItemName != "" {
 		where += " and ItemName = '" + req.ItemName + "'"
@@ -35,23 +40,23 @@ func(s Service) DictInfo(req *model.DictReq) (dictInfo []model.BaseItemdetails,
 	return dictInfo, nil
 }
 
-// UserList 获取用户信息
-func (s Service) UserList(req *model.UserInfoReq) (userInfos model.UserInfoRsp,err error) {
+// UserList 设备预约权管理:获取用户信息
+func (s Service) UserList(req *user.UserInfoReq) (userInfos user.UserInfoRsp, err error) {
 	where := "Enabled = 1"
 	departmentId := strconv.Itoa(req.DepartmentId)
 	instrumentId := strconv.Itoa(req.InstrumentId)
-	current:= req.PageNun
-	size:= req.PageSize
+	current := req.PageNun
+	size := req.PageSize
 	count := 0
 	model := s.Dao.DB.Model("base_user a")
-	if departmentId != "" && departmentId != "0"{
+	if departmentId != "" && departmentId != "0" {
 		where += " and DepartmentId = " + departmentId
 	}
 	if req.ReqType == 1 { // 预约资格
 		count, err = model.Where(where).Count()
-	}else if req.ReqType == 2 { // 优先预约权
-		where += " and Id not in(select UserId from base_equipment_qualification where EquipmentId = "+
-			instrumentId +" and Qualification in (0,3))"
+	} else if req.ReqType == 2 { // 优先预约权
+		where += " and Id not in(select UserId from base_equipment_qualification where EquipmentId = " +
+			instrumentId + " and Qualification in (0,3))"
 		count, err = model.Where(where).Count()
 	}
 	if err != nil {
@@ -60,4 +65,118 @@ func (s Service) UserList(req *model.UserInfoReq) (userInfos model.UserInfoRsp,e
 	userInfos.Total = count
 	model.Page(current, size).Scan(&userInfos.Records)
 	return userInfos, nil
-}
+}
+
+// GetProgramGroup 获取课题组信息
+func (s Service) GetProgramGroup(id int) ([]model.BaseProgramGroup, error) {
+	programGroup := []model.BaseProgramGroup{}
+	err := s.Dao.DB.Model("base_program_group").Where("OrganizeId = ?", id).Scan(&programGroup)
+	if err != nil {
+		return nil, err
+	}
+	return programGroup, nil
+}
+
+// GetUserList 主从用户管理:获取用户信息
+func (s Service) GetUserList(req *user.UserInfoReq, userId int32) (userInfos user.UserInfoRsp, err error) {
+	where := "a.Enabled = 1"
+	departmentId := strconv.Itoa(req.DepartmentId)
+	current := req.PageNun
+	size := req.PageSize
+	count := 0
+	model := s.Dao.DB.Model("base_user a").LeftJoin("base_role b", "a.RoleId = b.Id").
+		LeftJoin("user_account_bind c", "a.Id = c.UserId").
+		LeftJoin("base_account d", "c.AccountId = d.Id")
+	if departmentId != "" && departmentId != "0" {
+		where += " and DepartmentId = " + departmentId
+	}
+	if req.UserName != "" {
+		where += " and a.UserName = '" + req.UserName + "' or a.RealName = '" + req.UserName + "'"
+	}
+	if req.Mobile != "" {
+		where += " and a.Mobile = '" + req.Mobile + "'"
+	}
+	if req.ReqType == 1 { // 获取主用户信息
+		count, err = model.LeftJoin("master_user e", "a.Id = e.UserId ").
+			Where(where + " and e.Id is not null").Count()
+	} else if req.ReqType == 2 { // 从用户信息
+		count, err = model.LeftJoin("base_user_relation e", "a.Id = e.UserId").
+			Where(where + " and e.Pid = " + strconv.Itoa(int(userId))).Count()
+	} else if req.ReqType == 3 { // 不是主从用户信息
+		count, err = model.Where(where + " and a.Id not in (select UserId from master_user) and a.Id not in (select UserId from base_user_relation)").Count()
+	}
+	if err != nil {
+		return userInfos, err
+	}
+	userInfos.Total = count
+	model.Fields("a.Id, a.UserName, a.RealName, a.Mobile, a.DepartmentName, b.RealName as RoleInfo, d.AccountName, d.Id AccountId").
+		Page(current, size).Scan(&userInfos.Records)
+	return userInfos, nil
+}
+
+// AddMainUserOrSubUser 添加主从用户
+func (s Service) AddMainUserOrUser(req *user.AddMainOrSubReq, userInfo request.UserInfo) error {
+	for _, v := range req.Ids {
+		if req.ReqType == 1 { // 新增主用户
+			s.Dao.DB.Model("master_user").
+				Insert(g.Map{"UserId": v})
+		} else if req.ReqType == 2 { // 修改用户为从用户,并添加主从用户关系
+			//s.Dao.DB.Model("base_user").
+			//	Update("IsMain = 2", "Id = " + strconv.Itoa(v))
+			// 添加主从用户关系表
+			saveEntity := user.BaseUserRelation{
+				UserId:    v,
+				Pid:       int(userInfo.Id),
+				PName:     userInfo.RealName,
+				CreatedBy: int(userInfo.Id),
+				CreatedAt: gtime.Now(),
+			}
+			s.Dao.DB.Model("base_user_relation").Insert(saveEntity)
+		}
+	}
+	return nil
+}
+
+// DeleteMainUserOrSubUser 删除主从用户
+func (s Service) DeleteMainUserOrSubUser(req *user.AddMainOrSubReq, info request.UserInfo) error {
+	if req.ReqType == 1 { // 删除主用户 先判断是否有从用户
+		count, err := s.Dao.DB.Model("base_user_relation").Where("Pid = ?", req.Id).Count()
+		if err != nil {
+			return err
+		}
+		if count > 0 {
+			return errors.New("该用户有从用户,无法删除!")
+		}
+		s.Dao.DB.Model("master_user").Delete("UserId = ?", req.Id)
+	} else if req.ReqType == 2 { // 删除从用户 先判断是否有未结账
+		count, err := s.Dao.DB.Model("settle_account_main").
+			Where("AppointUserId = " + strconv.Itoa(req.Id) + " and SettleStatus = 1").Count()
+		if err != nil {
+			return err
+		}
+		if count > 0 {
+			return errors.New("该用户有未结账明细,无法删除!")
+		}
+		s.Dao.DB.Model("base_user_relation").Delete("UserId = ?", req.Id)
+	}
+	//s.Dao.DB.Model("base_user").
+	//	Update("IsMain = 0 and ModifiedOn = '"+ gtime.Now().String() +
+	//		"' and ModifiedUserId = "+ strconv.Itoa(int(info.Id)) +
+	//		" and ModifiedBy = '"+ info.RealName + "'", "Id = "+ strconv.Itoa(req.Id))
+
+	return nil
+}
+
+// UserBindAccount 用户绑定
+func (s Service) UserBindAccount(req *user.UserBindAccountReq) error {
+	_, err := s.Dao.DB.Model("user_account_bind").Delete("UserId = " + strconv.Itoa(req.UserId))
+	if err != nil {
+		return err
+	}
+	_, err = s.Dao.DB.Model("user_account_bind").
+		Insert(g.Map{"UserId": req.UserId, "AccountId": req.Id, "CreateOn": gtime.Now()})
+	if err != nil {
+		return err
+	}
+	return nil
+}