Browse Source

用户中心

yuliang1112 2 years ago
parent
commit
47ef25fd53
55 changed files with 2447 additions and 94 deletions
  1. 29 0
      .idea/watcherTasks.xml
  2. 31 0
      consts/product.go
  3. 49 9
      consts/project.go
  4. 52 0
      db/product.go
  5. 17 0
      db/product_photo.go
  6. 205 13
      db/project.go
  7. 78 0
      db/talent.go
  8. 216 3
      db/user.go
  9. 21 0
      dockerfile
  10. 57 0
      handler/account_income.go
  11. 63 0
      handler/create_user.go
  12. 67 0
      handler/creator_list.go
  13. 57 0
      handler/disabled_user.go
  14. 67 0
      handler/enterprise_user.go
  15. 55 0
      handler/get_user_list.go
  16. 2 1
      handler/login.go
  17. 57 0
      handler/platform_acc_info.go
  18. 82 0
      handler/product_create.go
  19. 62 0
      handler/product_findAll.go
  20. 58 0
      handler/project_all.go
  21. 58 0
      handler/project_create.go
  22. 1 1
      handler/project_show.go
  23. 88 0
      handler/project_taskList.go
  24. 61 0
      handler/update_user_info.go
  25. 7 0
      model/common_model/creator_list.go
  26. 7 0
      model/common_model/enterprise_user_conditions.go
  27. 16 0
      model/gorm_model/delivery.go
  28. 1 1
      model/gorm_model/platform_account_info.go
  29. 1 0
      model/gorm_model/talent.go
  30. 25 0
      model/http_model/account_income.go
  31. 4 3
      model/http_model/code_login.go
  32. 18 0
      model/http_model/create_user.go
  33. 33 0
      model/http_model/creator_list.go
  34. 14 0
      model/http_model/disabled_user.go
  35. 42 0
      model/http_model/enterprise_user.go
  36. 28 0
      model/http_model/platform_acc_info.go
  37. 32 0
      model/http_model/product_create.go
  38. 1 0
      model/http_model/product_findall.go
  39. 29 0
      model/http_model/project_all.go
  40. 45 0
      model/http_model/project_create.go
  41. 19 0
      model/http_model/update_user_info.go
  42. 29 0
      model/http_model/user_list.go
  43. 28 0
      pack/all_project.go
  44. 14 0
      pack/creator_list_conditions.go
  45. 14 0
      pack/enterprise_user_conditions.go
  46. 26 0
      pack/platform.go
  47. 17 0
      pack/project_taskList_conditions.go
  48. 54 0
      pack/project_task_list.go
  49. 77 0
      pack/user_list.go
  50. 16 11
      route/init.go
  51. 20 16
      service/login_auth.go
  52. 102 0
      service/product.go
  53. 141 36
      service/project.go
  54. 39 0
      service/user.go
  55. 15 0
      util/deduplication.go

+ 29 - 0
.idea/watcherTasks.xml

@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectTasksOptions">
+    <TaskOptions isEnabled="true">
+      <option name="arguments" value="fmt $FilePath$" />
+      <option name="checkSyntaxErrors" value="true" />
+      <option name="description" />
+      <option name="exitCodeBehavior" value="ERROR" />
+      <option name="fileExtension" value="go" />
+      <option name="immediateSync" value="false" />
+      <option name="name" value="go fmt" />
+      <option name="output" value="$FilePath$" />
+      <option name="outputFilters">
+        <array />
+      </option>
+      <option name="outputFromStdout" value="false" />
+      <option name="program" value="$GoExecPath$" />
+      <option name="runOnExternalChanges" value="false" />
+      <option name="scopeName" value="Project Files" />
+      <option name="trackOnlyRoot" value="true" />
+      <option name="workingDir" value="$ProjectFileDir$" />
+      <envs>
+        <env name="GOROOT" value="$GOROOT$" />
+        <env name="GOPATH" value="$GOPATH$" />
+        <env name="PATH" value="$GoBinDirs$" />
+      </envs>
+    </TaskOptions>
+  </component>
+</project>

+ 31 - 0
consts/product.go

@@ -0,0 +1,31 @@
+package consts
+
+var projectTypeMap = map[int64]string{
+	1:  "3C及电器",
+	2:  "食品饮料",
+	3:  "服装配饰",
+	4:  "医疗",
+	5:  "房地产",
+	6:  "家居建材",
+	7:  "教育培训",
+	8:  "出行旅游",
+	9:  "游戏",
+	10: "互联网平台",
+	11: "汽车",
+	12: "文体娱乐",
+	13: "影视传媒",
+	14: "线下店铺",
+	15: "软件服务",
+	16: "美妆",
+	17: "母婴宠物",
+	18: "日化",
+	19: "其他",
+}
+
+func GetProjectTypes(projectType int64) string {
+	toast, contain := projectTypeMap[projectType]
+	if contain {
+		return toast
+	}
+	return "未知"
+}

+ 49 - 9
consts/project.go

@@ -1,15 +1,15 @@
 package consts
 
 var projectStatusMap = map[int64]string{
-	1: "创建中",
-	2: "待审核",
-	3: "审核通过",
-	4: "招募中",
-	5: "招募完毕",
-	6: "待支付",
-	7: "已支付",
-	8: "失效",
-	9: "执行中",
+	1:  "创建中",
+	2:  "待审核",
+	3:  "审核通过",
+	4:  "招募中",
+	5:  "招募完毕",
+	6:  "待支付",
+	7:  "已支付",
+	8:  "失效",
+	9:  "执行中",
 	10: "已结案",
 }
 
@@ -66,3 +66,43 @@ func GetProjectContentType(status int64) string {
 	}
 	return "未知"
 }
+
+var UserRoleTypeMap = map[string]string{
+	"1": "超级管理员",
+	"2": "普通管理员",
+	"3": "企业用户",
+}
+
+func GetUserRoleType(status string) string {
+	toast, contain := UserRoleTypeMap[status]
+	if contain {
+		return toast
+	}
+	return "未知"
+}
+
+var UserStateTypeMap = map[string]string{
+	"0": "禁用",
+	"1": "正常",
+}
+
+func GetUserStateType(status string) string {
+	toast, contain := UserStateTypeMap[status]
+	if contain {
+		return toast
+	}
+	return "未知"
+}
+
+var CreatorIsBindAccount = map[int]string{
+	0: "否",
+	1: "是",
+}
+
+func GetCreatorIsBindAccountType(status int) string {
+	toast, contain := CreatorIsBindAccount[status]
+	if contain {
+		return toast
+	}
+	return "未知"
+}

+ 52 - 0
db/product.go

@@ -2,10 +2,20 @@ package db
 
 import (
 	"context"
+	"github.com/caixw/lib.go/conv"
 	"gorm.io/gorm"
 	"youngee_m_api/model/gorm_model"
 )
 
+func CreateProduct(ctx context.Context, product gorm_model.YounggeeProduct) (*int64, error) {
+	db := GetReadDB(ctx)
+	err := db.Create(&product).Error
+	if err != nil {
+		return nil, err
+	}
+	return &product.ProductID, nil
+}
+
 func GetProductByID(ctx context.Context, productID int64) (*gorm_model.YounggeeProduct, error) {
 	db := GetReadDB(ctx)
 	product := &gorm_model.YounggeeProduct{}
@@ -19,3 +29,45 @@ func GetProductByID(ctx context.Context, productID int64) (*gorm_model.YounggeeP
 	}
 	return product, nil
 }
+
+func GetEnterpriseIDByUserID(ctx context.Context, UserId string) int64 {
+	db := GetReadDB(ctx)
+	enterpriseInfo := gorm_model.Enterprise{}
+	userId := conv.MustInt64(UserId, 0)
+	err := db.Where("user_id = ?", userId).Find(&enterpriseInfo).Error
+	if err != nil {
+		return 0
+	}
+	enterpriseID := enterpriseInfo.EnterpriseID
+	return enterpriseID
+}
+
+func GetProductByEnterpriseID(ctx context.Context, enterpriseID int64) ([]gorm_model.YounggeeProduct, error) {
+	db := GetReadDB(ctx)
+	var products []gorm_model.YounggeeProduct
+	err := db.Where("enterprise_id = ?", enterpriseID).Find(&products).Error
+	if err != nil {
+		return nil, err
+	}
+	return products, nil
+}
+
+func GetEnterpriseIDByProductID(ctx context.Context, ProductID int64) int64 {
+	db := GetReadDB(ctx)
+	ProjectInfo := gorm_model.ProjectInfo{}
+	err := db.Where("product_id = ?", ProductID).Find(&ProjectInfo).Error
+	if err != nil {
+		return 0
+	}
+	enterpriseID := ProjectInfo.EnterpriseID
+	return enterpriseID
+}
+
+func UpdateProduct(ctx context.Context, product gorm_model.YounggeeProduct) (*int64, error) {
+	db := GetReadDB(ctx)
+	err := db.Model(&product).Updates(product).Error
+	if err != nil {
+		return nil, err
+	}
+	return &product.ProductID, nil
+}

+ 17 - 0
db/product_photo.go

@@ -32,3 +32,20 @@ func DeleteProjectPhotoByProjecttID(ctx context.Context, productID int64) error
 	}
 	return nil
 }
+
+func DeleteProductPhotoByProductID(ctx context.Context, productID int64) error {
+	db := GetReadDB(ctx)
+	err := db.Where("product_id = ?", productID).Delete(&gorm_model.YounggeeProductPhoto{}).Error
+	if err != nil {
+		return err
+	}
+	return nil
+}
+func CreateProductPhoto(ctx context.Context, productPhotos []gorm_model.YounggeeProductPhoto) error {
+	db := GetReadDB(ctx)
+	err := db.Create(&productPhotos).Error
+	if err != nil {
+		return err
+	}
+	return nil
+}

+ 205 - 13
db/project.go

@@ -9,12 +9,13 @@ import (
 	"reflect"
 	"youngee_m_api/model/common_model"
 	"youngee_m_api/model/gorm_model"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/pack"
 	"youngee_m_api/util"
 )
 
 func GetFullProjectList(ctx context.Context, pageSize, pageNum int32, condition *common_model.ProjectCondition) ([]*gorm_model.ProjectInfo, int64, error) {
 	db := GetReadDB(ctx)
-	// 根据企业id过滤
 	db = db.Debug().Model(gorm_model.ProjectInfo{})
 	// 根据Project条件过滤
 	conditionType := reflect.TypeOf(condition).Elem()
@@ -24,7 +25,9 @@ func GetFullProjectList(ctx context.Context, pageSize, pageNum int32, condition
 		tag := field.Tag.Get("condition")
 		value := conditionValue.FieldByName(field.Name)
 		if tag == "project_status" && util.IsBlank(value) {
-			db = db.Where(fmt.Sprintf("project_status != 1"))
+			db = db.Where(fmt.Sprintf("project_status != 3"))
+			db = db.Where(fmt.Sprintf("project_status != 5"))
+			db = db.Where(fmt.Sprintf("project_status != 7"))
 		}
 		if !util.IsBlank(value) && tag != "updated_at" && tag != "project_name" {
 			db = db.Where(fmt.Sprintf("%s = ?", tag), value.Interface())
@@ -48,7 +51,7 @@ func GetFullProjectList(ctx context.Context, pageSize, pageNum int32, condition
 	offset := pageSize * pageNum // assert pageNum start with 0
 	err := db.Order("project_id").Limit(int(limit)).Offset(int(offset)).Find(&fullProjects).Error
 	if err != nil {
-		logrus.WithContext(ctx).Errorf("[GetFullProjectList] error query mysql total, err:%+v", err)
+		logrus.WithContext(ctx).Errorf("[GetFullProjectList] error query mysql find, err:%+v", err)
 		return nil, 0, err
 	}
 	return fullProjects, total, nil
@@ -97,27 +100,216 @@ func UpdateProject(ctx context.Context, project gorm_model.ProjectInfo) (*int64,
 	return &project.ProjectID, nil
 }
 
-func ApproveProject(ctx context.Context, projectId string,isApprove int64) (error error,message string) {
-	project_id := conv.MustInt64(projectId,0)
+func ApproveProject(ctx context.Context, projectId string, isApprove int64) (error error, message string) {
+	project_id := conv.MustInt64(projectId, 0)
 	db := GetReadDB(ctx)
 	projectInfo := gorm_model.ProjectInfo{}
-	db = db.Debug().Model(gorm_model.ProjectInfo{}).Where("project_id = ?",project_id).First(&projectInfo)
-	if isApprove == 1 &&  projectInfo.ProjectStatus == 2{
+	db = db.Debug().Model(gorm_model.ProjectInfo{}).Where("project_id = ?", project_id).First(&projectInfo)
+	if isApprove == 1 && projectInfo.ProjectStatus == 2 {
 		err := db.Update("project_status", 4).Error
 		message = "审核通过"
 		if err != nil {
 			logrus.Println("DB AutoUpdateStatus error :", err)
-			return err,""
+			return err, ""
 		}
-	}else if isApprove == 2 &&  projectInfo.ProjectStatus == 2{
+	} else if isApprove == 2 && projectInfo.ProjectStatus == 2 {
 		err := db.Update("project_status", 8).Error
 		message = "项目存在风险已禁止发布"
 		if err != nil {
 			logrus.Println("DB AutoUpdateStatus error :", err)
-			return err,""
+			return err, ""
+		}
+	} else {
+		return nil, "操作失败"
+	}
+	return nil, message
+}
+
+func GetAllProject(ctx context.Context, pageSize, pageNum int32) ([]*http_model.GetAllProjectPreview, int64, error) {
+	db := GetReadDB(ctx)
+	db = db.Debug().Model(gorm_model.ProjectInfo{})
+	var allProjects []*http_model.GetAllProjectPreview
+	// 查询总数
+	var total int64
+	var fullProjects []*gorm_model.ProjectInfo
+	if err := db.Count(&total).Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[GetAllProject] error query mysql total, err:%+v", err)
+		return nil, 0, err
+	}
+	// 查询该页数据
+	limit := pageSize
+	offset := pageSize * pageNum // assert pageNum start with 0
+	err := db.Order("updated_at desc").Limit(int(limit)).Offset(int(offset)).Find(&fullProjects).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[GetAllProject] error query mysql find, err:%+v", err)
+		return nil, 0, err
+	}
+	var EnterpriseIDs []int64
+	for _, fullProject := range fullProjects {
+		EnterpriseIDs = append(EnterpriseIDs, fullProject.EnterpriseID)
+	}
+	fmt.Println("去重前 EnterpriseIDs:", EnterpriseIDs)
+	EnterpriseIDs = util.RemoveRepByMap(EnterpriseIDs)
+	fmt.Println("去重后 EnterpriseIDs:", EnterpriseIDs)
+	userMemo := map[int64]string{}
+	phoneMemo := map[int64]string{}
+	for _, EnterpriseID := range EnterpriseIDs {
+		userMemo[EnterpriseID] = GetUsernameEnterpriseID(ctx, EnterpriseID)
+	}
+	for _, EnterpriseID := range EnterpriseIDs {
+		phoneMemo[EnterpriseID] = GetPhoneByEnterpriseID(ctx, EnterpriseID)
+	}
+	for _, fullProject := range fullProjects {
+		allProject := new(http_model.GetAllProjectPreview)
+		allProject.ProjectUpdated = conv.MustString(fullProject.UpdatedAt, "")
+		allProject.ProjectStatus = conv.MustString(fullProject.ProjectStatus, "")
+		allProject.ProjectId = conv.MustString(fullProject.ProjectID, "")
+		allProject.EnterpriseID = fullProject.EnterpriseID
+		allProject.Username = userMemo[fullProject.EnterpriseID]
+		allProject.Phone = phoneMemo[fullProject.EnterpriseID]
+		allProjects = append(allProjects, allProject)
+	}
+	return allProjects, total, nil
+}
+
+// GetPhoneByEnterpriseID 根据企业ID查找用户联系方式
+func GetPhoneByEnterpriseID(ctx context.Context, enterpriseID int64) string {
+	db := GetReadDB(ctx)
+	var Enterprise gorm_model.Enterprise
+	// 通过企业ID获得用户ID
+	db = db.Model([]gorm_model.Enterprise{}).Where("enterprise_id", enterpriseID).First(&Enterprise)
+	userId := Enterprise.UserID
+	db1 := GetReadDB(ctx)
+	var user gorm_model.YounggeeUser
+	db1 = db1.Model([]gorm_model.YounggeeUser{}).Where("id", userId).First(&user)
+	phone := user.Phone
+	return phone
+}
+
+// GetUsernameEnterpriseID 根据企业ID查找用户名称
+func GetUsernameEnterpriseID(ctx context.Context, enterpriseID int64) string {
+	db := GetReadDB(ctx)
+	var Enterprise gorm_model.Enterprise
+	// 通过企业ID获得用户ID
+	db = db.Model([]gorm_model.Enterprise{}).Where("enterprise_id", enterpriseID).First(&Enterprise)
+	userId := Enterprise.UserID
+	db1 := GetReadDB(ctx)
+	var user gorm_model.YounggeeUser
+	db1 = db1.Model([]gorm_model.YounggeeUser{}).Where("id", userId).First(&user)
+	username := user.Username
+	return username
+}
+
+func GetProjectTaskList(ctx context.Context, projectID string, pageSize, pageNum int64, conditions *common_model.TaskConditions) ([]*http_model.ProjectTaskInfo, int64, error) {
+	db := GetReadDB(ctx)
+	// 查询task表信息
+	db = db.Debug().Model(gorm_model.YoungeeTaskInfo{})
+	// 根据Project条件过滤
+	conditionType := reflect.TypeOf(conditions).Elem()
+	conditionValue := reflect.ValueOf(conditions).Elem()
+	for i := 0; i < conditionType.NumField(); i++ {
+		field := conditionType.Field(i)
+		tag := field.Tag.Get("condition")
+		value := conditionValue.FieldByName(field.Name)
+		if !util.IsBlank(value) && tag != "platform_nickname" {
+			db = db.Where(fmt.Sprintf("%s = ?", tag), value.Interface())
+		} else if tag == "platform_nickname" {
+			continue
+		}
+	}
+	var taskInfos []gorm_model.YoungeeTaskInfo
+	db = db.Model(gorm_model.YoungeeTaskInfo{})
+	// 查询总数
+	var totalTask int64
+	if err := db.Count(&totalTask).Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[GetProjectTaskList] error query mysql total, err:%+v", err)
+		return nil, 0, err
+	}
+	db.Order("task_id").Find(&taskInfos)
+
+	// 查询账号id
+	var accountIds []int
+	taskMap := make(map[int]gorm_model.YoungeeTaskInfo)
+	for _, taskInfo := range taskInfos {
+		accountIds = append(accountIds, taskInfo.AccountId)
+		taskMap[taskInfo.AccountId] = taskInfo
+	}
+	db1 := GetReadDB(ctx)
+	db1 = db1.Debug().Model(gorm_model.YoungeePlatformAccountInfo{})
+	// 根据Project条件过滤
+	conditionType2 := reflect.TypeOf(conditions).Elem()
+	conditionValue2 := reflect.ValueOf(conditions).Elem()
+	for i := 0; i < conditionType2.NumField(); i++ {
+		field := conditionType2.Field(i)
+		tag := field.Tag.Get("condition")
+		value := conditionValue2.FieldByName(field.Name)
+		if !util.IsBlank(value) && tag == "platform_nickname" { // input:1		database:1,2,3    string
+			db1 = db1.Where(fmt.Sprintf("%s = ?", tag), value.Interface())
 		}
-	}else {
-		return nil,"操作失败"
 	}
-	return nil,message
+	var accountInfos []gorm_model.YoungeePlatformAccountInfo
+	db1 = db1.Model(gorm_model.YoungeePlatformAccountInfo{}).Where("account_id IN ?", accountIds).Find(&accountInfos)
+	// 查询总数
+	var totalAccount int64
+	if err := db1.Count(&totalAccount).Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[GetProjectTaskList] error query mysql total, err:%+v", err)
+		return nil, 0, err
+	}
+	var misNum int64
+	if totalAccount > totalTask {
+		misNum = totalAccount - totalTask
+	} else {
+		misNum = totalTask - totalAccount
+	}
+	logrus.Println("totalAccount,totalTask,misNum:", totalAccount, totalTask, misNum)
+	// 查询该页数据
+	limit := pageSize + misNum
+	offset := pageSize * pageNum // assert pageNum start with 0
+	err := db.Order("task_id").Limit(int(limit)).Offset(int(offset)).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[GetProjectTaskList] error query mysql total, err:%+v", err)
+		return nil, 0, err
+	}
+
+	accountMap := make(map[int]gorm_model.YoungeePlatformAccountInfo)
+	for _, accountInfo := range accountInfos {
+		accountMap[accountInfo.AccountID] = accountInfo
+	}
+	var taskAccounts []*http_model.TaskAccount
+	var projectTasks []*http_model.ProjectTaskInfo
+	for _, accountId := range accountIds {
+		taskAccount := new(http_model.TaskAccount)
+		_, ok := taskMap[accountId]
+		_, ok2 := accountMap[accountId]
+		if ok && ok2 {
+			taskAccount.Task = taskMap[accountId]
+			taskAccount.Account = accountMap[accountId]
+		}
+		taskAccounts = append(taskAccounts, taskAccount)
+	}
+
+	projectTasks = pack.TaskAccountToTaskInfo(taskAccounts)
+	var fullProjectTasks []*http_model.ProjectTaskInfo
+	// 删除只存在于一个表中的元素
+	for i := 0; i < len(projectTasks); i++ {
+		if projectTasks[i].TaskID != 0 {
+			fullProjectTasks = append(fullProjectTasks, projectTasks[i])
+		}
+	}
+	var total int64
+	if totalTask > totalAccount {
+		total = totalAccount
+	} else {
+		total = totalTask
+	}
+	return fullProjectTasks, total, nil
+}
+
+func CreateProject(ctx context.Context, projectInfo gorm_model.ProjectInfo) (*int64, error) {
+	db := GetWriteDB(ctx)
+	err := db.Create(&projectInfo).Error
+	if err != nil {
+		return nil, err
+	}
+	return &projectInfo.ProjectID, nil
 }

+ 78 - 0
db/talent.go

@@ -0,0 +1,78 @@
+package db
+
+import (
+	"context"
+	"github.com/caixw/lib.go/conv"
+	"github.com/sirupsen/logrus"
+	"gorm.io/gorm"
+	"youngee_m_api/model/gorm_model"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/pack"
+)
+
+func PlatformAccInfo(ctx context.Context, talentId string) (*http_model.PlatformAccInfoPreView, error) {
+	db := GetReadDB(ctx)
+	var gormPlatform []*gorm_model.YoungeePlatformAccountInfo
+	// 根据 talent_id 进行筛选
+	db = db.Debug().Model(gorm_model.YoungeePlatformAccountInfo{}).Where("talent_id = ?", talentId)
+	err := db.Find(&gormPlatform).Order("bind_date").Error
+	if err != nil {
+		if err == gorm.ErrRecordNotFound {
+			return nil, nil
+		} else {
+			return nil, err
+		}
+	}
+	// 查询总数
+	var total int64
+	if err = db.Count(&total).Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[PlatformAccInfo] error query mysql total, err:%+v", err)
+		return nil, err
+	}
+	platform := new(http_model.PlatformAccInfoPreView)
+	platform.PlatformAccInfoData = pack.GormPlatformToHttpPlatform(gormPlatform)
+	platform.Total = conv.MustString(total, "")
+	return platform, err
+}
+
+func AccountIncome(ctx context.Context, talentId string) (*http_model.TalentInfoResponse, error) {
+	db := GetReadDB(ctx)
+	var talentInfo *gorm_model.YoungeeTalentInfo
+	// 根据 talent_id 进行筛选
+	err := db.Debug().Model(gorm_model.YoungeeTalentInfo{}).Where("id = ?", talentId).
+		First(&talentInfo).Error
+	if err != nil {
+		if err == gorm.ErrRecordNotFound {
+			return nil, nil
+		} else {
+			return nil, err
+		}
+	}
+	data := new(http_model.TalentInfoResponse)
+	data.Income = talentInfo.Income
+	data.Withdrawed = talentInfo.Withdrawed
+	data.Canwithdraw = talentInfo.Canwithdraw
+	data.Withdrawing = talentInfo.Withdrawing
+
+	// 查询是否绑定物流地址
+	IsBindLocation := talentInfo.IsBindLocation
+	if IsBindLocation == 1 {
+		var deliveryInfo *gorm_model.YoungeeTalentDeliveryAddress
+		db1 := GetReadDB(ctx)
+		err = db1.Debug().Model(gorm_model.YoungeeTalentDeliveryAddress{}).
+			Where("talent_id = ? AND default_tag = ?", talentId, 1).
+			First(&deliveryInfo).Error
+		if err != nil {
+			if err == gorm.ErrRecordNotFound {
+				return nil, nil
+			} else {
+				return nil, err
+			}
+		}
+
+		data.ReceiverName = deliveryInfo.ReceiverName
+		data.PhoneNumber = deliveryInfo.PhoneNumber
+		data.DetailAddr = deliveryInfo.DetailAddr
+	}
+	return data, err
+}

+ 216 - 3
db/user.go

@@ -3,9 +3,16 @@ package db
 import (
 	"context"
 	"fmt"
+	"github.com/caixw/lib.go/conv"
 	"github.com/sirupsen/logrus"
 	"gorm.io/gorm"
+	"reflect"
+	"time"
+	"youngee_m_api/model/common_model"
 	"youngee_m_api/model/gorm_model"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/pack"
+	"youngee_m_api/util"
 )
 
 //GetUser 查找用户,查不到返回空
@@ -41,7 +48,7 @@ func GetUserByID(ctx context.Context, ID int64) (*gorm_model.YounggeeUser, error
 // GetAllUser 查找所有用户
 func GetAllUser(ctx context.Context) ([]string, error) {
 	db := GetReadDB(ctx)
-	db = db.Debug().Model([]gorm_model.YounggeeUser{}).Where("role = ? or role = ?","1","2")
+	db = db.Debug().Model([]gorm_model.YounggeeUser{}).Where("role = ? or role = ?", "1", "2")
 	var user []gorm_model.YounggeeUser
 	db.Find(&user)
 	var total int64
@@ -50,8 +57,214 @@ func GetAllUser(ctx context.Context) ([]string, error) {
 		return nil, err
 	}
 	var userList []string
-	for _,User := range user{
-		userList = append(userList,User.User)
+	for _, User := range user {
+		userList = append(userList, User.User)
 	}
 	return userList, nil
 }
+
+// GetUserList 获取员工用户列表
+func GetUserList(ctx context.Context, pageNum, pageSize int32) (*http_model.UserListData, error) {
+	db := GetReadDB(ctx)
+	db = db.Debug().Model([]gorm_model.YounggeeUser{}).Where("role = ? or role = ?", "1", "2")
+	var user []gorm_model.YounggeeUser
+	// 查询总数
+	var total int64
+	if err := db.Count(&total).Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[GetUserList] error query mysql total, err:%+v", err)
+		return nil, err
+	}
+	// 查询该页数据
+	limit := pageSize
+	offset := pageSize * pageNum // assert pageNum start with 0
+	err := db.Order("created_at desc").Limit(int(limit)).Offset(int(offset)).Find(&user).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[GetUserList] error query mysql find, err:%+v", err)
+		return nil, err
+	}
+	userList := new(http_model.UserListData)
+	userList.UserListPreview = pack.MGormUserListToHttpUserListPreview(user)
+	userList.Total = conv.MustString(total, "")
+	return userList, nil
+}
+
+func UpdateUserInfo(ctx context.Context, req *http_model.UpdateUserInfoRequest) (string, error) {
+	db := GetReadDB(ctx)
+	user, username, role, password, email, phone := req.User, req.Username, req.Role, req.Password, req.Email, req.Phone
+	db = db.Debug().Model([]gorm_model.YounggeeUser{}).Where("user = ?", user)
+	err := db.Updates(map[string]interface{}{
+		"username": username, "password": password, "email": email, "phone": phone, "role": role}).Error
+	if err != nil {
+		return "", err
+	}
+	return "更新成功", nil
+}
+
+func CreateUser(ctx context.Context, req *http_model.CreateUserRequest) (string, error) {
+	db := GetReadDB(ctx)
+	username, role, password, email, phone := req.Username, req.Role, req.Password, req.Email, req.Phone
+	var IsUserPhone gorm_model.YounggeeUser
+	err := db.Debug().Where(" phone = ?", req.Phone).First(&IsUserPhone).Error
+	if err == nil {
+		return "手机号已存在,不能再次创建", nil
+	}
+	var user gorm_model.YounggeeUser
+	var userInfo gorm_model.YounggeeUser
+	getMonth := time.Now().Format("01") //获取月
+	getDay := time.Now().Day()          //获取日
+	dayString := ""
+	if getDay < 10 {
+		dayString = conv.MustString(getDay, "")
+		dayString = "0" + dayString
+	} else {
+		dayString = conv.MustString(getDay, "")
+	}
+	monthAndDay := conv.MustString(getMonth, "") + dayString
+	err = db.Debug().Where(fmt.Sprintf(" user like '%s%%'", monthAndDay)).Last(&userInfo).Error
+
+	num := 1
+	if userInfo.User != "" {
+		num = conv.MustInt(userInfo.User[4:6], 0)
+		num = num + 1 //获取日
+	} else {
+		num = 1
+	}
+	numString := ""
+	if num < 10 {
+		numString = conv.MustString(num, "")
+		numString = "0" + numString
+	} else {
+		numString = conv.MustString(num, "")
+	}
+
+	user.Username = username
+	user.RealName = username
+	user.User = monthAndDay + numString
+	user.Role = role
+	user.Password = password
+	user.Email = email
+	user.Phone = phone
+	user.LastLoginTime = time.Now()
+	user.CreatedAt = time.Now()
+	user.UpdatedAt = time.Now()
+	err = db.Debug().Create(&user).Error
+	if err != nil {
+		return "创建失败", err
+	}
+	return "创建成功", nil
+}
+
+func DisabledUser(ctx context.Context, user string) (string, error) {
+	db := GetReadDB(ctx)
+	err := db.Debug().Model(gorm_model.YounggeeUser{}).Where("user = ?", user).Update("user_state", "0").Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[DisabledUser] error Update mysql find, err:%+v", err)
+		return "禁用失败", err
+	}
+	return "账号已禁止使用", nil
+}
+
+func GetEnterpriseUserList(ctx context.Context, pageSize, pageNum int32, conditions *common_model.EnterpriseUserConditions) ([]*http_model.EnterpriseUserPreview, int64, error) {
+	db := GetReadDB(ctx)
+	// 查询user表信息,筛选出企业用户
+	db = db.Debug().Model([]gorm_model.YounggeeUser{}).Where("role = ? ", "3")
+	// 根据 查询条件过滤
+	conditionType := reflect.TypeOf(conditions).Elem()
+	conditionValue := reflect.ValueOf(conditions).Elem()
+	for i := 0; i < conditionType.NumField(); i++ {
+		field := conditionType.Field(i)
+		tag := field.Tag.Get("condition")
+		value := conditionValue.FieldByName(field.Name)
+		if !util.IsBlank(value) && tag != "created_at" {
+			db = db.Where(fmt.Sprintf("%s = ?", tag), value.Interface())
+		} else if tag == "created_at" && value.Interface() != nil {
+			db = db.Where(fmt.Sprintf("created_at like '%s%%'", value.Interface()))
+		}
+	}
+	var users []gorm_model.YounggeeUser
+	var totalUser int64
+	if err := db.Count(&totalUser).Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[GetEnterpriseUserList] error query mysql total, err:%+v", err)
+		return nil, 0, err
+	}
+	db.Order("user").Find(&users)
+
+	// 查询 用户自增的id
+	var userIds []int64
+	userMap := make(map[int64]gorm_model.YounggeeUser)
+	for _, user := range users {
+		userIds = append(userIds, user.ID)
+		userMap[user.ID] = user
+	}
+
+	db1 := GetReadDB(ctx)
+	var enterprises []gorm_model.Enterprise
+	db1 = db1.Debug().Model(gorm_model.Enterprise{}).Where("user_id IN ?", userIds).Find(&enterprises)
+
+	// 查询该页数据
+	limit := pageSize
+	offset := pageSize * pageNum // assert pageNum start with 0
+	err := db.Order("user").Limit(int(limit)).Offset(int(offset)).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[GetEnterpriseUserList] error query mysql total, err:%+v", err)
+		return nil, 0, err
+	}
+	enterpriseMap := make(map[int64]gorm_model.Enterprise)
+	for _, enterprise := range enterprises {
+		enterpriseMap[enterprise.UserID] = enterprise
+	}
+
+	var enterpriseUsers []*http_model.EnterpriseUser
+	for _, userId := range userIds {
+		enterpriseUser := new(http_model.EnterpriseUser)
+		_, ok1 := userMap[userId]
+		_, ok2 := enterpriseMap[userId]
+		if ok1 && ok2 {
+			enterpriseUser.Enterprise = enterpriseMap[userId]
+			enterpriseUser.YoungeeUser = userMap[userId]
+		}
+		enterpriseUsers = append(enterpriseUsers, enterpriseUser)
+	}
+
+	var enterpriseUserDatas []*http_model.EnterpriseUserPreview
+	enterpriseUserDatas = pack.EnterpriseUserToEnterpriseUserData(enterpriseUsers)
+	return enterpriseUserDatas, totalUser, nil
+}
+
+func GetCreatorList(ctx context.Context, pageSize, pageNum int32, conditions *common_model.CreatorListConditions) ([]*http_model.CreatorListPreview, int64, error) {
+	db := GetReadDB(ctx)
+	db = db.Debug().Model(gorm_model.YoungeeTalentInfo{})
+	// 根据 条件过滤
+	conditionType := reflect.TypeOf(conditions).Elem()
+	conditionValue := reflect.ValueOf(conditions).Elem()
+	for i := 0; i < conditionType.NumField(); i++ {
+		field := conditionType.Field(i)
+		tag := field.Tag.Get("condition")
+		value := conditionValue.FieldByName(field.Name)
+		if !util.IsBlank(value) && tag != "create_date" {
+			db = db.Where(fmt.Sprintf("%s = ?", tag), value.Interface())
+		} else if tag == "create_date" && value.Interface() != nil {
+			db = db.Where(fmt.Sprintf("create_date like '%s%%'", value.Interface()))
+		}
+	}
+
+	// 查询总数
+	var total int64
+	var talentList []gorm_model.YoungeeTalentInfo
+	if err := db.Count(&total).Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[GetCreatorList] error query mysql total, err:%+v", err)
+		return nil, 0, err
+	}
+	// 查询该页数据
+	limit := pageSize
+	offset := pageSize * pageNum // assert pageNum start with 0
+	err := db.Order("id").Limit(int(limit)).Offset(int(offset)).Find(&talentList).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[GetCreatorList] error query mysql total, err:%+v", err)
+		return nil, 0, err
+	}
+
+	var CreatorList []*http_model.CreatorListPreview
+	CreatorList = pack.TalentListToCreatorListData(talentList)
+	return CreatorList, total, nil
+}

+ 21 - 0
dockerfile

@@ -0,0 +1,21 @@
+FROM golang:1.17 as builder
+
+WORKDIR /go/src/app
+
+COPY . .
+
+ENV youngee_env pro
+
+RUN go env -w GO111MODULE=on
+
+RUN go env -w GOPROXY=https://goproxy.cn,direct
+
+RUN go mod tidy
+
+RUN go build .
+
+EXPOSE 8400
+
+WORKDIR /go/src/app
+
+ENTRYPOINT ["./youngee_m_api"]

+ 57 - 0
handler/account_income.go

@@ -0,0 +1,57 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/util"
+)
+
+func WrapTalentInfoHandler(ctx *gin.Context) {
+	handler := newTalentInfo(ctx)
+	baseRun(handler)
+}
+
+func newTalentInfo(ctx *gin.Context) *TalentInfo {
+	return &TalentInfo{
+		req:  http_model.NewTalentInfoRequest(),
+		resp: http_model.NewTalentInfoResponse(),
+		ctx:  ctx,
+	}
+}
+
+type TalentInfo struct {
+	req  *http_model.TalentInfoRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (a TalentInfo) getContext() *gin.Context {
+	return a.ctx
+}
+
+func (a TalentInfo) getResponse() interface{} {
+	return a.resp
+}
+
+func (a TalentInfo) getRequest() interface{} {
+	return a.req
+}
+
+func (a TalentInfo) run() {
+	data, err := db.AccountIncome(a.ctx, a.req.TalentId)
+	if err != nil {
+		// 数据库查询失败,返回5001
+		logrus.Errorf("[AccountIncomeHandler] call AccountIncome err:%+v\n", err)
+		util.HandlerPackErrorResp(a.resp, consts.ErrorInternal, "")
+		logrus.Info("AccountIncomeHandler fail,req:%+v", a.req)
+		return
+	}
+	a.resp.Data = data
+}
+
+func (a TalentInfo) checkParam() error {
+	return nil
+}

+ 63 - 0
handler/create_user.go

@@ -0,0 +1,63 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/util"
+)
+
+func WrapCreateUserHandler(ctx *gin.Context) {
+	handler := newCreateUserhandler(ctx)
+	baseRun(handler)
+}
+
+func newCreateUserhandler(ctx *gin.Context) *CreateUserHandler {
+	return &CreateUserHandler{
+		req:  http_model.NewCreateUserRequest(),
+		resp: http_model.NewCreateUserResponse(),
+		ctx:  ctx,
+	}
+}
+
+type CreateUserHandler struct {
+	req  *http_model.CreateUserRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (c CreateUserHandler) getContext() *gin.Context {
+	return c.ctx
+}
+
+func (c CreateUserHandler) getResponse() interface{} {
+	return c.resp
+}
+
+func (c CreateUserHandler) getRequest() interface{} {
+	return c.req
+}
+
+func (c CreateUserHandler) run() {
+	toast, err := db.CreateUser(c.ctx, c.req)
+	if err != nil {
+		// 数据库查询失败,返回5001
+		logrus.Errorf("[CreateUserHandler] call CreateUser err:%+v\n", err)
+		util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
+		logrus.Info("CreateUserHandler fail,req:%+v", c.req)
+		return
+	}
+	if toast == "创建成功" {
+		c.resp.Message = "创建成功"
+	} else if toast == "手机号已存在,不能再次创建" {
+		c.resp.Status = 1
+	} else {
+		c.resp.Status = 2
+	}
+}
+
+func (c CreateUserHandler) checkParam() error {
+	return nil
+}

+ 67 - 0
handler/creator_list.go

@@ -0,0 +1,67 @@
+package handler
+
+import (
+	"errors"
+	"fmt"
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/pack"
+	"youngee_m_api/service"
+	"youngee_m_api/util"
+)
+
+func WrapCreatorListHandler(ctx *gin.Context) {
+	handler := newCreatorListHandler(ctx)
+	baseRun(handler)
+}
+
+func newCreatorListHandler(ctx *gin.Context) *CreatorList {
+	return &CreatorList{
+		req:  http_model.NewCreatorListRequest(),
+		resp: http_model.NewCreatorListResponse(),
+		ctx:  ctx,
+	}
+}
+
+type CreatorList struct {
+	req  *http_model.CreatorListRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (c CreatorList) getContext() *gin.Context {
+	return c.ctx
+}
+
+func (c CreatorList) getResponse() interface{} {
+	return c.resp
+}
+
+func (c CreatorList) getRequest() interface{} {
+	return c.req
+}
+
+func (c CreatorList) run() {
+	conditions := pack.HttpCreatorListRequestToCondition(c.req)
+	data, err := service.User.CreatorList(c.ctx, c.req.PageSize, c.req.PageNum, conditions)
+	if err != nil {
+		logrus.WithContext(c.ctx).Errorf("[EnterpriseUserHandler] error EnterpriseUserList, err:%+v", err)
+		util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, consts.DefaultToast)
+		return
+	}
+	c.resp.Data = data
+}
+
+func (c CreatorList) checkParam() error {
+	var errs []error
+	if c.req.PageNum < 0 || c.req.PageSize <= 0 {
+		errs = append(errs, errors.New("page param error"))
+	}
+	c.req.PageNum--
+	if len(errs) != 0 {
+		return fmt.Errorf("CreatorList check param errs:%+v", errs)
+	}
+	return nil
+}

+ 57 - 0
handler/disabled_user.go

@@ -0,0 +1,57 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/util"
+)
+
+func WrapDisabledUserHandler(ctx *gin.Context) {
+	handler := newDisabledUserHandler(ctx)
+	baseRun(handler)
+}
+
+func newDisabledUserHandler(ctx *gin.Context) *DisabledUserHandler {
+	return &DisabledUserHandler{
+		req:  http_model.NewDisabledUserRequest(),
+		resp: http_model.NewDisabledUserResponse(),
+		ctx:  ctx,
+	}
+}
+
+type DisabledUserHandler struct {
+	req  *http_model.DisabledUserRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (d DisabledUserHandler) getContext() *gin.Context {
+	return d.ctx
+}
+
+func (d DisabledUserHandler) getResponse() interface{} {
+	return d.resp
+}
+
+func (d DisabledUserHandler) getRequest() interface{} {
+	return d.req
+}
+
+func (d DisabledUserHandler) run() {
+	toast, err := db.DisabledUser(d.ctx, d.req.User)
+	if err != nil {
+		// 数据库查询失败,返回5001
+		logrus.Errorf("[DisabledUserHandler] call DisabledUser err:%+v\n", err)
+		util.HandlerPackErrorResp(d.resp, consts.ErrorInternal, "")
+		logrus.Info("DisabledUserHandler fail,req:%+v", d.req)
+		return
+	}
+	d.resp.Message = toast
+}
+
+func (d DisabledUserHandler) checkParam() error {
+	return nil
+}

+ 67 - 0
handler/enterprise_user.go

@@ -0,0 +1,67 @@
+package handler
+
+import (
+	"errors"
+	"fmt"
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/pack"
+	"youngee_m_api/service"
+	"youngee_m_api/util"
+)
+
+func WrapEnterpriseUserHandler(ctx *gin.Context) {
+	handler := newEnterpriseUser(ctx)
+	baseRun(handler)
+}
+
+func newEnterpriseUser(ctx *gin.Context) *EnterpriseUser {
+	return &EnterpriseUser{
+		req:  http_model.NewEnterpriseUserRequest(),
+		resp: http_model.NewEnterpriseUserResponse(),
+		ctx:  ctx,
+	}
+}
+
+type EnterpriseUser struct {
+	req  *http_model.EnterpriseUserRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (e EnterpriseUser) getContext() *gin.Context {
+	return e.ctx
+}
+
+func (e EnterpriseUser) getResponse() interface{} {
+	return e.resp
+}
+
+func (e EnterpriseUser) getRequest() interface{} {
+	return e.req
+}
+
+func (e EnterpriseUser) run() {
+	condition := pack.HttpEnterpriseUserRequestToCondition(e.req)
+	data, err := service.User.EnterpriseUserList(e.ctx, e.req.PageSize, e.req.PageNum, condition)
+	if err != nil {
+		logrus.WithContext(e.ctx).Errorf("[EnterpriseUserHandler] error EnterpriseUserList, err:%+v", err)
+		util.HandlerPackErrorResp(e.resp, consts.ErrorInternal, consts.DefaultToast)
+		return
+	}
+	e.resp.Data = data
+}
+
+func (e EnterpriseUser) checkParam() error {
+	var errs []error
+	if e.req.PageNum < 0 || e.req.PageSize <= 0 {
+		errs = append(errs, errors.New("page param error"))
+	}
+	e.req.PageNum--
+	if len(errs) != 0 {
+		return fmt.Errorf("EnterpriseUser check param errs:%+v", errs)
+	}
+	return nil
+}

+ 55 - 0
handler/get_user_list.go

@@ -0,0 +1,55 @@
+package handler
+
+import (
+	"errors"
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+)
+
+func WrapGetUserListHandler(ctx *gin.Context) {
+	handler := newGetUserListHandler(ctx)
+	baseRun(handler)
+}
+
+func newGetUserListHandler(ctx *gin.Context) *GetUserListHandler {
+	return &GetUserListHandler{
+		req:  http_model.NewGetUserListRequest(),
+		resp: http_model.NewGetUserListResponse(),
+		ctx:  ctx,
+	}
+}
+
+type GetUserListHandler struct {
+	req  *http_model.UserListRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (h *GetUserListHandler) getRequest() interface{} {
+	return h.req
+}
+func (h *GetUserListHandler) getContext() *gin.Context {
+	return h.ctx
+}
+func (h *GetUserListHandler) getResponse() interface{} {
+	return h.resp
+}
+func (h *GetUserListHandler) run() {
+	data, err := db.GetUserList(h.ctx, h.req.PageNum, h.req.PageSize)
+	if err != nil {
+		logrus.Errorf("[GetUserListHandler] GetUserList err:%+v\n", err)
+		logrus.Info("GetUserList fail,req:%+v", h.req)
+		return
+	}
+	h.resp.Data = data
+}
+func (h *GetUserListHandler) checkParam() error {
+	var errs []error
+	if h.req.PageNum < 0 || h.req.PageSize <= 0 {
+		errs = append(errs, errors.New("page param error"))
+	}
+	h.req.PageNum--
+	return nil
+}

+ 2 - 1
handler/login.go

@@ -38,7 +38,7 @@ func (h *CodeLoginHandler) getResponse() interface{} {
 	return h.resp
 }
 func (h *CodeLoginHandler) run() {
-	token,username, err := service.LoginAuth.AuthCode(h.ctx, h.req.User, h.req.Password)
+	token, username, role, err := service.LoginAuth.AuthCode(h.ctx, h.req.User, h.req.Password)
 	if err != nil {
 		logrus.Errorf("[CodeLoginHandler] call AuthCode err:%+v\n", err)
 		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, token)
@@ -48,6 +48,7 @@ func (h *CodeLoginHandler) run() {
 	data := http_model.CodeLoginData{}
 	data.Token = token
 	data.Username = username
+	data.Role = role
 	h.resp.Data = data
 }
 func (h *CodeLoginHandler) checkParam() error {

+ 57 - 0
handler/platform_acc_info.go

@@ -0,0 +1,57 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/util"
+)
+
+func WrapPlatformAccInfoHandler(ctx *gin.Context) {
+	handler := newPlatformAccInfo(ctx)
+	baseRun(handler)
+}
+
+func newPlatformAccInfo(ctx *gin.Context) *PlatformAccInfo {
+	return &PlatformAccInfo{
+		req:  http_model.NewPlatformAccInfoRequest(),
+		resp: http_model.NewPlatformAccInfoResponse(),
+		ctx:  ctx,
+	}
+}
+
+type PlatformAccInfo struct {
+	req  *http_model.PlatformAccInfoRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (p PlatformAccInfo) getContext() *gin.Context {
+	return p.ctx
+}
+
+func (p PlatformAccInfo) getResponse() interface{} {
+	return p.resp
+}
+
+func (p PlatformAccInfo) getRequest() interface{} {
+	return p.req
+}
+
+func (p PlatformAccInfo) run() {
+	data, err := db.PlatformAccInfo(p.ctx, p.req.TalentId)
+	if err != nil {
+		// 数据库查询失败,返回5001
+		logrus.Errorf("[PlatformAccInfoHandler] call PlatformAccInfo err:%+v\n", err)
+		util.HandlerPackErrorResp(p.resp, consts.ErrorInternal, "")
+		logrus.Info("PlatformAccInfoHandler fail,req:%+v", p.req)
+		return
+	}
+	p.resp.Data = data
+}
+
+func (p PlatformAccInfo) checkParam() error {
+	return nil
+}

+ 82 - 0
handler/product_create.go

@@ -0,0 +1,82 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	log "github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/service"
+	"youngee_m_api/util"
+)
+
+func WrapCreateProductHandler(ctx *gin.Context) {
+	handler := newCreateProductHandler(ctx)
+	baseRun(handler)
+}
+
+func newCreateProductHandler(ctx *gin.Context) *CreateProductHandler {
+	return &CreateProductHandler{
+		req:  http_model.NewCreateProductRequest(),
+		resp: http_model.NewCreateProductResponse(),
+		ctx:  ctx,
+	}
+}
+
+type CreateProductHandler struct {
+	req  *http_model.CreateProductRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (h *CreateProductHandler) getRequest() interface{} {
+	return h.req
+}
+func (h *CreateProductHandler) getContext() *gin.Context {
+	return h.ctx
+}
+func (h *CreateProductHandler) getResponse() interface{} {
+	return h.resp
+}
+func (h *CreateProductHandler) run() {
+	data := http_model.CreateProductRequest{}
+	data = *h.req
+	enterpriseID := db.GetEnterpriseIDByProductID(h.ctx, h.req.ProductId)
+	//根据品牌名和商品名查询商品是否存在,若存在则更新,否则新增
+	product, err := service.Product.FindByID(h.ctx, data.ProductId)
+	if err != nil {
+		logrus.Errorf("[CreateProductHandler] call FindByID err:%+v\n", err)
+		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
+		log.Info("CreateProduct fail,req:%+v", h.req)
+		return
+	} else {
+		if product != nil {
+			// 该商品存在,更新
+			data.ProductId = product.ProductID
+			res, err := service.Product.Update(h.ctx, data, enterpriseID)
+			if err != nil {
+				logrus.Errorf("[CreateProductHandler] call Update err:%+v\n", err)
+				util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
+				log.Info("CreateProduct fail,req:%+v", h.req)
+				return
+			}
+			h.resp.Message = "成功更新商品信息"
+			h.resp.Data = res
+		} else {
+			// 商品不存在,新增
+			res, err := service.Product.Create(h.ctx, data, enterpriseID)
+			if err != nil {
+				logrus.Errorf("[CreateProductHandler] call Create err:%+v\n", err)
+				util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
+				log.Info("CreateProduct fail,req:%+v", h.req)
+				return
+			}
+			h.resp.Message = "成功新增商品信息"
+			h.resp.Data = res
+		}
+	}
+}
+func (h *CreateProductHandler) checkParam() error {
+	return nil
+}

+ 62 - 0
handler/product_findAll.go

@@ -0,0 +1,62 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	log "github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/service"
+	"youngee_m_api/util"
+)
+
+func WrapFindAllProductHandler(ctx *gin.Context) {
+	handler := newFindAllProductHandler(ctx)
+	baseRun(handler)
+}
+
+func newFindAllProductHandler(ctx *gin.Context) *FindAllProductHandler {
+	return &FindAllProductHandler{
+		req:  http_model.NewFindAllProductRequest(),
+		resp: http_model.NewFindAllProductResponse(),
+		ctx:  ctx,
+	}
+}
+
+type FindAllProductHandler struct {
+	req  *http_model.FindAllProductRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (h *FindAllProductHandler) getRequest() interface{} {
+	return h.req
+}
+func (h *FindAllProductHandler) getContext() *gin.Context {
+	return h.ctx
+}
+func (h *FindAllProductHandler) getResponse() interface{} {
+	return h.resp
+}
+func (h *FindAllProductHandler) run() {
+	enterpriseID := db.GetEnterpriseIDByUserID(h.ctx, h.req.UserID)
+	if enterpriseID == 0 {
+		// 数据库查询失败,返回5001
+		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
+		log.Info("FindAllProduct fail,req:%+v", h.req)
+		return
+	}
+	res, err := service.Product.FindAll(h.ctx, enterpriseID)
+	if err != nil {
+		// 数据库查询失败,返回5001
+		logrus.Errorf("[FindAllProductHandler] call FindAll err:%+v\n", err)
+		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
+		log.Info("FindAllProduct fail,req:%+v", h.req)
+		return
+	}
+	h.resp.Data = res
+}
+func (h *FindAllProductHandler) checkParam() error {
+	return nil
+}

+ 58 - 0
handler/project_all.go

@@ -0,0 +1,58 @@
+package handler
+
+import (
+	"errors"
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/service"
+	"youngee_m_api/util"
+)
+
+func WrapGetAllProjectHandler(ctx *gin.Context) {
+	handler := newGetAllProjectHandler(ctx)
+	baseRun(handler)
+}
+
+func newGetAllProjectHandler(ctx *gin.Context) *GetAllProjectHandler {
+	return &GetAllProjectHandler{
+		req:  http_model.NewGetAllProjectRequest(),
+		resp: http_model.NewGetAllProjectResponse(),
+		ctx:  ctx,
+	}
+}
+
+type GetAllProjectHandler struct {
+	req  *http_model.GetAllProjectRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (h *GetAllProjectHandler) getRequest() interface{} {
+	return h.req
+}
+func (h *GetAllProjectHandler) getContext() *gin.Context {
+	return h.ctx
+}
+func (h *GetAllProjectHandler) getResponse() interface{} {
+	return h.resp
+}
+func (h *GetAllProjectHandler) run() {
+	data, err := service.Project.GetAllProject(h.ctx, h.req.PageSize, h.req.PageNum)
+	if err != nil {
+		logrus.WithContext(h.ctx).Errorf("[GetAllProjectHandler] error GetAllProjectHandler, err:%+v", err)
+		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, consts.DefaultToast)
+		return
+	}
+	h.resp.Data = data
+}
+
+func (h *GetAllProjectHandler) checkParam() error {
+	var errs []error
+	if h.req.PageNum < 0 || h.req.PageSize <= 0 {
+		errs = append(errs, errors.New("page param error"))
+	}
+	h.req.PageNum--
+	return nil
+}

+ 58 - 0
handler/project_create.go

@@ -0,0 +1,58 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	log "github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/service"
+	"youngee_m_api/util"
+)
+
+func WrapCreateProjectHandler(ctx *gin.Context) {
+	handler := newCreateProjectHandler(ctx)
+	baseRun(handler)
+}
+
+func newCreateProjectHandler(ctx *gin.Context) *CreateProjectHandler {
+	return &CreateProjectHandler{
+		req:  http_model.NewCreateProjectRequest(),
+		resp: http_model.NewCreateProjectResponse(),
+		ctx:  ctx,
+	}
+}
+
+type CreateProjectHandler struct {
+	req  *http_model.CreateProjectRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (h *CreateProjectHandler) getRequest() interface{} {
+	return h.req
+}
+func (h *CreateProjectHandler) getContext() *gin.Context {
+	return h.ctx
+}
+func (h *CreateProjectHandler) getResponse() interface{} {
+	return h.resp
+}
+func (h *CreateProjectHandler) run() {
+	data := http_model.CreateProjectRequest{}
+	data = *h.req
+	enterpriseID := db.GetEnterpriseIDByProductID(h.ctx, h.req.ProductID)
+	res, err := service.Project.Create(h.ctx, data, enterpriseID)
+	if err != nil {
+		logrus.Errorf("[CreateProjectHandler] call Create err:%+v\n", err)
+		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
+		log.Info("CreateProject fail,req:%+v", h.req)
+		return
+	}
+	h.resp.Message = "成功创建项目"
+	h.resp.Data = res
+}
+func (h *CreateProjectHandler) checkParam() error {
+	return nil
+}

+ 1 - 1
handler/project_show.go

@@ -40,7 +40,7 @@ func (h *ShowProjectHandler) getResponse() interface{} {
 func (h *ShowProjectHandler) run() {
 	data := http_model.ShowProjectRequest{}
 	data = *h.req
-	res, err := service.Project.GetPorjectDetail(h.ctx,data.EnterpriseID, data.ProjectID)
+	res, err := service.Project.GetProjectDetail(h.ctx,data.EnterpriseID, data.ProjectID)
 	if err != nil {
 		logrus.Errorf("[ShowProjectHandler] call Show err:%+v\n", err)
 		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")

+ 88 - 0
handler/project_taskList.go

@@ -0,0 +1,88 @@
+package handler
+
+import (
+	"errors"
+	"fmt"
+	"github.com/caixw/lib.go/conv"
+	"youngee_m_api/consts"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/pack"
+	"youngee_m_api/service"
+	"youngee_m_api/util"
+
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+)
+
+// WrapProjectTaskListHandler
+// @BasePath /youngee/m/
+// SendCode godoc
+// @Summary ProjectTaskList 项目任务列表
+// @Schemes
+// @Description 展示某个项目的任务列表
+// @Accept json
+// @Produce json
+// @Param req body http_model.ProjectTaskListRequest true "查询项目的任务列表的请求结构体"
+// @Success 200 {object} http_model.CommonResponse{data=http_model.ProjectTaskListData} "查询项目的任务列表相应结构体"
+// @Router /product/taskList [post]
+func WrapProjectTaskListHandler(ctx *gin.Context) {
+	handler := newProjectTaskListHandler(ctx)
+	baseRun(handler)
+}
+
+func newProjectTaskListHandler(ctx *gin.Context) *ProjectTaskListHandler {
+	return &ProjectTaskListHandler{
+		req:  http_model.NewProjectTaskListRequest(),
+		resp: http_model.NewProjectTaskListResponse(),
+		ctx:  ctx,
+	}
+}
+
+type ProjectTaskListHandler struct {
+	req  *http_model.ProjectTaskListRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (h *ProjectTaskListHandler) getRequest() interface{} {
+	return h.req
+}
+func (h *ProjectTaskListHandler) getContext() *gin.Context {
+	return h.ctx
+}
+func (h *ProjectTaskListHandler) getResponse() interface{} {
+	return h.resp
+}
+func (h *ProjectTaskListHandler) run() {
+	conditions := pack.HttpProjectTaskRequestToCondition(h.req)
+	data, err := service.Project.GetProjectTaskList(h.ctx, h.req.ProjectId, h.req.PageSize, h.req.PageNum, conditions)
+	if err != nil {
+		logrus.WithContext(h.ctx).Errorf("[ProjectTaskListHandler] error GetProjectTaskList, err:%+v", err)
+		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, consts.DefaultToast)
+		return
+	}
+	h.resp.Data = data
+}
+func (h *ProjectTaskListHandler) checkParam() error {
+	var errs []error
+	if h.req.PageNum < 0 || h.req.PageSize <= 0 {
+		errs = append(errs, errors.New("page param error"))
+	}
+	h.req.PageNum--
+	h.req.ProjectId = util.IsNull(h.req.ProjectId)
+	if _, err := conv.Int64(h.req.ProjectId); err != nil {
+		errs = append(errs, err)
+	}
+	h.req.StrategyId = util.IsNull(h.req.StrategyId)
+	if _, err := conv.Int64(h.req.StrategyId); err != nil {
+		errs = append(errs, err)
+	}
+	h.req.TaskStatus = util.IsNull(h.req.TaskStatus)
+	if _, err := conv.Int64(h.req.TaskStatus); err != nil {
+		errs = append(errs, err)
+	}
+	if len(errs) != 0 {
+		return fmt.Errorf("check param errs:%+v", errs)
+	}
+	return nil
+}

+ 61 - 0
handler/update_user_info.go

@@ -0,0 +1,61 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/util"
+)
+
+func WrapUpdateUserInfoHandler(ctx *gin.Context) {
+	handler := newUpdateUserInfoHandler(ctx)
+	baseRun(handler)
+}
+
+func newUpdateUserInfoHandler(ctx *gin.Context) *UpdateUserInfoHandler {
+	return &UpdateUserInfoHandler{
+		req:  http_model.NewUpdateUserInfoRequest(),
+		resp: http_model.NewUpdateUserInfoResponse(),
+		ctx:  ctx,
+	}
+}
+
+type UpdateUserInfoHandler struct {
+	req  *http_model.UpdateUserInfoRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (u UpdateUserInfoHandler) getContext() *gin.Context {
+	return u.ctx
+}
+
+func (u UpdateUserInfoHandler) getResponse() interface{} {
+	return u.resp
+}
+
+func (u UpdateUserInfoHandler) getRequest() interface{} {
+	return u.req
+}
+
+func (u UpdateUserInfoHandler) run() {
+	toast, err := db.UpdateUserInfo(u.ctx, u.req)
+	if err != nil {
+		// 数据库查询失败,返回5001
+		logrus.Errorf("[UpdateUserInfoHandler] call UpdateUserInfo err:%+v\n", err)
+		util.HandlerPackErrorResp(u.resp, consts.ErrorInternal, "")
+		logrus.Info("UpdateUserInfoHandler fail,req:%+v", u.req)
+		return
+	}
+	if toast == "更新成功" {
+		u.resp.Message = "更新成功"
+	} else {
+		u.resp.Message = "更新失败"
+	}
+}
+
+func (u UpdateUserInfoHandler) checkParam() error {
+	return nil
+}

+ 7 - 0
model/common_model/creator_list.go

@@ -0,0 +1,7 @@
+package common_model
+
+type CreatorListConditions struct {
+	Id               string `condition:"id"`                 // 达人id
+	TalentWxNickname string `condition:"talent_wx_nickname"` // 达人的微信昵称
+	CreateDate       string `condition:"create_date"`        // 创建时间
+}

+ 7 - 0
model/common_model/enterprise_user_conditions.go

@@ -0,0 +1,7 @@
+package common_model
+
+type EnterpriseUserConditions struct {
+	User      string `condition:"user"`       // 企业用户ID
+	Username  string `condition:"username"`   // 企业名称
+	CreatedAt string `condition:"created_at"` // 创建时间
+}

+ 16 - 0
model/gorm_model/delivery.go

@@ -0,0 +1,16 @@
+// Code generated by sql2gorm. DO NOT EDIT.
+package gorm_model
+
+type YoungeeTalentDeliveryAddress struct {
+	AddressID    int64  `gorm:"column:address_id;primary_key;AUTO_INCREMENT"`
+	TalentID     string `gorm:"column:talent_id"`              // 达人id(youngee_talent_info表中的id)
+	RegionCode   int    `gorm:"column:region_code;NOT NULL"`   // 区域码,取info_region表中的self_code字段值
+	DetailAddr   string `gorm:"column:detail_addr;NOT NULL"`   // 详细地址
+	PhoneNumber  string `gorm:"column:phone_number;NOT NULL"`  // 联系电话
+	ReceiverName string `gorm:"column:receiver_name;NOT NULL"` // 收货人名字
+	DefaultTag   int    `gorm:"column:default_tag;NOT NULL"`   // 是否默认收货地址
+}
+
+func (m *YoungeeTalentDeliveryAddress) TableName() string {
+	return "youngee_talent_delivery_address"
+}

+ 1 - 1
model/gorm_model/project_account.go → model/gorm_model/platform_account_info.go

@@ -8,7 +8,7 @@ import (
 type YoungeePlatformAccountInfo struct {
 	AccountID          int       `gorm:"column:account_id;primary_key;AUTO_INCREMENT"`
 	TalentID           string    `gorm:"column:talent_id;NOT NULL"`             // 达人账号id(youngee_talent_info表id值)
-	PlatformID         int       `gorm:"column:platform_id;NOT NULL"`           // 平台id,与third_platform_info中的id相同
+	PlatformID         int64     `gorm:"column:platform_id;NOT NULL"`           // 平台id,与third_platform_info中的id相同
 	PlatformNickname   string    `gorm:"column:platform_nickname;NOT NULL"`     // 在平台上的昵称
 	HomePageUrl        string    `gorm:"column:home_page_url;NOT NULL"`         // 主页链接
 	FansCount          int64     `gorm:"column:fans_count;NOT NULL"`            // 粉丝数

+ 1 - 0
model/gorm_model/talent.go

@@ -21,6 +21,7 @@ type YoungeeTalentInfo struct {
 	VisitStoreRegion  int       `gorm:"column:visit_store_region"`           // 探店区域,取region_info表中的self_code
 	IsBindInfo        uint      `gorm:"column:is_bind_info;default:0"`       // 是否填写个人资料
 	IsBindLocation    uint      `gorm:"column:is_bind_location;default:0"`   // 是否绑定收货地址
+	IsBindAccount     int       `gorm:"column:is_bind_account"`              // 是否绑定账号,1是0否
 	IsBindBank        uint      `gorm:"column:is_bind_bank;default:0"`       // 是否绑定银行账户信息
 	InBlacklist       uint      `gorm:"column:in_blacklist;default:0"`       // 是否加入黑名单 0否 1是
 	TaskAll           int       `gorm:"column:task_all;default:0"`           // 任务总数

+ 25 - 0
model/http_model/account_income.go

@@ -0,0 +1,25 @@
+package http_model
+
+type TalentInfoRequest struct {
+	TalentId string `json:"talent_id"`
+}
+
+type TalentInfoResponse struct {
+	Income       int64  `json:"income"`        // 收益总数
+	Withdrawing  int64  `json:"withdrawing"`   // 提现中金额
+	Canwithdraw  int64  `json:"canwithdraw"`   // 可提现金额
+	Withdrawed   int64  `json:"withdrawed"`    // 已提现金额
+	DetailAddr   string `json:"detail_addr"`   // 详细地址
+	PhoneNumber  string `json:"phone_number"`  // 联系电话
+	ReceiverName string `json:"receiver_name"` // 收货人名字
+}
+
+func NewTalentInfoRequest() *TalentInfoRequest {
+	return new(TalentInfoRequest)
+}
+
+func NewTalentInfoResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(TalentInfoResponse)
+	return resp
+}

+ 4 - 3
model/http_model/code_login.go

@@ -1,13 +1,14 @@
 package http_model
 
 type CodeLoginRequest struct {
-	User string `json:"user"`
-	Password  string `json:"password"`
+	User     string `json:"user"`
+	Password string `json:"password"`
 }
 
 type CodeLoginData struct {
-	Token string `json:"token"`
+	Token    string `json:"token"`
 	Username string `json:"username"`
+	Role     string `json:"role"`
 }
 
 func NewCodeLoginRequest() *CodeLoginRequest {

+ 18 - 0
model/http_model/create_user.go

@@ -0,0 +1,18 @@
+package http_model
+
+type CreateUserRequest struct {
+	Username string `json:"username"`
+	Role     string `json:"role"`
+	Password string `json:"password"`
+	Email    string `json:"email"`
+	Phone    string `json:"phone"`
+}
+
+func NewCreateUserRequest() *CreateUserRequest {
+	return new(CreateUserRequest)
+}
+
+func NewCreateUserResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	return resp
+}

+ 33 - 0
model/http_model/creator_list.go

@@ -0,0 +1,33 @@
+package http_model
+
+type CreatorListRequest struct {
+	PageSize         int32  `json:"page_size"`
+	PageNum          int32  `json:"page_num"`
+	Id               string `json:"id"`                 // 达人id
+	TalentWxNickname string `json:"talent_wx_nickname"` // 达人的微信昵称
+	CreateDate       string `json:"create_date"`        // 创建时间
+}
+
+type CreatorListPreview struct {
+	Id               string `json:"id"`                  // 达人id
+	TalentWxNickname string `json:"talent_wx_nickname"`  // 达人的微信昵称
+	IsBindAccount    string `json:"is_bind_account"`     // 是否绑定账号
+	CanWithDraw      int64  `json:"canwithdraw"`         // 可用余额
+	TalentPhone      string `json:"talent_phone_number"` // 达人的联系方式
+	CreateDate       string `json:"create_date"`         // 创建时间
+}
+
+type CreatorListData struct {
+	CreatorListPreview []*CreatorListPreview `json:"creator_list_preview"`
+	Total              string                `json:"total"`
+}
+
+func NewCreatorListRequest() *CreatorListRequest {
+	return new(CreatorListRequest)
+}
+
+func NewCreatorListResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(CreatorListData)
+	return resp
+}

+ 14 - 0
model/http_model/disabled_user.go

@@ -0,0 +1,14 @@
+package http_model
+
+type DisabledUserRequest struct {
+	User string `json:"user"`
+}
+
+func NewDisabledUserRequest() *DisabledUserRequest {
+	return new(DisabledUserRequest)
+}
+
+func NewDisabledUserResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	return resp
+}

+ 42 - 0
model/http_model/enterprise_user.go

@@ -0,0 +1,42 @@
+package http_model
+
+import "youngee_m_api/model/gorm_model"
+
+type EnterpriseUserRequest struct {
+	PageSize  int32  `json:"page_size"`
+	PageNum   int32  `json:"page_num"`
+	User      string `json:"user"`       // 企业用户ID
+	Username  string `json:"username"`   // 企业名称
+	CreatedAt string `json:"created_at"` // 创建时间
+}
+
+type EnterpriseUserPreview struct {
+	User             string `json:"user"`              // 企业用户ID
+	UserID           string `json:"userID"`            // 用户ID
+	Username         string `json:"username"`          // 企业名称
+	Balance          int64  `json:"balance"`           // 账户余额
+	FrozenBalance    int64  `json:"frozen_balance"`    // 冻结余额
+	AvailableBalance int64  `json:"available_balance"` // 可用余额
+	Phone            string `json:"phone"`             // 联系方式
+	CreatedAt        string `json:"created_at"`        // 创建时间
+}
+
+type EnterpriseUserData struct {
+	EnterpriseUserPreview []*EnterpriseUserPreview `json:"enterprise_user_preview"`
+	Total                 string                   `json:"total"`
+}
+
+type EnterpriseUser struct {
+	Enterprise  gorm_model.Enterprise
+	YoungeeUser gorm_model.YounggeeUser
+}
+
+func NewEnterpriseUserRequest() *EnterpriseUserRequest {
+	return new(EnterpriseUserRequest)
+}
+
+func NewEnterpriseUserResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(EnterpriseUserData)
+	return resp
+}

+ 28 - 0
model/http_model/platform_acc_info.go

@@ -0,0 +1,28 @@
+package http_model
+
+type PlatformAccInfoRequest struct {
+	TalentId string `json:"talent_id"`
+}
+
+type PlatformAccInfoData struct {
+	Platform           string `json:"platform"`              //社媒平台
+	PlatformNickname   string `json:"platform_nickname"`     //账号昵称
+	Fans               int64  `json:"fans"`                  //粉丝量
+	HomePageCaptureUrl string `json:"home_page_capture_url"` //主页截图链接
+	HomePageUrl        string `json:"home_page_url"`         //主页链接
+}
+
+type PlatformAccInfoPreView struct {
+	PlatformAccInfoData []*PlatformAccInfoData `json:"platform_acc_info_data"`
+	Total               string                 `json:"total"`
+}
+
+func NewPlatformAccInfoRequest() *PlatformAccInfoRequest {
+	return new(PlatformAccInfoRequest)
+}
+
+func NewPlatformAccInfoResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(PlatformAccInfoPreView)
+	return resp
+}

+ 32 - 0
model/http_model/product_create.go

@@ -0,0 +1,32 @@
+package http_model
+
+type CreateProductPhoto struct {
+	PhotoUrl string `json:"photo_url"` // 图片或视频url
+	PhotoUid string `json:"photo_uid"`
+	Symbol   int64  `json:"symbol"` // 图片为主图或详情图标志位,1为主图,2为详情图,3为视频
+}
+
+type CreateProductRequest struct {
+	ProductId     int64                `json:"product_id"`
+	ProductName   string               `json:"product_name"` // 商品名称
+	ProductType   int64                `json:"product_type"` // 商品类型
+	ShopAddress   string               `json:"shop_address"` // 店铺地址,商品类型为线下品牌时需填写
+	ProductDetail string               `json:"product_detail"`
+	ProductPrice  int64                `json:"product_price"`  // 商品价值
+	ProductPhotos []CreateProductPhoto `json:"product_photos"` // 商品图片列表
+	ProductUrl    string               `json:"product_url"`    // 商品链接,可为电商网址、公司官网、大众点评的店铺地址等可以说明商品信息或者品牌信息的线上地址;
+	BrandName     string               `json:"brand_name"`
+}
+
+type CreateProductData struct {
+	ProductID int64 `json:"product_id"` // 商品id
+}
+
+func NewCreateProductRequest() *CreateProductRequest {
+	return new(CreateProductRequest)
+}
+func NewCreateProductResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(CreateProductData)
+	return resp
+}

+ 1 - 0
model/http_model/product_findall.go

@@ -1,6 +1,7 @@
 package http_model
 
 type FindAllProductRequest struct {
+	UserID string `json:"userID"` // 用户ID
 }
 
 type ProductInfo struct {

+ 29 - 0
model/http_model/project_all.go

@@ -0,0 +1,29 @@
+package http_model
+
+type GetAllProjectRequest struct {
+	PageSize int32 `json:"page_size"`
+	PageNum  int32 `json:"page_num"`
+}
+
+type GetAllProjectPreview struct {
+	ProjectUpdated string `json:"project_updated"` // 最后操作时间
+	EnterpriseID   int64  `json:"enterprise_id"`   // 所属企业id
+	Username       string `json:"username"`        // 用户名称
+	ProjectStatus  string `json:"project_status"`  // 项目状态
+	Phone          string `json:"phone"`           // 联系方式
+	ProjectId      string `json:"project_id"`      // 项目ID
+}
+
+type GetAllProjectData struct {
+	AllProjectPreview []*GetAllProjectPreview `json:"all_project_preview"`
+	Total             string                  `json:"total"`
+}
+
+func NewGetAllProjectRequest() *GetAllProjectRequest {
+	return new(GetAllProjectRequest)
+}
+func NewGetAllProjectResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(GetAllProjectData)
+	return resp
+}

+ 45 - 0
model/http_model/project_create.go

@@ -0,0 +1,45 @@
+package http_model
+
+import "time"
+
+type CreateProjectPhoto struct {
+	PhotoUrl string `json:"photo_url"` // 图片url
+	PhotoUid string `json:"photo_uid"`
+}
+
+type CreateRecruitStrategy struct {
+	FeeForm       int64 `json:"fee_form"`       // 稿费形式,1-3分别代表自报价、固定稿费、产品置换
+	StrategyID    int64 `json:"strategy_id"`    // 策略id
+	FollowersLow  int64 `json:"followers_low"`  // 达人粉丝数下限
+	FollowersUp   int64 `json:"followers_up"`   // 达人粉丝数上限
+	RecruitNumber int64 `json:"recruit_number"` // 招募数量
+	Offer         int64 `json:"offer"`          // 报价
+}
+
+type CreateProjectRequest struct {
+	ProjectName      string                  `json:"project_name"`      // 项目名称
+	ProjectStatus    int64                   `json:"project_status"`    // 项目状态,1-7分别代表创建中、待审核、招募中、待支付、失效、执行中、已结案
+	ProjectType      int64                   `json:"project_type"`      // 项目类型,1代表全流程项目,2代表专项项目
+	ProjectPlatform  int64                   `json:"project_platform"`  // 项目平台,1-7分别代表小红书、抖音、微博、快手、b站、大众点评、知乎
+	ProjectForm      int64                   `json:"project_form"`      // 项目形式,1-4分别代表实体商品寄拍、虚拟产品测评、线下探店打卡、素材微原创
+	TalentType       string                  `json:"talent_type"`       // 达人类型
+	RecruitDdl       time.Time               `json:"recruit_ddl"`       // 招募截止时间
+	ContentType      int64                   `json:"content_type"`      // 内容形式,1代表图文,2代表视频
+	ProjectDetail    string                  `json:"project_detail"`    // 项目详情
+	RecruitStrategys []CreateRecruitStrategy `json:"recruit_strategys"` // 定价策略
+	ProjectPhotos    []CreateProjectPhoto    `json:"project_photos"`    // 项目图片
+	ProductID        int64                   `json:"product_id"`        // 关联商品id
+}
+
+type CreateProjectData struct {
+	ProjectID int64 `json:"Project_id"` // 项目id
+}
+
+func NewCreateProjectRequest() *CreateProjectRequest {
+	return new(CreateProjectRequest)
+}
+func NewCreateProjectResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(CreateProjectData)
+	return resp
+}

+ 19 - 0
model/http_model/update_user_info.go

@@ -0,0 +1,19 @@
+package http_model
+
+type UpdateUserInfoRequest struct {
+	User     string `json:"user"`
+	Username string `json:"username"`
+	Role     string `json:"role"`
+	Password string `json:"password"`
+	Email    string `json:"email"`
+	Phone    string `json:"phone"`
+}
+
+func NewUpdateUserInfoRequest() *UpdateUserInfoRequest {
+	return new(UpdateUserInfoRequest)
+}
+
+func NewUpdateUserInfoResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	return resp
+}

+ 29 - 0
model/http_model/user_list.go

@@ -0,0 +1,29 @@
+package http_model
+
+type UserListRequest struct {
+	PageSize int32 `json:"page_size"`
+	PageNum  int32 `json:"page_num"`
+}
+type UserListPreview struct {
+	User      string `json:"user"`       // 账号
+	Username  string `json:"username"`   // 后台用户名
+	Password  string `json:"password"`   // 用户密码
+	Role      string `json:"role"`       // 角色 1,超级管理员; 2,管理员;3,企业用户
+	Phone     string `json:"phone"`      // 绑定手机
+	Email     string `json:"email"`      // 电子邮件
+	UserState string `json:"user_state"` // 0,禁用,1,正常
+	CreatedAt string `json:"created_at"` // 创建时间
+}
+type UserListData struct {
+	UserListPreview []*UserListPreview `json:"user_list_preview"`
+	Total           string             `json:"total"`
+}
+
+func NewGetUserListRequest() *UserListRequest {
+	return new(UserListRequest)
+}
+func NewGetUserListResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(UserListData)
+	return resp
+}

+ 28 - 0
pack/all_project.go

@@ -0,0 +1,28 @@
+package pack
+
+import (
+	"github.com/caixw/lib.go/conv"
+	"youngee_m_api/consts"
+	"youngee_m_api/model/http_model"
+)
+
+func MGormAllProjectToHttpAllProjectPreview(allProjectPreviews []*http_model.GetAllProjectPreview) []*http_model.GetAllProjectPreview {
+	var httpProjectPreviews []*http_model.GetAllProjectPreview
+	for _, projectInfo := range allProjectPreviews {
+		httpProjectPreview := GormAllProjectToHttpAllProjectPreview(projectInfo)
+		httpProjectPreviews = append(httpProjectPreviews, httpProjectPreview)
+	}
+	return httpProjectPreviews
+}
+func GormAllProjectToHttpAllProjectPreview(projectInfo *http_model.GetAllProjectPreview) *http_model.GetAllProjectPreview {
+	updatedTime := conv.MustString(projectInfo.ProjectUpdated, "")
+	updatedTime = updatedTime[0:19]
+	return &http_model.GetAllProjectPreview{
+		EnterpriseID:   projectInfo.EnterpriseID,
+		ProjectStatus:  consts.GetProjectStatus(conv.MustInt64(projectInfo.ProjectStatus, 0)),
+		ProjectUpdated: updatedTime,
+		ProjectId:      projectInfo.ProjectId,
+		Phone:          projectInfo.Phone,
+		Username:       projectInfo.Username,
+	}
+}

+ 14 - 0
pack/creator_list_conditions.go

@@ -0,0 +1,14 @@
+package pack
+
+import (
+	"youngee_m_api/model/common_model"
+	"youngee_m_api/model/http_model"
+)
+
+func HttpCreatorListRequestToCondition(req *http_model.CreatorListRequest) *common_model.CreatorListConditions {
+	return &common_model.CreatorListConditions{
+		Id:               req.Id,
+		TalentWxNickname: req.TalentWxNickname,
+		CreateDate:       req.CreateDate,
+	}
+}

+ 14 - 0
pack/enterprise_user_conditions.go

@@ -0,0 +1,14 @@
+package pack
+
+import (
+	"youngee_m_api/model/common_model"
+	"youngee_m_api/model/http_model"
+)
+
+func HttpEnterpriseUserRequestToCondition(req *http_model.EnterpriseUserRequest) *common_model.EnterpriseUserConditions {
+	return &common_model.EnterpriseUserConditions{
+		User:      req.User,
+		Username:  req.Username,
+		CreatedAt: req.CreatedAt,
+	}
+}

+ 26 - 0
pack/platform.go

@@ -0,0 +1,26 @@
+package pack
+
+import (
+	"youngee_m_api/consts"
+	"youngee_m_api/model/gorm_model"
+	"youngee_m_api/model/http_model"
+)
+
+func GormPlatformToHttpPlatform(gormPlatform []*gorm_model.YoungeePlatformAccountInfo) []*http_model.PlatformAccInfoData {
+	var platformAccInfos []*http_model.PlatformAccInfoData
+	for _, v := range gormPlatform {
+		platformAccInfo := gormPlatformToHttpPlatform(v)
+		platformAccInfos = append(platformAccInfos, platformAccInfo)
+	}
+	return platformAccInfos
+}
+
+func gormPlatformToHttpPlatform(platformAccountInfo *gorm_model.YoungeePlatformAccountInfo) *http_model.PlatformAccInfoData {
+	return &http_model.PlatformAccInfoData{
+		Platform:           consts.GetProjectPlatform(platformAccountInfo.PlatformID),
+		PlatformNickname:   platformAccountInfo.PlatformNickname,
+		Fans:               platformAccountInfo.FansCount,
+		HomePageCaptureUrl: platformAccountInfo.HomePageCaptureUrl,
+		HomePageUrl:        platformAccountInfo.HomePageUrl,
+	}
+}

+ 17 - 0
pack/project_taskList_conditions.go

@@ -0,0 +1,17 @@
+package pack
+
+import (
+	"github.com/caixw/lib.go/conv"
+	"youngee_m_api/model/common_model"
+	"youngee_m_api/model/http_model"
+)
+
+func HttpProjectTaskRequestToCondition(req *http_model.ProjectTaskListRequest) *common_model.TaskConditions {
+	return &common_model.TaskConditions{
+		ProjectId:        conv.MustInt64(req.ProjectId, 0),
+		TaskStatus:       conv.MustInt64(req.TaskStatus, 0),
+		StrategyId:       conv.MustInt64(req.StrategyId, 0),
+		TaskId:           conv.MustString(req.TaskId, ""),
+		PlatformNickname: conv.MustString(req.PlatformNickname, ""),
+	}
+}

+ 54 - 0
pack/project_task_list.go

@@ -0,0 +1,54 @@
+package pack
+
+import (
+	"github.com/caixw/lib.go/conv"
+	"youngee_m_api/model/http_model"
+)
+
+func MGormProjectTaskToHttpProjectTaskPreview(gormProjectTaskInfos []*http_model.ProjectTaskInfo) []*http_model.ProjectTaskPreview {
+	var httpProjectPreviews []*http_model.ProjectTaskPreview
+	for _, gormProjectTaskInfo := range gormProjectTaskInfos {
+		httpProjectTaskPreview := GormFullProjectToHttpProjectTaskPreview(gormProjectTaskInfo)
+		httpProjectPreviews = append(httpProjectPreviews, httpProjectTaskPreview)
+	}
+	return httpProjectPreviews
+}
+
+func GormFullProjectToHttpProjectTaskPreview(projectTaskInfo *http_model.ProjectTaskInfo) *http_model.ProjectTaskPreview {
+	createDate := conv.MustString(projectTaskInfo.CreateDate, "")
+	createDate = createDate[0:19]
+	return &http_model.ProjectTaskPreview{
+		TaskId:             conv.MustString(projectTaskInfo.TaskID, ""),
+		PlatformNickname:   conv.MustString(projectTaskInfo.PlatformNickname, ""),
+		FansCount:          conv.MustString(projectTaskInfo.FansCount, ""),
+		HomePageCaptureUrl: conv.MustString(projectTaskInfo.HomePageCaptureUrl, ""),
+		StrategyId:         conv.MustString(projectTaskInfo.StrategyID, ""),
+		TaskReward:         conv.MustString(projectTaskInfo.TaskReward, ""),
+		HomePageUrl:        conv.MustString(projectTaskInfo.HomePageUrl, ""),
+		TaskStatus:         conv.MustString(projectTaskInfo.TaskStatus, ""),
+		CreateDate:         createDate,
+	}
+}
+
+func TaskAccountToTaskInfo(taskAccounts []*http_model.TaskAccount) []*http_model.ProjectTaskInfo {
+	var projectTasks []*http_model.ProjectTaskInfo
+	for _, taskAccount := range taskAccounts {
+		projectTask := GetTaskInfoStruct(taskAccount)
+		projectTasks = append(projectTasks, projectTask)
+	}
+	return projectTasks
+}
+
+func GetTaskInfoStruct(taskAccount *http_model.TaskAccount) *http_model.ProjectTaskInfo {
+	return &http_model.ProjectTaskInfo{
+		TaskID:             taskAccount.Task.TaskId,
+		TaskReward:         taskAccount.Task.TaskReward,
+		PlatformNickname:   taskAccount.Account.PlatformNickname,
+		CreateDate:         taskAccount.Task.CreateDate,
+		HomePageUrl:        taskAccount.Account.HomePageUrl,
+		HomePageCaptureUrl: taskAccount.Account.HomePageCaptureUrl,
+		FansCount:          taskAccount.Account.FansCount,
+		TaskStatus:         string(rune(taskAccount.Task.TaskStatus)),
+		StrategyID:         taskAccount.Task.StrategyId,
+	}
+}

+ 77 - 0
pack/user_list.go

@@ -0,0 +1,77 @@
+package pack
+
+import (
+	"github.com/caixw/lib.go/conv"
+	"youngee_m_api/consts"
+	"youngee_m_api/model/gorm_model"
+	"youngee_m_api/model/http_model"
+)
+
+func MGormUserListToHttpUserListPreview(users []gorm_model.YounggeeUser) []*http_model.UserListPreview {
+	var httpUserListPreviews []*http_model.UserListPreview
+	for _, user := range users {
+		httpUserListPreview := GormUserListToHttpUserListPreview(user)
+		httpUserListPreviews = append(httpUserListPreviews, httpUserListPreview)
+	}
+	return httpUserListPreviews
+}
+func GormUserListToHttpUserListPreview(gormUser gorm_model.YounggeeUser) *http_model.UserListPreview {
+	createdTime := conv.MustString(gormUser.CreatedAt, "")
+	createdTime = createdTime[0:19]
+	return &http_model.UserListPreview{
+		User:      gormUser.User,
+		Username:  gormUser.Username,
+		Password:  gormUser.Password,
+		Role:      consts.GetUserRoleType(gormUser.Role),
+		Email:     gormUser.Email,
+		Phone:     gormUser.Phone,
+		UserState: consts.GetUserStateType(gormUser.UserState),
+		CreatedAt: createdTime,
+	}
+}
+
+func EnterpriseUserToEnterpriseUserData(enterpriseUsers []*http_model.EnterpriseUser) []*http_model.EnterpriseUserPreview {
+	var enterpriseUserPreviews []*http_model.EnterpriseUserPreview
+	for _, enterpriseUser := range enterpriseUsers {
+		enterpriseUserPreview := GetEnterPriseUserStruct(enterpriseUser)
+		enterpriseUserPreviews = append(enterpriseUserPreviews, enterpriseUserPreview)
+	}
+	return enterpriseUserPreviews
+}
+
+func GetEnterPriseUserStruct(enterpriseUser *http_model.EnterpriseUser) *http_model.EnterpriseUserPreview {
+	createdAt := conv.MustString(enterpriseUser.YoungeeUser.CreatedAt, "")
+	createdAt = createdAt[0:19]
+	return &http_model.EnterpriseUserPreview{
+		User:             enterpriseUser.YoungeeUser.User,
+		UserID:           conv.MustString(enterpriseUser.Enterprise.UserID, ""),
+		Username:         enterpriseUser.YoungeeUser.Username,
+		Balance:          enterpriseUser.Enterprise.Balance,
+		AvailableBalance: enterpriseUser.Enterprise.AvailableBalance,
+		FrozenBalance:    enterpriseUser.Enterprise.FrozenBalance,
+		Phone:            enterpriseUser.YoungeeUser.Phone,
+		CreatedAt:        createdAt,
+	}
+}
+
+func TalentListToCreatorListData(talentList []gorm_model.YoungeeTalentInfo) []*http_model.CreatorListPreview {
+	var CreatorListPreviews []*http_model.CreatorListPreview
+	for _, talent := range talentList {
+		talentPreview := GetCreatorListStruct(talent)
+		CreatorListPreviews = append(CreatorListPreviews, talentPreview)
+	}
+	return CreatorListPreviews
+}
+
+func GetCreatorListStruct(talent gorm_model.YoungeeTalentInfo) *http_model.CreatorListPreview {
+	createDate := conv.MustString(talent.CreateDate, "")
+	createDate = createDate[0:19]
+	return &http_model.CreatorListPreview{
+		Id:               talent.ID,
+		TalentWxNickname: talent.TalentWxNickname,
+		IsBindAccount:    consts.GetCreatorIsBindAccountType(talent.IsBindAccount),
+		CanWithDraw:      talent.Canwithdraw,
+		TalentPhone:      talent.TalentPhoneNumber,
+		CreateDate:       createDate,
+	}
+}

+ 16 - 11
route/init.go

@@ -18,15 +18,6 @@ func InitRoute(r *gin.Engine) {
 		}
 		c.JSON(200, resp)
 	})
-	//r.Any("/testDemo", func(c *gin.Context) {
-	//	resp := http_model.CommonResponse{
-	//		Status:  0,
-	//		Message: "",
-	//		Data:    "pong",
-	//	}
-	//	c.JSON(200, resp)
-	//	// 注意这里只是debug用的 接口要写成handler形式
-	//})
 	m := r.Group("/youngee/m")
 	{
 		m.POST("/test", func(c *gin.Context) {
@@ -39,11 +30,25 @@ func InitRoute(r *gin.Engine) {
 		})
 		m.POST("/product/list", handler.WrapFullProjectListHandler)
 		m.POST("/project/show", handler.WrapShowProjectHandler)
-		//m.POST("/product/findall", handler.WrapFindAllProductHandler)
+		m.POST("/product/findall", handler.WrapFindAllProductHandler)
+		m.POST("/project/create", handler.WrapCreateProjectHandler)
+		m.POST("/product/create", handler.WrapCreateProductHandler)
 		m.POST("/product/find", handler.WrapFindProductHandler)
 		m.POST("/pay/paysum", handler.WrapPaySumHandler)
 		m.POST("/project/update", handler.WrapUpdateProjectHandler)
 		m.POST("/project/approve", handler.WrapApproveProjectHandler)
+		m.POST("/project/all", handler.WrapGetAllProjectHandler)
+		m.POST("/project/taskList", handler.WrapProjectTaskListHandler)
+	}
+	u := r.Group("/youngee/m/user")
+	{
+		u.POST("/getUserList", handler.WrapGetUserListHandler)
+		u.POST("/updateUserInfo", handler.WrapUpdateUserInfoHandler)
+		u.POST("/createUser", handler.WrapCreateUserHandler)
+		u.POST("/disabledUser", handler.WrapDisabledUserHandler)
+		u.POST("/enterpriseUser", handler.WrapEnterpriseUserHandler)
+		u.POST("/creatorList", handler.WrapCreatorListHandler)
+		u.POST("/platformAccInfo", handler.WrapPlatformAccInfoHandler)
+		u.POST("/talentInfo", handler.WrapTalentInfoHandler)
 	}
-
 }

+ 20 - 16
service/login_auth.go

@@ -47,38 +47,42 @@ func (l *loginAuth) AuthToken(ctx context.Context, token string) (*redis_model.A
 	return auth, nil
 }
 
-func (l *loginAuth) AuthCode(ctx context.Context, User string, password string) (string,string, error) {
+func (l *loginAuth) AuthCode(ctx context.Context, User string, password string) (string, string, string, error) {
 	user, err := db.GetUser(ctx, User)
 	if err != nil {
-		return "","", err
+		return "", "", "", err
 	} else if user == nil {
 		// 账号不存在
 		logrus.Debugf("[AuthCode] auth fail,User:%+v", User)
-		return "账号不存在","", errors.New("auth fail")
-	} else if string(user.Role) != consts.BRole && string(user.Role) != consts.BRole2{
+		return "账号不存在", "", "", errors.New("auth fail")
+	} else if string(user.Role) != consts.BRole && string(user.Role) != consts.BRole2 {
 		// 账号权限有误
 		logrus.Debugf("[AuthCode] auth fail,User:%+v", User)
-		return "权限错误,请登录管理账号","", errors.New("auth fail")
+		return "权限错误,请登录管理账号", "", "", errors.New("auth fail")
+	} else if string(user.UserState) != "1" {
+		// 账号已经被禁用
+		logrus.Debugf("[AuthCode] auth fail,User:%+v", User)
+		return "账号已经被禁用", "", "", errors.New("auth fail")
 	}
 	var token string
-	if user.Password == password{
+	if user.Password == password {
 		token = l.getToken(ctx, user.User)
 		auth := &redis_model.Auth{
-			Phone:        user.Phone,
-			ID:           user.ID,
-			User:         user.User,
-			Username:     user.Username,
-			RealName:     user.RealName,
-			Role:         user.Role,
-			Email:        user.Email,
-			Token:        token,
+			Phone:    user.Phone,
+			ID:       user.ID,
+			User:     user.User,
+			Username: user.Username,
+			RealName: user.RealName,
+			Role:     user.Role,
+			Email:    user.Email,
+			Token:    token,
 		}
 		if err := l.setSession(ctx, user.User, auth); err != nil {
 			fmt.Printf("setSession error\n")
-			return "", "",err
+			return "", "", "", err
 		}
 	}
-	return token,user.Username,nil
+	return token, user.Username, user.Role, nil
 }
 
 func (l *loginAuth) setSession(ctx context.Context, user string, auth *redis_model.Auth) error {

+ 102 - 0
service/product.go

@@ -2,7 +2,9 @@ package service
 
 import (
 	"context"
+	"youngee_m_api/consts"
 	"youngee_m_api/db"
+	"youngee_m_api/model/gorm_model"
 	"youngee_m_api/model/http_model"
 )
 
@@ -11,6 +13,43 @@ var Product *product
 type product struct {
 }
 
+func (*product) Create(ctx context.Context, newProduct http_model.CreateProductRequest, enterpriseID int64) (*http_model.CreateProductData, error) {
+	product := gorm_model.YounggeeProduct{
+		ProductName:   newProduct.ProductName,
+		ProductType:   newProduct.ProductType,
+		ShopAddress:   newProduct.ShopAddress,
+		ProductPrice:  newProduct.ProductPrice,
+		ProductDetail: newProduct.ProductDetail,
+		ProductUrl:    newProduct.ProductUrl,
+		EnterpriseID:  enterpriseID,
+		BrandName:     newProduct.BrandName,
+	}
+	productID, err := db.CreateProduct(ctx, product)
+	if err != nil {
+		return nil, err
+	}
+	if newProduct.ProductPhotos != nil {
+		productPhotos := []gorm_model.YounggeeProductPhoto{}
+		for _, photo := range newProduct.ProductPhotos {
+			productPhoto := gorm_model.YounggeeProductPhoto{
+				PhotoUrl:  photo.PhotoUrl,
+				PhotoUid:  photo.PhotoUid,
+				Symbol:    photo.Symbol,
+				ProductID: *productID,
+			}
+			productPhotos = append(productPhotos, productPhoto)
+		}
+		err = db.CreateProductPhoto(ctx, productPhotos)
+		if err != nil {
+			return nil, err
+		}
+	}
+	res := &http_model.CreateProductData{
+		ProductID: *productID,
+	}
+	return res, nil
+}
+
 func (*product) FindByID(ctx context.Context, productID int64) (*http_model.FindProductData, error) {
 	product, err := db.GetProductByID(ctx, productID)
 	if err != nil {
@@ -44,3 +83,66 @@ func (*product) FindByID(ctx context.Context, productID int64) (*http_model.Find
 	}
 	return &findProductData, nil
 }
+
+func (*product) FindAll(ctx context.Context, enterpriseID int64) (*http_model.FindAllProductData, error) {
+	products, err := db.GetProductByEnterpriseID(ctx, enterpriseID)
+	if err != nil {
+		// 数据库查询error
+		return nil, err
+	}
+	findAllProductData := http_model.FindAllProductData{}
+	for _, product := range products {
+		productData := http_model.ProductInfo{
+			ProductID:   product.ProductID,
+			BrandName:   product.BrandName,
+			ProductName: product.ProductName,
+			ProductType: consts.GetProjectTypes(product.ProductType),
+		}
+		findAllProductData.ProductInfos = append(findAllProductData.ProductInfos, productData)
+	}
+	return &findAllProductData, nil
+}
+
+func (*product) Update(ctx context.Context, newProduct http_model.CreateProductRequest, enterpriseID int64) (*http_model.CreateProductData, error) {
+	product := gorm_model.YounggeeProduct{
+		ProductID:     newProduct.ProductId,
+		ProductName:   newProduct.ProductName,
+		ProductType:   newProduct.ProductType,
+		ShopAddress:   newProduct.ShopAddress,
+		ProductPrice:  newProduct.ProductPrice,
+		ProductDetail: newProduct.ProductDetail,
+		ProductUrl:    newProduct.ProductUrl,
+		EnterpriseID:  enterpriseID,
+		BrandName:     newProduct.BrandName,
+	}
+	productID, err := db.UpdateProduct(ctx, product)
+	if err != nil {
+		return nil, err
+	}
+	// 删除该商品之前的所有图片
+	err = db.DeleteProductPhotoByProductID(ctx, *productID)
+	if err != nil {
+		return nil, err
+	}
+	if newProduct.ProductPhotos != nil {
+		// 新增图片
+		productPhotos := []gorm_model.YounggeeProductPhoto{}
+		for _, photo := range newProduct.ProductPhotos {
+			productPhoto := gorm_model.YounggeeProductPhoto{
+				PhotoUrl:  photo.PhotoUrl,
+				PhotoUid:  photo.PhotoUid,
+				Symbol:    photo.Symbol,
+				ProductID: *productID,
+			}
+			productPhotos = append(productPhotos, productPhoto)
+		}
+		err = db.CreateProductPhoto(ctx, productPhotos)
+		if err != nil {
+			return nil, err
+		}
+	}
+	res := &http_model.CreateProductData{
+		ProductID: *productID,
+	}
+	return res, nil
+}

+ 141 - 36
service/project.go

@@ -6,6 +6,8 @@ import (
 	"github.com/caixw/lib.go/conv"
 	"github.com/gin-gonic/gin"
 	"github.com/sirupsen/logrus"
+	"strconv"
+	"strings"
 	"youngee_m_api/db"
 	"youngee_m_api/model/common_model"
 	"youngee_m_api/model/gorm_model"
@@ -18,19 +20,19 @@ var Project *project
 type project struct {
 }
 
-func (*project) GetFullProjectList(ctx context.Context , pageSize, pageNum int32, condition *common_model.ProjectCondition) (*http_model.FullProjectListData, error) {
-	fullProjects, total, err := db.GetFullProjectList(ctx , pageSize, pageNum, condition)
+func (*project) GetFullProjectList(ctx context.Context, pageSize, pageNum int32, condition *common_model.ProjectCondition) (*http_model.FullProjectListData, error) {
+	fullProjects, total, err := db.GetFullProjectList(ctx, pageSize, pageNum, condition)
 	if err != nil {
 		logrus.WithContext(ctx).Errorf("[project service] call GetFullProjectList error,err:%+v", err)
 		return nil, err
 	}
 	fullProjectListData := new(http_model.FullProjectListData)
 	fullProjectListData.FullProjectPreview = pack.MGormFullProjectToHttpFullProjectPreview(fullProjects)
-	fullProjectListData.Total = conv.MustString(total,"")
+	fullProjectListData.Total = conv.MustString(total, "")
 	return fullProjectListData, nil
 }
 
-func (*project) GetPorjectDetail(ctx context.Context,EnterpriseID string, projectID int64) (*http_model.ShowProjectData, error) {
+func (*project) GetProjectDetail(ctx context.Context, EnterpriseID string, projectID int64) (*http_model.ShowProjectData, error) {
 	project, err := db.GetProjectDetail(ctx, projectID)
 	if err != nil {
 		logrus.WithContext(ctx).Errorf("[project service] call GetPorjectDetail error,err:%+v", err)
@@ -50,19 +52,19 @@ func (*project) GetPorjectDetail(ctx context.Context,EnterpriseID string, projec
 	fmt.Println("%+v", user.Phone)
 	//var RecruitStrategys []http_model.ShowRecruitStrategy
 	ProjectDetail := http_model.ShowProjectData{
-		ProjectID:       conv.MustString(project.ProjectID,""),
-		ProjectName:     conv.MustString(project.ProjectName,""),
-		ProjectStatus:   conv.MustString(project.ProjectStatus,""),
-		ProjectType:     conv.MustString(project.ProjectType,""),
-		ProjectPlatform: conv.MustString(project.ProjectPlatform,""),
-		ProjectForm:     conv.MustString(project.ProjectForm,""),
-		TalentType:      conv.MustString(project.TalentType,""),
+		ProjectID:       conv.MustString(project.ProjectID, ""),
+		ProjectName:     conv.MustString(project.ProjectName, ""),
+		ProjectStatus:   conv.MustString(project.ProjectStatus, ""),
+		ProjectType:     conv.MustString(project.ProjectType, ""),
+		ProjectPlatform: conv.MustString(project.ProjectPlatform, ""),
+		ProjectForm:     conv.MustString(project.ProjectForm, ""),
+		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,""),
-		Balance:         conv.MustString(enterprise.Balance,""),
+		ContentType:     conv.MustString(project.ContentType, ""),
+		ProjectDetail:   conv.MustString(project.ProjectDetail, ""),
+		ProductID:       conv.MustString(project.ProductID, ""),
+		EnterpriseID:    conv.MustString(project.EnterpriseID, ""),
+		Balance:         conv.MustString(enterprise.Balance, ""),
 		CreateAt:        project.CreatedAt,
 		UpdateAt:        project.UpdatedAt,
 		Phone:           user.Phone,
@@ -74,12 +76,12 @@ func (*project) GetPorjectDetail(ctx context.Context,EnterpriseID string, projec
 	}
 	for _, strategy := range Strategys {
 		RecruitStrategy := http_model.ShowRecruitStrategy{
-			FeeForm:       conv.MustString(strategy.FeeForm,""),
-			StrategyID:    conv.MustString(strategy.StrategyID,""),
-			FollowersLow:  conv.MustString(strategy.FollowersLow,""),
-			FollowersUp:   conv.MustString(strategy.FollowersUp,""),
-			RecruitNumber: conv.MustString(strategy.RecruitNumber,""),
-			Offer:         conv.MustString(strategy.Offer,""),
+			FeeForm:       conv.MustString(strategy.FeeForm, ""),
+			StrategyID:    conv.MustString(strategy.StrategyID, ""),
+			FollowersLow:  conv.MustString(strategy.FollowersLow, ""),
+			FollowersUp:   conv.MustString(strategy.FollowersUp, ""),
+			RecruitNumber: conv.MustString(strategy.RecruitNumber, ""),
+			Offer:         conv.MustString(strategy.Offer, ""),
 		}
 		ProjectDetail.RecruitStrategys = append(ProjectDetail.RecruitStrategys, RecruitStrategy)
 	}
@@ -101,13 +103,13 @@ func (*project) GetPorjectDetail(ctx context.Context,EnterpriseID string, projec
 func (*project) Update(ctx context.Context, newProject http_model.UpdateProjectRequest, enterpriseID string) (*http_model.UpdateProjectData, error) {
 	fmt.Println("newproject:", newProject)
 	project := gorm_model.ProjectInfo{
-		ProjectID:     conv.MustInt64(newProject.ProjectID,0),
+		ProjectID:     conv.MustInt64(newProject.ProjectID, 0),
 		RecruitDdl:    newProject.RecruitDdl,
 		TalentType:    newProject.TalentType,
-		ContentType:   conv.MustInt64(newProject.ContentType,0),
+		ContentType:   conv.MustInt64(newProject.ContentType, 0),
 		ProjectDetail: newProject.ProjectDetail,
-		ProjectForm:   conv.MustInt64(newProject.ProjectForm,0),
-		EnterpriseID:  conv.MustInt64(enterpriseID,0),
+		ProjectForm:   conv.MustInt64(newProject.ProjectForm, 0),
+		EnterpriseID:  conv.MustInt64(enterpriseID, 0),
 		ProjectStatus: 4,
 	}
 	projectID, err := db.UpdateProject(ctx, project)
@@ -147,12 +149,12 @@ func (*project) Update(ctx context.Context, newProject http_model.UpdateProjectR
 		RecruitStrategys := []gorm_model.RecruitStrategy{}
 		for _, Strategy := range newProject.RecruitStrategys {
 			RecruitStrategy := gorm_model.RecruitStrategy{
-				FeeForm:       conv.MustInt64(Strategy.FeeForm,0),
-				StrategyID:    conv.MustInt64(Strategy.StrategyID,0),
-				FollowersLow:  conv.MustInt64(Strategy.FollowersLow,0),
-				FollowersUp:   conv.MustInt64(Strategy.FollowersUp,0),
-				RecruitNumber: conv.MustInt64(Strategy.RecruitNumber,0),
-				Offer:         conv.MustInt64(Strategy.Offer,0),
+				FeeForm:       conv.MustInt64(Strategy.FeeForm, 0),
+				StrategyID:    conv.MustInt64(Strategy.StrategyID, 0),
+				FollowersLow:  conv.MustInt64(Strategy.FollowersLow, 0),
+				FollowersUp:   conv.MustInt64(Strategy.FollowersUp, 0),
+				RecruitNumber: conv.MustInt64(Strategy.RecruitNumber, 0),
+				Offer:         conv.MustInt64(Strategy.Offer, 0),
 				ProjectID:     project.ProjectID,
 			}
 			fmt.Printf("Offer:\t %+v", Strategy.Offer)
@@ -170,11 +172,114 @@ func (*project) Update(ctx context.Context, newProject http_model.UpdateProjectR
 }
 
 func (*project) ApproveProject(ctx *gin.Context, data http_model.ApproveProjectRequest) (error, string) {
-	fmt.Println("data.IsApprove:",data.IsApprove)
-	err,message := db.ApproveProject(ctx, data.ProjectId ,data.IsApprove)
+	fmt.Println("data.IsApprove:", data.IsApprove)
+	err, message := db.ApproveProject(ctx, data.ProjectId, data.IsApprove)
 	if err != nil {
 		logrus.WithContext(ctx).Errorf("[project service] call ChangeTaskStatus error,err:%+v", err)
-		return err,""
+		return err, ""
 	}
-	return nil,message
+	return nil, message
+}
+
+func (*project) GetAllProject(ctx context.Context, pageSize, pageNum int32) (*http_model.GetAllProjectData, error) {
+	allProjectPreviews, total, err := db.GetAllProject(ctx, pageSize, pageNum)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[project service] call GetAllProject error,err:%+v", err)
+		return nil, err
+	}
+	allProjects := new(http_model.GetAllProjectData)
+	allProjects.AllProjectPreview = pack.MGormAllProjectToHttpAllProjectPreview(allProjectPreviews)
+	allProjects.Total = conv.MustString(total, "")
+	return allProjects, nil
+}
+
+func (*project) GetProjectTaskList(ctx context.Context, projectID string, pageSize, pageNum int64, conditions *common_model.TaskConditions) (*http_model.ProjectTaskListData, error) {
+	projectTasks, total, err := db.GetProjectTaskList(ctx, projectID, pageSize, pageNum, conditions)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[project service] call GetProjectTaskList error,err:%+v", err)
+		return nil, err
+	}
+	projectTaskListData := new(http_model.ProjectTaskListData)
+	projectTaskListData.ProjectTaskPreview = pack.MGormProjectTaskToHttpProjectTaskPreview(projectTasks)
+	projectTaskListData.Total = conv.MustString(total, "")
+	return projectTaskListData, nil
+}
+
+func (*project) Create(ctx context.Context, newProject http_model.CreateProjectRequest, enterpriseID int64) (*http_model.CreateProjectData, error) {
+	// build gorm_model.ProjectInfo
+	// 查询关联商品信息
+	product, err := db.GetProductByID(ctx, newProject.ProductID)
+	if err != nil {
+		return nil, err
+	}
+	// 按照品牌名-商品名对项目进行命名
+	projectName := product.BrandName + "-" + product.ProductName
+	//feeForm := fmt.Sprintf("[")
+	feeFrom := []string{}
+	for _, strategy := range newProject.RecruitStrategys {
+		//if strategy.StrategyID
+		feeFrom = append(feeFrom, strconv.FormatInt(strategy.FeeForm, 10))
+		//feeForm += string(strategy.StrategyID)
+	}
+	feeFroms := strings.Join(feeFrom, ",")
+
+	projectInfo := gorm_model.ProjectInfo{
+		ProjectName:     projectName,
+		ProjectStatus:   1,
+		ProjectType:     newProject.ProjectType,
+		TalentType:      newProject.TalentType,
+		ProjectPlatform: newProject.ProjectPlatform,
+		ProjectForm:     newProject.ProjectForm,
+		RecruitDdl:      newProject.RecruitDdl,
+		ProjectDetail:   newProject.ProjectDetail,
+		ContentType:     newProject.ContentType,
+		EnterpriseID:    enterpriseID,
+		ProductID:       newProject.ProductID,
+		FeeForm:         feeFroms,
+	}
+	// db create ProjectInfo
+	projectID, err := db.CreateProject(ctx, projectInfo)
+	if err != nil {
+		return nil, err
+	}
+	if newProject.ProjectPhotos != nil {
+		// build []gorm_model.ProjectPhoto
+		projectPhotos := []gorm_model.ProjectPhoto{}
+		for _, photo := range newProject.ProjectPhotos {
+			projectPhoto := gorm_model.ProjectPhoto{
+				PhotoUrl:  photo.PhotoUrl,
+				PhotoUid:  photo.PhotoUid,
+				ProjectID: *projectID,
+			}
+			projectPhotos = append(projectPhotos, projectPhoto)
+		}
+		// db create ProjectPhoto
+		err = db.CreateProjectPhoto(ctx, projectPhotos)
+		if err != nil {
+			return nil, err
+		}
+	}
+	// build
+	recruitStrategys := []gorm_model.RecruitStrategy{}
+	for _, strategy := range newProject.RecruitStrategys {
+		recruitStrategy := gorm_model.RecruitStrategy{
+			FeeForm:       strategy.FeeForm,
+			StrategyID:    strategy.StrategyID,
+			FollowersLow:  strategy.FollowersLow,
+			FollowersUp:   strategy.FollowersUp,
+			RecruitNumber: strategy.RecruitNumber,
+			Offer:         strategy.Offer,
+			ProjectID:     *projectID,
+		}
+		recruitStrategys = append(recruitStrategys, recruitStrategy)
+	}
+	err = db.CreateRecruitStrategy(ctx, recruitStrategys)
+	if err != nil {
+		return nil, err
+	}
+	res := &http_model.CreateProjectData{
+		ProjectID: *projectID,
+	}
+	fmt.Printf("%+v", res)
+	return res, nil
 }

+ 39 - 0
service/user.go

@@ -0,0 +1,39 @@
+package service
+
+import (
+	"context"
+	"github.com/caixw/lib.go/conv"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/db"
+	"youngee_m_api/model/common_model"
+	"youngee_m_api/model/http_model"
+)
+
+var User *user
+
+type user struct {
+}
+
+func (*user) EnterpriseUserList(ctx context.Context, pageSize, pageNum int32, condition *common_model.EnterpriseUserConditions) (*http_model.EnterpriseUserData, error) {
+	enterpriseUsers, total, err := db.GetEnterpriseUserList(ctx, pageSize, pageNum, condition)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[user service] call GetEnterpriseUserList error,err:%+v", err)
+		return nil, err
+	}
+	EnterpriseUserData := new(http_model.EnterpriseUserData)
+	EnterpriseUserData.EnterpriseUserPreview = enterpriseUsers
+	EnterpriseUserData.Total = conv.MustString(total, "")
+	return EnterpriseUserData, nil
+}
+
+func (*user) CreatorList(ctx context.Context, pageSize, pageNum int32, conditions *common_model.CreatorListConditions) (*http_model.CreatorListData, error) {
+	CreatorList, total, err := db.GetCreatorList(ctx, pageSize, pageNum, conditions)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[user service] call GetEnterpriseUserList error,err:%+v", err)
+		return nil, err
+	}
+	CreatorListData := new(http_model.CreatorListData)
+	CreatorListData.CreatorListPreview = CreatorList
+	CreatorListData.Total = conv.MustString(total, "")
+	return CreatorListData, nil
+}

+ 15 - 0
util/deduplication.go

@@ -0,0 +1,15 @@
+package util
+
+// RemoveRepByMap 通过map主键唯一的特性过滤重复元素
+func RemoveRepByMap(slc []int64) []int64 {
+	result := []int64{}
+	tempMap := map[int64]byte{} // 存放不重复主键
+	for _, e := range slc {
+		l := len(tempMap)
+		tempMap[e] = 0
+		if len(tempMap) != l { // 加入map后,map长度变化,则元素不重复
+			result = append(result, e)
+		}
+	}
+	return result
+}