作者 陈志颖

feat:修改导入兑换清单功能,增加用户uid

... ... @@ -10,6 +10,7 @@ import (
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/query"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/service"
"path"
"strconv"
)
type SuMoneyController struct {
... ... @@ -200,22 +201,16 @@ func (controller *SuMoneyController) ListExchangeActivities () {
func (controller *SuMoneyController) UpdateExchangeActivities () {
cashPoolService := service.NewCashPoolService(nil)
updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{}
json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), updateExchangeCashActivityCommand)
activityId, _ := controller.GetInt64(":activityId")
updateExchangeCashActivityCommand.ExchangeCashActivityId = activityId
data, err := cashPoolService.UpdateExchangeCashActivity(updateExchangeCashActivityCommand)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
... ... @@ -224,19 +219,14 @@ func (controller *SuMoneyController) UpdateExchangeActivities () {
func (controller *SuMoneyController) CreateExchangeActivities () {
cashPoolService := service.NewCashPoolService(nil)
createExchangeCashActivityCommand := &command.CreateExchangeCashActivityCommand{}
json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), createExchangeCashActivityCommand)
data, err := cashPoolService.CreateExchangeCashActivity(createExchangeCashActivityCommand)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
... ... @@ -245,20 +235,15 @@ func (controller *SuMoneyController) CreateExchangeActivities () {
func (controller *SuMoneyController) RemoveExchangeActivities () {
cashPoolService := service.NewCashPoolService(nil)
removeExchangeCashActivityCommand := &command.RemoveExchangeCashActivityCommand{}
activityId, _ := controller.GetInt64(":activityId")
removeExchangeCashActivityCommand. ExchangeCashActivityId = activityId
data, err := cashPoolService.RemoveExchangeCashActivity(removeExchangeCashActivityCommand)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
... ... @@ -267,20 +252,15 @@ func (controller *SuMoneyController) RemoveExchangeActivities () {
func (controller *SuMoneyController) GetExchangeCashActivity () {
cashPoolService := service.NewCashPoolService(nil)
getExchangeCashActivityQuery := &query.GetExchangeCashActivityQuery{}
activityId, _ := controller.GetInt64(":activityId")
getExchangeCashActivityQuery.ExchangeCashActivityId = activityId
data, err := cashPoolService.GetExchangeCashActivity(getExchangeCashActivityQuery)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
... ... @@ -289,29 +269,21 @@ func (controller *SuMoneyController) GetExchangeCashActivity () {
func (controller *SuMoneyController) ListExchangeList () {
cashPoolService := service.NewCashPoolService(nil)
listExchangeCashListQuery := &query.ListExchangeCashPersonQuery{}
activityId, _ := controller.GetInt64("activityId")
listExchangeCashListQuery.ExchangeCashActivityId = activityId
exchangeCashPersonNameMatch := controller.GetString("personNameMatch")
listExchangeCashListQuery.ExchangeCashPersonNameMatch = exchangeCashPersonNameMatch
offset, _ := controller.GetInt("offset")
listExchangeCashListQuery.Offset = offset
limit, _ := controller.GetInt("limit")
listExchangeCashListQuery.Limit = limit
data, err := cashPoolService.ListExchangeCashPerson(listExchangeCashListQuery)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
... ... @@ -320,19 +292,14 @@ func (controller *SuMoneyController) ListExchangeList () {
func (controller *SuMoneyController) CreateExchangeList () {
cashPoolService := service.NewCashPoolService(nil)
createExchangeCashPersonCommand := &command.CreateExchangeCashPersonCommand{}
json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), createExchangeCashPersonCommand)
data, err := cashPoolService.CreateExchangeCashPerson(createExchangeCashPersonCommand)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
... ... @@ -341,22 +308,16 @@ func (controller *SuMoneyController) CreateExchangeList () {
func (controller *SuMoneyController) UpdateExchangeList () {
cashPoolService := service.NewCashPoolService(nil)
updateExchangeCashPersonCommand := &command.UpdateExchangeCashPersonCommand{}
json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), updateExchangeCashPersonCommand)
personId, _ := controller.GetInt64(":personId")
updateExchangeCashPersonCommand. ExchangeCashPersonId = personId
data, err := cashPoolService.UpdateExchangeCashPerson(updateExchangeCashPersonCommand)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
... ... @@ -365,20 +326,15 @@ func (controller *SuMoneyController) UpdateExchangeList () {
func (controller *SuMoneyController) RemoveExchangeList () {
cashPoolService := service.NewCashPoolService(nil)
removeExchangeCashPersonCommand := &command.RemoveExchangeCashPersonCommand{}
personId, _ := controller.GetInt64(":personId")
removeExchangeCashPersonCommand.ExchangeCashPersonId = personId
data, err := cashPoolService.RemoveExchangeCashPerson(removeExchangeCashPersonCommand)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
... ... @@ -387,20 +343,15 @@ func (controller *SuMoneyController) RemoveExchangeList () {
func (controller *SuMoneyController) GetExchangeCashPerson () {
cashPoolService := service.NewCashPoolService(nil)
getExchangeCashPersonQuery := &query.GetExchangeCashPersonQuery{}
personId, _ := controller.GetInt64(":personId")
getExchangeCashPersonQuery.ExchangeCashPersonId = personId
data, err := cashPoolService.GetExchangeCashPerson(getExchangeCashPersonQuery)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
... ... @@ -409,10 +360,9 @@ func (controller *SuMoneyController) GetExchangeCashPerson () {
func (controller *SuMoneyController) ImportExchangeList () {
cashPoolService := service.NewCashPoolService(nil)
createExchangeCashPersonCommand := &command.CreateExchangeCashPersonCommand{}
activityId, _ := controller.GetInt64("activityId")
file, h, _ := controller.GetFile("file") //获取上传的文件
ext := path.Ext(h.Filename)
//验证后缀名是否符合要求
AllowExtMap := map[string]bool{
".xlsx":true,
... ... @@ -421,46 +371,33 @@ func (controller *SuMoneyController) ImportExchangeList () {
controller.Ctx.WriteString( "后缀名不符合上传要求" )
return
}
xlsx, err := excelize.OpenReader(file)
if err != nil {
fmt.Println(err)
return
}
var response utils.JsonResponse
dataList := make([]interface{}, 0)
rows, _ := xlsx.GetRows("Sheet1")
fmt.Print(rows)
for i, row := range rows {
if i > 0 {
for _, _ = range row {
//fmt.Print(row[0], "\t")
//fmt.Print(row[1], "\t")
//fmt.Print(row[2], "\t")
//fmt.Print(row[3], "\t")
//createExchangeCashPersonCommand.ExchangeCashPerson.EmployeeInfo.EmployeeName = row[0]
//createExchangeCashPersonCommand.ExchangeCashPerson.EmployeeInfo.EmployeeAccount = row[1]
//createExchangeCashPersonCommand.ExchangedCash, _ = strconv.ParseFloat(row[2],64)
//createExchangeCashPersonCommand.ExchangedSuMoney, _ = strconv.ParseFloat(row[3], 64)
data, err := cashPoolService.CreateExchangeCashPerson(createExchangeCashPersonCommand)
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
dataList = append(dataList, data)
response = utils.ResponseData(controller.Ctx, dataList)
}
createExchangeCashPersonCommand.ExchangeCashActivityId = activityId
createExchangeCashPersonCommand.PersonId, _ = strconv.ParseInt(row[0], 10, 32)
createExchangeCashPersonCommand.PersonName = row[1]
createExchangeCashPersonCommand.PersonAccount = row[2]
createExchangeCashPersonCommand.ExchangedSuMoney, _ = strconv.ParseFloat(row[3], 64)
}
fmt.Print(createExchangeCashPersonCommand)
data, err := cashPoolService.CreateExchangeCashPerson(createExchangeCashPersonCommand)
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
dataList = append(dataList, data)
response = utils.ResponseData(controller.Ctx, dataList)
}
}
}
controller.Data["json"] = response
controller.ServeJSON()
}
\ No newline at end of file
... ...