细节fix
This commit is contained in:
@@ -15,7 +15,7 @@ func (dao UserDAO) Insert(resource *entity.User) {
|
||||
}
|
||||
|
||||
// ID查询
|
||||
func (dao UserDAO) SelectOne(id uint) entity.User {
|
||||
func (dao UserDAO) SelectOne(id uint64) entity.User {
|
||||
var user entity.User
|
||||
config.SqlExcutor.First(&user, id)
|
||||
return user
|
||||
@@ -65,7 +65,7 @@ func (UserDAO) UpdateById(user *entity.User) {
|
||||
}
|
||||
|
||||
// 删除
|
||||
func (UserDAO) DeleteById(id uint) {
|
||||
func (UserDAO) DeleteById(id uint64) {
|
||||
user := entity.User{}
|
||||
user.ID = id
|
||||
config.SqlExcutor.Delete(&user)
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"lingye-gin/src/base"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
base.LingYeDO
|
||||
UserName string `gorm:"column:user_name;type:varchar(255);not null;index:idx_username"`
|
||||
NickName string `gorm:"column:nick_name;type:varchar(255)"`
|
||||
Email string `gorm:"column:email;type:varchar(255)"`
|
||||
PhoneNumber string `gorm:"column:phone_number;type:varchar(255)"`
|
||||
Sex string `gorm:"column:sex;type:varchar(255)"`
|
||||
Avatar string `gorm:"column:avatar;type:varchar(255)"`
|
||||
Password string `gorm:"column:password;type:varchar(255);not null"`
|
||||
Status string `gorm:"column:status;type:varchar(255);not null"`
|
||||
Remark string `gorm:"column:remark;type:text(0)"`
|
||||
}
|
||||
|
||||
// 设置User的表名为`sys_user`
|
||||
func (User) TableName() string {
|
||||
return "sys_user"
|
||||
}
|
||||
@@ -26,7 +26,7 @@ func DescribeUsers(c *gin.Context) {
|
||||
|
||||
func DescribeUserById(c *gin.Context) {
|
||||
id := c.Params.ByName("id")
|
||||
user := userService.DescribeUserById(util.StringToUInt(id))
|
||||
user := userService.DescribeUserById(util.StringToUInt64(id))
|
||||
if user.ID == 0 {
|
||||
c.JSON(http.StatusNotFound, gin.H{
|
||||
"code": http.StatusNotFound,
|
||||
@@ -54,7 +54,7 @@ func CreateUser(c *gin.Context) {
|
||||
|
||||
func ModifyUserById(c *gin.Context) {
|
||||
id := c.Params.ByName("id")
|
||||
localUser := userService.DescribeUserById(util.StringToUInt(id))
|
||||
localUser := userService.DescribeUserById(util.StringToUInt64(id))
|
||||
if localUser.ID == 0 {
|
||||
c.JSON(http.StatusNotFound, gin.H{
|
||||
"code": http.StatusNotFound,
|
||||
@@ -74,7 +74,7 @@ func ModifyUserById(c *gin.Context) {
|
||||
|
||||
func DeleteUserById(c *gin.Context) {
|
||||
id := c.Params.ByName("id")
|
||||
uid := util.StringToUInt(id)
|
||||
uid := util.StringToUInt64(id)
|
||||
localUser := userService.DescribeUserById(uid)
|
||||
if localUser.ID == 0 {
|
||||
c.JSON(http.StatusNotFound, gin.H{
|
||||
|
||||
@@ -21,7 +21,7 @@ func (service UserService) Save(resource *dto.UserDTO) {
|
||||
service.userDao.Insert(record)
|
||||
}
|
||||
|
||||
func (service UserService) RemoveById(id uint) {
|
||||
func (service UserService) RemoveById(id uint64) {
|
||||
if id == 0 {
|
||||
panic("id is zero")
|
||||
}
|
||||
@@ -41,6 +41,6 @@ func (service UserService) DescribeUsers(condition query.UserQuery) ([]entity.Us
|
||||
return service.userDao.SelectPage(condition)
|
||||
}
|
||||
|
||||
func (service UserService) DescribeUserById(id uint) entity.User {
|
||||
func (service UserService) DescribeUserById(id uint64) entity.User {
|
||||
return service.userDao.SelectOne(id)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user