Skip to content

Conversation

@lanxi0320
Copy link

修复个人中心修改头像昵称不生效

@Azir-11 Azir-11 requested a review from Copilot November 5, 2025 04:26
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR restricts the fields that can be updated in the SetSelfInfo function to only HeaderImg and NickName, adding security controls for user self-updates.

Key Changes

  • Added Select() clause to limit updateable fields in SetSelfInfo to HeaderImg and NickName only

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

func (userService *UserService) SetSelfInfo(req system.SysUser) error {
return global.GVA_DB.Model(&system.SysUser{}).
Where("id=?", req.ID).
Select("HeaderImg", "NickName").
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Field names in the Select clause should use snake_case to match database column names ('header_img', 'nick_name') instead of struct field names. Looking at SetUserInfo (line 232), it correctly uses snake_case field names. This inconsistency may cause the update to fail or not work as intended.

Suggested change
Select("HeaderImg", "NickName").
Select("header_img", "nick_name").

Copilot uses AI. Check for mistakes.
func (userService *UserService) SetSelfInfo(req system.SysUser) error {
return global.GVA_DB.Model(&system.SysUser{}).
Where("id=?", req.ID).
Select("HeaderImg", "NickName").
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent indentation detected. The Select line uses spaces instead of tabs, which is inconsistent with the surrounding code style (lines 251-252, 254 use tabs).

Suggested change
Select("HeaderImg", "NickName").
Select("HeaderImg", "NickName").

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant