Parcourir la source

用户名修改,问题加备注

ice il y a 3 ans
Parent
commit
17665adeff

+ 2 - 2
server/api/v1/autocode/problem_info.go

@@ -45,9 +45,9 @@ func (problemInfoApi *ProblemInfoApi) CreateProblemInfo(c *gin.Context) {
 
 	if err := problemInfoService.CreateProblemInfo(problemInfo); err != nil {
 		global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
-		response.FailWithMessage("创建失败", c)
+		response.FailWithMessage("发布失败", c)
 	} else {
-		response.OkWithMessage("创建成功", c)
+		response.OkWithMessage("发布成功", c)
 	}
 }
 

+ 17 - 0
server/api/v1/system/sys_user.go

@@ -356,6 +356,23 @@ func (b *BaseApi) SetUserInfo(c *gin.Context) {
 	}
 }
 
+func (b *BaseApi) SetUserName(c *gin.Context) {
+	var user system.SysUser
+	_ = c.ShouldBindJSON(&user)
+	if err := utils.Verify(user, utils.IdVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
+		return
+	}
+	_, userNow := userService.FindUserById(int(user.ID))
+	userNow.Username = user.Username
+	if err, ReqUser := userService.SetUserName(userNow); err != nil {
+		global.GVA_LOG.Error("设置失败!", zap.Any("err", err))
+		response.FailWithMessage("设置失败", c)
+	} else {
+		response.OkWithDetailed(gin.H{"userInfo": ReqUser}, "设置成功", c)
+	}
+}
+
 // @Tags SysUser
 // @Summary 获取用户信息
 // @Security ApiKeyAuth

+ 92 - 1
server/docs/docs.go

@@ -697,6 +697,44 @@ var doc = `{
                     }
                 }
             }
+        },
+		"/user/setUserName": {
+            "put": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "consumes": [
+                    "application/json"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "SysUser"
+                ],
+                "summary": "设置用户信息",
+                "parameters": [
+                    {
+                        "description": "只用提交 ID, userName 就可以",
+                        "name": "data",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/system.SysUser"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "{\"success\":true,\"data\":{},\"msg\":\"设置成功\"}",
+                        "schema": {
+                            "type": "string"
+                        }
+                    }
+                }
+            }
         }
     },
     "definitions": {
@@ -770,6 +808,10 @@ var doc = `{
 					"description": "问题图片(多图用|分割)",
 					"type": "string"
 				},
+				"remark": {
+					"description": "问题备注",
+					"type": "string"
+				},
 				"video": {
 					"description": "问题视频",
 					"type": "string"
@@ -882,7 +924,56 @@ var doc = `{
                     "type": "string"
                 }
             }
-		}
+		},
+		"system.SysUser": {
+            "type": "object",
+            "properties": {
+                "activeColor": {
+                    "description": "活跃颜色",
+                    "type": "string"
+                },
+                "authorityId": {
+                    "description": "用户角色ID",
+                    "type": "string"
+                },
+                "baseColor": {
+                    "description": "基础颜色",
+                    "type": "string"
+                },
+                "createdAt": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "headerImg": {
+                    "description": "用户头像",
+                    "type": "string"
+                },
+                "ID": {
+                    "description": "主键ID",
+                    "type": "integer"
+                },
+                "nickName": {
+                    "description": "用户昵称",
+                    "type": "string"
+                },
+                "sideMode": {
+                    "description": "用户侧边主题",
+                    "type": "string"
+                },
+                "updatedAt": {
+                    "description": "更新时间",
+                    "type": "string"
+                },
+                "userName": {
+                    "description": "用户名",
+                    "type": "string"
+                },
+                "uuid": {
+                    "description": "用户UUID",
+                    "type": "string"
+                }
+            }
+        },
     },
     "securityDefinitions": {
         "ApiKeyAuth": {

+ 1 - 0
server/model/autocode/problem_info.go

@@ -23,6 +23,7 @@ type ProblemInfo struct {
 	HandImgs   string `json:"handImgs" form:"handImgs" gorm:"column:hand_imgs;comment:处理图片;type:varchar(255);"`
 	HandText   string `json:"handText" form:"handText" gorm:"column:hand_text;comment:处理内容;type:varchar(255);"`
 	Department string `json:"department" form:"department" gorm:"column:department;comment:责任部门;type:varchar(255);"`
+	Remark string `json:"remark" form:"remark" gorm:"column:remark;comment:问题备注;type:varchar(600);"`
 }
 
 // TableName ProblemInfo 表名

+ 1 - 0
server/router/system/sys_user.go

@@ -20,6 +20,7 @@ func (s *UserRouter) InitUserRouter(Router *gin.RouterGroup) {
 		userRouter.POST("setUserAuthority", baseApi.SetUserAuthority)     // 设置用户权限
 		userRouter.DELETE("deleteUser", baseApi.DeleteUser)               // 删除用户
 		userRouter.PUT("setUserInfo", baseApi.SetUserInfo)                // 设置用户信息
+		userRouter.PUT("setUserName", baseApi.SetUserName)                // 设置用户信息
 		userRouter.POST("setUserAuthorities", baseApi.SetUserAuthorities) // 设置用户权限组
 		userRouter.GET("getUserInfo", baseApi.GetUserInfo)                // 获取自身信息
 		userRouter.GET("getUserInfoById", baseApi.GetUserInfoById)        // 获取自身信息

+ 1 - 1
server/service/autocode/problem_info.go

@@ -64,6 +64,6 @@ func (problemInfoService *ProblemInfoService) GetProblemInfoInfoList(info autoCo
 	var problemInfos []autocode.ProblemInfo
 	// 如果有条件搜索 下方会自动创建搜索语句
 	err = db.Count(&total).Error
-	err = db.Limit(limit).Offset(offset).Find(&problemInfos).Error
+	err = db.Limit(limit).Offset(offset).Order("created_at desc").Find(&problemInfos).Error
 	return err, problemInfos, total
 }

+ 7 - 2
server/service/system/sys_user.go

@@ -154,6 +154,11 @@ func (userService *UserService) SetUserInfo(reqUser system.SysUser) (err error,
 	return err, reqUser
 }
 
+func (userService *UserService) SetUserName(reqUser system.SysUser) (err error, user system.SysUser) {
+	err = global.GVA_DB.Where("id=?", reqUser.ID).Save(reqUser).Error
+	return err, reqUser
+}
+
 //@author: [piexlmax](https://github.com/piexlmax)
 //@function: GetUserInfo
 //@description: 获取用户信息
@@ -172,10 +177,10 @@ func (userService *UserService) GetUserInfo(uuid uuid.UUID) (err error, user sys
 //@param: id int
 //@return: err error, user *model.SysUser
 
-func (userService *UserService) FindUserById(id int) (err error, user *system.SysUser) {
+func (userService *UserService) FindUserById(id int) (err error, user system.SysUser) {
 	var u system.SysUser
 	err = global.GVA_DB.Where("`id` = ?", id).First(&u).Error
-	return err, &u
+	return err, u
 }
 
 //@author: [SliverHorn](https://github.com/SliverHorn)

+ 3 - 0
web/src/view/problemInfo/problemInfo.vue

@@ -80,6 +80,7 @@
               <el-tag v-show="formData.status == 'Processed'" type="success">已处理</el-tag>
             </el-descriptions-item>
             <el-descriptions-item label="责任部门">{{ formData.department }}</el-descriptions-item>
+            <el-descriptions-item span="2"  label="问题备注">{{ formData.remark }}</el-descriptions-item>
           </el-descriptions>
         </el-card>
         <el-card class="box-card">
@@ -160,6 +161,7 @@ export default {
         position: '',
         matter: '',
         siteType: '',
+        remark: '',
         status: '',
         handImgs: '',
         handText: '',
@@ -253,6 +255,7 @@ export default {
         imgList: [],
         position: '',
         matter: '',
+        remark: '',
         handImgList: [],
         siteType: '',
         status: '',