| @@ -285,7 +285,8 @@ class UsersController < ApplicationController | |||||
| :gender, :location, :location_city, | :gender, :location, :location_city, | ||||
| :occupation, :technical_title, | :occupation, :technical_title, | ||||
| :school_id, :department_id, :province, :city, | :school_id, :department_id, :province, :city, | ||||
| :custom_department, :identity, :student_id, :description] | |||||
| :custom_department, :identity, :student_id, :description, | |||||
| :show_email, :show_location, :show_department] | |||||
| ) | ) | ||||
| end | end | ||||
| @@ -1,7 +1,7 @@ | |||||
| <!-- | <!-- | ||||
| * @Date: 2021-03-01 10:35:21 | * @Date: 2021-03-01 10:35:21 | ||||
| * @LastEditors: viletyy | * @LastEditors: viletyy | ||||
| * @LastEditTime: 2021-06-02 16:40:02 | |||||
| * @LastEditTime: 2021-06-03 10:18:53 | |||||
| * @FilePath: /forgeplus/app/docs/slate/source/includes/_users.md | * @FilePath: /forgeplus/app/docs/slate/source/includes/_users.md | ||||
| --> | --> | ||||
| # Users | # Users | ||||
| @@ -66,13 +66,17 @@ await octokit.request('PATCH/PUT /api/users/:login.json') | |||||
| ### 请求字段说明: | ### 请求字段说明: | ||||
| 参数 | 类型 | 字段说明 | 参数 | 类型 | 字段说明 | ||||
| --------- | ----------- | ----------- | --------- | ----------- | ----------- | ||||
| |user.nickname |string |用户昵称 | | |||||
| |user.image |string/file |用户头像 | | |||||
| |user.nickname |string |用户昵称 | | |||||
| |user.image |base64/file |用户头像 | | |||||
| |user.user_extension_attributes.gender |int |性别, 0男 1女 | | |user.user_extension_attributes.gender |int |性别, 0男 1女 | | ||||
| |user.user_extension_attributes.province |string |省份 | | |user.user_extension_attributes.province |string |省份 | | ||||
| |user.user_extension_attributes.city |string |城市 | | |user.user_extension_attributes.city |string |城市 | | ||||
| |user.user_extension_attributes.description |string |个性签名 | | |||||
| |user.user_extension_attributes.description |string |简介 | | |||||
| |user.user_extension_attributes.custom_department|string |单位名称 | | |user.user_extension_attributes.custom_department|string |单位名称 | | ||||
| |user.user_extension_attributes.technical_title |string |职业 | | |||||
| |user.user_extension_attributes.show_email |bool |是否展示邮箱 | | |||||
| |user.user_extension_attributes.show_location |bool |是否展示位置 | | |||||
| |user.user_extension_attributes.show_department |bool |是否展示公司 | | |||||
| > 请求的JSON示例: | > 请求的JSON示例: | ||||
| @@ -181,7 +181,9 @@ class User < Owner | |||||
| attr_accessor :password, :password_confirmation | attr_accessor :password, :password_confirmation | ||||
| delegate :description, :gender, :department_id, :school_id, :location, :location_city, :technical_title, :province, :city, :custom_department, to: :user_extension, allow_nil: true | |||||
| delegate :description, :gender, :department_id, :school_id, :location, :location_city, | |||||
| :show_email, :show_location, :show_department, | |||||
| :technical_title, :province, :city, :custom_department, to: :user_extension, allow_nil: true | |||||
| before_save :update_hashed_password | before_save :update_hashed_password | ||||
| after_create do | after_create do | ||||
| @@ -25,6 +25,9 @@ | |||||
| # province :string(255) | # province :string(255) | ||||
| # city :string(255) | # city :string(255) | ||||
| # custom_department :string(255) | # custom_department :string(255) | ||||
| # show_email :boolean default("0") | |||||
| # show_location :boolean default("0") | |||||
| # show_department :boolean default("0") | |||||
| # | # | ||||
| # Indexes | # Indexes | ||||
| # | # | ||||
| @@ -19,8 +19,8 @@ json.common_projects_count @projects_common_count | |||||
| json.mirror_projects_count @projects_mirrior_count | json.mirror_projects_count @projects_mirrior_count | ||||
| json.sync_mirror_projects_count @projects_sync_mirrior_count | json.sync_mirror_projects_count @projects_sync_mirrior_count | ||||
| json.created_time format_time(@user.created_on) | json.created_time format_time(@user.created_on) | ||||
| json.email @user.mail | |||||
| json.province @user.province | |||||
| json.city @user.city | |||||
| json.custom_department @user.custom_department | |||||
| json.email @user.show_email ? @user.mail : nil | |||||
| json.province @user.show_location ? @user.province : nil | |||||
| json.city @user.show_location ? @user.city : nil | |||||
| json.custom_department @user.show_department ? @user.custom_department : nil | |||||
| json.description @user.description | json.description @user.description | ||||
| @@ -0,0 +1,7 @@ | |||||
| class AddShowConditionToUserExtensions < ActiveRecord::Migration[5.2] | |||||
| def change | |||||
| add_column :user_extensions, :show_email, :boolean, default: false | |||||
| add_column :user_extensions, :show_location, :boolean, default: false | |||||
| add_column :user_extensions, :show_department, :boolean, default: false | |||||
| end | |||||
| end | |||||
| @@ -617,7 +617,7 @@ Success — a happy kitten is an authenticated kitten! | |||||
| <!-- | <!-- | ||||
| * @Date: 2021-03-01 10:35:21 | * @Date: 2021-03-01 10:35:21 | ||||
| * @LastEditors: viletyy | * @LastEditors: viletyy | ||||
| * @LastEditTime: 2021-06-02 16:40:02 | |||||
| * @LastEditTime: 2021-06-03 10:18:53 | |||||
| * @FilePath: /forgeplus/app/docs/slate/source/includes/_users.md | * @FilePath: /forgeplus/app/docs/slate/source/includes/_users.md | ||||
| --> | --> | ||||
| <h1 id='users'>Users</h1><h2 id='1ae74893b1'>获取当前登陆用户信息</h2> | <h1 id='users'>Users</h1><h2 id='1ae74893b1'>获取当前登陆用户信息</h2> | ||||
| @@ -704,7 +704,7 @@ Success — a happy kitten is an authenticated kitten! | |||||
| </tr> | </tr> | ||||
| <tr> | <tr> | ||||
| <td>user.image</td> | <td>user.image</td> | ||||
| <td>string/file</td> | |||||
| <td>base64/file</td> | |||||
| <td>用户头像</td> | <td>用户头像</td> | ||||
| </tr> | </tr> | ||||
| <tr> | <tr> | ||||
| @@ -725,13 +725,33 @@ Success — a happy kitten is an authenticated kitten! | |||||
| <tr> | <tr> | ||||
| <td>user.user_extension_attributes.description</td> | <td>user.user_extension_attributes.description</td> | ||||
| <td>string</td> | <td>string</td> | ||||
| <td>个性签名</td> | |||||
| <td>简介</td> | |||||
| </tr> | </tr> | ||||
| <tr> | <tr> | ||||
| <td>user.user_extension_attributes.custom_department</td> | <td>user.user_extension_attributes.custom_department</td> | ||||
| <td>string</td> | <td>string</td> | ||||
| <td>单位名称</td> | <td>单位名称</td> | ||||
| </tr> | </tr> | ||||
| <tr> | |||||
| <td>user.user_extension_attributes.technical_title</td> | |||||
| <td>string</td> | |||||
| <td>职业</td> | |||||
| </tr> | |||||
| <tr> | |||||
| <td>user.user_extension_attributes.show_email</td> | |||||
| <td>bool</td> | |||||
| <td>是否展示邮箱</td> | |||||
| </tr> | |||||
| <tr> | |||||
| <td>user.user_extension_attributes.show_location</td> | |||||
| <td>bool</td> | |||||
| <td>是否展示位置</td> | |||||
| </tr> | |||||
| <tr> | |||||
| <td>user.user_extension_attributes.show_department</td> | |||||
| <td>bool</td> | |||||
| <td>是否展示公司</td> | |||||
| </tr> | |||||
| </tbody></table> | </tbody></table> | ||||
| <blockquote> | <blockquote> | ||||