sun-pc-linux 1 month ago
parent
commit
b1f3368154

+ 6 - 3
pack-nrhe/docker-compose.yaml

@@ -49,8 +49,8 @@ services:
       MONGO_INITDB_ROOT_USERNAME: root
       MONGO_INITDB_ROOT_PASSWORD: nrhe_zzzxxx
     volumes:
-      - ~/nrhe-svc/data/mongo/db:/data/db
-      - ~/nrhe-svc/data/mongo/log:/var/log/mongodb
+      - ./data/mongo/db:/data/db
+      - ./data/mongo/log:/var/log/mongodb
     ports: 
       - 17017:27017
 
@@ -60,6 +60,9 @@ services:
     depends_on:
       - nrhe-bus
     volumes:
-      - ~/nrhe-svc/data/template:/root/projects/template
+      - ./data/template:/root/projects/template
+      - ./mongo-migrations:/root/projects/migrations
     environment: 
       NATS: nats://nrhe-bus:4222
+      MONGO_MIGRATIONS: /root/projects/migrations==mongodb://root:nrhe_zzzxxx@nrhe-mongo:27017/nrhe?authSource=admin
+

+ 15 - 0
pack-nrhe/mongo-migrations/1_users.down.json

@@ -0,0 +1,15 @@
+[
+    {
+        "delete": "users",
+        "deletes": [
+           {
+             "q" : {
+                "_id": {
+                    "$oid": "637dde15ad5446a2050456f1"
+                }
+             },
+             "limit" : 1
+           }
+        ]
+     }
+]

+ 16 - 0
pack-nrhe/mongo-migrations/1_users.up.json

@@ -0,0 +1,16 @@
+[
+    {
+        "insert": "users",
+        "documents": [ {
+            "_id": {
+                "$oid": "637dde15ad5446a2050456f1"
+            },
+            "nid": "管理员",
+            "loginName": "admin",
+            "password": "e10adc3949ba59abbe56e057f20f883e",
+            "roles": ["admin"],
+            "updateTime": "2024-10-15T08:47:05.583Z",
+            "createTime": "2024-10-15T08:47:05.583Z"
+        }]
+     }
+]

+ 1 - 1
src/Dockerfile

@@ -5,7 +5,7 @@ RUN mkdir -p /root/projects
 
 WORKDIR /root/projects
 
-ADD ./template ./package
+ADD ./template ./template
 ADD ./app.yaml ./app.yaml
 ADD ./nrhe-train ./nrhe-train
 

+ 105 - 17
src/api/api.http

@@ -1,23 +1,109 @@
-@host = 45.152.67.125:8085/cr
+@host = 192.168.110.131:8085/nrhe
 
 
 ###
-# 提交学习时长
-# 成功返回
-# {
-#     "errorNo": 200,
-#     "result": true,
-#     "errorDesc": ""
-# }
-# 失败返回
-# {
-#     "errorNo": 200,
-#     "result": false,
-#     "errorDesc": "错误描述"
-# }
-GET http://{{host}}/user/learn/inc?t=1 HTTP/1.1
+# 用户管理
+
+	# crrouter.POST("/user/login/password", UserLoginPassword)
+	# // 用户管理
+	# crrouter.POSTJWT("/admin/user/create", CreateUser)
+	# crrouter.POSTJWT("/admin/user/delete/:id", DeleteUser)
+	# crrouter.POSTJWT("/admin/user/delete/batch", BatchDeleteUser)
+	# crrouter.GETJWT("/admin/user/list", UserList)
+	# crrouter.GETJWT("/admin/user/detail/:id", UserDetail)
+	# crrouter.POSTJWT("/admin/user/update", UpdateUser)
+
+	# crrouter.POSTJWT("/admin/user/import", ImportUser)
+	# crrouter.POSTJWT("/admin/user/export", ExportUser)
+	# crrouter.POSTJWT("/admin/user/tmplate", UserTmplate)
+
+### 
+# 登录
+POST http://{{host}}/user/login/password HTTP/1.1
 Content-Type: application/json
-Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MjI4MjU4OTIsImlkIjoiNjQyYTUyNGY1ZjUwYmM5MDNmOTg2Mzk0Iiwia2V5IjoiYm94Y29zdCIsIm5hbWUiOiLlrZnog5wiLCJvcmlnX2lhdCI6MTcyMjIyMTA5MiwicGFyZW50IjoiNjQyYTUyNGY1ZjUwYmM5MDNmOTg2Mzk0IiwicGhvbmUiOiIxMzQwODU0NzgyMyIsInJvbGUiOiIiLCJzdGF0ZSI6MSwidXNlclR5cGUiOjJ9.Cz7qI3-Vah0io5ZLIFDyVOf8qsqdmbT8WHdprrjbdXw
+Authorization: Bearer xxx
+
+{
+    "loginName": "xxx",
+    "password": "xxx",
+    "role": "admin/student"
+}
+
+### 
+# 创建用户
+POST http://{{host}}/admin/user/create HTTP/1.1
+Content-Type: application/json
+Authorization: Bearer xxx
+
+{
+    "nid": "昵称",
+    "loginName": "xxx",
+    "password": "xxx",
+    "avatar": "xxx.png",
+    "roles": ["admin/student"]
+}
+
+
+### 
+# 删除用户
+POST http://{{host}}/admin/user/delete/:id HTTP/1.1
+Content-Type: application/json
+Authorization: Bearer xxx
+
+
+### 
+# 批量删除用户
+POST http://{{host}}/admin/user/delete/batch HTTP/1.1
+Content-Type: application/json
+Authorization: Bearer xxx
+
+{
+    "ids": ["xxx","xxx"]
+}
+
+
+### 
+# 用户列表
+GET http://{{host}}/admin/user/list?page=1&size=10&query={} HTTP/1.1
+Content-Type: application/json
+Authorization: Bearer xxx
+
+### 
+# 编辑用户
+POST http://{{host}}/admin/user/update HTTP/1.1
+Content-Type: application/json
+Authorization: Bearer xxx
+
+{
+    "_id": "xxx",
+    "nid": "昵称",
+    "loginName": "xxx",
+    "password": "xxx",
+    "avatar": "xxx.png",
+    "roles": ["admin/student"]
+}
+
+
+### 
+# 导出用户
+GET http://{{host}}/admin/user/export HTTP/1.1
+Content-Type: application/json
+Authorization: Bearer xxx
+
+
+### 
+# 导入用户
+# 上传文件名为file
+POST http://{{host}}/admin/user/import HTTP/1.1
+Content-Type: application/json
+Authorization: Bearer xxx
+
+
+### 
+# 下载模板
+GET http://{{host}}/admin/user/tmplate HTTP/1.1
+Content-Type: application/json
+Authorization: Bearer xxx
 
 
 ###
@@ -28,10 +114,12 @@ Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MjM1MzA5M
 
 
 {
+    "produceName": "xx",
     "examRecord": [
         {
             "title":"xxxx",
-            "result": "正确"
+            "result": "正确",
+            "isCorrect": true,
         }
     ],
     "totalScore": 93,

+ 7 - 2
src/api/router.go

@@ -18,12 +18,17 @@ func RegRouters(svc *Service) {
 	crrouter.POSTJWT("/admin/user/delete/:id", DeleteUser)
 	crrouter.POSTJWT("/admin/user/delete/batch", BatchDeleteUser)
 	crrouter.GETJWT("/admin/user/list", UserList)
-	crrouter.GETJWT("/admin/user/detail/:id", UserDetail)
+	// crrouter.GETJWT("/admin/user/detail/:id", UserDetail)
 	crrouter.POSTJWT("/admin/user/update", UpdateUser)
+
+	crrouter.POSTJWT("/admin/user/import", ImportUser)
+	crrouter.GETJWT("/admin/user/export", ExportUser)
+	crrouter.GETJWT("/admin/user/tmplate", UserTmplate)
+
 	// 获取自己的详情信息
 	crrouter.GETJWT("/user/profile", UserProfile)
 	// 增加用户学习时长
-	crrouter.GETJWT("/user/learn/inc", UserLearnInc)
+	// crrouter.GETJWT("/user/learn/inc", UserLearnInc)
 	// 考核历史
 	crrouter.POSTJWT("/exam/history/create", ExamHistoryCreate)
 	crrouter.GETJWT("/exam/history/list", ExamHistoryList)

+ 0 - 201
src/api/test-excel.go

@@ -1,201 +0,0 @@
-package api
-
-import (
-	"fmt"
-	"nrhe-train/db/model"
-	"strings"
-
-	"github.com/xuri/excelize/v2"
-)
-
-type TestExcel struct {
-	Row              int
-	Title            string //标题
-	Excel            *excelize.File
-	SheetName        string
-	AlignCenterStyle int
-	Content          []*model.Test
-	RowMap           map[string]int
-	RowWidthArray    []float64
-	RowsHeightArray  []map[int]float64
-}
-
-// 批量设置行高
-func (b *TestExcel) setRowsHeight() {
-	for _, rowHeight := range b.RowsHeightArray {
-		for row, height := range rowHeight {
-			b.Excel.SetRowHeight(b.SheetName, row, height)
-		}
-	}
-
-}
-
-// 获取范围内单元格的宽度 A:F
-func (b *TestExcel) getRangeWidth(r string) float64 {
-	rg := strings.Split(r, ":")
-
-	if len(rg) == 1 {
-		start := b.RowMap[rg[0]]
-		return b.RowWidthArray[start]
-	} else if len(rg) == 2 {
-		start := b.RowMap[rg[0]]
-		end := b.RowMap[rg[1]]
-		rowr := b.RowWidthArray[start : end+1]
-		width := 0.0
-		for _, v := range rowr {
-			width += v
-		}
-		return width
-	}
-	return 0.0
-}
-
-func (b *TestExcel) drawTitle() error {
-	b.Row++
-	startCell := fmt.Sprintf("A%d", b.Row)
-	// marginLeft := excelize.PageMarginLeft(0.1)
-	endCell := fmt.Sprintf("H%d", b.Row)
-
-	b.RowMap = map[string]int{"A": 0, "B": 1, "C": 2, "D": 3, "E": 4, "F": 5, "G": 6, "H": 7}
-
-	b.RowWidthArray = []float64{36, 8, 20, 20, 20, 20, 8, 6}
-	b.Excel.SetColWidth(b.SheetName, "A", "A", 36)
-	b.Excel.SetColWidth(b.SheetName, "B", "B", 8)
-	b.Excel.SetColWidth(b.SheetName, "C", "C", 20)
-	b.Excel.SetColWidth(b.SheetName, "D", "D", 20)
-	b.Excel.SetColWidth(b.SheetName, "E", "E", 20)
-	b.Excel.SetColWidth(b.SheetName, "F", "F", 20)
-	b.Excel.SetColWidth(b.SheetName, "G", "G", 8)
-	b.Excel.SetColWidth(b.SheetName, "H", "H", 6)
-
-	// b.Excel.SetPageMargins(b.SheetName, marginLeft)
-	err := b.Excel.MergeCell(b.SheetName, startCell, endCell)
-	if err != nil {
-		return err
-	}
-
-	style, err := b.Excel.NewStyle(&excelize.Style{
-		Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center"},
-		Font:      &excelize.Font{Bold: true, Size: 18}})
-	if err != nil {
-		return err
-	}
-	err = b.Excel.SetCellStyle(b.SheetName, startCell, startCell, style)
-	if err != nil {
-		return err
-	}
-	b.Excel.SetRowHeight(b.SheetName, b.Row, 26)
-
-	b.Excel.SetCellValue(b.SheetName, startCell, b.Title)
-	return nil
-}
-
-func (b *TestExcel) drawTableTitle() error {
-	b.Row++
-	var drawCol = func(prefix string, value string) error {
-		cell := fmt.Sprintf("%s%d", prefix, b.Row)
-		// left2Cell := fmt.Sprintf("%s%d", prefix, b.Row+1)
-
-		// err := b.Excel.MergeCell(b.SheetName, left1Cell, left2Cell)
-		// if err != nil {
-		// 	return err
-		// }
-		err := b.Excel.SetCellStyle(b.SheetName, cell, cell, b.AlignCenterStyle)
-		if err != nil {
-			return err
-		}
-
-		return b.Excel.SetCellValue(b.SheetName, cell, value)
-	}
-
-	drawCol("A", "题目")
-	drawCol("B", "类型")
-	drawCol("C", "选项A")
-	drawCol("D", "选项B")
-	drawCol("E", "选项C")
-	drawCol("F", "选项D")
-	drawCol("G", "分值")
-	drawCol("H", "答案")
-	b.Excel.SetRowHeight(b.SheetName, b.Row, 22)
-
-	return nil
-}
-
-func (b *TestExcel) drawTableContent() error {
-	b.Row++
-	var DrawRow = func(rowIndex int, values ...string) float64 {
-		charas := []string{"A", "B", "C", "D", "E", "F", "G", "H"}
-		// 获取该行最大行高
-		max := getRowHeight(values[0], b.getRangeWidth(charas[0]))
-		for i, c := range charas {
-			v := ""
-			if i < len(values) {
-				v = values[i]
-			}
-			b.Excel.SetCellValue(b.SheetName, fmt.Sprintf("%s%d", c, rowIndex), v)
-			val2Cel := fmt.Sprintf("%s%d", c, rowIndex)
-			b.Excel.SetCellStyle(b.SheetName, val2Cel, val2Cel, b.AlignCenterStyle)
-
-			if getRowHeight(v, b.getRangeWidth(c)) > max {
-				max = getRowHeight(v, b.getRangeWidth(c))
-			}
-		}
-		return max
-	}
-
-	tests := b.Content
-	if len(tests) > 0 {
-		for _, test := range tests {
-			rowMaxHeight := DrawRow(b.Row, test.Content, test.Type, test.Options["A"], test.Options["B"], test.Options["C"], test.Options["D"], fmt.Sprintf("%d", *test.Socre), test.Answer)
-			b.RowsHeightArray = append(b.RowsHeightArray, map[int]float64{b.Row: rowMaxHeight})
-			b.Row++
-		}
-	}
-
-	return nil
-}
-
-func (b *TestExcel) Draws() {
-	b.drawTitle()
-
-	b.drawTableTitle()
-	b.drawTableContent()
-	// 设置行高
-	b.setRowsHeight()
-}
-
-func NewTestExcel(f *excelize.File) *TestExcel {
-
-	border := []excelize.Border{
-		{Type: "top", Style: 1, Color: "000000"},
-		{Type: "left", Style: 1, Color: "000000"},
-		{Type: "right", Style: 1, Color: "000000"},
-		{Type: "bottom", Style: 1, Color: "000000"},
-	}
-
-	styleLeft, _ := f.NewStyle(&excelize.Style{
-		Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center", WrapText: true},
-		Border:    border,
-	})
-
-	b := &TestExcel{
-		Title:            "考核试题",
-		SheetName:        "Sheet1",
-		Excel:            f,
-		AlignCenterStyle: styleLeft,
-		RowMap:           map[string]int{"A": 0, "B": 1, "C": 2, "D": 3, "E": 4, "F": 5, "G": 6, "H": 7},
-		RowWidthArray:    []float64{17, 17, 12, 10, 12, 12, 12, 20},
-		RowsHeightArray:  make([]map[int]float64, 0),
-	}
-
-	// f.SetPageMargins(b.SheetName, excelize.PageMarginTop(1), excelize.PageMarginLeft(0), excelize.PageMarginRight(0))
-
-	return b
-}
-
-func (b *TestExcel) FormatToEmpty(str *string) {
-	if *str == "0" || *str == "0.000" {
-		*str = "-"
-	}
-
-}

+ 0 - 171
src/api/test.go

@@ -1,171 +0,0 @@
-package api
-
-import (
-	"copter-train/db/model"
-	"errors"
-	"fmt"
-	"net/url"
-	"nrhe-train/db/repo"
-	"nrhe-train/log"
-	"strconv"
-	"time"
-
-	"github.com/gin-gonic/gin"
-	"github.com/xuri/excelize/v2"
-	"go.mongodb.org/mongo-driver/bson"
-)
-
-const TESTS_TMPLATE_FILE = "./template"
-
-// 导入试题
-func ImportTest(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-	isAdmin, err := IsAdmin(c, apictx)
-	if err != nil {
-		return nil, err
-	}
-	if !isAdmin {
-		return nil, errors.New("没有权限")
-	}
-	db := c.Param("scope")
-	if len(db) == 0 {
-		return nil, errors.New("scope不能为空")
-	}
-	file, _, err := c.Request.FormFile("file")
-	if err != nil {
-		return nil, errors.New("文件错误")
-	}
-	excel, err := excelize.OpenReader(file)
-	if err != nil {
-		return nil, err
-	}
-	excelIndex := excel.GetActiveSheetIndex()
-	sheetName := excel.GetSheetName(excelIndex)
-	tests, err := excel.GetRows(sheetName)
-	if err != nil {
-		return nil, err
-	}
-	errors := []string{}
-
-	if len(tests) > 0 {
-		for index, ts := range tests {
-			rowNum := index + 1
-			// 标题行
-			if index == 0 {
-				continue
-			}
-			// 表头
-			if index == 1 {
-				continue
-			}
-			// 去除可能的空行
-			if len(ts) == 0 {
-				continue
-			}
-			// 去除可能的空行
-			if len(ts[0]) == 0 {
-				continue
-			}
-			// 问题(content) 试题类型(type)  (options)选项A 选项B 选项C 选项D 分值(score) (answer)答案
-			test := &model.Test{}
-			test.Content = ts[0]
-			test.Uid = apictx.User.ID
-			test.Type = ts[1]
-			socre, _ := strconv.Atoi(ts[6])
-			test.Socre = &socre
-			test.Answer = ts[7]
-
-			if ts[1] == "选择" {
-				test.Options = map[string]string{
-					"A": ts[2],
-					"B": ts[3],
-					"C": ts[4],
-					"D": ts[5],
-				}
-			}
-			if ts[1] == "判断" {
-				test.Options = map[string]string{
-					"T": "正确",
-					"F": "错误",
-				}
-			}
-			test.CreateTime = time.Now()
-			test.UpdateTime = time.Now()
-
-			_, err = repo.RepoAddDoc(apictx.CreateRepoCtx(), db, repo.CollectionTest, test)
-			if err != nil {
-				errors = append(errors, fmt.Sprintf("第%d行错误: %s", rowNum, "保存数据失败, 请检查数据格式是否正确"))
-				log.Error(err)
-			}
-
-		}
-	}
-
-	return errors, nil
-}
-
-// 导出试题
-func ExportTest(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-	isAdmin, err := IsAdmin(c, apictx)
-	if err != nil {
-		return nil, err
-	}
-	if !isAdmin {
-		return nil, errors.New("没有权限")
-	}
-	db := c.Param("scope")
-	if len(db) == 0 {
-		return nil, errors.New("scope不能为空")
-	}
-	f := excelize.NewFile()
-	index, _ := f.NewSheet("Sheet1")
-	f.SetActiveSheet(index)
-	f.SetDefaultFont("宋体")
-
-	testExcel := NewTestExcel(f)
-	testExcel.Title = fmt.Sprintf("%s-考核试题", db)
-
-	_, _, query := UtilQueryPageSize(c)
-	// 获取试题列表
-	tests := make([]*model.Test, 0)
-	err = repo.RepoSeachDocs(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
-		Db:          db,
-		CollectName: repo.CollectionTest,
-		Query:       query,
-		Sort:        bson.M{"createTime": 1},
-	}, &tests)
-	if err != nil {
-		return nil, err
-	}
-	testExcel.Content = tests
-	fmt.Println(len(tests))
-	testExcel.Draws()
-	fileName := url.PathEscape(fmt.Sprintf("%s-考核试题.xlsx", db))
-	c.Header("Content-Type", "application/octet-stream")
-	c.Header("Content-Disposition", "attachment; filename="+fileName)
-	c.Header("Content-Transfer-Encoding", "binary")
-
-	err = f.Write(c.Writer)
-	if err != nil {
-		return nil, err
-	}
-
-	return nil, nil
-}
-
-// 下载试题模板
-func TestTmplate(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-	db := c.Param("scope")
-	fmt.Println(db)
-	filename := "考核试题模板.xlsx"
-	// url.PathEscape将字符串中的特殊字符进行编码,使其符合URL规范
-	filename = url.PathEscape(filename)
-
-	// 设置下载的文件名
-	c.Writer.Header().Add("Content-Disposition", fmt.Sprintf("attachment; filename=%s", filename))
-
-	// 设置文件类型
-	c.Writer.Header().Add("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
-
-	c.File(TESTS_TMPLATE_FILE)
-	return nil, nil
-}

+ 2 - 2
src/api/user-excel.go

@@ -97,8 +97,8 @@ func (b *UserExcel) drawTableTitle() error {
 		return b.Excel.SetCellValue(b.SheetName, cell, value)
 	}
 
-	drawCol("A", "用户名")
-	drawCol("B", "编号")
+	drawCol("A", "账号")
+	drawCol("B", "昵称")
 	drawCol("C", "角色")
 	drawCol("D", "密码")
 	b.Excel.SetRowHeight(b.SheetName, b.Row, 22)

+ 23 - 24
src/api/user.go

@@ -5,7 +5,6 @@ import (
 	"fmt"
 	"net/url"
 	"nrhe-train/log"
-	"strconv"
 	"time"
 
 	"nrhe-train/db/model"
@@ -231,28 +230,28 @@ func UserProfile(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	return GetUserById(apictx, apictx.User.ID)
 }
 
-func UserLearnInc(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-	_time := c.Query("t")
-	increase, _ := strconv.Atoi(_time)
-	if increase < 1 {
-
-		return false, fmt.Errorf("增加学习时长小于1: %d", increase)
-	}
-	userInfo, err := GetUserById(apictx, apictx.User.ID)
-	if err != nil {
-		return false, errors.New("未找到该用户信息")
-	}
-	learnTime := userInfo.LearnTime
-	// 增加学习时长
-	newTime := learnTime + increase
-	_, err = repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), repo.CollectionUser, apictx.User.ID, &model.User{LearnTime: newTime})
-	if err != nil {
-		fmt.Println(err)
-		log.Error(err)
-		return false, errors.New("更新学习时长出错")
-	}
-	return true, nil
-}
+// func UserLearnInc(c *gin.Context, apictx *ApiSession) (interface{}, error) {
+// 	_time := c.Query("t")
+// 	increase, _ := strconv.Atoi(_time)
+// 	if increase < 1 {
+
+// 		return false, fmt.Errorf("增加学习时长小于1: %d", increase)
+// 	}
+// 	userInfo, err := GetUserById(apictx, apictx.User.ID)
+// 	if err != nil {
+// 		return false, errors.New("未找到该用户信息")
+// 	}
+// 	learnTime := userInfo.LearnTime
+// 	// 增加学习时长
+// 	newTime := learnTime + increase
+// 	_, err = repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), repo.CollectionUser, apictx.User.ID, &model.User{LearnTime: newTime})
+// 	if err != nil {
+// 		fmt.Println(err)
+// 		log.Error(err)
+// 		return false, errors.New("更新学习时长出错")
+// 	}
+// 	return true, nil
+// }
 
 // 根据id获取用户信息
 func GetUserById(apictx *ApiSession, id string) (*model.User, error) {
@@ -456,6 +455,6 @@ func UserTmplate(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	// 设置文件类型
 	c.Writer.Header().Add("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
 
-	c.File("./template/xxx.xlsx")
+	c.File("./template/用户信息模板.xlsx")
 	return nil, nil
 }

+ 1 - 1
src/db/model/examHistory.go

@@ -21,5 +21,5 @@ type ExamHistory struct {
 type Record struct {
 	Title     string `bson:"title,omitempty" json:"title"`
 	Result    string `bson:"result,omitempty" json:"result"`
-	IsCorrect bool   `bson:"isCorrect,omitempty" json:"isCorrect"`
+	IsCorrect *bool  `bson:"isCorrect,omitempty" json:"isCorrect"`
 }

+ 1 - 1
src/db/model/user.go

@@ -13,7 +13,7 @@ type User struct {
 	Password  string             `bson:"password,omitempty" json:"password,omitempty"`
 	Avatar    string             `bson:"avatar,omitempty" json:"avatar,omitempty"`
 	// 学习总时长
-	LearnTime int `bson:"learnTime,omitempty" json:"learnTime,omitempty"`
+	// LearnTime int `bson:"learnTime,omitempty" json:"learnTime,omitempty"`
 	// student,teacher,admin
 	Roles      []string  `bson:"roles,omitempty" json:"roles,omitempty"`
 	CreateTime time.Time `bson:"createTime,omitempty" json:"createTime,omitempty"`

+ 17 - 15
src/main.go

@@ -2,14 +2,13 @@ package main
 
 import (
 	"flag"
+	"fmt"
 	"nrhe-train/api"
 	"nrhe-train/bus"
 	"nrhe-train/conf"
 	"nrhe-train/db"
-	"nrhe-train/log"
 
 	"go.uber.org/dig"
-	"infish.cn/comm"
 )
 
 var confFile = flag.String("conf", "./app.yaml", "conf file")
@@ -31,17 +30,20 @@ func BuildApp() *dig.Container {
 }
 
 func main() {
-	flag.Parse()
-	app := BuildApp()
-	err := app.Invoke(func(svc *api.Service, bus *comm.NatsBus) error {
-		go bus.Run(nil)
-
-		svc.Run()
-		return nil
-	})
-
-	if err != nil {
-		log.Errorf("the pink service start fail %+v", err)
-		panic(err)
-	}
+	password := api.UtilMd5("123456")
+	fmt.Println(password)
+	// comm.AppMongoMiration()
+	// flag.Parse()
+	// app := BuildApp()
+	// err := app.Invoke(func(svc *api.Service, bus *comm.NatsBus) error {
+	// 	go bus.Run(nil)
+
+	// 	svc.Run()
+	// 	return nil
+	// })
+
+	// if err != nil {
+	// 	log.Errorf("the pink service start fail %+v", err)
+	// 	panic(err)
+	// }
 }