@@ -17,3 +17,21 @@ func (gt AdminState) String() string { | |||||
return "未知" | return "未知" | ||||
} | } | ||||
} | } | ||||
type IsSuperAdministrator int32 | |||||
const ( | |||||
IsSuperAdministratorTure = 1 | |||||
IsSuperAdministratorFalse = 2 | |||||
) | |||||
func (gt IsSuperAdministrator) String() string { | |||||
switch gt { | |||||
case IsSuperAdministratorTure: | |||||
return "超管" | |||||
case IsSuperAdministratorFalse: | |||||
return "非超管" | |||||
default: | |||||
return "未知" | |||||
} | |||||
} |
@@ -0,0 +1,89 @@ | |||||
package hdl | |||||
import ( | |||||
"applet/app/admin/enum" | |||||
"applet/app/admin/md" | |||||
"applet/app/admin/svc" | |||||
"applet/app/db" | |||||
"applet/app/e" | |||||
"applet/app/utils" | |||||
"github.com/gin-gonic/gin" | |||||
) | |||||
func MenuList(c *gin.Context) { | |||||
admin := svc.GetUser(c) | |||||
qrcodeWithBatchRecordsDb := db.PermissionGroupDb{} | |||||
qrcodeWithBatchRecordsDb.Set() | |||||
groupList, err := qrcodeWithBatchRecordsDb.FindPermissionGroup() | |||||
if err != nil { | |||||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||||
return | |||||
} | |||||
//1、查询出当前用户所有角色 | |||||
adminRoleDb := db.AdminRoleDb{} | |||||
adminRoleDb.Set() | |||||
roles, err := adminRoleDb.FindAdminRole(admin.AdmId) | |||||
if err != nil { | |||||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||||
return | |||||
} | |||||
roleDb := db.RoleDb{} | |||||
roleDb.Set(0) | |||||
var adminHasPermissionGroupIds []string | |||||
for _, v := range *roles { | |||||
list, _, err := roleDb.FindPermissionGroupByRole(v.RoleId) | |||||
if err != nil { | |||||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||||
return | |||||
} | |||||
for _, v1 := range list { | |||||
adminHasPermissionGroupIds = append(adminHasPermissionGroupIds, utils.IntToStr(v1.PermissionGroup.Id)) | |||||
} | |||||
} | |||||
var tempRespMap = map[string]*md.PermissionGroupListResp{} | |||||
var tempRespMapKeys []string | |||||
for _, v := range *groupList { | |||||
isCheck := false | |||||
if utils.InArr(utils.IntToStr(v.Id), adminHasPermissionGroupIds) { | |||||
isCheck = true | |||||
} | |||||
tempRespMap[utils.IntToStr(v.Id)] = &md.PermissionGroupListResp{ | |||||
Id: v.Id, | |||||
Name: v.Name, | |||||
State: v.State, | |||||
ParentId: v.ParentId, | |||||
CreateAt: v.CreateAt.Format("2006-01-02 15:04:05"), | |||||
UpdateAt: v.UpdateAt.Format("2006-01-02 15:04:05"), | |||||
IsCheck: isCheck, | |||||
} | |||||
tempRespMapKeys = append(tempRespMapKeys, utils.IntToStr(v.Id)) | |||||
} | |||||
for _, v := range tempRespMap { | |||||
if v.ParentId != 0 { | |||||
tempRespMap[utils.IntToStr(v.ParentId)].SubPermissionGroupList = append(tempRespMap[utils.IntToStr(v.ParentId)].SubPermissionGroupList, *v) | |||||
} | |||||
} | |||||
var resp []md.PermissionGroupListResp | |||||
for _, v := range tempRespMapKeys { | |||||
resp = append(resp, *tempRespMap[v]) | |||||
} | |||||
e.OutSuc(c, map[string]interface{}{ | |||||
"list": resp, | |||||
"state": []map[string]interface{}{ | |||||
{ | |||||
"name": enum.PermissionGroupState(enum.PermissionGroupStateForNormal).String(), | |||||
"value": enum.PermissionGroupStateForNormal, | |||||
}, | |||||
{ | |||||
"name": enum.PermissionGroupState(enum.PermissionGroupStateForDiscard).String(), | |||||
"value": enum.PermissionGroupStateForDiscard, | |||||
}, | |||||
}, | |||||
}, nil) | |||||
return | |||||
} |
@@ -94,15 +94,15 @@ func RoleList(c *gin.Context) { | |||||
for _, v := range *roleList { | for _, v := range *roleList { | ||||
var temp md.RoleListResp | var temp md.RoleListResp | ||||
temp.Data = v | temp.Data = v | ||||
adminRole, err := adminRoleDb.GetAdminRoleByRole(v.Id) | |||||
if err != nil { | |||||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||||
adminRole, err1 := adminRoleDb.GetAdminRoleByRole(v.Id) | |||||
if err1 != nil { | |||||
e.OutErr(c, e.ERR_DB_ORM, err1.Error()) | |||||
return | return | ||||
} | } | ||||
if adminRole != nil { | if adminRole != nil { | ||||
admin, err := adminDb.GetAdmin(adminRole.AdmId) | |||||
if err != nil { | |||||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||||
admin, err2 := adminDb.GetAdmin(adminRole.AdmId) | |||||
if err2 != nil { | |||||
e.OutErr(c, e.ERR_DB_ORM, err2.Error()) | |||||
return | return | ||||
} | } | ||||
temp.AdminList = append(temp.AdminList, struct { | temp.AdminList = append(temp.AdminList, struct { | ||||
@@ -1,6 +1,7 @@ | |||||
package mw | package mw | ||||
import ( | import ( | ||||
"applet/app/admin/enum" | |||||
"applet/app/admin/md" | "applet/app/admin/md" | ||||
"applet/app/admin/svc" | "applet/app/admin/svc" | ||||
"applet/app/e" | "applet/app/e" | ||||
@@ -12,6 +13,11 @@ import ( | |||||
// CheckPermission 检查权限 | // CheckPermission 检查权限 | ||||
func CheckPermission(c *gin.Context) { | func CheckPermission(c *gin.Context) { | ||||
admin := svc.GetUser(c) | admin := svc.GetUser(c) | ||||
//TODO::判断是否为超管 | |||||
if admin.IsSuperAdministrator == enum.IsSuperAdministratorTure { | |||||
c.Next() | |||||
} | |||||
rolePermissionKey := fmt.Sprintf(md.AdminRolePermissionKey, utils.GetIP(c.Request), utils.AnyToString(admin.AdmId)) | rolePermissionKey := fmt.Sprintf(md.AdminRolePermissionKey, utils.GetIP(c.Request), utils.AnyToString(admin.AdmId)) | ||||
isHasPermission, err := svc.CheckUserRole(rolePermissionKey, c.Request.RequestURI, admin.AdmId) | isHasPermission, err := svc.CheckUserRole(rolePermissionKey, c.Request.RequestURI, admin.AdmId) | ||||
if err != nil { | if err != nil { | ||||
@@ -55,8 +55,8 @@ func CentralKitchenForSchoolUserUpdate(req md.CentralKitchenForSchoolUserUpdateR | |||||
Identity: enum2.UserIdentityForCentralKitchenForTeacher, | Identity: enum2.UserIdentityForCentralKitchenForTeacher, | ||||
EnterpriseId: req.EnterpriseId, | EnterpriseId: req.EnterpriseId, | ||||
Memo: "", | Memo: "", | ||||
CreateAt: now, | |||||
UpdateAt: now, | |||||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||||
}) | }) | ||||
if err3 != nil { | if err3 != nil { | ||||
_ = session.Rollback() | _ = session.Rollback() | ||||
@@ -73,8 +73,8 @@ func CentralKitchenForSchoolUserUpdate(req md.CentralKitchenForSchoolUserUpdateR | |||||
Identity: enum2.UserIdentityForCentralKitchenForStudent, | Identity: enum2.UserIdentityForCentralKitchenForStudent, | ||||
EnterpriseId: req.EnterpriseId, | EnterpriseId: req.EnterpriseId, | ||||
Memo: "", | Memo: "", | ||||
CreateAt: now, | |||||
UpdateAt: now, | |||||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||||
}) | }) | ||||
if err1 != nil { | if err1 != nil { | ||||
_ = session.Rollback() | _ = session.Rollback() | ||||
@@ -84,8 +84,8 @@ func CentralKitchenForSchoolUserUpdate(req md.CentralKitchenForSchoolUserUpdateR | |||||
_, err2 := classWithUserDb.ClassWithUserInsertBySession(session, &model.ClassWithUser{ | _, err2 := classWithUserDb.ClassWithUserInsertBySession(session, &model.ClassWithUser{ | ||||
UserIdentityId: insertId, | UserIdentityId: insertId, | ||||
ClassId: v.ClassId, | ClassId: v.ClassId, | ||||
CreateAt: now, | |||||
UpdateAt: now, | |||||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||||
}) | }) | ||||
if err2 != nil { | if err2 != nil { | ||||
_ = session.Rollback() | _ = session.Rollback() | ||||
@@ -269,8 +269,8 @@ func CentralKitchenForSchoolStudentUpdate(req md.CentralKitchenForSchoolStudentU | |||||
_, err = classWithUserDb.ClassWithUserInsertBySession(session, &model.ClassWithUser{ | _, err = classWithUserDb.ClassWithUserInsertBySession(session, &model.ClassWithUser{ | ||||
UserIdentityId: req.UserIdentityId, | UserIdentityId: req.UserIdentityId, | ||||
ClassId: req.ClassId, | ClassId: req.ClassId, | ||||
CreateAt: time.Time{}, | |||||
UpdateAt: time.Time{}, | |||||
CreateAt: time.Time{}.Format("2006-01-02 15:04:05"), | |||||
UpdateAt: time.Time{}.Format("2006-01-02 15:04:05"), | |||||
}) | }) | ||||
return session.Commit() | return session.Commit() | ||||
@@ -357,7 +357,7 @@ func CentralKitchenForSchoolOrdList(req md.CentralKitchenForSchoolOrdListReq) (r | |||||
} | } | ||||
} | } | ||||
sess := db.Db.Desc("central_kitchen_for_school_package_ord.id") | |||||
sess := db.Db.Desc("central_kitchen_for_school_package_ord.id") | |||||
if req.EnterpriseId != 0 { | if req.EnterpriseId != 0 { | ||||
sess.And("central_kitchen_for_school_package_ord.enterprise_id =?", req.EnterpriseId) | sess.And("central_kitchen_for_school_package_ord.enterprise_id =?", req.EnterpriseId) | ||||
} | } | ||||
@@ -13,6 +13,16 @@ func AddCentralKitchenForSchoolPackage(req md.SaveCentralKitchenForSchoolPackage | |||||
defer session.Close() | defer session.Close() | ||||
session.Begin() | session.Begin() | ||||
now := time.Now() | now := time.Now() | ||||
//TODO::判断当前月份是否存在 | |||||
centralKitchenForSchoolPackageDb := db.CentralKitchenForSchoolPackageDb{} | |||||
isHasPackage, err := centralKitchenForSchoolPackageDb.GetCentralKitchenForSchoolPackageByMonth(req.Year, req.Month) | |||||
if err != nil { | |||||
return err | |||||
} | |||||
if isHasPackage != nil { | |||||
return errors.New("请勿重复添加【" + req.Month + "】套餐") | |||||
} | |||||
//1、查询`central_kitchen_for_school_with_spec` | //1、查询`central_kitchen_for_school_with_spec` | ||||
centralKitchenForSchoolWithSpec := db.CentralKitchenForSchoolWithSpec{} | centralKitchenForSchoolWithSpec := db.CentralKitchenForSchoolWithSpec{} | ||||
centralKitchenForSchoolWithSpec.Set(req.EnterpriseId) | centralKitchenForSchoolWithSpec.Set(req.EnterpriseId) | ||||
@@ -22,7 +32,6 @@ func AddCentralKitchenForSchoolPackage(req md.SaveCentralKitchenForSchoolPackage | |||||
return err | return err | ||||
} | } | ||||
//1、新增`central_kitchen_for_school_package` | //1、新增`central_kitchen_for_school_package` | ||||
centralKitchenForSchoolPackageDb := db.CentralKitchenForSchoolPackageDb{} | |||||
packageId, err := centralKitchenForSchoolPackageDb.CentralKitchenForSchoolPackageInsertBySession(session, &model.CentralKitchenForSchoolPackage{ | packageId, err := centralKitchenForSchoolPackageDb.CentralKitchenForSchoolPackageInsertBySession(session, &model.CentralKitchenForSchoolPackage{ | ||||
EnterpriseId: req.EnterpriseId, | EnterpriseId: req.EnterpriseId, | ||||
Year: req.Year, | Year: req.Year, | ||||
@@ -4,6 +4,7 @@ import ( | |||||
"applet/app/admin/md" | "applet/app/admin/md" | ||||
"applet/app/db" | "applet/app/db" | ||||
"applet/app/db/model" | "applet/app/db/model" | ||||
md2 "applet/app/md" | |||||
"applet/app/utils" | "applet/app/utils" | ||||
"applet/app/utils/cache" | "applet/app/utils/cache" | ||||
"encoding/json" | "encoding/json" | ||||
@@ -19,6 +20,13 @@ func CheckUserRole(cacheKey, uri string, admId int) (isHasPermission bool, err e | |||||
var rolePermission []string | var rolePermission []string | ||||
var rolePermissionString string | var rolePermissionString string | ||||
rolePermissionString, _ = cache.GetString(cacheKey) | rolePermissionString, _ = cache.GetString(cacheKey) | ||||
//TODO::判断是否在白名单中 | |||||
if utils.InArr(uri, md2.WhiteUri) { | |||||
isHasPermission = true | |||||
return | |||||
} | |||||
//if rolePermissionString != "" { | //if rolePermissionString != "" { | ||||
if false { | if false { | ||||
if err = json.Unmarshal([]byte(rolePermissionString), &rolePermission); err != nil { | if err = json.Unmarshal([]byte(rolePermissionString), &rolePermission); err != nil { | ||||
@@ -37,50 +37,92 @@ func SaveCentralKitchenForSchoolUserIdentity(c *gin.Context) { | |||||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | e.OutErr(c, e.ERR_DB_ORM, err.Error()) | ||||
return | return | ||||
} | } | ||||
if isHasUserIdentity != nil && isHasUserIdentity.Uid != 0 && isHasUserIdentity.Uid != user.Id { | |||||
e.OutErr(c, e.ERR, "当前身份信息已被绑定使用") | |||||
return | |||||
} | |||||
//2、新增身份信息 | |||||
now := time.Time{} | now := time.Time{} | ||||
userIdentity := &model.UserIdentity{ | |||||
Uid: user.Id, | |||||
Name: req.Name, | |||||
IdNo: req.IdNo, | |||||
Kind: enum.UserIdentityKindForCommon, | |||||
Identity: identity, | |||||
EnterpriseId: req.EnterpriseId, | |||||
State: enum.UserIdentityStateForNormal, | |||||
Memo: "", | |||||
CreateAt: now, | |||||
UpdateAt: now, | |||||
} | |||||
insertAffected, err := userIdentityDb.UserIdentityInsert(userIdentity) | |||||
if err != nil { | |||||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||||
return | |||||
} | |||||
if insertAffected <= 0 { | |||||
e.OutErr(c, e.ERR_DB_ORM, "新增身份数据失败") | |||||
return | |||||
} | |||||
if isHasUserIdentity == nil { | |||||
//2、新增身份信息 | |||||
userIdentity := &model.UserIdentity{ | |||||
Uid: user.Id, | |||||
Name: req.Name, | |||||
IdNo: req.IdNo, | |||||
Kind: enum.UserIdentityKindForCommon, | |||||
Identity: identity, | |||||
EnterpriseId: req.EnterpriseId, | |||||
State: enum.UserIdentityStateForNormal, | |||||
Memo: "", | |||||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||||
} | |||||
insertAffected, err := userIdentityDb.UserIdentityInsert(userIdentity) | |||||
if err != nil { | |||||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||||
return | |||||
} | |||||
if insertAffected <= 0 { | |||||
e.OutErr(c, e.ERR_DB_ORM, "新增身份数据失败") | |||||
return | |||||
} | |||||
//3、新增 class_with_user 记录 | |||||
if !req.IsTeacher { | |||||
classWithUserDb := db.ClassWithUserDb{} | |||||
classWithUserDb.Set() | |||||
_, err = classWithUserDb.ClassWithUserInsert(&model.ClassWithUser{ | |||||
UserIdentityId: insertAffected, | |||||
ClassId: req.ClassId, | |||||
CreateAt: now, | |||||
UpdateAt: now, | |||||
}) | |||||
//3、新增 class_with_user 记录 | |||||
if !req.IsTeacher { | |||||
classWithUserDb := db.ClassWithUserDb{} | |||||
classWithUserDb.Set() | |||||
_, err = classWithUserDb.ClassWithUserInsert(&model.ClassWithUser{ | |||||
UserIdentityId: insertAffected, | |||||
ClassId: req.ClassId, | |||||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||||
}) | |||||
if err != nil { | |||||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||||
return | |||||
} | |||||
} | |||||
} else { | |||||
if isHasUserIdentity.Uid != user.Id { | |||||
e.OutErr(c, e.ERR, "当前身份信息已被绑定使用") | |||||
return | |||||
} | |||||
//4、修改身份信息 | |||||
isHasUserIdentity.Uid = user.Id | |||||
isHasUserIdentity.Name = req.Name | |||||
_, err = userIdentityDb.UserIdentityUpdate(isHasUserIdentity.Id, isHasUserIdentity, "uid", "name") | |||||
if err != nil { | if err != nil { | ||||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | e.OutErr(c, e.ERR_DB_ORM, err.Error()) | ||||
return | return | ||||
} | } | ||||
//5、修改 class_with_user 记录 | |||||
if !req.IsTeacher { | |||||
classWithUserDb := db.ClassWithUserDb{} | |||||
classWithUserDb.Set() | |||||
classWithUser, err1 := classWithUserDb.GetClassWithUserByUserIdentityId(isHasUserIdentity.Id) | |||||
if err1 != nil { | |||||
e.OutErr(c, e.ERR_DB_ORM, err1.Error()) | |||||
return | |||||
} | |||||
if classWithUser == nil { | |||||
_, err2 := classWithUserDb.ClassWithUserInsert(&model.ClassWithUser{ | |||||
UserIdentityId: isHasUserIdentity.Id, | |||||
ClassId: req.ClassId, | |||||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||||
}) | |||||
if err2 != nil { | |||||
e.OutErr(c, e.ERR_DB_ORM, err2.Error()) | |||||
return | |||||
} | |||||
} else { | |||||
classWithUser.ClassId = req.ClassId | |||||
_, err2 := classWithUserDb.ClassWithUserUpdateByUserIdentity(isHasUserIdentity.Id, classWithUser, "class_id") | |||||
if err2 != nil { | |||||
e.OutErr(c, e.ERR_DB_ORM, err2.Error()) | |||||
return | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
e.OutSuc(c, "success", nil) | e.OutSuc(c, "success", nil) | ||||
return | return | ||||
} | } | ||||
@@ -131,8 +173,8 @@ func SaveSelfSupportForSchoolUserIdentity(c *gin.Context) { | |||||
EnterpriseId: req.EnterpriseId, | EnterpriseId: req.EnterpriseId, | ||||
State: enum.UserIdentityStateForNormal, | State: enum.UserIdentityStateForNormal, | ||||
Memo: "", | Memo: "", | ||||
CreateAt: now, | |||||
UpdateAt: now, | |||||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||||
} | } | ||||
insertAffected, err := userIdentityDb.UserIdentityInsert(userIdentity) | insertAffected, err := userIdentityDb.UserIdentityInsert(userIdentity) | ||||
if err != nil { | if err != nil { | ||||
@@ -150,8 +192,8 @@ func SaveSelfSupportForSchoolUserIdentity(c *gin.Context) { | |||||
_, err = classWithUserDb.ClassWithUserInsert(&model.ClassWithUser{ | _, err = classWithUserDb.ClassWithUserInsert(&model.ClassWithUser{ | ||||
UserIdentityId: insertAffected, | UserIdentityId: insertAffected, | ||||
ClassId: req.ClassId, | ClassId: req.ClassId, | ||||
CreateAt: now, | |||||
UpdateAt: now, | |||||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||||
}) | }) | ||||
if err != nil { | if err != nil { | ||||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | e.OutErr(c, e.ERR_DB_ORM, err.Error()) | ||||
@@ -185,8 +227,8 @@ func SaveSelfSupportForSchoolUserIdentity(c *gin.Context) { | |||||
_, err2 := classWithUserDb.ClassWithUserInsert(&model.ClassWithUser{ | _, err2 := classWithUserDb.ClassWithUserInsert(&model.ClassWithUser{ | ||||
UserIdentityId: isHasUserIdentity.Id, | UserIdentityId: isHasUserIdentity.Id, | ||||
ClassId: req.ClassId, | ClassId: req.ClassId, | ||||
CreateAt: now, | |||||
UpdateAt: now, | |||||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||||
}) | }) | ||||
if err2 != nil { | if err2 != nil { | ||||
e.OutErr(c, e.ERR_DB_ORM, err2.Error()) | e.OutErr(c, e.ERR_DB_ORM, err2.Error()) | ||||
@@ -13,9 +13,7 @@ import ( | |||||
func OrderList(req md.CentralKitchenForSchoolOrderListReq) (m []model.CentralKitchenForSchoolPackageOrd, total int64, err error) { | func OrderList(req md.CentralKitchenForSchoolOrderListReq) (m []model.CentralKitchenForSchoolPackageOrd, total int64, err error) { | ||||
sess := db.Db.Desc("id").Where("user_identity_id =?", req.UserIdentityId).Limit(req.Limit, (req.Page-1)*req.Limit) | sess := db.Db.Desc("id").Where("user_identity_id =?", req.UserIdentityId).Limit(req.Limit, (req.Page-1)*req.Limit) | ||||
if req.OrdState != 0 { | |||||
sess.And("ord_state = ?", req.OrdState) | |||||
} | |||||
sess.And("ord_state = ?", req.OrdState) | |||||
total, err = sess.FindAndCount(&m) | total, err = sess.FindAndCount(&m) | ||||
if err != nil { | if err != nil { | ||||
return | return | ||||
@@ -15,16 +15,12 @@ func (adminRoleDb *AdminRoleDb) Set() { // set方法 | |||||
adminRoleDb.Db = Db | adminRoleDb.Db = Db | ||||
} | } | ||||
func (adminRoleDb *AdminRoleDb) GetAdminRole(id int) (m *model.AdminRole, err error) { | |||||
m = new(model.AdminRole) | |||||
has, err := adminRoleDb.Db.Where("adm_id =?", id).Get(m) | |||||
if err != nil { | |||||
func (adminRoleDb *AdminRoleDb) FindAdminRole(id int) (*[]model.AdminRole, error) { | |||||
var m []model.AdminRole | |||||
if err := adminRoleDb.Db.Where("adm_id =?", id).Find(&m); err != nil { | |||||
return nil, logx.Error(err) | return nil, logx.Error(err) | ||||
} | } | ||||
if has == false { | |||||
return nil, nil | |||||
} | |||||
return m, nil | |||||
return &m, nil | |||||
} | } | ||||
func (adminRoleDb *AdminRoleDb) AdminDeleteBySessionForAdmId(session *xorm.Session, admId interface{}) (int64, error) { | func (adminRoleDb *AdminRoleDb) AdminDeleteBySessionForAdmId(session *xorm.Session, admId interface{}) (int64, error) { | ||||
@@ -28,6 +28,18 @@ func (centralKitchenForSchoolPackageDb *CentralKitchenForSchoolPackageDb) GetCen | |||||
return m, nil | return m, nil | ||||
} | } | ||||
func (centralKitchenForSchoolPackageDb *CentralKitchenForSchoolPackageDb) GetCentralKitchenForSchoolPackageByMonth(year, month string) (m *model.CentralKitchenForSchoolPackage, err error) { | |||||
m = new(model.CentralKitchenForSchoolPackage) | |||||
has, err := centralKitchenForSchoolPackageDb.Db.Where("year =? and month =?", year, month).Get(m) | |||||
if err != nil { | |||||
return nil, logx.Error(err) | |||||
} | |||||
if has == false { | |||||
return nil, nil | |||||
} | |||||
return m, nil | |||||
} | |||||
func (centralKitchenForSchoolPackageDb *CentralKitchenForSchoolPackageDb) FindCentralKitchenForSchoolPackage() (*[]model.CentralKitchenForSchoolPackage, error) { | func (centralKitchenForSchoolPackageDb *CentralKitchenForSchoolPackageDb) FindCentralKitchenForSchoolPackage() (*[]model.CentralKitchenForSchoolPackage, error) { | ||||
var m []model.CentralKitchenForSchoolPackage | var m []model.CentralKitchenForSchoolPackage | ||||
if err := centralKitchenForSchoolPackageDb.Db.Desc("id").Find(&m); err != nil { | if err := centralKitchenForSchoolPackageDb.Db.Desc("id").Find(&m); err != nil { | ||||
@@ -16,7 +16,7 @@ func (permissionGroupDb *PermissionGroupDb) Set() { // set方法 | |||||
func (permissionGroupDb *PermissionGroupDb) FindPermissionGroup() (*[]model.PermissionGroup, error) { | func (permissionGroupDb *PermissionGroupDb) FindPermissionGroup() (*[]model.PermissionGroup, error) { | ||||
var m []model.PermissionGroup | var m []model.PermissionGroup | ||||
if err := permissionGroupDb.Db.Desc("id").Find(&m); err != nil { | |||||
if err := permissionGroupDb.Db.Asc("id").Find(&m); err != nil { | |||||
return nil, logx.Error(err) | return nil, logx.Error(err) | ||||
} | } | ||||
return &m, nil | return &m, nil | ||||
@@ -31,7 +31,7 @@ func (userIdentityDb *UserIdentityDb) GetUserIdentity(id int) (m *model.UserIden | |||||
func (userIdentityDb *UserIdentityDb) UserIdentityExist(enterpriseId int, idNo string) (m *model.UserIdentity, err error) { | func (userIdentityDb *UserIdentityDb) UserIdentityExist(enterpriseId int, idNo string) (m *model.UserIdentity, err error) { | ||||
m = new(model.UserIdentity) | m = new(model.UserIdentity) | ||||
has, err := userIdentityDb.Db.Where("enterprise_id =?", enterpriseId).And("id_no =?", idNo).Exist(m) | |||||
has, err := userIdentityDb.Db.Where("enterprise_id =?", enterpriseId).And("id_no =?", idNo).Get(m) | |||||
if err != nil { | if err != nil { | ||||
return nil, logx.Error(err) | return nil, logx.Error(err) | ||||
} | } | ||||
@@ -1,13 +1,9 @@ | |||||
package model | package model | ||||
import ( | |||||
"time" | |||||
) | |||||
type ClassWithUser struct { | type ClassWithUser struct { | ||||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||||
UserIdentityId int `json:"user_identity_id" xorm:"not null default 0 comment('用户身份id') INT(11)"` | |||||
ClassId int `json:"class_id" xorm:"not null default 0 INT(11)"` | |||||
CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||||
UpdateAt time.Time `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||||
UserIdentityId int `json:"user_identity_id" xorm:"not null default 0 comment('用户身份id') INT(11)"` | |||||
ClassId int `json:"class_id" xorm:"not null default 0 INT(11)"` | |||||
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||||
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||||
} | } |
@@ -1,19 +1,15 @@ | |||||
package model | package model | ||||
import ( | |||||
"time" | |||||
) | |||||
type UserIdentity struct { | type UserIdentity struct { | ||||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||||
Uid int `json:"uid" xorm:"not null default 0 comment('用户id') INT(11)"` | |||||
Name string `json:"name" xorm:"not null default '' comment('名称') VARCHAR(255)"` | |||||
IdNo string `json:"id_no" xorm:"not null default '' comment('身份证号码') VARCHAR(255)"` | |||||
Kind int `json:"kind" xorm:"not null default 1 comment('类型(1:普通用户 2:工作人员)') TINYINT(1)"` | |||||
Identity int `json:"identity" xorm:"not null default 1 comment('身份类型(1:央厨-学生 2:央厨-教职员工 3:央厨-工作人员 4:自营-学生 5:自营-教职员工 6:自营-工作人员)') TINYINT(1)"` | |||||
EnterpriseId int `json:"enterprise_id" xorm:"not null default 0 comment('所属单位id') INT(11)"` | |||||
State int `json:"state" xorm:"not null default 1 comment('状态(1:正常 2:冻结)') TINYINT(1)"` | |||||
Memo string `json:"memo" xorm:"not null default '' comment('备注信息') VARCHAR(244)"` | |||||
CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||||
UpdateAt time.Time `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||||
Uid int `json:"uid" xorm:"not null default 0 comment('用户id') INT(11)"` | |||||
Name string `json:"name" xorm:"not null default '' comment('名称') VARCHAR(255)"` | |||||
IdNo string `json:"id_no" xorm:"not null default '' comment('身份证号码') VARCHAR(255)"` | |||||
Kind int `json:"kind" xorm:"not null default 1 comment('类型(1:普通用户 2:工作人员)') TINYINT(1)"` | |||||
Identity int `json:"identity" xorm:"not null default 1 comment('身份类型(1:央厨-学生 2:央厨-教职员工 3:央厨-工作人员 4:自营-学生 5:自营-教职员工 6:自营-工作人员)') TINYINT(1)"` | |||||
EnterpriseId int `json:"enterprise_id" xorm:"not null default 0 comment('所属单位id') INT(11)"` | |||||
State int `json:"state" xorm:"not null default 1 comment('状态(1:正常 2:冻结)') TINYINT(1)"` | |||||
Memo string `json:"memo" xorm:"not null default '' comment('备注信息') VARCHAR(244)"` | |||||
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||||
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||||
} | } |
@@ -0,0 +1,5 @@ | |||||
package md | |||||
var WhiteUri = []string{ | |||||
"/api/admin/comm/getMenuList", | |||||
} |
@@ -62,6 +62,10 @@ func rBanner(r *gin.RouterGroup) { | |||||
r.DELETE("/delete/:id", hdl2.BannerDelete) | r.DELETE("/delete/:id", hdl2.BannerDelete) | ||||
} | } | ||||
func rComm(r *gin.RouterGroup) { | |||||
r.POST("/getMenuList", hdl2.MenuList) // 获取菜单栏列表 | |||||
} | |||||
func rOss(r *gin.RouterGroup) { | func rOss(r *gin.RouterGroup) { | ||||
r.POST("/upload/token", hdl2.ImgReqUpload) // 文件上传获取七牛云上传token | r.POST("/upload/token", hdl2.ImgReqUpload) // 文件上传获取七牛云上传token | ||||
} | } | ||||
@@ -164,6 +168,7 @@ func AdminRoute(r *gin.RouterGroup) { | |||||
r.Use(mw.CheckPermission) //检测权限 | r.Use(mw.CheckPermission) //检测权限 | ||||
rOss(r.Group("/oss")) | rOss(r.Group("/oss")) | ||||
rComm(r.Group("/comm")) | |||||
rCompany(r.Group("/company")) //公司管理 | rCompany(r.Group("/company")) //公司管理 | ||||
rNotice(r.Group("/notice")) //公告管理 | rNotice(r.Group("/notice")) //公告管理 | ||||
rBanner(r.Group("/banner")) //轮播图管理 | rBanner(r.Group("/banner")) //轮播图管理 | ||||