Ohio-HYF пре 3 година
родитељ
комит
e6858e9d2e
7 измењених фајлова са 28 додато и 22 уклоњено
  1. 1 1
      config/dev.yaml
  2. 3 3
      config/pro.yaml
  3. 5 5
      db/user.go
  4. 7 6
      model/gorm_model/user.go
  5. 4 3
      service/enterprise.go
  6. 3 0
      service/product.go
  7. 5 4
      service/project.go

+ 1 - 1
config/dev.yaml

@@ -15,4 +15,4 @@ server:
   host: 0.0.0.0
   port: 8300
   session:
-    ttl: 60 # minute
+    ttl: -1 # minute

+ 3 - 3
config/pro.yaml

@@ -1,8 +1,8 @@
 mysql:
-  host: 139.9.53.143
+  host: 192.168.0.165
   port: 3306
-  user: talent
-  password: talentDB_123
+  user: test
+  password: testDB_123
   database: youngmini
 
 redis:

+ 5 - 5
db/user.go

@@ -8,7 +8,7 @@ import (
 	"gorm.io/gorm"
 )
 
-func CreateUser(ctx context.Context, user gorm_model.User) (*int64, error) {
+func CreateUser(ctx context.Context, user gorm_model.YounggeeUser) (*int64, error) {
 	db := GetReadDB(ctx)
 	err := db.Create(&user).Error
 	if err != nil {
@@ -18,9 +18,9 @@ func CreateUser(ctx context.Context, user gorm_model.User) (*int64, error) {
 }
 
 //GetUserByPhone 查不到返回空
-func GetUserByPhone(ctx context.Context, phone string) (*gorm_model.User, error) {
+func GetUserByPhone(ctx context.Context, phone string) (*gorm_model.YounggeeUser, error) {
 	db := GetReadDB(ctx)
-	user := &gorm_model.User{}
+	user := &gorm_model.YounggeeUser{}
 	err := db.Model(user).Where("phone = ?", phone).First(user).Error
 	if err != nil {
 		if err == gorm.ErrRecordNotFound {
@@ -33,9 +33,9 @@ func GetUserByPhone(ctx context.Context, phone string) (*gorm_model.User, error)
 }
 
 //GetUserByPhone 查不到返回空
-func GetUserByID(ctx context.Context, ID int64) (*gorm_model.User, error) {
+func GetUserByID(ctx context.Context, ID int64) (*gorm_model.YounggeeUser, error) {
 	db := GetReadDB(ctx)
-	user := &gorm_model.User{}
+	user := &gorm_model.YounggeeUser{}
 	err := db.Model(user).Where("id = ?", ID).First(user).Error
 	if err != nil {
 		if err == gorm.ErrRecordNotFound {

+ 7 - 6
model/gorm_model/user.go

@@ -5,7 +5,7 @@ import (
 	"time"
 )
 
-type User struct {
+type YounggeeUser struct {
 	ID            int64       `gorm:"column:id;primary_key;AUTO_INCREMENT"` // 用户表id
 	User          string    `gorm:"column:user"`                          // 账号
 	Username      string    `gorm:"column:username"`                      // 后台用户名
@@ -14,12 +14,13 @@ type User struct {
 	Role          string    `gorm:"column:role"`                          // 角色 1,超级管理员; 2,管理员;3,企业用户
 	Phone         string    `gorm:"column:phone"`                         // 绑定手机
 	Email         string    `gorm:"column:email"`                         // 电子邮件
-	LastLogintime time.Time `gorm:"column:last_login_time"`               // 最后一次登录时间
-	UserState     string    `gorm:"column:user_state"`                    // 0,禁用,1,正常
+	LastLoginTime time.Time `gorm:"column:last_login_time"`               // 最后一次登录时间
+	UserState     string    `gorm:"column:user_state;default:1;NOT NULL"` // 0,禁用,1,正常
 	CreatedAt     time.Time `gorm:"column:created_at"`                    // 创建时间
 	UpdatedAt     time.Time `gorm:"column:updated_at"`                    // 更新时间
 }
 
-func (m *User) TableName() string {
-	return "user"
-}
+func (m *YounggeeUser) TableName() string {
+	return "younggee_user"
+}
+

+ 4 - 3
service/enterprise.go

@@ -2,11 +2,12 @@ package service
 
 import (
 	"context"
-	log "github.com/sirupsen/logrus"
 	"time"
 	"youngee_b_api/db"
 	"youngee_b_api/model/gorm_model"
 	"youngee_b_api/model/http_model"
+
+	log "github.com/sirupsen/logrus"
 )
 
 var Enterprise *enterprise
@@ -15,7 +16,7 @@ type enterprise struct {
 }
 
 func (*enterprise) CreateEnterpriseUser(ctx context.Context, newEnterprise http_model.RegisterRequest) (*http_model.RegisterData, error) {
-	user := gorm_model.User{
+	user := gorm_model.YounggeeUser{
 		Phone:         newEnterprise.Phone,
 		User:          "1001",
 		Username:      newEnterprise.BusinessName,
@@ -23,7 +24,7 @@ func (*enterprise) CreateEnterpriseUser(ctx context.Context, newEnterprise http_
 		RealName:      newEnterprise.RealName,
 		Role:          "3",
 		Email:         newEnterprise.Email,
-		LastLogintime: time.Now().UTC().Local(),
+		LastLoginTime: time.Now().UTC().Local(),
 	}
 	userId, err := db.CreateUser(ctx, user)
 	if err != nil {

+ 3 - 0
service/product.go

@@ -116,6 +116,9 @@ func (*product) FindByID(ctx context.Context, productID int64) (*http_model.Find
 	if err != nil {
 		return nil, err
 	}
+	if product == nil {
+		return nil, nil
+	}
 	productPhotos, err := db.GetProductPhotoByProductID(ctx, productID)
 	if err != nil {
 		return nil, err

+ 5 - 4
service/project.go

@@ -3,14 +3,14 @@ package service
 import (
 	"context"
 	"fmt"
-	"github.com/issue9/conv"
-	"github.com/sirupsen/logrus"
-	"time"
 	"youngee_b_api/db"
 	"youngee_b_api/model/common_model"
 	"youngee_b_api/model/gorm_model"
 	"youngee_b_api/model/http_model"
 	"youngee_b_api/pack"
+
+	"github.com/issue9/conv"
+	"github.com/sirupsen/logrus"
 )
 
 var Project *project
@@ -34,7 +34,7 @@ func (*project) Create(ctx context.Context, newProject http_model.CreateProjectR
 		TalentType:      newProject.TalentType,
 		ProjectPlatform: newProject.ProjectPlatform,
 		ProjectForm:     newProject.ProjectForm,
-		RecruitDdl:      time.Now().UTC().Local(),
+		RecruitDdl:      newProject.RecruitDdl,
 		ProjectDetail:   newProject.ProjectDetail,
 		ContentType:     newProject.ContentType,
 		EnterpriseID:    enterpriseID,
@@ -194,6 +194,7 @@ func (*project) GetPorjectDetail(ctx context.Context, projectID int64) (*http_mo
 		TalentType:      conv.MustString(project.TalentType),
 		RecruitDdl:      project.RecruitDdl,
 		ContentType:     conv.MustString(project.ContentType),
+		ProjectDetail:   conv.MustString(project.ProjectDetail),
 		ProductID:       conv.MustString(project.ProductID),
 		EnterpriseID:    conv.MustString(project.EnterpriseID),
 		CreateAt:        project.CreatedAt,