作者 陈志颖

fix:修复导出素币兑换清单

... ... @@ -6,6 +6,7 @@
# Folders
_obj
_test
public/file
# Architecture specific extensions/prefixes
*.[568vq]
... ... @@ -22,4 +23,5 @@ _testmain.go
*.exe
*.test
.log
.idea
\ No newline at end of file
.idea
... ...
... ... @@ -37,7 +37,7 @@ func main() {
}()
// excel文件路径映射
beego.SetStaticPath("/public", "public")
beego.SetStaticPath("/download", "download")
beego.Run()
}
... ...
... ... @@ -9,6 +9,7 @@ import (
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/command"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/query"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/service"
"os"
"path"
"strconv"
)
... ... @@ -341,7 +342,6 @@ func (controller *SuMoneyController) ImportExchangeList () {
return
}
// TODO 增加导入失败原因返回
var response utils.JsonResponse
dataList := make([]interface{}, 0)
rows, _ := xlsx.GetRows("Sheet1")
... ... @@ -354,7 +354,7 @@ func (controller *SuMoneyController) ImportExchangeList () {
for _, _ = range row {
createExchangeCashPersonCommand.ExchangeCashActivityId = activityId
// TODO 非空校验
if createExchangeCashPersonCommand.PersonName == "" || createExchangeCashPersonCommand.PersonAccount == "" || createExchangeCashPersonCommand.ExchangedSuMoney == 0{
if row[0] == "" || createExchangeCashPersonCommand.PersonAccount == "" || createExchangeCashPersonCommand.ExchangedSuMoney == 0{
controller.Ctx.WriteString( "空字段" )
return
}
... ... @@ -363,7 +363,6 @@ func (controller *SuMoneyController) ImportExchangeList () {
createExchangeCashPersonCommand.PersonAccount = row[1]
createExchangeCashPersonCommand.ExchangedSuMoney, _ = strconv.ParseFloat(row[2], 64)
}
data, err := cashPoolService.CreateExchangeCashPerson(createExchangeCashPersonCommand)
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
... ... @@ -458,12 +457,26 @@ func (controller *SuMoneyController) ExportExchangeList() {
}
}
f.SetActiveSheet(index)
// 创建下载文件夹
mkErr :=os.Mkdir("download", os.ModePerm)
if err!=nil{
fmt.Println(mkErr)
}
//保存为文件
f.Path="public/file/素币兑换清单.xlsx"
f.Path="download/素币兑换清单.xlsx"
if err := f.Save(); err != nil {
fmt.Println(err)
}
controller.Ctx.Output.Download(f.Path,"素币兑换清单.xlsx")
// 下载完成删除文件
removeErr := os.Remove(f.Path)
if err != nil {
fmt.Println(removeErr)
}
}
}
... ...
#mmm-worth 1
\ No newline at end of file
不能预览此文件类型