change some file.

This commit is contained in:
skong 2024-01-23 01:44:35 +08:00
parent d5d56a0a0d
commit fa96b157c4
5 changed files with 21 additions and 13 deletions

View File

@ -73,8 +73,19 @@ all:
docker:
make build;
docker compose restart api-manage;
docker start api-manage;
docker logs api-manage;
.PHONY: start
# start server
start:
docker compose start && docker compose start && docker logs api-manage;
.PHONY: stop
# stop server
stop:
docker compose stop;
# show help
help:
@echo ''

View File

@ -8,9 +8,9 @@ import (
// Class 定义班级结构体
type Class struct {
ClassId string `json:"class_id" gorm:"type:varchar(11);not null;unique;primaryKey;comment:班级ID"`
ClassName string `json:"class_name" gorm:"unique;comment:班级名称"`
TeacherID string `json:"teacher_id" gorm:"not null;comment:教师ID"`
ClassId string `json:"class_id" gorm:"type:varchar(255);not null;unique;primaryKey;comment:班级ID"`
ClassName string `json:"class_name" gorm:"type:varchar(255);unique;comment:班级名称"`
TeacherID string `json:"teacher_id" gorm:"type:varchar(255);not null;comment:教师ID"`
CreatedAt time.Time `json:"created_at" gorm:"comment:创建时间"`
UpdatedAt time.Time `json:"updated_at" gorm:"comment:更新时间"`
}

View File

@ -75,6 +75,7 @@ func (receiver *UserCase) UpdateUser(ctx context.Context, req *remote.UpdateUser
Username: req.Username,
Password: auth.HashString(req.Password),
Role: req.Role,
Email: req.Email,
UpdatedAt: time.Now(),
}

View File

@ -9,8 +9,8 @@ services:
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_PORT=3306
# ports:
# - 33060:3306
ports:
- 33060:3306
api-redis:
image: redis:latest
networks:

View File

@ -12,7 +12,6 @@ import (
"net/http"
"github.com/Fromsko/gouitls/auth"
"github.com/Fromsko/gouitls/logs"
"github.com/gin-gonic/gin"
)
@ -80,15 +79,14 @@ func (u *APIUseCase) User() *Method {
},
Put: func(ctx *gin.Context) {
echo := logs.InitLogger()
userID := ctx.Param("user_id")
oldPasswd := ctx.PostForm("oldpwd")
newPasswd := ctx.PostForm("newpwd")
role := ctx.PostForm("role")
remoteUser(func(_ context.Context, usc user.UserServiceClient) {
remoteUser(func(c context.Context, usc user.UserServiceClient) {
// 检查密码是否正确
reply, _ := usc.GetUser(ctx, &user.GetUserRequest{UserId: userID})
reply, _ := usc.GetUser(c, &user.GetUserRequest{UserId: userID})
fmt.Println(reply.Data, reply.Code, reply.Msg)
if reply.Code == 400 {
@ -106,12 +104,10 @@ func (u *APIUseCase) User() *Method {
// 非管理员 不能修改角色信息
role = v.(string)
}
// 单独修改
email := ctx.DefaultPostForm("email", reply.Data.Email)
echo.Info(auth.HashString(oldPasswd))
echo.Info(reply.Data.Password)
// 密码不正确
if oldPasswd != "" && auth.HashString(oldPasswd) != reply.Data.Password {
ctx.JSON(200, common.OnFailed(400, "更新失败", "密码不正确"))
@ -119,7 +115,7 @@ func (u *APIUseCase) User() *Method {
}
// 更新用户
reply, err := usc.UpdateUser(ctx, &user.UpdateUserRequest{
reply, err := usc.UpdateUser(c, &user.UpdateUserRequest{
UserId: userID,
Username: reply.Data.Username,
Password: newPasswd,