1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
package apis
import (
"fmt"
cDto "go-admin/common/dto"
"strconv"
"github.com/gin-gonic/gin"
"github.com/go-admin-team/go-admin-core/sdk/api"
"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user"
_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response"
"go-admin/app/operate/service"
"go-admin/app/operate/service/dto"
"go-admin/common/actions"
)
type OrgMatchEvaluate struct {
api.Api
}
// GetPage <赛事>赛后评价列表
// @Summary <赛事>赛后评价列表
// @Description <赛事>赛后评价列表
// @Tags <赛事>赛后评价
// @Param data body dto.OrgMatchEvaluateGetPageReq true "body"
// @Param pageSize query int false "页条数"
// @Param pageIndex query int false "页码"
// @Param data body dto.OrgMatchEvaluateGetPageReq true "data"
// @Success 200 {string} string "{"code": 200, "data": [...]}"
// @Router /api/v1/org-match-evaluate [get]
// @Security Bearer
func (e OrgMatchEvaluate) GetPage(c *gin.Context) {
req := dto.OrgMatchEvaluateGetPageReq{}
s := service.OrgMatchEvaluate{}
err := e.MakeContext(c).
MakeOrm().
Bind(&req).
MakeService(&s.Service).
Errors
if err != nil {
e.Logger.Error(err)
e.Error(500, err, err.Error())
return
}
p := actions.GetPermissionFromContext(c)
list := make([]dto.OrgMatchEvaluateGetPageReply, 0)
var count int64
err = s.GetPage(&req, p, &list, &count)
if err != nil {
e.Error(500, err, fmt.Sprintf("获取比赛球员信息 失败,\r\n失败信息 %s", err.Error()))
return
}
e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
}
// GetPage <赛事>赛后评价比赛列表
// @Summary <赛事>赛后评价比赛列表
// @Description <赛事>赛后评价比赛列表
// @Tags <赛事>赛后评价
// @Param id path string false "id"
// @Success 200 {string} string "{"code": 200, "data": [...]}"
// @Router /api/v1/org-match-evaluate/get-match [get]
// @Security Bearer
func (e OrgMatchEvaluate) GetPageMatch(c *gin.Context) {
req := dto.GetPageMatchReq{}
s := service.OrgMatchEvaluate{}
err := e.MakeContext(c).
MakeOrm().
Bind(&req).
MakeService(&s.Service).
Errors
if err != nil {
e.Logger.Error(err)
e.Error(500, err, err.Error())
return
}
p := actions.GetPermissionFromContext(c)
reply := new(dto.GetPageMatchReply)
replyGetMatchInfo := new(cDto.PageMatchInfo)
err = s.GetMatchInfo(strconv.Itoa(req.Id), p, replyGetMatchInfo)
if err != nil {
e.Error(500, err, fmt.Sprintf("获取比赛球员信息 失败,\r\n失败信息 %s", err.Error()))
return
}
reply.MatchInfo = *replyGetMatchInfo
imgList := make([]cDto.Wonderful, 0)
err = s.GetPageWonderful(replyGetMatchInfo.EvaluateId, &imgList, 1)
if err != nil {
e.Error(500, err, fmt.Sprintf("获取比赛球员信息 失败,\r\n失败信息 %s", err.Error()))
return
}
reply.MatchImg = imgList
mvList := make([]cDto.Wonderful, 0)
err = s.GetPageWonderful(replyGetMatchInfo.EvaluateId, &mvList, 2)
if err != nil {
e.Error(500, err, fmt.Sprintf("获取比赛球员信息 失败,\r\n失败信息 %s", err.Error()))
return
}
reply.MatchMv = mvList
replyGetRoundsScoring := make([]cDto.RoundsScoring, 0)
err = s.GetRoundsScoring(replyGetMatchInfo.PlayerId, replyGetMatchInfo.Rounds, "0", &replyGetRoundsScoring)
if err != nil {
e.Error(500, err, fmt.Sprintf("获取比赛球员信息 失败,\r\n失败信息 %s", err.Error()))
return
}
reply.RoundsScoring = replyGetRoundsScoring
replyGetTotalScoring := make([]cDto.TotalScoring, 0)
err = s.GetTotalScoring(replyGetMatchInfo.PlayerId, replyGetMatchInfo.Rounds, replyGetMatchInfo.SeasonId, &replyGetTotalScoring)
if err != nil {
e.Error(500, err, fmt.Sprintf("获取比赛球员信息 失败,\r\n失败信息 %s", err.Error()))
return
}
reply.TotalScoring = replyGetTotalScoring
e.OK(reply, "查询成功")
}
// Get <赛事>赛后评价比赛详情
// @Summary <赛事>赛后评价比赛详情
// @Description <赛事>赛后评价比赛详情
// @Tags <赛事>赛后评价
// @Param id path string false "id"
// @Success 200 {string} string "{"code": 200, "data": [...]}"
// @Router /api/v1/org-match-evaluate/{id} [get]
// @Security Bearer
func (e OrgMatchEvaluate) Get(c *gin.Context) {
req := dto.OrgMatchEvaluateGetReq{}
s := service.OrgMatchEvaluate{}
err := e.MakeContext(c).
MakeOrm().
Bind(&req).
MakeService(&s.Service).
Errors
if err != nil {
e.Logger.Error(err)
e.Error(500, err, err.Error())
return
}
p := actions.GetPermissionFromContext(c)
reply := new(dto.OrgMatchEvaluateGetReply)
replyGetMatchInfo := new(cDto.PageMatchInfo)
err = s.GetMatchInfo(strconv.Itoa(req.Id), p, replyGetMatchInfo)
if err != nil {
e.Error(500, err, fmt.Sprintf("获取比赛球员信息 失败,\r\n失败信息 %s", err.Error()))
return
}
reply.MatchInfo = *replyGetMatchInfo
replyGetRoundsScoring := make([]cDto.RoundsScoring, 0)
err = s.GetRoundsScoring(replyGetMatchInfo.PlayerId, replyGetMatchInfo.Rounds, strconv.Itoa(req.Id), &replyGetRoundsScoring)
if err != nil {
e.Error(500, err, fmt.Sprintf("获取比赛球员信息 失败,\r\n失败信息 %s", err.Error()))
return
}
reply.RoundsScoring = replyGetRoundsScoring
e.OK(reply, "查询成功")
}
// Update <赛事>赛后评价影像维护
// @Summary <赛事>赛后评价影像维护
// @Description <赛事>赛后评价影像维护
// @Tags <赛事>赛后评价
// @Accept application/json
// @Product application/json
// @Param data body dto.OrgMatchEvaluateUpdateReq true "body"
// @Success 200 {string} string "{"code": 200, "message": "修改成功"}"
// @Router /api/v1/org-match-evaluate/{id} [put]
// @Security Bearer
func (e OrgMatchEvaluate) Update(c *gin.Context) {
req := dto.OrgMatchEvaluateUpdateReq{}
s := service.OrgMatchEvaluate{}
err := e.MakeContext(c).
MakeOrm().
Bind(&req).
MakeService(&s.Service).
Errors
if err != nil {
e.Logger.Error(err)
e.Error(500, err, err.Error())
return
}
req.SetUpdateBy(user.GetUserId(c))
p := actions.GetPermissionFromContext(c)
err, playerId := s.IsBeing(req.MatchId, req.Rounds, req.PlayerId)
eId := 0
if playerId == 0 {
reqInsertData := dto.OrgMatchEvaluateInsertReq{
MatchId: req.MatchId,
Rounds: req.Rounds,
PlayerId: req.PlayerId,
MvStatus: req.MvStatus,
Status: req.Status,
}
err, eId = s.Insert(&reqInsertData)
} else {
err, eId = s.Update(&req, p)
}
if err != nil {
e.Error(500, err, fmt.Sprintf("修改比赛球员信息 失败,\r\n失败信息 %s", err.Error()))
return
}
reqWonderfulInsert := dto.OrgMatchEvaluateWonderfulInsertReq{}
reqWonderfulUpdate := dto.OrgMatchEvaluateWonderfulUpdateReq{}
sWonderful := service.OrgMatchEvaluateWonderful{}
err = e.MakeContext(c).
MakeOrm().
MakeService(&sWonderful.Service).
Errors
if err != nil {
e.Logger.Error(err)
e.Error(500, err, err.Error())
return
}
delIds := make([]int, 0)
for _, v := range req.MatchImg {
if v.WonderfulId != "" {
upId, _ := strconv.Atoi(v.WonderfulId)
reqWonderfulUpdate.Id = upId
reqWonderfulUpdate.WonderfulUrl = v.WonderfulUrl
reqWonderfulUpdate.WonderfulTitle = v.WonderfulTitle
reqWonderfulUpdate.FileId = v.FileId
reqWonderfulUpdate.UpdateBy = user.GetUserId(c)
sWonderful.Update(&reqWonderfulUpdate)
delIds = append(delIds, upId)
} else {
reqWonderfulInsert.Type = "1"
reqWonderfulInsert.MatchEvaluateId = strconv.Itoa(eId)
reqWonderfulInsert.WonderfulUrl = v.WonderfulUrl
reqWonderfulInsert.WonderfulTitle = v.WonderfulTitle
reqWonderfulUpdate.FileId = v.FileId
reqWonderfulInsert.CreateBy = user.GetUserId(c)
sWonderful.Insert(&reqWonderfulInsert)
delIds = append(delIds, reqWonderfulInsert.Id)
}
}
for _, vMv := range req.MatchMv {
if vMv.WonderfulId != "" {
upId, _ := strconv.Atoi(vMv.WonderfulId)
reqWonderfulUpdate.Id = upId
reqWonderfulUpdate.WonderfulUrl = vMv.WonderfulUrl
reqWonderfulUpdate.WonderfulTitle = vMv.WonderfulTitle
reqWonderfulUpdate.FileId = vMv.FileId
reqWonderfulUpdate.UpdateBy = user.GetUserId(c)
sWonderful.Update(&reqWonderfulUpdate)
delIds = append(delIds, upId)
} else {
reqWonderfulInsert.Type = "2"
reqWonderfulInsert.MatchEvaluateId = strconv.Itoa(eId)
reqWonderfulInsert.WonderfulUrl = vMv.WonderfulUrl
reqWonderfulInsert.WonderfulTitle = vMv.WonderfulTitle
reqWonderfulUpdate.FileId = vMv.FileId
reqWonderfulInsert.CreateBy = user.GetUserId(c)
sWonderful.Insert(&reqWonderfulInsert)
delIds = append(delIds, reqWonderfulInsert.Id)
}
}
reqWonderfulDelete := dto.OrgMatchEvaluateWonderfulDeleteReq{}
reqWonderfulDelete.Ids = delIds
reqWonderfulDelete.EId = eId
sWonderful.Remove(&reqWonderfulDelete)
e.OK(req.GetId(), "修改成功")
}