From 3664ae4c3ed18ebc49a1f7e34c3c2228136e90d3 Mon Sep 17 00:00:00 2001 From: jiangyong27 Date: Sat, 29 Mar 2025 17:34:55 +0800 Subject: [PATCH] usrrole2 --- server/controller/salary.go | 10 +++++----- server/controller/staff.go | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/server/controller/salary.go b/server/controller/salary.go index 720ebed..f624656 100644 --- a/server/controller/salary.go +++ b/server/controller/salary.go @@ -19,7 +19,7 @@ func NewSalary() *Salary { func (s *Salary) List(ctx *gin.Context) { sess := ctx.Keys[session.ContextSession].(*session.AdminSession) - if sess.GetAdmin().GetConfig().IsFinance() { + if !sess.GetAdmin().GetConfig().IsFinance() { panic(config.ErrPriv.New()) } var req api.ListSalaryReq @@ -30,7 +30,7 @@ func (s *Salary) List(ctx *gin.Context) { func (s *Salary) Create(ctx *gin.Context) { sess := ctx.Keys[session.ContextSession].(*session.AdminSession) - if sess.GetAdmin().GetConfig().IsFinance() { + if !sess.GetAdmin().GetConfig().IsFinance() { panic(config.ErrPriv.New()) } var req api.CreateSalaryReq @@ -42,7 +42,7 @@ func (s *Salary) Create(ctx *gin.Context) { func (s *Salary) Update(ctx *gin.Context) { sess := ctx.Keys[session.ContextSession].(*session.AdminSession) - if sess.GetAdmin().GetConfig().IsFinance() { + if !sess.GetAdmin().GetConfig().IsFinance() { panic(config.ErrPriv.New()) } var req api.UpdateSalaryReq @@ -54,7 +54,7 @@ func (s *Salary) Update(ctx *gin.Context) { func (s *Salary) Pay(ctx *gin.Context) { sess := ctx.Keys[session.ContextSession].(*session.AdminSession) - if sess.GetAdmin().GetConfig().IsFinance() { + if !sess.GetAdmin().GetConfig().IsFinance() { panic(config.ErrPriv.New()) } var req api.PaySalaryReq @@ -66,7 +66,7 @@ func (s *Salary) Pay(ctx *gin.Context) { func (s *Salary) Delete(ctx *gin.Context) { sess := ctx.Keys[session.ContextSession].(*session.AdminSession) - if sess.GetAdmin().GetConfig().IsFinance() { + if !sess.GetAdmin().GetConfig().IsFinance() { panic(config.ErrPriv.New()) } id := cast.ToInt64(ctx.Query("id")) diff --git a/server/controller/staff.go b/server/controller/staff.go index 8d89b27..6f38d2f 100644 --- a/server/controller/staff.go +++ b/server/controller/staff.go @@ -54,7 +54,7 @@ func (s *Staff) List(ctx *gin.Context) { func (s *Staff) Create(ctx *gin.Context) { sess := ctx.Keys[session.ContextSession].(*session.AdminSession) - if sess.GetAdmin().GetConfig().IsHr() { + if !sess.GetAdmin().GetConfig().IsHr() { panic(config.ErrPriv.New()) } @@ -67,7 +67,7 @@ func (s *Staff) Create(ctx *gin.Context) { func (s *Staff) Update(ctx *gin.Context) { sess := ctx.Keys[session.ContextSession].(*session.AdminSession) - if sess.GetAdmin().GetConfig().IsHr() { + if !sess.GetAdmin().GetConfig().IsHr() { panic(config.ErrPriv.New()) } var req api.StaffUpdateReq @@ -80,7 +80,7 @@ func (s *Staff) Update(ctx *gin.Context) { func (s *Staff) Delete(ctx *gin.Context) { sess := ctx.Keys[session.ContextSession].(*session.AdminSession) - if sess.GetAdmin().GetConfig().IsHr() { + if !sess.GetAdmin().GetConfig().IsHr() { panic(config.ErrPriv.New()) } @@ -91,7 +91,7 @@ func (s *Staff) Delete(ctx *gin.Context) { func (s *Staff) Pay(ctx *gin.Context) { sess := ctx.Keys[session.ContextSession].(*session.AdminSession) - if sess.GetAdmin().GetConfig().IsFinance() { + if !sess.GetAdmin().GetConfig().IsFinance() { panic(config.ErrPriv.New()) } var req api.StaffPayReq