2025-03-06 17:45:28 +08:00
|
|
|
package controller
|
2025-03-12 23:57:24 +08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"enterprise/common/dao"
|
|
|
|
"enterprise/server/api"
|
|
|
|
"enterprise/server/service"
|
|
|
|
"enterprise/server/session"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/spf13/cast"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Salary struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewSalary() *Salary {
|
|
|
|
return &Salary{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Salary) List(ctx *gin.Context) {
|
|
|
|
var req api.ListSalaryReq
|
|
|
|
session.CheckParamError(ctx.ShouldBind(&req))
|
|
|
|
total, summary, items := service.NewStaffSalary().List(ctx.Keys[session.ContextSession].(*session.AdminSession), &req)
|
|
|
|
ctx.JSON(http.StatusOK, session.NewSummaryRsp(total, summary, items))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Salary) Create(ctx *gin.Context) {
|
|
|
|
var req api.CreateSalaryReq
|
|
|
|
session.CheckParamError(ctx.ShouldBind(&req))
|
|
|
|
service.NewStaffSalary().Create(ctx.Keys[session.ContextSession].(*session.AdminSession), &req)
|
|
|
|
ctx.JSON(http.StatusOK, session.NewRspOk())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Salary) Update(ctx *gin.Context) {
|
|
|
|
var req api.UpdateSalaryReq
|
|
|
|
session.CheckParamError(ctx.ShouldBind(&req))
|
|
|
|
service.NewStaffSalary().Update(ctx.Keys[session.ContextSession].(*session.AdminSession), &req)
|
|
|
|
ctx.JSON(http.StatusOK, session.NewRspOk())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Salary) Delete(ctx *gin.Context) {
|
|
|
|
id := cast.ToInt64(ctx.Query("id"))
|
|
|
|
dao.NewStaffSalaryDao().Delete(id)
|
|
|
|
ctx.JSON(http.StatusOK, session.NewRspOk())
|
|
|
|
}
|