This commit is contained in:
parent
6b22c2472f
commit
fa2596ccd4
|
@ -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() {
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue