DengBiao преди 1 година
родител
ревизия
4dd35067da
променени са 6 файла, в които са добавени 110 реда и са изтрити 3 реда
  1. +14
    -0
      app/admin/hdl/hdl_role.go
  2. +1
    -1
      app/customer/svc/svc_curl_smart_pay.go
  3. +10
    -2
      app/db/db_admin.go
  4. +10
    -0
      app/db/db_admin_role_permission_group.go
  5. +68
    -0
      app/db/db_admin_with_enterprise.go
  6. +7
    -0
      app/db/model/admin_with_enterprise.go

+ 14
- 0
app/admin/hdl/hdl_role.go Целия файл

@@ -305,6 +305,20 @@ func AdminList(c *gin.Context) {
for _, v1 := range permissionGroupList {
roleList = append(roleList, v1.Role.Name)
}

adminEnterpriseList, _, err1 := adminDb.FindAdminWithEnterprise(v.AdmId)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err1.Error())
return
}
var enterpriseList []map[string]interface{}
for _, v1 := range adminEnterpriseList {
enterpriseList = append(enterpriseList, map[string]interface{}{
"name": v1.Enterprise.Name,
"id": v1.Enterprise.Id,
})
}

result = append(result, md.AdminListResp{
AdmId: v.AdmId,
Username: v.Username,


+ 1
- 1
app/customer/svc/svc_curl_smart_pay.go Целия файл

@@ -293,7 +293,7 @@ func CurlEducateSceneTokenQuery(args md.CurlEducateSceneTokenReq, userIdentity *
info.SchoolFacePaymentStatus = res["school_face_payment_status"]
info.ConcentrateSchoolFacePassStatus = concentrateSchoolFacePassStatus
info.UpdateAt = now
_, err2 := selfSupportForUserFaceInfoDb.SelfSupportForUserFaceInfoUpdate(info, "parent_user_id", "parent_logon_id", "user_id", "school_face_pass_status", "school_face_payment_status", "update_at")
_, err2 := selfSupportForUserFaceInfoDb.SelfSupportForUserFaceInfoUpdate(info, "parent_user_id", "parent_logon_id", "user_id", "school_face_pass_status", "school_face_payment_status", "concentrate_school_face_pass_status", "update_at")
if err2 != nil {
return err2, nil
}


+ 10
- 2
app/db/db_admin.go Целия файл

@@ -76,8 +76,16 @@ func (adminDb *AdminDb) FindAdminRolePermissionGroup(admId int) (list []*AdminRo
total, err = adminDb.Db.Where("admin.adm_id =?", admId).
Join("LEFT", "admin_role", "admin.adm_id = admin_role.adm_id").
Join("LEFT", "role", "admin_role.role_id = role.id").
Join("LEFT", "role_permission_group", "role.id = role_permission_group.role_id").
Join("LEFT", "permission_group", "role_permission_group.group_id = permission_group.id").
//Join("LEFT", "role_permission_group", "role.id = role_permission_group.role_id").
//Join("LEFT", "permission_group", "role_permission_group.group_id = permission_group.id").
FindAndCount(&list)
return
}

func (adminDb *AdminDb) FindAdminWithEnterprise(admId int) (list []*AdminEnterprise, total int64, err error) {
total, err = adminDb.Db.Where("admin.adm_id =?", admId).
Join("LEFT", "admin_with_enterprise", "admin.adm_id = admin_with_enterprise.adm_id").
Join("LEFT", "enterprise", "admin_with_enterprise.enterprise_id = enterprise.id").
FindAndCount(&list)
return
}


+ 10
- 0
app/db/db_admin_role_permission_group.go Целия файл

@@ -15,3 +15,13 @@ type AdminRolePermissionGroup struct {
func (AdminRolePermissionGroup) TableName() string {
return "admin"
}

type AdminEnterprise struct {
model2.Admin `xorm:"extends"`
model2.AdminWithEnterprise `xorm:"extends"`
model2.Enterprise `xorm:"extends"`
}

func (AdminEnterprise) TableName() string {
return "admin"
}

+ 68
- 0
app/db/db_admin_with_enterprise.go Целия файл

@@ -0,0 +1,68 @@
package db

import (
"applet/app/db/model"
"applet/app/utils/logx"
"reflect"
"xorm.io/xorm"
)

type AdminWithEnterpriseDb struct {
Db *xorm.Engine `json:"db"`
}

func (adminWithEnterpriseDb *AdminWithEnterpriseDb) Set() { // set方法
adminWithEnterpriseDb.Db = Db
}

func (adminWithEnterpriseDb *AdminWithEnterpriseDb) FindAdminRole(id int) (*[]model.AdminRole, error) {
var m []model.AdminRole
if err := adminWithEnterpriseDb.Db.Where("adm_id =?", id).Find(&m); err != nil {
return nil, logx.Error(err)
}
return &m, nil
}

func (adminWithEnterpriseDb *AdminWithEnterpriseDb) AdminDeleteBySessionForAdmId(session *xorm.Session, admId interface{}) (int64, error) {
if reflect.TypeOf(admId).Kind() == reflect.Slice {
return session.In("adm_id", admId).Delete(model.AdminRole{})
} else {
return session.Where("adm_id = ?", admId).Delete(model.AdminRole{})
}
}

func (adminWithEnterpriseDb *AdminWithEnterpriseDb) GetAdminRoleByRole(id int) (m *model.AdminRole, err error) {
m = new(model.AdminRole)
has, err := adminWithEnterpriseDb.Db.Where("role_id =?", id).Get(m)
if err != nil {
return nil, logx.Error(err)
}
if has == false {
return nil, nil
}
return m, nil
}

func (adminWithEnterpriseDb *AdminWithEnterpriseDb) AdminRoleDeleteForRoleBySession(session *xorm.Session, roleId interface{}) (int64, error) {
if reflect.TypeOf(roleId).Kind() == reflect.Slice {
return session.In("role_id", roleId).Delete(model.AdminRole{})
} else {
return session.Where("role_id = ?", roleId).Delete(model.AdminRole{})
}
}

func (adminWithEnterpriseDb *AdminWithEnterpriseDb) AdminRoleDeleteBySession(session *xorm.Session, id interface{}) (int64, error) {
if reflect.TypeOf(id).Kind() == reflect.Slice {
return session.In("id", id).Delete(model.AdminRole{})
} else {
return session.Where("adm_id = ?", id).Delete(model.AdminRole{})
}
}

func (adminWithEnterpriseDb *AdminWithEnterpriseDb) BatchAddAdminRoleBySession(session *xorm.Session, mm []*model.AdminRole) (int64, error) {
affected, err := session.Insert(mm)
if err != nil {
return 0, err
}
return affected, nil
}

+ 7
- 0
app/db/model/admin_with_enterprise.go Целия файл

@@ -0,0 +1,7 @@
package model

type AdminWithEnterprise struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
AdmId int `json:"adm_id" xorm:"not null default 0 comment('管理员id') INT(11)"`
EnterpriseId int `json:"enterprise_id" xorm:"not null default 0 comment('校企id') INT(11)"`
}

Зареждане…
Отказ
Запис