animeic 2 年之前
父节点
当前提交
cbddc5d091
共有 4 个文件被更改,包括 10 次插入5 次删除
  1. 二进制
      oilseal-train/.~用户列表.xlsx
  2. 4 1
      oilseal-train/api/test.go
  3. 6 4
      oilseal-train/api/user.go
  4. 二进制
      oilseal-train/用户列表.xlsx

二进制
oilseal-train/.~用户列表.xlsx


+ 4 - 1
oilseal-train/api/test.go

@@ -19,6 +19,7 @@ func Test(r *GinRouter) {
 	r.POSTJWT("/test/delete/:id", TestDelete)
 }
 
+// 新增
 func TestAdd(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	err := IsAdmin(apictx)
 	if err != nil {
@@ -49,6 +50,7 @@ func TestAdd(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	return repo.RepoAddDoc(apictx.CreateRepoCtx(), repo.CollectionTest, &form)
 }
 
+// 列表
 func TestList(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	// err := IsAdmin(apictx)
 	// if err != nil {
@@ -87,6 +89,7 @@ func TestList(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	return result, err
 }
 
+// 更新
 func TestEdit(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	// 操作用户为admin
 	err := IsAdmin(apictx)
@@ -105,7 +108,7 @@ func TestEdit(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	return repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), repo.CollectionTest, form.Id.Hex(), &form)
 }
 
-// 删除用户
+// 删除
 func TestDelete(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	// 操作用户为admin
 	err := IsAdmin(apictx)

+ 6 - 4
oilseal-train/api/user.go

@@ -274,8 +274,8 @@ func UserExportXls(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	}
 
 	setCellKey := map[string]string{
-		"A": "name",
-		"B": "loginName",
+		"A": "loginName",
+		"B": "name",
 		"C": "role",
 		"D": "password",
 	}
@@ -298,13 +298,15 @@ func UserExportXls(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	}
 	// 另存为
 	_ = os.MkdirAll("excel", os.ModePerm)
-	filename1 := time.Now().Format("20060102150405") + ".xlsx"
+	// filename1 := time.Now().Format("20060102150405") + ".xlsx"
+	filename1 := "用户列表.xlsx"
 	err = f.SaveAs(filename1)
 	if err != nil {
 		return nil, err
 	}
 
-	filename := time.Now().Format("20060102150405") + ".xlsx"
+	// filename := time.Now().Format("20060102150405") + ".xlsx"
+	filename := "用户列表.xlsx"
 	c.Header("Content-Type", "application/octet-stream")
 	c.Header("Content-Disposition", fmt.Sprintf("attachment; filename=%s", filename))
 	c.Header("Content-Transfer-Encoding", "binary")

二进制
oilseal-train/用户列表.xlsx