dao-exam-record.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. package dao
  2. import (
  3. "database/sql"
  4. "encoding/json"
  5. "exam_system/config"
  6. "exam_system/entity"
  7. "exam_system/result"
  8. "exam_system/utils"
  9. "exam_system/vo"
  10. "fmt"
  11. "strconv"
  12. "time"
  13. "github.com/gin-gonic/gin"
  14. "github.com/jmoiron/sqlx"
  15. uuid "github.com/satori/go.uuid"
  16. "github.com/xuri/excelize/v2"
  17. )
  18. func AddExamRecord(er *entity.ExamRecord) *result.Result {
  19. // 2、插入
  20. uuId := uuid.NewV4().String()
  21. sqlStr := "update exam_record er set create_at=?,update_at=?,token=?,ip=inet_aton(?),status=? where er.id = ? and er.user_id=?"
  22. _, err := config.DB.Exec(sqlStr, time.Now(), time.Now(), uuId, er.Ip, entity.TESTING, er.Id, er.UserId)
  23. if err != nil {
  24. return result.UNKNOW_ERROR.SetData(err)
  25. }
  26. fmt.Println("--------------------ADDTOKEN--------------------------------")
  27. fmt.Printf("ID:%d\n", er.Id)
  28. fmt.Printf("TOKEN:%s\n", uuId)
  29. return result.SuccessResult(gin.H{
  30. "id": er.Id,
  31. "token": uuId,
  32. })
  33. }
  34. func ExamRecordDetail(id, uid int) *result.Result {
  35. // 1、考试详情
  36. sqlStr := `select e.name,e.create_at,e.update_at,e.duration,e.start_at,e.end_at,e.publish_at,tp.score,tp.pass_score,er.score user_score,timestampdiff(minute,er.create_at,er.update_at) user_take_time
  37. from user u left join exam_record er on u.id = er.user_id
  38. LEFT JOIN exam e ON e.id = er.exam_id
  39. LEFT JOIN test_paper tp ON e.tp_id = tp.id
  40. LEFT JOIN exam_class ec ON e.id = ec.exam_id
  41. LEFT JOIN class c ON ec.class_id = c.id
  42. where er.id = ? and u.id = ? and e.delete_at is null `
  43. var t vo.ExamRecordVo1
  44. err := config.DB.Get(&t, sqlStr, id, uid)
  45. if err != nil {
  46. if err == sql.ErrNoRows {
  47. return result.DATA_NOT_FOUND
  48. }
  49. return result.UNKNOW_ERROR.SetMsg(err.Error())
  50. }
  51. if t.PublishAt.After(time.Now()) {
  52. t.UserScore = nil
  53. }
  54. // 题目答案, 用户答案
  55. sqlStr = "select er.answer from exam_record er where er.id = ? and er.delete_at is null"
  56. var answerStr string
  57. err = config.DB.Get(&answerStr, sqlStr, id)
  58. if err != nil {
  59. return result.UNKNOW_ERROR.SetMsg(err.Error())
  60. }
  61. var avs []*vo.AnswerVo
  62. err = json.Unmarshal([]byte(answerStr), &avs)
  63. if err != nil {
  64. return result.FORMATE_ERROR
  65. }
  66. for i := 0; i < len(avs); i++ {
  67. var av vo.AnswerVo
  68. sqlStr = "select * from subject where id = ?"
  69. err = config.DB.Get(&av, sqlStr, avs[i].Id)
  70. if err != nil {
  71. if err == sql.ErrNoRows {
  72. continue
  73. }
  74. return result.UNKNOW_ERROR.SetMsg(err.Error())
  75. }
  76. if t.PublishAt.After(time.Now()) {
  77. av.Answer = ""
  78. }
  79. av.OwnAnswer = avs[i].OwnAnswer
  80. avs[i] = &av
  81. }
  82. return result.SuccessResult(gin.H{
  83. "exam_detail": &t,
  84. "subject": &avs,
  85. })
  86. }
  87. func ExamRecordList(page, size int, query map[string]interface{}, uid int) *result.Result {
  88. // 1、获取list
  89. sqlStr := `select er.id,e.name,e.create_at,e.update_at,e.duration,e.start_at,e.end_at,e.publish_at,inet_ntoa(er.ip) ip,tp.score,tp.pass_score,er.score user_score,timestampdiff(minute,er.create_at,er.update_at) user_take_time
  90. from user u left join exam_record er on u.id = er.user_id
  91. LEFT JOIN exam e ON e.id = er.exam_id
  92. LEFT JOIN test_paper tp ON e.tp_id = tp.id
  93. LEFT JOIN exam_class ec ON e.id = ec.exam_id
  94. LEFT JOIN class c ON ec.class_id = c.id
  95. where u.id = ? and e.delete_at is null and er.status!=0 `
  96. params := []interface{}{uid}
  97. if query["name"] != nil {
  98. sqlStr += "and e.name like ? "
  99. params = append(params, "%"+query["name"].(string)+"%")
  100. }
  101. sqlStr += "group by er.id "
  102. if query["create_at"] != nil {
  103. if query["create_at"] == "desc" {
  104. sqlStr += "order by create_at desc "
  105. } else {
  106. sqlStr += "order by create_at asc "
  107. }
  108. } else if query["user_take_time"] != nil {
  109. if query["user_take_time"] == "desc" {
  110. sqlStr += "order by user_take_time desc "
  111. } else {
  112. sqlStr += "order by user_take_time asc "
  113. }
  114. } else if query["user_score"] != nil {
  115. if query["user_score"] == "desc" {
  116. sqlStr += "order by user_score desc "
  117. } else {
  118. sqlStr += "order by user_score asc "
  119. }
  120. } else {
  121. sqlStr += "order by create_at desc "
  122. }
  123. sqlStr += "limit ?,?"
  124. params = append(params, utils.PostionSize(page, size), size)
  125. var evos []*vo.ExamRecordVo1
  126. err := config.DB.Select(&evos, sqlStr, params...)
  127. if err != nil {
  128. return result.UNKNOW_ERROR.SetMsg(err.Error())
  129. }
  130. // 2、总数
  131. sqlStr = `select count(distinct(er.id))
  132. from user u left join exam_record er on u.id = er.user_id
  133. LEFT JOIN exam e ON e.id = er.exam_id
  134. LEFT JOIN test_paper tp ON e.tp_id = tp.id
  135. LEFT JOIN exam_class ec ON e.id = ec.exam_id
  136. LEFT JOIN class c ON ec.class_id = c.id
  137. where u.id = ? and e.delete_at is null and er.status!=0 `
  138. params = []interface{}{uid}
  139. if query["name"] != nil {
  140. sqlStr += "and e.name like ? "
  141. params = append(params, "%"+query["name"].(string)+"%")
  142. }
  143. sqlStr += "group by er.id"
  144. for _, e := range evos {
  145. if e.PublishAt.After(time.Now()) {
  146. e.UserScore = nil
  147. }
  148. }
  149. var total int
  150. err = config.DB.Get(&total, sqlStr, params...)
  151. if err != nil {
  152. return result.UNKNOW_ERROR.SetMsg(err.Error())
  153. }
  154. return result.SUCCESS.SetData(result.NewPage(page, len(evos), total, evos))
  155. }
  156. func UpdateExamRecord(erv *vo.ExamRecordVo) *result.Result {
  157. tx, err := config.DB.Beginx()
  158. return utils.Transation(tx, err, func(tx *sqlx.Tx) *result.Result {
  159. // 1、查询是否存在该记录
  160. sqlStr := `select er.id, er.exam_id
  161. from exam_record er
  162. left join exam e on e.id = er.exam_id
  163. where er.id = ?
  164. and er.token = ?
  165. and er.update_at - er.create_at <= e.duration
  166. and e.end_at > ?
  167. `
  168. fmt.Println("--------------------UPDATETOKEN--------------------------------")
  169. fmt.Printf("ID:%d\n", erv.Id)
  170. fmt.Printf("TOKEN:%s\n", erv.Token)
  171. err = tx.Get(erv, sqlStr, erv.Id, erv.Token, time.Now())
  172. if err != nil {
  173. if err == sql.ErrNoRows {
  174. return result.DATA_NOT_FOUND.SetMsg("该场考试已过期")
  175. }
  176. return result.UNKNOW_ERROR.SetMsg(err.Error())
  177. }
  178. sqlStr = "update exam_record set token = null,status = ? where id = ?"
  179. var res sql.Result
  180. res, err = tx.Exec(sqlStr, entity.TESTED, erv.Id)
  181. if err != nil {
  182. return result.UNKNOW_ERROR.SetMsg(err.Error())
  183. }
  184. // 2、查询出所需id
  185. sqlStr = "select c.sub_ids from chapter c left join exam e on c.tp_id = e.tp_id where e.id=?"
  186. var subIdStrs []string
  187. err = tx.Select(&subIdStrs, sqlStr, erv.ExamId)
  188. if err != nil {
  189. return result.UNKNOW_ERROR.SetMsg(err.Error())
  190. }
  191. subIds := make([]*vo.SubIdsVo, 0)
  192. for _, subIdStr := range subIdStrs {
  193. var subIdsVo []*vo.SubIdsVo
  194. err = json.Unmarshal([]byte(subIdStr), &subIdsVo)
  195. if err != nil {
  196. return result.UNKNOW_ERROR.SetMsg(err.Error())
  197. }
  198. subIds = append(subIds, subIdsVo...)
  199. }
  200. // 2.1 构造一个key为id的 map
  201. subIdMap := make(map[int]int, 0)
  202. for _, subId := range subIds {
  203. subIdMap[*subId.Id] = *subId.Score
  204. }
  205. // 2、 批量查询id
  206. toatalScore := 0
  207. for _, answerVo := range erv.AnswerVo {
  208. // 判断提交的试题是否在考试范围内
  209. if _, ok := subIdMap[*answerVo.Id]; !ok {
  210. return result.UNKNOW_ERROR.SetMsg("不存在该试题")
  211. }
  212. fmt.Printf("answerId:%d\n", &answerVo.Id)
  213. fmt.Printf("owner:%s\n", answerVo.OwnAnswer)
  214. var score int
  215. sqlStr = "select count(id) from subject where id=? and answer=?"
  216. err = tx.Get(&score, sqlStr, answerVo.Id, utils.SubjectSort(answerVo.OwnAnswer))
  217. if err != nil {
  218. return result.UNKNOW_ERROR.SetMsg(err.Error())
  219. }
  220. toatalScore += score * subIdMap[*answerVo.Id]
  221. delete(subIdMap, *answerVo.Id)
  222. }
  223. if len(subIdMap) != 0 {
  224. return result.UNKNOW_ERROR.SetMsg("试题提交不完整")
  225. }
  226. var anwserData []byte
  227. anwserData, err = json.Marshal(erv.AnswerVo)
  228. // 插入记录表
  229. sqlStr = "update exam_record set score=?,answer=?,update_at=? where id=? and delete_at is null "
  230. res, err = tx.Exec(sqlStr, toatalScore, string(anwserData), time.Now(), erv.Id)
  231. if err != nil {
  232. return result.UNKNOW_ERROR.SetData(err)
  233. }
  234. affected, _ := res.RowsAffected()
  235. return result.SuccessResult(result.NewResultChange(affected))
  236. })
  237. }
  238. func DeleteExamRecords(ids []string) *result.Result {
  239. parm := []interface{}{time.Now()}
  240. parmStr := ""
  241. for k, id := range ids {
  242. parm = append(parm, id)
  243. if k == (len(ids) - 1) {
  244. parmStr += "?"
  245. } else {
  246. parmStr += "?,"
  247. }
  248. }
  249. sqlStr := fmt.Sprintf("update exam_record set delete_at=? where id in (%s)", parmStr)
  250. res, err := config.DB.Exec(sqlStr, parm...)
  251. if err != nil {
  252. return result.UNKNOW_ERROR.SetMsg(err.Error())
  253. }
  254. affected, _ := res.RowsAffected()
  255. return result.SUCCESS.SetData(result.NewResultChange(affected))
  256. }
  257. func AdminExamRecordDetail(id int) *result.Result {
  258. // 1、考试详情
  259. // sqlStr := `select e.name,e.create_at,e.update_at,e.duration,e.start_at,e.end_at,e.publish_at,tp.score,tp.pass_score,er.score user_score,timestampdiff(minute,er.create_at,er.update_at) user_take_time
  260. //from exam_record er left join exam e on er.exam_id = e.id
  261. // left join test_paper tp on e.tp_id = tp.id
  262. // left join exam_class ec on e.id = ec.exam_id
  263. // left join class c on ec.class_id = c.id
  264. // left join user u on u.class_id = c.id
  265. // where er.id=? and e.delete_at is null
  266. // GROUP BY er.id`
  267. //
  268. // var t vo.ExamRecordVo1
  269. // err := config.DB.Get(&t, sqlStr, id)
  270. // if err != nil {
  271. // if err == sql.ErrNoRows {
  272. // return result.DATA_NOT_FOUND
  273. // }
  274. // return result.UNKNOW_ERROR.SetMsg(err.Error())
  275. // }
  276. // 题目答案, 用户答案
  277. sqlStr := "select er.answer from exam_record er where er.id = ? and er.delete_at is null"
  278. var answerStr string
  279. err := config.DB.Get(&answerStr, sqlStr, id)
  280. if err != nil {
  281. return result.UNKNOW_ERROR.SetMsg(err.Error())
  282. }
  283. var avs []*vo.AnswerVo
  284. err = json.Unmarshal([]byte(answerStr), &avs)
  285. if err != nil {
  286. return result.FORMATE_ERROR
  287. }
  288. for i := 0; i < len(avs); i++ {
  289. var av vo.AnswerVo
  290. sqlStr = "select * from subject where id = ?"
  291. err = config.DB.Get(&av, sqlStr, avs[i].Id)
  292. if err != nil {
  293. if err.Error() == "sql: no rows in result set" {
  294. continue
  295. }
  296. return result.UNKNOW_ERROR.SetMsg(err.Error())
  297. }
  298. av.OwnAnswer = avs[i].OwnAnswer
  299. if avs[i].OwnAnswer == "-1" {
  300. av.OwnAnswer = ""
  301. }
  302. avs[i] = &av
  303. }
  304. return result.SuccessResult(gin.H{
  305. //"exam_detail": &t,
  306. "subject": &avs,
  307. })
  308. }
  309. func AdminExamRecordList(page, size int, query map[string]interface{}, examId int) *result.Result {
  310. // 1、获取list
  311. sqlStr := `select er.id,
  312. e.name,
  313. e.create_at,
  314. e.update_at,
  315. e.duration,
  316. e.start_at,
  317. e.end_at,
  318. e.publish_at,
  319. tp.score,
  320. tp.pass_score,
  321. er.score user_score,
  322. u.username,
  323. c.name classname,
  324. timestampdiff(minute, er.create_at, er.update_at) user_take_time
  325. from exam_record er
  326. LEFT JOIN exam e ON er.exam_id = e.id
  327. LEFT JOIN test_paper tp ON e.tp_id = tp.id
  328. LEFT JOIN user u on er.user_id = u.id
  329. LEFT JOIN class c on u.class_id = c.id
  330. where e.id = ?
  331. and e.delete_at is null `
  332. params := []interface{}{examId}
  333. if query["name"] != nil {
  334. sqlStr += "and e.name like ? "
  335. params = append(params, "%"+query["name"].(string)+"%")
  336. }
  337. if query["class_id"] != nil {
  338. sqlStr += "and c.id = ? "
  339. params = append(params, query["class_id"])
  340. }
  341. if query["create_at"] != nil {
  342. if query["create_at"] == "desc" {
  343. sqlStr += "order by create_at desc "
  344. } else {
  345. sqlStr += "order by create_at asc "
  346. }
  347. } else if query["user_take_time"] != nil {
  348. if query["user_take_time"] == "desc" {
  349. sqlStr += "order by user_take_time desc "
  350. } else {
  351. sqlStr += "order by user_take_time asc "
  352. }
  353. } else if query["user_score"] != nil {
  354. if query["user_score"] == "desc" {
  355. sqlStr += "order by user_score desc "
  356. } else {
  357. sqlStr += "order by user_score asc "
  358. }
  359. } else {
  360. sqlStr += "order by create_at desc "
  361. }
  362. sqlStr += "limit ?,?"
  363. params = append(params, utils.PostionSize(page, size), size)
  364. var evos []*vo.ExamRecordVo1
  365. err := config.DB.Select(&evos, sqlStr, params...)
  366. if err != nil {
  367. return result.UNKNOW_ERROR.SetMsg(err.Error())
  368. }
  369. // 2、总数
  370. sqlStr = `select count(er.id)
  371. from exam_record er
  372. LEFT JOIN exam e ON er.exam_id = e.id
  373. LEFT JOIN test_paper tp ON e.tp_id = tp.id
  374. LEFT JOIN user u on er.user_id = u.id
  375. LEFT JOIN class c on u.class_id = c.id
  376. where e.id = ? and e.delete_at is null `
  377. params = []interface{}{examId}
  378. if query["name"] != nil {
  379. sqlStr += "and e.name like ? "
  380. params = append(params, "%"+query["name"].(string)+"%")
  381. }
  382. if query["class_id"] != nil {
  383. sqlStr += "and c.id = ? "
  384. params = append(params, query["class_id"])
  385. }
  386. var total int
  387. err = config.DB.Get(&total, sqlStr, params...)
  388. if err != nil {
  389. return result.UNKNOW_ERROR.SetMsg(err.Error())
  390. }
  391. return result.SUCCESS.SetData(result.NewPage(page, len(evos), total, evos))
  392. }
  393. func AdminDownloadExamRecord(file *excelize.File, id string) *result.Result {
  394. // 1、获取list
  395. sqlStr := `SELECT
  396. e.name exam_name,
  397. u.username,
  398. CONCAT(t.name,c.name,'>') term_class,
  399. u.username name,
  400. u.sid,
  401. er.create_at,
  402. er.update_at,
  403. inet_ntoa( er.ip ) ip,
  404. er.score user_score,
  405. timestampdiff( MINUTE, er.create_at, er.update_at ) user_take_time
  406. FROM
  407. exam e left join exam_record er on e.id = er.exam_id
  408. LEFT JOIN user u ON u.id = er.user_id
  409. LEFT JOIN class c ON u.class_id = c.id
  410. LEFT JOIN term t on c.term_id = t.id
  411. WHERE
  412. u.delete_at IS NULL and e.id = ?
  413. `
  414. var evos []*vo.ExamRecordVo2
  415. err := config.DB.Select(&evos, sqlStr, id)
  416. if err != nil {
  417. if err == sql.ErrNoRows {
  418. return result.DATA_NOT_FOUND
  419. }
  420. return result.UNKNOW_ERROR.SetMsg(err.Error())
  421. }
  422. file.SetCellValue("Sheet1", "A1", evos[0].ExamName)
  423. i := 4
  424. for _, evo := range evos {
  425. if evo.TermClass != nil {
  426. file.SetCellValue("Sheet1", "A"+strconv.Itoa(i), *evo.TermClass)
  427. }
  428. file.SetCellValue("Sheet1", "B"+strconv.Itoa(i), evo.Name)
  429. file.SetCellValue("Sheet1", "C"+strconv.Itoa(i), evo.Sid)
  430. file.SetCellValue("Sheet1", "D"+strconv.Itoa(i), evo.CreateAt.Format("2006-01-02 15:04:05"))
  431. file.SetCellValue("Sheet1", "E"+strconv.Itoa(i), evo.UpdateAt.Format("2006-01-02 15:04:05"))
  432. if evo.UserScore != nil {
  433. file.SetCellValue("Sheet1", "F"+strconv.Itoa(i), *evo.UserScore)
  434. }
  435. i++
  436. }
  437. return result.SUCCESS
  438. }
  439. func UpdateExamRecordTask(examId int) *result.Result {
  440. tx, err := config.DB.Beginx()
  441. return utils.Transation(tx, err, func(tx *sqlx.Tx) *result.Result {
  442. var ervs []*vo.ExamRecordVo
  443. // 1、查询是否存在该记录
  444. // 考试已结束
  445. sqlStr := `select er.id, er.exam_id
  446. from exam_record er
  447. left join exam e on e.id = er.exam_id
  448. where e.id = ? and e.end_at < ?
  449. `
  450. err = tx.Select(&ervs, sqlStr, examId, time.Now())
  451. if err != nil {
  452. if err == sql.ErrNoRows {
  453. return result.SUCCESS
  454. }
  455. return result.UNKNOW_ERROR.SetMsg(err.Error())
  456. }
  457. sqlStr = "update exam_record set token = null,status = ? where id = ?"
  458. var updateEr *sql.Stmt
  459. updateEr, err = tx.Prepare(sqlStr)
  460. if err != nil {
  461. return result.UNKNOW_ERROR.SetMsg(err.Error())
  462. }
  463. sqlStr = "update exam_record set score=?,answer=?,update_at=? where id=? and delete_at is null "
  464. var updateErScore *sql.Stmt
  465. updateErScore, err = tx.Prepare(sqlStr)
  466. if err != nil {
  467. return result.UNKNOW_ERROR.SetMsg(err.Error())
  468. }
  469. for _, erv := range ervs {
  470. _, err = updateEr.Exec(entity.TIMEOUT, erv.Id)
  471. if err != nil {
  472. return result.UNKNOW_ERROR.SetMsg(err.Error())
  473. }
  474. // 2、查询出所需id
  475. sqlStr = "select c.sub_ids from chapter c left join exam e on c.tp_id = e.tp_id where e.id=?"
  476. var subIdStrs []string
  477. err = tx.Select(&subIdStrs, sqlStr, erv.ExamId)
  478. if err != nil {
  479. return result.UNKNOW_ERROR.SetMsg(err.Error())
  480. }
  481. subIds := make([]*vo.SubIdsVo, 0)
  482. for _, subIdStr := range subIdStrs {
  483. var subIdsVo []*vo.SubIdsVo
  484. err = json.Unmarshal([]byte(subIdStr), &subIdsVo)
  485. if err != nil {
  486. return result.UNKNOW_ERROR.SetMsg(err.Error())
  487. }
  488. subIds = append(subIds, subIdsVo...)
  489. }
  490. // 2.1 构造一个key为id的 map
  491. subIdMap := make(map[int]int, 0)
  492. for _, subId := range subIds {
  493. subIdMap[*subId.Id] = *subId.Score
  494. }
  495. // 2、 批量查询id
  496. toatalScore := 0
  497. for _, answerVo := range erv.AnswerVo {
  498. // 判断提交的试题是否在考试范围内
  499. // if _, ok := subIdMap[*answerVo.Id]; !ok {
  500. // return result.UNKNOW_ERROR.SetMsg("不存在该试题")
  501. // }
  502. var score int
  503. sqlStr = "select count(id) from subject where id=? and answer=?"
  504. err = tx.Get(&score, sqlStr, answerVo.Id, utils.SubjectSort(answerVo.OwnAnswer))
  505. if err != nil {
  506. return result.UNKNOW_ERROR.SetMsg(err.Error())
  507. }
  508. toatalScore += score * subIdMap[*answerVo.Id]
  509. fmt.Println("=========TASK==========================")
  510. fmt.Println(toatalScore)
  511. delete(subIdMap, *answerVo.Id)
  512. }
  513. // if len(subIdMap) != 0 {
  514. // return result.UNKNOW_ERROR.SetMsg("试题提交不完整")
  515. // }
  516. var anwserData []byte
  517. anwserData, err = json.Marshal(erv.AnswerVo)
  518. fmt.Println("=========TASK-ANSER==========================")
  519. fmt.Println(string(anwserData))
  520. // 插入记录表
  521. _, err = updateErScore.Exec(toatalScore, string(anwserData), time.Now(), erv.Id)
  522. if err != nil {
  523. return result.UNKNOW_ERROR.SetData(err)
  524. }
  525. }
  526. return result.SUCCESS
  527. })
  528. }