Kaynağa Gözat

仓库管理

mainqaq 2 yıl önce
ebeveyn
işleme
9c60e23337
2 değiştirilmiş dosya ile 31 ekleme ve 0 silme
  1. 10 0
      models/secondary_models.go
  2. 21 0
      service/secondary_service.go

+ 10 - 0
models/secondary_models.go Dosyayı Görüntüle

@@ -35,3 +35,13 @@ type StorehouseConfig struct {
35 35
 func (StorehouseConfig) TableName() string {
36 36
 	return "xt_storehouse_config"
37 37
 }
38
+
39
+type App_Role_byli struct {
40
+	Id       int64  `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"`
41
+	OrgId    int64  `gorm:"column:org_id" json:"org_id"`
42
+	UserName string `gorm:"column:user_name" json:"user_name"` // 用户名称
43
+}
44
+
45
+func (App_Role_byli) TableName() string {
46
+	return "sgj_users.sgj_user_admin_role"
47
+}

+ 21 - 0
service/secondary_service.go Dosyayı Görüntüle

@@ -301,6 +301,10 @@ func Byliinit() (err error) {
301 301
 	if err != nil && err.Error() != "record not found" {
302 302
 		return
303 303
 	}
304
+	err = initxt_storehouse(tx)
305
+	if err != nil && err.Error() != "record not found" {
306
+		return
307
+	}
304 308
 	err = initxt_stock_flow(tx)
305 309
 	if err != nil && err.Error() != "record not found" {
306 310
 		return
@@ -418,6 +422,17 @@ func StoreReduceConfig(tx *gorm.DB) (err error) {
418 422
 	return
419 423
 }
420 424
 
425
+//初始化 xt_storehouse()把插入管理员的名字
426
+func initxt_storehouse(tx *gorm.DB) (err error) {
427
+	err = tx.Exec("UPDATE sgj_xt.xt_storehouse as t," +
428
+		"(SELECT o.id,o.creator,u.name from sgj_users.sgj_user_org as o,sgj_users.sgj_user_admin as u," +
429
+		"(SELECT DISTINCT org_id from sgj_xt.xt_gobal_template)as t " +
430
+		"WHERE o.creator = u.id AND t.org_id = o.id )tmp " +
431
+		"SET t.storehouse_admin_id = tmp.creator,t.storehouse_admin_name = tmp.name,t.mtime = UNIX_TIMESTAMP()" +
432
+		"WHERE t.status = 1 and t.user_org_id = tmp.id").Error
433
+	return
434
+}
435
+
421 436
 //初始化 xt_stock_flow(完成)
422 437
 func initxt_stock_flow(tx *gorm.DB) (err error) {
423 438
 	err = tx.Exec("UPDATE sgj_xt.xt_stock_flow as t," +
@@ -670,3 +685,9 @@ func initxt_supplier_warehousing_cancel_order(tx *gorm.DB) (err error) {
670 685
 		"WHERE (t.storehouse_id = 0 or t.storehouse_id is null) and t.user_org_id = tmp.orgid").Error
671 686
 	return
672 687
 }
688
+
689
+//查询机构下的所有用户名
690
+func GetuserName(orgid int64) (username []models.App_Role_byli, err error) {
691
+	err = XTReadDB().Select("id,org_id,user_name").Where("org_id = ?", orgid).Find(&username).Error
692
+	return
693
+}