This commit is contained in:
jiangyong27 2025-04-08 15:28:11 +08:00
parent 6b22c2472f
commit fa2596ccd4
3 changed files with 34 additions and 0 deletions

View File

@ -53,6 +53,13 @@ func (s *Salary) Update(ctx *gin.Context) {
ctx.JSON(http.StatusOK, session.NewRspOk())
}
func (s *Salary) Upload(ctx *gin.Context) {
rsp := service.NewStaffSalary().Upload(ctx)
ctx.Keys[session.ContextResponse] = rsp
ctx.JSON(http.StatusOK, session.NewRsp(rsp))
}
func (s *Salary) Pay(ctx *gin.Context) {
sess := ctx.Keys[session.ContextSession].(*session.AdminSession)
if !sess.GetAdmin().GetConfig().IsAdmin() {

View File

@ -37,6 +37,7 @@ func initRoutge(engine *gin.Engine) {
apiGroup.POST("/staff/salary/pay", controller.NewSalary().Pay)
apiGroup.POST("/salary/pay", controller.NewSalary().Pay)
apiGroup.PUT("/staff/salary", controller.NewSalary().Update)
apiGroup.POST("/staff/salary/upload", controller.NewSalary().Upload)
apiGroup.DELETE("/staff/salary", controller.NewSalary().Delete)
noTokenGroup.GET("/staff/salary/bill", controller.NewSalary().Bill)

View File

@ -33,6 +33,32 @@ func NewStaffSalary() *StaffSalary {
return &StaffSalary{}
}
func (s *StaffSalary) Upload(ctx *gin.Context) interface{} {
var err error
saveFile := "/tmp/"
fileName := ""
file, _ := ctx.FormFile("file")
if file == nil {
panic(config.ErrParam.New().Append("未获取到文件信息"))
}
// 保存本地临时文件
fileName = time.Now().Format("20060102150405")
saveFile = "/tmp/" + fileName
err = ctx.SaveUploadedFile(file, saveFile)
if err != nil {
panic(config.ErrInternal.New().Append(err))
}
defer os.Remove(saveFile)
data := make(map[string]interface{})
data["count"] = 10
data["amount"] = "12.34"
return data
}
func (s *StaffSalary) List(sess *session.AdminSession, req *api.ListSalaryReq) (int64, interface{}, interface{}) {
if !sess.GetAdmin().GetConfig().IsFinance() {
return 0, nil, nil