cslms-api/internal/models/user.go
2023-12-27 17:31:49 +09:00

53 lines
2.6 KiB
Go

package models
import "time"
// CREATE TABLE `Users` (
// `id` bigint(20) NOT NULL AUTO_INCREMENT,
// `guid_id` longtext DEFAULT NULL,
// `first_name` longtext DEFAULT NULL,
// `last_name` longtext DEFAULT NULL,
// `user_name` longtext DEFAULT NULL,
// `password` longtext DEFAULT NULL,
// `gender` char(1) DEFAULT 'M' COMMENT 'M(남)/F(여)',
// `user_role` longtext DEFAULT NULL,
// `memo_cs` longtext DEFAULT NULL,
// `register_at` datetime(3) DEFAULT NULL,
// `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT '업데이트될때마다 자동저장',
// `phone_cs` longtext DEFAULT NULL,
// `upload_image` longtext DEFAULT NULL,
// PRIMARY KEY (`id`) USING BTREE,
// KEY `guid_id` (`guid_id`(768)),
// KEY `first_name` (`first_name`(768)),
// KEY `last_name` (`last_name`(768)),
// KEY `user_name` (`user_name`(768))
// ) ENGINE=InnoDB AUTO_INCREMENT=1000023 DEFAULT CHARSET=utf8mb4;
type User struct {
ID int64 `json:"id" db:"id" example:"100001" gorm:"column:id;primary_key;"`
GUID string `json:"guid_id" db:"guid_id" example:"137c1683-2ad6-4201-b256-253828b61c49" gorm:"column:guid_id;size:255;"`
FirstName string `json:"first_name" db:"first_name" example:"길순" gorm:"column:first_name;size:255;"`
LastName string `json:"last_name" db:"last_name" example:"홍" gorm:"column:last_name;size:255;"`
Username string `json:"user_name" db:"user_name" example:"user0" gorm:"column:user_name;size:50;uniqueIndex;"`
Password string `json:"-" db:"password" gorm:"column:password;size:255;not null;"`
Gender string `json:"gender" db:"gender" example:"F" gorm:"column:gender;size:1;"`
UserRole string `json:"user_role" db:"user_role" example:"member" gorm:"column:user_role;size:255;"`
Memo string `json:"memo_cs" db:"memo_cs" example:"사용자 메모" gorm:"column:memo_cs;size:255;"`
Phone string `json:"phone_cs" db:"phone_cs" example:"010-1234-5678" gorm:"column:phone_cs;size:255;"`
Image string `json:"upload_image" db:"upload_image" example:"image_url" gorm:"column:upload_image;size:255;"`
RegisterAt time.Time `json:"register_at" db:"regiser_at" gorm:"column:register_at;type:DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP;index;->:false"`
}
// 테이블이름 정의
func (User) TableName() string {
return "Users"
}
type UserListResponse struct {
Data []User `json:"data"`
Total int64 `json:"total" example:"90"`
Page int `json:"page" example:"1"`
TotalPage int64 `json:"totalPage" example:"9"`
PageSize int `json:"pageSize" example:"10"`
}