瀏覽代碼

管理后台后端

yuliang1112 2 年之前
當前提交
5a40a1f69b
共有 69 個文件被更改,包括 2562 次插入0 次删除
  1. 8 0
      .idea/.gitignore
  2. 8 0
      .idea/modules.xml
  3. 6 0
      .idea/vcs.xml
  4. 9 0
      .idea/youngee_m_api.iml
  5. 18 0
      config/dev.yaml
  6. 45 0
      config/init.go
  7. 6 0
      config/mail.json
  8. 18 0
      config/pro.yaml
  9. 28 0
      consts/error_code.go
  10. 68 0
      consts/project.go
  11. 7 0
      consts/session.go
  12. 22 0
      db/enterprise.go
  13. 29 0
      db/init.go
  14. 21 0
      db/product.go
  15. 34 0
      db/product_photo.go
  16. 124 0
      db/project.go
  17. 24 0
      db/recruit_strategy.go
  18. 17 0
      db/task.go
  19. 57 0
      db/user.go
  20. 39 0
      go.mod
  21. 117 0
      go.sum
  22. 49 0
      handler/base.go
  23. 51 0
      handler/get_login_user.go
  24. 55 0
      handler/login.go
  25. 56 0
      handler/pay_sum.go
  26. 55 0
      handler/product_find.go
  27. 95 0
      handler/product_list.go
  28. 57 0
      handler/project_approve.go
  29. 55 0
      handler/project_show.go
  30. 55 0
      handler/project_update.go
  31. 16 0
      main.go
  32. 37 0
      middleware/login_auth.go
  33. 11 0
      model/common_model/project_condition.go
  34. 9 0
      model/common_model/task_conditions.go
  35. 23 0
      model/gorm_model/enterprise.go
  36. 25 0
      model/gorm_model/product.go
  37. 20 0
      model/gorm_model/product_photo.go
  38. 30 0
      model/gorm_model/project.go
  39. 25 0
      model/gorm_model/project_account.go
  40. 19 0
      model/gorm_model/project_photo.go
  41. 35 0
      model/gorm_model/project_task.go
  42. 19 0
      model/gorm_model/recruit_strategy.go
  43. 37 0
      model/gorm_model/talent.go
  44. 26 0
      model/gorm_model/user.go
  45. 19 0
      model/http_model/code_login.go
  46. 10 0
      model/http_model/common_response.go
  47. 36 0
      model/http_model/full_project_list.go
  48. 17 0
      model/http_model/get_login_user.go
  49. 24 0
      model/http_model/pay_sum.go
  50. 33 0
      model/http_model/product_find.go
  51. 24 0
      model/http_model/product_findall.go
  52. 16 0
      model/http_model/project_approve.go
  53. 52 0
      model/http_model/project_show.go
  54. 60 0
      model/http_model/project_taskList.go
  55. 42 0
      model/http_model/project_update.go
  56. 13 0
      model/redis_model/auth.go
  57. 28 0
      model/system_model/config.go
  58. 31 0
      pack/full_project.go
  59. 21 0
      pack/full_project_condition.go
  60. 19 0
      redis/init.go
  61. 27 0
      redis/operation.go
  62. 49 0
      route/init.go
  63. 142 0
      service/login_auth.go
  64. 35 0
      service/pay.go
  65. 46 0
      service/product.go
  66. 180 0
      service/project.go
  67. 16 0
      util/encoding.go
  68. 27 0
      util/resp.go
  69. 30 0
      util/type.go

+ 8 - 0
.idea/.gitignore

@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+# Editor-based HTTP Client requests
+/httpRequests/

+ 8 - 0
.idea/modules.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/youngee_m_api.iml" filepath="$PROJECT_DIR$/.idea/youngee_m_api.iml" />
+    </modules>
+  </component>
+</project>

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
+  </component>
+</project>

+ 9 - 0
.idea/youngee_m_api.iml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="WEB_MODULE" version="4">
+  <component name="Go" enabled="true" />
+  <component name="NewModuleRootManager">
+    <content url="file://$MODULE_DIR$" />
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>

+ 18 - 0
config/dev.yaml

@@ -0,0 +1,18 @@
+mysql:
+  host: 139.9.53.143
+  port: 3306
+  user: talent
+  password: talentDB_123
+  database: youngmini
+
+redis:
+  host: 139.9.53.143
+  port: 6379
+  auth: younggeeRedis_123
+  database: 1
+
+server:
+  host: 0.0.0.0
+  port: 8400
+  session:
+    ttl: -1 # minute

+ 45 - 0
config/init.go

@@ -0,0 +1,45 @@
+package config
+
+import (
+	"fmt"
+	"gopkg.in/yaml.v2"
+	"io/ioutil"
+	"os"
+	"youngee_m_api/db"
+	"youngee_m_api/model/system_model"
+	"youngee_m_api/redis"
+	"youngee_m_api/service"
+)
+
+func Init() *system_model.Server {
+	config := new(system_model.Config)
+	env := getEnv()
+	configPath := fmt.Sprintf("./config/%s.yaml", env)
+
+	file, err := ioutil.ReadFile(configPath)
+	if err != nil {
+		panic(err)
+	}
+	//yaml文件内容影射到结构体中
+	err = yaml.Unmarshal(file, config)
+	if err != nil {
+		panic(err)
+	}
+	loadExternelConfig(config)
+	return config.Server
+}
+
+func loadExternelConfig(config *system_model.Config) {
+	db.Init(config.Mysql)
+	redis.Init(config.Redis)
+	service.LoginAuthInit(config.Server.Session)
+	//service.SendCodeInit(config.Server.Session)
+}
+
+func getEnv() string {
+	env := os.Getenv("youngee_env")
+	if env == "" {
+		env = "dev"
+	}
+	return env
+}

+ 6 - 0
config/mail.json

@@ -0,0 +1,6 @@
+{
+    "stmp_server": "smtp.qq.com",
+    "stmp_port": "587",
+    "stmp_user_name": "2467835131@qq.com",
+    "stmp_auth_token": "fqvrcfvlugygdjdc"
+}

+ 18 - 0
config/pro.yaml

@@ -0,0 +1,18 @@
+mysql:
+  host: 192.168.0.165
+  port: 3306
+  user: test
+  password: testDB_123
+  database: youngmini
+
+redis:
+  host: 139.9.53.143
+  port: 6379
+  auth: younggeeRedis_123
+  database: 1
+
+server:
+  host: 0.0.0.0
+  port: 8400
+  session:
+    ttl: -1 #minute

+ 28 - 0
consts/error_code.go

@@ -0,0 +1,28 @@
+package consts
+
+import "github.com/go-redis/redis/v8"
+
+var RedisNil = redis.Nil
+var errorCodeToastMap = map[int32]string{}
+
+const DefaultToast = ""
+
+const ErrorSuccess int32 = 0
+const ErrorNotLogin int32 = 4001
+const ErrorParamCheck int32 = 5001
+const ErrorInternal int32 = 5001
+
+func init() {
+	errorCodeToastMap[ErrorSuccess] = "请求成功"
+	errorCodeToastMap[ErrorNotLogin] = "请登录后操作"
+	errorCodeToastMap[ErrorParamCheck] = "参数有误"
+	errorCodeToastMap[ErrorInternal] = "网络错误"
+}
+
+func GetErrorToast(errorCode int32) string {
+	toast, contain := errorCodeToastMap[errorCode]
+	if contain {
+		return toast
+	}
+	return "网络错误,请稍后再试"
+}

+ 68 - 0
consts/project.go

@@ -0,0 +1,68 @@
+package consts
+
+var projectStatusMap = map[int64]string{
+	1: "创建中",
+	2: "待审核",
+	3: "审核通过",
+	4: "招募中",
+	5: "招募完毕",
+	6: "待支付",
+	7: "已支付",
+	8: "失效",
+	9: "执行中",
+	10: "已结案",
+}
+
+func GetProjectStatus(status int64) string {
+	toast, contain := projectStatusMap[status]
+	if contain {
+		return toast
+	}
+	return "未知"
+}
+
+var ProjectPlatformMap = map[int64]string{
+	1: "小红书",
+	2: "抖音",
+	3: "微博",
+	4: "快手",
+	5: "b站",
+	6: "大众点评",
+	7: "知乎",
+}
+
+func GetProjectPlatform(status int64) string {
+	toast, contain := ProjectPlatformMap[status]
+	if contain {
+		return toast
+	}
+	return "未知"
+}
+
+var ProjectFormMap = map[int64]string{
+	1: "实体商品寄拍",
+	2: "虚拟产品测评",
+	3: "线下探店打卡",
+	4: "素材微原创",
+}
+
+func GetProjectForm(status int64) string {
+	toast, contain := ProjectFormMap[status]
+	if contain {
+		return toast
+	}
+	return "未知"
+}
+
+var ProjectContentTypeMap = map[int64]string{
+	1: "图文",
+	2: "视频",
+}
+
+func GetProjectContentType(status int64) string {
+	toast, contain := ProjectContentTypeMap[status]
+	if contain {
+		return toast
+	}
+	return "未知"
+}

+ 7 - 0
consts/session.go

@@ -0,0 +1,7 @@
+package consts
+
+const SessionAuthSchema = "session_auth"
+const SessionRedisPrefix = "m_user:"
+const AuthSalt = "fa2tg4y"
+const BRole = "1"
+const BRole2 = "2"

+ 22 - 0
db/enterprise.go

@@ -0,0 +1,22 @@
+package db
+
+import (
+	"context"
+	"gorm.io/gorm"
+	"youngee_m_api/model/gorm_model"
+)
+
+//企业ID查找
+func GetEnterpriseByEnterpriseID(ctx context.Context, EnterpriseID int64) (*gorm_model.Enterprise, error) {
+	db := GetReadDB(ctx)
+	enterprise := gorm_model.Enterprise{}
+	err := db.Where("enterprise_id = ?", EnterpriseID).First(&enterprise).Error
+	if err != nil {
+		if err == gorm.ErrRecordNotFound {
+			return nil, nil
+		} else {
+			return nil, err
+		}
+	}
+	return &enterprise, nil
+}

+ 29 - 0
db/init.go

@@ -0,0 +1,29 @@
+package db
+
+import (
+	"context"
+	"fmt"
+	"youngee_m_api/model/system_model"
+
+	"gorm.io/driver/mysql"
+	"gorm.io/gorm"
+)
+
+var client *gorm.DB
+
+func Init(config *system_model.Mysql) {
+	dsn := "%v:%v@tcp(%v:%v)/%v?charset=utf8mb4&parseTime=True&loc=Local"
+	dsn = fmt.Sprintf(dsn, config.User, config.Password, config.Host, config.Port, config.Database)
+	db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})
+	if err != nil {
+		panic(err)
+	}
+	client = db
+}
+
+func GetReadDB(ctx context.Context) *gorm.DB {
+	return client.WithContext(ctx)
+}
+func GetWriteDB(ctx context.Context) *gorm.DB {
+	return client.WithContext(ctx)
+}

+ 21 - 0
db/product.go

@@ -0,0 +1,21 @@
+package db
+
+import (
+	"context"
+	"gorm.io/gorm"
+	"youngee_m_api/model/gorm_model"
+)
+
+func GetProductByID(ctx context.Context, productID int64) (*gorm_model.YounggeeProduct, error) {
+	db := GetReadDB(ctx)
+	product := &gorm_model.YounggeeProduct{}
+	err := db.First(&product, productID).Error
+	if err != nil {
+		if err == gorm.ErrRecordNotFound {
+			return nil, nil
+		} else {
+			return nil, err
+		}
+	}
+	return product, nil
+}

+ 34 - 0
db/product_photo.go

@@ -0,0 +1,34 @@
+package db
+
+import (
+	"context"
+	"youngee_m_api/model/gorm_model"
+)
+
+func GetProductPhotoByProductID(ctx context.Context, productID int64) ([]gorm_model.YounggeeProductPhoto, error) {
+	db := GetReadDB(ctx)
+	var productPhotos []gorm_model.YounggeeProductPhoto
+	err := db.Where("product_id = ?", productID).Find(&productPhotos).Error
+	if err != nil {
+		return nil, err
+	}
+	return productPhotos, nil
+}
+
+func CreateProjectPhoto(ctx context.Context, projectPhotos []gorm_model.ProjectPhoto) error {
+	db := GetReadDB(ctx)
+	err := db.Create(&projectPhotos).Error
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
+func DeleteProjectPhotoByProjecttID(ctx context.Context, productID int64) error {
+	db := GetReadDB(ctx)
+	err := db.Where("project_id = ?", productID).Delete(&gorm_model.ProjectPhoto{}).Error
+	if err != nil {
+		return err
+	}
+	return nil
+}

+ 124 - 0
db/project.go

@@ -0,0 +1,124 @@
+package db
+
+import (
+	"context"
+	"fmt"
+	"github.com/caixw/lib.go/conv"
+	"github.com/sirupsen/logrus"
+	"gorm.io/gorm"
+	"reflect"
+	"youngee_m_api/model/common_model"
+	"youngee_m_api/model/gorm_model"
+	"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()
+	conditionValue := reflect.ValueOf(condition).Elem()
+	for i := 0; i < conditionType.NumField(); i++ {
+		field := conditionType.Field(i)
+		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"))
+		}
+		if !util.IsBlank(value) && tag != "updated_at" && tag != "project_name" {
+			db = db.Where(fmt.Sprintf("%s = ?", tag), value.Interface())
+		}
+		if tag == "updated_at" && value.Interface() != "0" {
+			db = db.Where(fmt.Sprintf("%s > ?", tag), value.Interface())
+		}
+		if tag == "project_name" && !util.IsBlank(value) {
+			db = db.Where(fmt.Sprintf("%s = ?", tag), value.Interface())
+		}
+	}
+	// 查询总数
+	var total int64
+	var fullProjects []*gorm_model.ProjectInfo
+	if err := db.Count(&total).Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[GetFullProjectList] error query mysql total, err:%+v", err)
+		return nil, 0, err
+	}
+	// 查询该页数据
+	limit := pageSize
+	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)
+		return nil, 0, err
+	}
+	return fullProjects, total, nil
+}
+
+func GetProjectDetail(ctx context.Context, projectID int64) (*gorm_model.ProjectInfo, error) {
+	db := GetReadDB(ctx)
+	var ProjectDetail *gorm_model.ProjectInfo
+	err := db.Where("project_id = ?", projectID).First(&ProjectDetail).Error
+	if err != nil {
+		if err == gorm.ErrRecordNotFound {
+			return nil, nil
+		} else {
+			return nil, err
+		}
+	}
+	return ProjectDetail, nil
+}
+
+func GetRecruitStrategys(ctx context.Context, ProjectID int64) ([]gorm_model.RecruitStrategy, error) {
+	db := GetReadDB(ctx)
+	RecruitStrategys := []gorm_model.RecruitStrategy{}
+	err := db.Where("project_id=?", ProjectID).Find(&RecruitStrategys).Error
+	if err != nil {
+		return nil, err
+	}
+	return RecruitStrategys, nil
+}
+
+func GetProjectPhoto(ctx context.Context, ProjectID int64) ([]gorm_model.ProjectPhoto, error) {
+	db := GetReadDB(ctx)
+	var ProjectPhoto []gorm_model.ProjectPhoto
+	err := db.Where("project_id=?", ProjectID).Find(&ProjectPhoto).Error
+	if err != nil {
+		return nil, err
+	}
+	return ProjectPhoto, nil
+}
+
+func UpdateProject(ctx context.Context, project gorm_model.ProjectInfo) (*int64, error) {
+	db := GetReadDB(ctx)
+	err := db.Model(&project).Updates(project).Error
+	if err != nil {
+		return nil, err
+	}
+	return &project.ProjectID, nil
+}
+
+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)
+	fmt.Println("isApprove:",isApprove)
+	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,""
+		}
+	}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,""
+		}
+	}else {
+		return nil,"操作失败"
+	}
+	return nil,message
+}

+ 24 - 0
db/recruit_strategy.go

@@ -0,0 +1,24 @@
+package db
+
+import (
+	"context"
+	"youngee_m_api/model/gorm_model"
+)
+
+func CreateRecruitStrategy(ctx context.Context, recruitStrategys []gorm_model.RecruitStrategy) error {
+	db := GetReadDB(ctx)
+	err := db.Create(&recruitStrategys).Error
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
+func DeleteRecruitStrategyByProjectID(ctx context.Context, projectID int64) error {
+	db := GetReadDB(ctx)
+	err := db.Where("project_id = ?", projectID).Delete(&gorm_model.RecruitStrategy{}).Error
+	if err != nil {
+		return err
+	}
+	return nil
+}

+ 17 - 0
db/task.go

@@ -0,0 +1,17 @@
+package db
+
+import (
+	"context"
+	"youngee_m_api/model/gorm_model"
+)
+
+func GetTaskList(ctx context.Context, projectID int64) ([]gorm_model.YoungeeTaskInfo, error) {
+	db := GetReadDB(ctx)
+	var tasks []gorm_model.YoungeeTaskInfo
+
+	err := db.Where("project_id=?", projectID).Find(&tasks).Error
+	if err != nil {
+		return nil, err
+	}
+	return tasks, nil
+}

+ 57 - 0
db/user.go

@@ -0,0 +1,57 @@
+package db
+
+import (
+	"context"
+	"fmt"
+	"github.com/sirupsen/logrus"
+	"gorm.io/gorm"
+	"youngee_m_api/model/gorm_model"
+)
+
+//GetUser 查找用户,查不到返回空
+func GetUser(ctx context.Context, User string) (*gorm_model.YounggeeUser, error) {
+	db := GetReadDB(ctx)
+	user := &gorm_model.YounggeeUser{}
+	err := db.Model(user).Where("user = ?", User).First(user).Error
+	if err != nil {
+		if err == gorm.ErrRecordNotFound {
+			fmt.Println("record not found")
+			return nil, nil
+		}
+		return nil, err
+	}
+	return user, nil
+}
+
+//GetUserByPhone 查不到返回空
+func GetUserByID(ctx context.Context, ID int64) (*gorm_model.YounggeeUser, error) {
+	db := GetReadDB(ctx)
+	user := &gorm_model.YounggeeUser{}
+	err := db.Model(user).Where("id = ?", ID).First(user).Error
+	if err != nil {
+		if err == gorm.ErrRecordNotFound {
+			fmt.Println("record not found")
+			return nil, nil
+		}
+		return nil, err
+	}
+	return user, nil
+}
+
+// GetAllUser 查找所有用户
+func GetAllUser(ctx context.Context) ([]string, error) {
+	db := GetReadDB(ctx)
+	db = db.Debug().Model([]gorm_model.YounggeeUser{}).Where("role = ? or role = ?","1","2")
+	var user []gorm_model.YounggeeUser
+	db.Find(&user)
+	var total int64
+	if err := db.Count(&total).Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[GetAllUser] error query mysql total, err:%+v", err)
+		return nil, err
+	}
+	var userList []string
+	for _,User := range user{
+		userList = append(userList,User.User)
+	}
+	return userList, nil
+}

+ 39 - 0
go.mod

@@ -0,0 +1,39 @@
+module youngee_m_api
+
+go 1.17
+
+require (
+	github.com/caixw/lib.go v0.0.0-20141220110639-1781da9139e0
+	github.com/cstockton/go-conv v1.0.0
+	github.com/gin-gonic/gin v1.8.1
+	github.com/sirupsen/logrus v1.8.1
+	gopkg.in/yaml.v2 v2.4.0
+	gorm.io/driver/mysql v1.3.4
+	gorm.io/gorm v1.23.6
+)
+
+require (
+	github.com/cespare/xxhash/v2 v2.1.2 // indirect
+	github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
+	github.com/gin-contrib/sse v0.1.0 // indirect
+	github.com/go-playground/locales v0.14.0 // indirect
+	github.com/go-playground/universal-translator v0.18.0 // indirect
+	github.com/go-playground/validator/v10 v10.10.0 // indirect
+	github.com/go-redis/redis/v8 v8.11.5 // indirect
+	github.com/go-sql-driver/mysql v1.6.0 // indirect
+	github.com/goccy/go-json v0.9.7 // indirect
+	github.com/jinzhu/inflection v1.0.0 // indirect
+	github.com/jinzhu/now v1.1.4 // indirect
+	github.com/json-iterator/go v1.1.12 // indirect
+	github.com/leodido/go-urn v1.2.1 // indirect
+	github.com/mattn/go-isatty v0.0.14 // indirect
+	github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
+	github.com/modern-go/reflect2 v1.0.2 // indirect
+	github.com/pelletier/go-toml/v2 v2.0.1 // indirect
+	github.com/ugorji/go/codec v1.2.7 // indirect
+	golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 // indirect
+	golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 // indirect
+	golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
+	golang.org/x/text v0.3.6 // indirect
+	google.golang.org/protobuf v1.28.0 // indirect
+)

+ 117 - 0
go.sum

@@ -0,0 +1,117 @@
+github.com/caixw/lib.go v0.0.0-20141220110639-1781da9139e0 h1:MnIURgMAFAMyxAHu8h2TbnjxMMd7SKVCPyTZz5EfwNA=
+github.com/caixw/lib.go v0.0.0-20141220110639-1781da9139e0/go.mod h1:hQL8hyiiVE/BSo7gh13njx+DpvoPh/yE8/BkKKc62RA=
+github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
+github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
+github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
+github.com/cstockton/go-conv v1.0.0 h1:zj/q/0MpQ/97XfiC9glWiohO8lhgR4TTnHYZifLTv6I=
+github.com/cstockton/go-conv v1.0.0/go.mod h1:HuiHkkRgOA0IoBNPC7ysG7kNpjDYlgM7Kj62yQPxjy4=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
+github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
+github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
+github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
+github.com/gin-gonic/gin v1.8.1 h1:4+fr/el88TOO3ewCmQr8cx/CtZ/umlIRIs5M4NTNjf8=
+github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk=
+github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
+github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
+github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU=
+github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs=
+github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho=
+github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
+github.com/go-playground/validator/v10 v10.10.0 h1:I7mrTYv78z8k8VXa/qJlOlEXn/nBh+BF8dHX5nt/dr0=
+github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos=
+github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
+github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
+github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
+github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
+github.com/goccy/go-json v0.9.7 h1:IcB+Aqpx/iMHu5Yooh7jEzJk1JZ7Pjtmys2ukPr7EeM=
+github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
+github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
+github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
+github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
+github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
+github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
+github.com/jinzhu/now v1.1.4 h1:tHnRBy1i5F2Dh8BAFxqFzxKqqvezXrL2OW1TnX+Mlas=
+github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
+github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
+github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
+github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
+github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
+github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
+github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
+github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
+github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
+github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
+github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
+github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
+github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
+github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
+github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
+github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
+github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
+github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
+github.com/pelletier/go-toml/v2 v2.0.1 h1:8e3L2cCQzLFi2CR4g7vGFuFxX7Jl1kKX8gW+iV0GUKU=
+github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo=
+github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
+github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
+github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
+github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
+github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
+github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
+github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
+github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/ugorji/go v1.2.7 h1:qYhyWUUd6WbiM+C6JZAUkIJt/1WrjzNHY9+KCIjVqTo=
+github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M=
+github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0=
+github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
+golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI=
+golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
+golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 h1:qWPm9rbaAMKs8Bq/9LRpbMqxWRVUAQwMI9fVrssnTfw=
+golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
+golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 h1:DzZ89McO9/gWPsQXS/FVKAlG02ZjaQ6AlZRBimEYOd0=
+golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
+golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069 h1:siQdpVirKtzPhKl3lZWozZraCFObP8S1v6PRp0bLrtU=
+golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
+golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
+golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
+golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
+google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
+google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
+gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
+gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
+gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
+gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
+gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gorm.io/driver/mysql v1.3.4 h1:/KoBMgsUHC3bExsekDcmNYaBnfH2WNeFuXqqrqMc98Q=
+gorm.io/driver/mysql v1.3.4/go.mod h1:s4Tq0KmD0yhPGHbZEwg1VPlH0vT/GBHJZorPzhcxBUE=
+gorm.io/gorm v1.23.4/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
+gorm.io/gorm v1.23.6 h1:KFLdNgri4ExFFGTRGGFWON2P1ZN28+9SJRN8voOoYe0=
+gorm.io/gorm v1.23.6/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=

+ 49 - 0
handler/base.go

@@ -0,0 +1,49 @@
+package handler
+
+import (
+	"net/http"
+	"youngee_m_api/consts"
+	"youngee_m_api/util"
+
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+)
+
+type BaseHandler interface {
+	getContext() *gin.Context
+	getResponse() interface{}
+	getRequest() interface{}
+	run()
+	checkParam() error
+}
+
+func baseRun(baseHandler BaseHandler) {
+	ctx := baseHandler.getContext()
+	method := ctx.Request.Method
+	req := baseHandler.getRequest()
+	var err error
+	if method == http.MethodPost || method == http.MethodPut {
+		err = ctx.ShouldBindJSON(req)
+	} else if method == http.MethodGet {
+		err = ctx.BindQuery(req)
+	}
+	if err != nil {
+		util.PackErrorResp(ctx, consts.ErrorParamCheck)
+		ctx.Abort()
+		logrus.Infof("[baseHandler] bind json error,err:%+v", err)
+		return
+	}
+	if err = baseHandler.checkParam(); err != nil {
+		util.PackErrorResp(ctx, consts.ErrorParamCheck)
+		ctx.Abort()
+		logrus.Infof("[baseHandler] checkParam error,err:%+v", err)
+		return
+	}
+	baseHandler.run()
+	if ctx.IsAborted() {
+		return
+	}
+	resp := baseHandler.getResponse()
+	ctx.JSON(http.StatusOK, resp)
+	logrus.Infof("[baseHandler] http success")
+}

+ 51 - 0
handler/get_login_user.go

@@ -0,0 +1,51 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+)
+
+func WrapGetLoginUserHandler(ctx *gin.Context) {
+	handler := newGetLoginUserHandler(ctx)
+	baseRun(handler)
+}
+
+func newGetLoginUserHandler(ctx *gin.Context) *GetLoginUserHandler {
+	return &GetLoginUserHandler{
+		req:  http_model.NewGetLoginUserRequest(),
+		resp: http_model.NewGetLoginUserResponse(),
+		ctx:  ctx,
+	}
+}
+
+type GetLoginUserHandler struct {
+	req  *http_model.GetLoginUserRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (h *GetLoginUserHandler) getRequest() interface{} {
+	return h.req
+}
+func (h *GetLoginUserHandler) getContext() *gin.Context {
+	return h.ctx
+}
+func (h *GetLoginUserHandler) getResponse() interface{} {
+	return h.resp
+}
+func (h *GetLoginUserHandler) run() {
+	user,err := db.GetAllUser(h.ctx)
+	if err != nil {
+		logrus.Errorf("[GetLoginUserHandler] get LoginUser err:%+v\n", err)
+		logrus.Info("GetLoginUser fail,req:%+v", h.req)
+		return
+	}
+	data := http_model.GetLoginUserList{}
+	data.User = user
+	h.resp.Data = data
+}
+func (h *GetLoginUserHandler) checkParam() error {
+	return nil
+}

+ 55 - 0
handler/login.go

@@ -0,0 +1,55 @@
+package handler
+
+import (
+	"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 WrapCodeLoginHandler(ctx *gin.Context) {
+	handler := newCodeLoginHandler(ctx)
+	baseRun(handler)
+}
+
+func newCodeLoginHandler(ctx *gin.Context) *CodeLoginHandler {
+	return &CodeLoginHandler{
+		req:  http_model.NewCodeLoginRequest(),
+		resp: http_model.NewCodeLoginResponse(),
+		ctx:  ctx,
+	}
+}
+
+type CodeLoginHandler struct {
+	req  *http_model.CodeLoginRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (h *CodeLoginHandler) getRequest() interface{} {
+	return h.req
+}
+func (h *CodeLoginHandler) getContext() *gin.Context {
+	return h.ctx
+}
+func (h *CodeLoginHandler) getResponse() interface{} {
+	return h.resp
+}
+func (h *CodeLoginHandler) run() {
+	token, 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)
+		logrus.Info("login fail,req:%+v", h.req)
+		return
+	}
+	data := http_model.CodeLoginData{}
+	data.Token = token
+	// h.resp.Message = "登陆成功"
+	h.resp.Data = data
+}
+func (h *CodeLoginHandler) checkParam() error {
+	return nil
+}

+ 56 - 0
handler/pay_sum.go

@@ -0,0 +1,56 @@
+package handler
+
+import (
+	"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 WrapPaySumHandler(ctx *gin.Context) {
+	handler := newPaySumHandler(ctx)
+	baseRun(handler)
+}
+
+func newPaySumHandler(ctx *gin.Context) *PaySumHandler {
+	return &PaySumHandler{
+		req:  http_model.NewPaySumRequest(),
+		resp: http_model.NewPaySumResponse(),
+		ctx:  ctx,
+	}
+}
+
+type PaySumHandler struct {
+	req  *http_model.PaySumRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (h *PaySumHandler) getRequest() interface{} {
+	return h.req
+}
+func (h *PaySumHandler) getContext() *gin.Context {
+	return h.ctx
+}
+func (h *PaySumHandler) getResponse() interface{} {
+	return h.resp
+}
+func (h *PaySumHandler) run() {
+	data := http_model.PaySumRequest{}
+	data = *h.req
+	res, err := service.Pay.GetPaysum(h.ctx, data)
+	if err != nil {
+		// 数据库查询失败,返回5001
+		logrus.Errorf("[FindAllProductHandler] call FindAll err:%+v\n", err)
+		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
+		logrus.Info("FindAllProduct fail,req:%+v", h.req)
+		return
+	}
+	// h.resp.Message = "查询成功"
+	h.resp.Data = res
+}
+func (h *PaySumHandler) checkParam() error {
+	return nil
+}

+ 55 - 0
handler/product_find.go

@@ -0,0 +1,55 @@
+package handler
+
+import (
+	"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 WrapFindProductHandler(ctx *gin.Context) {
+	handler := newFindProductHandler(ctx)
+	baseRun(handler)
+}
+
+func newFindProductHandler(ctx *gin.Context) *FindProductHandler {
+	return &FindProductHandler{
+		req:  http_model.NewFindProductRequest(),
+		resp: http_model.NewFindProductResponse(),
+		ctx:  ctx,
+	}
+}
+
+type FindProductHandler struct {
+	req  *http_model.FindProductRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (h *FindProductHandler) getRequest() interface{} {
+	return h.req
+}
+func (h *FindProductHandler) getContext() *gin.Context {
+	return h.ctx
+}
+func (h *FindProductHandler) getResponse() interface{} {
+	return h.resp
+}
+func (h *FindProductHandler) run() {
+	data := *&http_model.FindProductRequest{}
+	data = *h.req
+	res, err := service.Product.FindByID(h.ctx, data.ProductID)
+	if err != nil {
+		// 数据库查询失败,返回5001
+		logrus.Errorf("[FindProductHandler] call FindByID err:%+v\n", err)
+		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
+		logrus.Info("FindProduct fail,req:%+v", h.req)
+		return
+	}
+	h.resp.Data = res
+}
+func (h *FindProductHandler) checkParam() error {
+	return nil
+}

+ 95 - 0
handler/product_list.go

@@ -0,0 +1,95 @@
+package handler
+
+import (
+	"errors"
+	"fmt"
+	"github.com/cstockton/go-conv"
+	"time"
+	"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"
+)
+
+func WrapFullProjectListHandler(ctx *gin.Context) {
+	handler := newFullProjectListHandler(ctx)
+	baseRun(handler)
+}
+
+func newFullProjectListHandler(ctx *gin.Context) *FullProjectListHandler {
+	return &FullProjectListHandler{
+		req:  http_model.NewFullProjectListRequest(),
+		resp: http_model.NewFullProjectListResponse(),
+		ctx:  ctx,
+	}
+}
+
+type FullProjectListHandler struct {
+	req  *http_model.FullProjectListRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (h *FullProjectListHandler) getRequest() interface{} {
+	return h.req
+}
+func (h *FullProjectListHandler) getContext() *gin.Context {
+	return h.ctx
+}
+func (h *FullProjectListHandler) getResponse() interface{} {
+	return h.resp
+}
+func (h *FullProjectListHandler) run() {
+	condition := pack.HttpFullProjectRequestToCondition(h.req)
+	data, err := service.Project.GetFullProjectList(h.ctx, h.req.PageSize, h.req.PageNum, condition)
+	if err != nil {
+		logrus.WithContext(h.ctx).Errorf("[FullProjectListHandler] error GetFullProjectList, err:%+v", err)
+		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, consts.DefaultToast)
+		return
+	}
+	h.resp.Data = data
+}
+
+func (h *FullProjectListHandler) 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.ProjectForm = util.IsNull(h.req.ProjectForm)
+	if _, err := conv.Int64(h.req.ProjectForm); err != nil {
+		errs = append(errs, err)
+	}
+	h.req.ProjectId = util.IsNull(h.req.ProjectId)
+	if _, err := conv.Int64(h.req.ProjectId); err != nil {
+		errs = append(errs, err)
+	}
+	//h.req.ProjectName = util.IsNull(h.req.ProjectName)
+
+	h.req.ProjectStatus = util.IsNull(h.req.ProjectStatus)
+	if _, err := conv.Int64(h.req.ProjectStatus); err != nil {
+		errs = append(errs, err)
+	}
+	formatTime, _ := time.Parse("2006-01-02 15:04:05", h.req.ProjectUpdated)
+	//fmt.Println(h.req.ProjectUpdated)
+	h.req.ProjectUpdated = util.IsNull(h.req.ProjectUpdated)
+	if _, err := conv.Int64(formatTime.Unix()); err != nil {
+		errs = append(errs, err)
+	}
+	h.req.ProjectContentType = util.IsNull(h.req.ProjectContentType)
+	if _, err := conv.Int64(h.req.ProjectContentType); err != nil {
+		errs = append(errs, err)
+	}
+	h.req.ProjectPlatform = util.IsNull(h.req.ProjectPlatform)
+	if _, err := conv.Int64(h.req.ProjectPlatform); err != nil {
+		errs = append(errs, err)
+	}
+	if len(errs) != 0 {
+		return fmt.Errorf("check param errs:%+v", errs)
+	}
+	return nil
+}

+ 57 - 0
handler/project_approve.go

@@ -0,0 +1,57 @@
+package handler
+
+import (
+	"fmt"
+	"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 WrapApproveProjectHandler(ctx *gin.Context) {
+	handler := newApproveProjectHandler(ctx)
+	baseRun(handler)
+}
+
+func newApproveProjectHandler(ctx *gin.Context) *ApproveProjectHandler {
+	return &ApproveProjectHandler{
+		req:  http_model.NewApproveProjectRequest(),
+		resp: http_model.NewApproveProjectResponse(),
+		ctx:  ctx,
+	}
+}
+
+type ApproveProjectHandler struct {
+	req  *http_model.ApproveProjectRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (h *ApproveProjectHandler) getRequest() interface{} {
+	return h.req
+}
+func (h *ApproveProjectHandler) getContext() *gin.Context {
+	return h.ctx
+}
+func (h *ApproveProjectHandler) getResponse() interface{} {
+	return h.resp
+}
+func (h *ApproveProjectHandler) run() {
+	data := http_model.ApproveProjectRequest{}
+	data = *h.req
+	fmt.Println(data.IsApprove,data.ProjectId)
+	err,message := service.Project.ApproveProject(h.ctx, data)
+	if err != nil {
+		// 数据库查询失败,返回5001
+		logrus.Errorf("[FindAllProductHandler] call FindAll err:%+v\n", err)
+		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
+		logrus.Info("FindAllProduct fail,req:%+v", h.req)
+		return
+	}
+	h.resp.Message = message
+}
+func (h *ApproveProjectHandler) checkParam() error {
+	return nil
+}

+ 55 - 0
handler/project_show.go

@@ -0,0 +1,55 @@
+package handler
+
+import (
+	"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 WrapShowProjectHandler(ctx *gin.Context) {
+	handler := newShowProjectHandler(ctx)
+	baseRun(handler)
+}
+
+func newShowProjectHandler(ctx *gin.Context) *ShowProjectHandler {
+	return &ShowProjectHandler{
+		req:  http_model.NewShowProjectRequest(),
+		resp: http_model.NewShowProjectResponse(),
+		ctx:  ctx,
+	}
+}
+
+type ShowProjectHandler struct {
+	req  *http_model.ShowProjectRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (h *ShowProjectHandler) getRequest() interface{} {
+	return h.req
+}
+func (h *ShowProjectHandler) getContext() *gin.Context {
+	return h.ctx
+}
+func (h *ShowProjectHandler) getResponse() interface{} {
+	return h.resp
+}
+func (h *ShowProjectHandler) run() {
+	data := http_model.ShowProjectRequest{}
+	data = *h.req
+	res, err := service.Project.GetPorjectDetail(h.ctx,data.EnterpriseID, data.ProjectID)
+	if err != nil {
+		logrus.Errorf("[ShowProjectHandler] call Show err:%+v\n", err)
+		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
+		logrus.Info("ShowProject fail,req:%+v", h.req)
+		return
+	}
+	h.resp.Message = "成功查询项目"
+	h.resp.Data = res
+}
+func (h *ShowProjectHandler) checkParam() error {
+	return nil
+}

+ 55 - 0
handler/project_update.go

@@ -0,0 +1,55 @@
+package handler
+
+import (
+	"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 WrapUpdateProjectHandler(ctx *gin.Context) {
+	handler := newUpdateProjectHandler(ctx)
+	baseRun(handler)
+}
+
+func newUpdateProjectHandler(ctx *gin.Context) *UpdateProjectHandler {
+	return &UpdateProjectHandler{
+		req:  http_model.NewUpdateProjectRequest(),
+		resp: http_model.NewUpdateProjectResponse(),
+		ctx:  ctx,
+	}
+}
+
+type UpdateProjectHandler struct {
+	req  *http_model.UpdateProjectRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (h *UpdateProjectHandler) getRequest() interface{} {
+	return h.req
+}
+func (h *UpdateProjectHandler) getContext() *gin.Context {
+	return h.ctx
+}
+func (h *UpdateProjectHandler) getResponse() interface{} {
+	return h.resp
+}
+func (h *UpdateProjectHandler) run() {
+	data := http_model.UpdateProjectRequest{}
+	data = *h.req
+	res, err := service.Project.Update(h.ctx, data, data.EnterpriseID)
+	if err != nil {
+		logrus.Errorf("[UpdateProjectHandler] call Create err:%+v\n", err)
+		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
+		logrus.Info("UpdateProject fail,req:%+v", h.req)
+		return
+	}
+	h.resp.Message = "成功创建项目"
+	h.resp.Data = res
+}
+func (h *UpdateProjectHandler) checkParam() error {
+	return nil
+}

+ 16 - 0
main.go

@@ -0,0 +1,16 @@
+package main
+
+import (
+	"fmt"
+	"github.com/gin-gonic/gin"
+	"youngee_m_api/config"
+	"youngee_m_api/route"
+)
+
+func main() {
+	r := gin.Default()
+	route.InitRoute(r)
+	config := config.Init()
+	addr := fmt.Sprintf("%v:%v", config.Host, config.Port)
+	r.Run(addr)
+}

+ 37 - 0
middleware/login_auth.go

@@ -0,0 +1,37 @@
+package middleware
+
+import (
+	"fmt"
+	"youngee_m_api/consts"
+	"youngee_m_api/model/redis_model"
+	"youngee_m_api/service"
+	"youngee_m_api/util"
+
+	log "github.com/sirupsen/logrus"
+
+	"github.com/gin-gonic/gin"
+)
+
+func LoginAuthMiddleware(c *gin.Context) {
+	token := c.Request.Header.Get("Authorization")
+	if token != "" {
+		fmt.Println(token)
+		if auth, err := service.LoginAuth.AuthToken(c, token); err == nil {
+			c.Set(consts.SessionAuthSchema, auth)
+			c.Next()
+			return
+		} else {
+			log.Infof("[LoginAuthMiddleware] auth fail,err:%+v", err)
+		}
+	}
+	util.PackErrorResp(c, consts.ErrorNotLogin)
+	c.Abort()
+}
+
+func GetSessionAuth(c *gin.Context) *redis_model.Auth {
+	auth, contain := c.Get(consts.SessionAuthSchema)
+	if contain {
+		return auth.(*redis_model.Auth)
+	}
+	return new(redis_model.Auth)
+}

+ 11 - 0
model/common_model/project_condition.go

@@ -0,0 +1,11 @@
+package common_model
+
+type ProjectCondition struct {
+	ProjectId          int64 `condition:"project_id"`       // 项目ID
+	ProjectName        string `condition:"project_name"`     // 项目名
+	ProjectStatus      int64  `condition:"project_status"`   // 项目状态
+	ProjectPlatform    int64  `condition:"project_platform"` // 项目平台
+	ProjectForm        int64  `condition:"project_form"`     // 项目形式
+	ProjectContentType int64  `condition:"content_type"`     // 内容形式
+	ProjectUpdated     string `condition:"updated_at"`       // 最后操作时间
+}

+ 9 - 0
model/common_model/task_conditions.go

@@ -0,0 +1,9 @@
+package common_model
+
+type TaskConditions struct {
+	ProjectId        int64  `condition:"project_id"`        // 项目ID
+	TaskStatus       int64  `condition:"task_status"`       // 任务状态
+	StrategyId       int64  `condition:"strategy_id"`       // 策略ID
+	TaskId           string `condition:"task_id"`           // 任务ID
+	PlatformNickname string `condition:"platform_nickname"` // 账号昵称
+}

+ 23 - 0
model/gorm_model/enterprise.go

@@ -0,0 +1,23 @@
+// Code generated by sql2gorm. DO NOT EDIT.
+package gorm_model
+
+import (
+	"time"
+)
+
+type Enterprise struct {
+	EnterpriseID     int64       `gorm:"column:enterprise_id"` // 企业id
+	Industry         int64       `gorm:"column:industry"`                                 // 行业,1-14分别代表能源、化工、材料、机械设备/军工、企业服务/造纸印刷、运输设备、旅游酒店、媒体/信息通信服务、批发/零售、消费品、卫生保健/医疗、金融、建材/建筑/房地产、公共事业
+	BusinessName     string    `gorm:"column:business_name"`                            // 公司或组织名称
+	UserID           int64       `gorm:"column:user_id"`                                  // 对应用户id
+	Balance          int64       `gorm:"column:balance"`                                  // 账户余额
+	FrozenBalance    int64       `gorm:"column:frozen_balance"`                           // 冻结余额
+	AvailableBalance int64       `gorm:"column:available_balance"`                        // 可用余额
+	CreatedAt        time.Time `gorm:"column:created_at"`                               // 创建时间
+	UpdatedAt        time.Time `gorm:"column:updated_at"`                               // 更新时间
+}
+
+func (m *Enterprise) TableName() string {
+	return "enterprise"
+}
+

+ 25 - 0
model/gorm_model/product.go

@@ -0,0 +1,25 @@
+// Code generated by sql2gorm. DO NOT EDIT.
+package gorm_model
+
+import (
+	"time"
+)
+
+type YounggeeProduct struct {
+	ProductID     int64       `gorm:"column:product_id;primary_key;AUTO_INCREMENT"` // 商品id
+	ProductName   string    `gorm:"column:product_name"`                          // 商品名称
+	ProductType   int64       `gorm:"column:product_type"`                          // 商品类型
+	ShopAddress   string    `gorm:"column:shop_address"`                          // 店铺地址,商品类型为线下品牌时需填写
+	ProductPrice  int64     `gorm:"column:product_price"`                         // 商品价值
+	ProductDetail string    `gorm:"column:product_detail"`
+	ProductUrl    string    `gorm:"column:product_url"`   // 商品链接,可为电商网址、公司官网、大众点评的店铺地址等可以说明商品信息或者品牌信息的线上地址;
+	EnterpriseID  int64       `gorm:"column:enterprise_id"` // 所属企业id
+	CreatedAt     time.Time `gorm:"column:created_at"`    // 创建时间
+	UpdatedAt     time.Time `gorm:"column:updated_at"`    // 更新时间
+	BrandName     string    `gorm:"column:brand_name"`
+}
+
+func (m *YounggeeProduct) TableName() string {
+	return "younggee_product"
+}
+

+ 20 - 0
model/gorm_model/product_photo.go

@@ -0,0 +1,20 @@
+// Code generated by sql2gorm. DO NOT EDIT.
+package gorm_model
+
+import (
+	"time"
+)
+
+type YounggeeProductPhoto struct {
+	ProductPhotoID int64       `gorm:"column:product_photo_id;primary_key;AUTO_INCREMENT"` // 商品图片id
+	PhotoUrl       string    `gorm:"column:photo_url"`                                   // 图片或视频url
+	PhotoUid       string    `gorm:"column:photo_uid"`
+	Symbol         int64       `gorm:"column:symbol"`     // 图片为主图或详情图标志位,1为主图,2为详情图,3为视频
+	ProductID      int64       `gorm:"column:product_id"` // 所属商品id
+	CreatedAt      time.Time `gorm:"column:created_at"` // 创建时间
+}
+
+func (m *YounggeeProductPhoto) TableName() string {
+	return "younggee_product_photo"
+}
+

+ 30 - 0
model/gorm_model/project.go

@@ -0,0 +1,30 @@
+// Code generated by sql2gorm. DO NOT EDIT.
+package gorm_model
+
+import (
+	"time"
+)
+
+type ProjectInfo struct {
+	ProjectID       int64     `gorm:"column:project_id;primary_key;AUTO_INCREMENT"` // 项目id
+	ProjectName     string    `gorm:"column:project_name"`                          // 项目名称
+	ProjectStatus   int64     `gorm:"column:project_status"`                        // 项目状态,1-10分别代表创建中、待审核、审核通过、招募中、招募完毕、待支付、已支付、失效、执行中、已结案
+	ProjectType     int64     `gorm:"column:project_type"`                          // 项目类型,1代表全流程项目,2代表专项项目
+	ProjectPlatform int64     `gorm:"column:project_platform"`                      // 项目平台,1-7分别代表小红书、抖音、微博、快手、b站、大众点评、知乎
+	ProjectForm     int64     `gorm:"column:project_form"`                          // 项目形式,1-4分别代表实体商品寄拍、虚拟产品测评、线下探店打卡、素材微原创
+	TalentType      string    `gorm:"column:talent_type"`                           // 达人类型
+	RecruitDdl      time.Time `gorm:"column:recruit_ddl"`                           // 招募截止时间
+	ContentType     int64     `gorm:"column:content_type"`                          // 内容形式,1代表图文,2代表视频
+	ProjectDetail   string    `gorm:"column:project_detail"`                        // 项目详情
+	ApplyNum        int64     `gorm:"column:apply_num;default:0;NOT NULL"`          // 报名人数
+	RecruitNum      int64     `gorm:"column:recruit_num;default:0;NOT NULL"`        // 已招募人数
+	EnterpriseID    int64     `gorm:"column:enterprise_id"`                         // 所属企业id
+	ProductID       int64     `gorm:"column:product_id"`                            // 关联商品id
+	CreatedAt       time.Time `gorm:"column:created_at"`                            // 创建时间
+	UpdatedAt       time.Time `gorm:"column:updated_at"`                            // 修改时间
+	FeeForm         string    `gorm:"column:fee_form"`                              // 稿费形式列表
+}
+
+func (m *ProjectInfo) TableName() string {
+	return "project_info"
+}

+ 25 - 0
model/gorm_model/project_account.go

@@ -0,0 +1,25 @@
+// Code generated by sql2gorm. DO NOT EDIT.
+package gorm_model
+
+import (
+	"time"
+)
+
+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相同
+	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"`            // 粉丝数
+	HomePageCaptureUrl string    `gorm:"column:home_page_capture_url;NOT NULL"` // 主页截图链接
+	BindDate           time.Time `gorm:"column:bind_date;NOT NULL"`             // 绑定时间
+	Deleted            int       `gorm:"column:deleted;default:0"`              // 是否被解绑
+	UpdatedAt          time.Time `gorm:"column:updated_at"`                     // 更新时间
+	UpdatedPerson      int       `gorm:"column:updated_person"`                 // 更新人,0代表本人,1代表管理员
+	UpdatedAdminID     int       `gorm:"column:updated_admin_id"`               // 上一次更新的管理员id
+}
+
+func (m *YoungeePlatformAccountInfo) TableName() string {
+	return "youngee_platform_account_info"
+}

+ 19 - 0
model/gorm_model/project_photo.go

@@ -0,0 +1,19 @@
+// Code generated by sql2gorm. DO NOT EDIT.
+package gorm_model
+
+import (
+	"time"
+)
+
+type ProjectPhoto struct {
+	ProjectPhotoID int64       `gorm:"column:project_photo_id;primary_key;AUTO_INCREMENT"` // 项目图片id
+	PhotoUrl       string    `gorm:"column:photo_url"`                                   // 图片url
+	PhotoUid       string    `gorm:"column:photo_uid"`
+	ProjectID      int64       `gorm:"column:project_id"` // 所属项目id
+	CreatedAt      time.Time `gorm:"column:created_at"` // 创建时间
+}
+
+func (m *ProjectPhoto) TableName() string {
+	return "project_photo"
+}
+

+ 35 - 0
model/gorm_model/project_task.go

@@ -0,0 +1,35 @@
+// Code generated by sql2gorm. DO NOT EDIT.
+package gorm_model
+
+import (
+	"time"
+)
+
+type YoungeeTaskInfo struct {
+	TaskId                 int       `gorm:"column:task_id;type:int(11);primary_key;AUTO_INCREMENT;comment:任务id" json:"task_id"`
+	ProjectId              int       `gorm:"column:project_id;type:int(11);comment:项目id;NOT NULL" json:"project_id"`
+	TalentId               string    `gorm:"column:talent_id;type:varchar(25);comment:达人id;NOT NULL" json:"talent_id"`
+	AccountId              int       `gorm:"column:account_id;type:int(11);comment:账号id;NOT NULL" json:"account_id"`
+	TalentPlatformInfoSnap string    `gorm:"column:talent_platform_info_snap;type:json;comment:达人平台信息快照;NOT NULL" json:"talent_platform_info_snap"`
+	TalentPersonalInfoSnap string    `gorm:"column:talent_personal_info_snap;type:json;comment:达人个人信息快照;NOT NULL" json:"talent_personal_info_snap"`
+	TalentPostAddrSnap     string    `gorm:"column:talent_post_addr_snap;type:json;comment:收货地址快照;NOT NULL" json:"talent_post_addr_snap"`
+	StrategyId             int       `gorm:"column:strategy_id;type:int(11);comment:报名选择的招募策略id" json:"strategy_id"`
+	TaskReward             float64   `gorm:"column:task_reward;type:float;comment:达人报酬;NOT NULL" json:"task_reward"`
+	SettleAmount           float64   `gorm:"column:settle_amount;type:float;comment:达人实际所得(扣除违约扣款);NOT NULL" json:"settle_amount"`
+	AllPayment             float64   `gorm:"column:all_payment;type:float;comment:企业支付;NOT NULL" json:"all_payment"`
+	RealPayment            float64   `gorm:"column:real_payment;type:float;comment:企业实际支付(扣除违约扣款);NOT NULL" json:"real_payment"`
+	Penalty                int       `gorm:"column:penalty;type:int(11);comment:违约扣款比例,百分之;NOT NULL" json:"penalty"`
+	FeeForm                int       `gorm:"column:fee_form;type:tinyint(4);comment:稿费形式,1,2,3分别代表产品置换、固定稿费、自报价;NOT NULL" json:"fee_form"`
+	ServiceCharge          float64   `gorm:"column:service_charge;type:float;comment:服务费" json:"service_charge"`
+	ServiceRate            int       `gorm:"column:service_rate;type:int(11);comment:服务费率,千分之" json:"service_rate"`
+	TaskStatus             int       `gorm:"column:task_status;type:tinyint(4);default:1;comment:任务状态 1待选 2已选 3落选;NOT NULL" json:"task_status"`
+	TaskStage              int       `gorm:"column:task_stage;type:tinyint(1);comment:任务阶段;NOT NULL" json:"task_stage"`
+	CreateDate             time.Time `gorm:"column:create_date;type:datetime;comment:创建时间;NOT NULL" json:"create_date"`
+	SelectDate             time.Time `gorm:"column:select_date;type:datetime;comment:反选时间" json:"select_date"`
+	CompleteStatus         int       `gorm:"column:complete_status;type:tinyint(1);default:1;comment:结束方式 1未结束 2正常结束 3反选失败 4被解约;NOT NULL" json:"complete_status"`
+	CompleteDate           time.Time `gorm:"column:complete_date;type:datetime;comment:结束时间" json:"complete_date"`
+}
+
+func (m *YoungeeTaskInfo) TableName() string {
+	return "youngee_task_info"
+}

+ 19 - 0
model/gorm_model/recruit_strategy.go

@@ -0,0 +1,19 @@
+// Code generated by sql2gorm. DO NOT EDIT.
+package gorm_model
+
+
+type RecruitStrategy struct {
+	RecruitStrategyID int64 `gorm:"column:recruit_strategy_id;primary_key"` // 招募策略id
+	FeeForm           int64 `gorm:"column:fee_form"`                        // 稿费形式,1-3分别代表产品置换、固定稿费、自报价
+	StrategyID        int64 `gorm:"column:strategy_id"`                     // 策略id
+	FollowersLow      int64 `gorm:"column:followers_low"`                   // 达人粉丝数下限
+	FollowersUp       int64 `gorm:"column:followers_up"`                    // 达人粉丝数上限
+	RecruitNumber     int64 `gorm:"column:recruit_number"`                  // 招募数量
+	Offer             int64 `gorm:"column:offer"`                           // 报价
+	ProjectID         int64 `gorm:"column:project_id"`                      // 所属项目id
+}
+
+func (m *RecruitStrategy) TableName() string {
+	return "recruit_strategy"
+}
+

+ 37 - 0
model/gorm_model/talent.go

@@ -0,0 +1,37 @@
+// Code generated by sql2gorm. DO NOT EDIT.
+package gorm_model
+
+import (
+	"time"
+)
+
+type YoungeeTalentInfo struct {
+	ID                string    `gorm:"column:id;primary_key"`               // 达人id
+	TalentWxOpenid    string    `gorm:"column:talent_wx_openid;NOT NULL"`    // 达人的微信openid
+	TalentWxNickname  string    `gorm:"column:talent_wx_nickname"`           // 达人的微信昵称
+	TalentWxNumber    string    `gorm:"column:talent_wx_number"`             // 达人微信号
+	Income            int64     `gorm:"column:income;default:0"`             // 收益总数
+	Withdrawing       int64     `gorm:"column:withdrawing;default:0"`        // 提现中金额
+	Canwithdraw       int64     `gorm:"column:canwithdraw;default:0"`        // 可提现金额
+	Withdrawed        int64     `gorm:"column:withdrawed;default:0"`         // 已提现金额
+	TalentGender      int       `gorm:"column:talent_gender"`                // 性别,0未知 1男 2女
+	TalentPhoneNumber string    `gorm:"column:talent_phone_number"`          // 电话号码
+	TalentAgeBracket  int       `gorm:"column:talent_age_bracket"`           // 年龄段,取tallent_age_bracket表id
+	TalentNationality int       `gorm:"column:talent_nationality"`           // 国籍,取tallent_nationality表id
+	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"`   // 是否绑定收货地址
+	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"`           // 任务总数
+	TaskApply         int       `gorm:"column:task_apply;default:0"`         // 报名任务数量
+	TaskExecute       int       `gorm:"column:task_execute;default:0"`       // 执行中任务数量
+	TaskEnd           int       `gorm:"column:task_end;default:0"`           // 结束任务数量
+	CreateDate        time.Time `gorm:"column:create_date;NOT NULL"`         // 创建时间
+	LastLoginDate     time.Time `gorm:"column:last_login_date;NOT NULL"`     // 最后登录时间
+	ApplyNum          int       `gorm:"column:apply_num;default:5;NOT NULL"` // 剩余申请次数(每天更新)
+}
+
+func (m *YoungeeTalentInfo) TableName() string {
+	return "youngee_talent_info"
+}

+ 26 - 0
model/gorm_model/user.go

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

+ 19 - 0
model/http_model/code_login.go

@@ -0,0 +1,19 @@
+package http_model
+
+type CodeLoginRequest struct {
+	User string `json:"user"`
+	Password  string `json:"password"`
+}
+
+type CodeLoginData struct {
+	Token string `json:"token"`
+}
+
+func NewCodeLoginRequest() *CodeLoginRequest {
+	return new(CodeLoginRequest)
+}
+func NewCodeLoginResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(CodeLoginData)
+	return resp
+}

+ 10 - 0
model/http_model/common_response.go

@@ -0,0 +1,10 @@
+package http_model
+
+// CommonResponse 接口通用的返回结构体
+type CommonResponse struct {
+	Status  int32       `json:"status"`
+	Message string      `json:"message"`
+	Data    interface{} `json:"data"`
+}
+type CommonRequest interface {
+}

+ 36 - 0
model/http_model/full_project_list.go

@@ -0,0 +1,36 @@
+package http_model
+
+type FullProjectListRequest struct {
+	PageSize           int32  `json:"page_size"`
+	PageNum            int32  `json:"page_num"`
+	ProjectId          string `json:"project_id"`           // 项目ID
+	ProjectName        string `json:"project_name"`         // 项目名
+	ProjectStatus      string `json:"project_status"`       // 项目状态
+	ProjectPlatform    string `json:"project_platform"`     // 项目平台
+	ProjectForm        string `json:"project_form"`         // 项目形式
+	ProjectContentType string `json:"project_content_type"` // 内容形式
+	ProjectUpdated     string `json:"project_updated"`      // 最后操作时间
+}
+type FullProjectPreview struct {
+	ProjectId          string   `json:"project_id"`           // 项目ID
+	ProjectName        string   `json:"project_name"`         // 项目名
+	EnterpriseID    int64     `json:"enterprise_id"`                         // 所属企业id
+	ProjectStatus      string   `json:"project_status"`       // 项目状态
+	ProjectPlatform    string   `json:"project_platform"`     // 项目平台
+	ProjectForm        string   `json:"project_form"`         // 项目形式
+	ProjectContentType string   `json:"project_content_type"` // 内容形式
+	ProjectUpdated     string   `json:"project_updated"`      // 最后操作时间
+}
+type FullProjectListData struct {
+	FullProjectPreview []*FullProjectPreview `json:"full_project_pre_view"`
+	Total              string                `json:"total"`
+}
+
+func NewFullProjectListRequest() *FullProjectListRequest {
+	return new(FullProjectListRequest)
+}
+func NewFullProjectListResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(FullProjectListData)
+	return resp
+}

+ 17 - 0
model/http_model/get_login_user.go

@@ -0,0 +1,17 @@
+package http_model
+
+type GetLoginUserRequest struct {}
+
+type GetLoginUserList struct {
+	User []string `json:"user"`
+}
+
+func NewGetLoginUserRequest() *GetLoginUserRequest {
+	return new(GetLoginUserRequest)
+}
+
+func NewGetLoginUserResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(GetLoginUserList)
+	return resp
+}

+ 24 - 0
model/http_model/pay_sum.go

@@ -0,0 +1,24 @@
+package http_model
+
+type PaySumRequest struct {
+	ProjectId string `json:"project_id"` // 项目ID
+}
+type PaySum struct {
+	StrategyId int     `json:"strategy_id"`  // 策略ID
+	AllPayment float64 `json:"all_payment"` //任务的全部费用
+}
+type PaySumResponce struct {
+	//ProjectId  string  `json:"project_id"`   // 项目ID
+	PaySum []PaySum `json:"pay_sum"` //总数
+	//FeeForm    int     `json:"fee_form""`    //稿费形式
+}
+
+func NewPaySumRequest() *PaySumRequest {
+	return new(PaySumRequest)
+}
+
+func NewPaySumResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(ProjectTaskListData)
+	return resp
+}

+ 33 - 0
model/http_model/product_find.go

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

+ 24 - 0
model/http_model/product_findall.go

@@ -0,0 +1,24 @@
+package http_model
+
+type FindAllProductRequest struct {
+}
+
+type ProductInfo struct {
+	ProductID   int64  `json:"product_id"`
+	BrandName   string `json:"brand_name"`
+	ProductName string `json:"product_name"`
+	ProductType string `json:"product_type"`
+}
+
+type FindAllProductData struct {
+	ProductInfos []ProductInfo `json:"product_infos"`
+}
+
+func NewFindAllProductRequest() *FindAllProductRequest {
+	return new(FindAllProductRequest)
+}
+func NewFindAllProductResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(FindAllProductData)
+	return resp
+}

+ 16 - 0
model/http_model/project_approve.go

@@ -0,0 +1,16 @@
+package http_model
+
+
+type ApproveProjectRequest struct {
+	ProjectId string `json:"project_id"` // 项目ID
+	IsApprove int64 `json:"is_approve"`
+}
+
+func NewApproveProjectRequest() *ApproveProjectRequest {
+	return new(ApproveProjectRequest)
+}
+
+func NewApproveProjectResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	return resp
+}

+ 52 - 0
model/http_model/project_show.go

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

+ 60 - 0
model/http_model/project_taskList.go

@@ -0,0 +1,60 @@
+package http_model
+
+import (
+	"time"
+	"youngee_m_api/model/gorm_model"
+)
+
+type ProjectTaskListRequest struct {
+	PageSize         int64  `json:"page_size"`
+	PageNum          int64  `json:"page_num"`
+	ProjectId        string `json:"project_id"`        // 项目ID
+	TaskId           string `json:"task_id"`           // 任务ID
+	StrategyId       string `json:"strategy_id"`       // 策略ID
+	TaskStatus       string `json:"task_status"`       // 任务状态
+	PlatformNickname string `json:"platform_nickname"` // 账号昵称
+}
+
+type ProjectTaskPreview struct {
+	TaskId             string `json:"task_id"`               // 任务ID
+	PlatformNickname   string `json:"platform_nickname"`     // 账号昵称
+	FansCount          string `json:"fans_count"`            // 粉丝数
+	HomePageCaptureUrl string `json:"home_page_capture_url"` // 主页截图链接
+	StrategyId         string `json:"strategy_id"`           // 报名选择的招募策略id
+	TaskReward         string `json:"task_reward"`           // 任务奖励金额
+	HomePageUrl        string `json:"home_page_url"`         // 主页链接
+	TaskStatus         string `json:"task_status"`           // 任务状态
+	CreateDate         string `json:"create_date"`           // 创建时间
+}
+
+type ProjectTaskInfo struct {
+	TaskID             int       `json:"task_id"`               // 任务id
+	PlatformNickname   string    `json:"platform_nickname"`     // 在平台上的昵称
+	FansCount          int64     `json:"fans_count"`            // 粉丝数
+	HomePageCaptureUrl string    `json:"home_page_capture_url"` // 主页截图链接
+	StrategyID         int       `json:"strategy_id"`           // 报名选择的招募策略id
+	TaskReward         float64   `json:"task_reward"`           // 任务奖励金额
+	HomePageUrl        string    `json:"home_page_url"`         // 主页链接
+	TaskStatus         string    `json:"task_status"`           // 任务状态 1待选 2已选 3落选
+	CreateDate         time.Time `json:"create_date"`           // 创建时间
+}
+
+type TaskAccount struct {
+	Task    gorm_model.YoungeeTaskInfo
+	Account gorm_model.YoungeePlatformAccountInfo
+}
+
+type ProjectTaskListData struct {
+	ProjectTaskPreview []*ProjectTaskPreview `json:"project_task_pre_view"`
+	Total              string                `json:"total"`
+}
+
+func NewProjectTaskListRequest() *ProjectTaskListRequest {
+	return new(ProjectTaskListRequest)
+}
+
+func NewProjectTaskListResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(ProjectTaskListData)
+	return resp
+}

+ 42 - 0
model/http_model/project_update.go

@@ -0,0 +1,42 @@
+package http_model
+
+import "time"
+
+type UpdateProjectPhoto struct {
+	PhotoUrl string `json:"photo_url"` // 图片url
+	PhotoUid string `json:"photo_uid"`
+}
+
+type UpdateRecruitStrategy 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 UpdateProjectRequest struct {
+	ProjectForm      string                  `json:"project_form"`      // 项目形式,1-4分别代表实体商品寄拍、虚拟产品测评、线下探店打卡、素材微原创
+	TalentType       string                  `json:"talent_type"`       // 达人类型
+	RecruitDdl       time.Time               `json:"recruit_ddl"`       // 招募截止时间
+	ContentType      string                  `json:"content_type"`      // 内容形式,1代表图文,2代表视频
+	ProjectDetail    string                  `json:"project_detail"`    // 项目详情
+	RecruitStrategys []UpdateRecruitStrategy `json:"recruit_strategys"` // 定价策略
+	ProjectPhotos    []UpdateProjectPhoto    `json:"project_photos"`    // 项目图片
+	EnterpriseID     string                  `json:"enterprise_id"`     // 企业id
+	ProjectID        string                  `json:"project_id"`        // 项目id
+}
+
+type UpdateProjectData struct {
+	ProjectID int64 `json:"Project_id"` // 项目id
+}
+
+func NewUpdateProjectRequest() *UpdateProjectRequest {
+	return new(UpdateProjectRequest)
+}
+func NewUpdateProjectResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(UpdateProjectData)
+	return resp
+}

+ 13 - 0
model/redis_model/auth.go

@@ -0,0 +1,13 @@
+package redis_model
+
+// Auth redis 存放的用户信息Session
+type Auth struct {
+	Phone        string `json:"phone"`
+	ID           int64  `json:"id"`        // 用户表id
+	User         string `json:"user"`      // 账号
+	Username     string `json:"username"`  // 后台用户名
+	RealName     string `json:"real_name"` // 真实姓名
+	Role         string `json:"role"`      // 角色 1,超级管理员; 2,管理员;3,企业用户
+	Email        string `json:"email"`     // 电子邮件
+	Token        string `json:"token"`
+}

+ 28 - 0
model/system_model/config.go

@@ -0,0 +1,28 @@
+package system_model
+
+type Config struct {
+	Mysql  *Mysql  `yaml:"mysql"`
+	Redis  *Redis  `yaml:"redis"`
+	Server *Server `yaml:"server"`
+}
+type Mysql struct {
+	Host     string `yaml:"host"`
+	Port     int32  `yaml:"port"`
+	User     string `yaml:"user"`
+	Password string `yaml:"password"`
+	Database string `yaml:"database"`
+}
+type Redis struct {
+	Host     string `yaml:"host"`
+	Port     int32  `yaml:"port"`
+	Auth     string `yaml:"auth"`
+	Database int32  `yaml:"database"`
+}
+type Session struct {
+	TTL int32 `yaml:"ttl"`
+}
+type Server struct {
+	Host    string   `yaml:"host"`
+	Port    int32    `yaml:"port"`
+	Session *Session `yaml:"session"`
+}

+ 31 - 0
pack/full_project.go

@@ -0,0 +1,31 @@
+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 MGormFullProjectToHttpFullProjectPreview(gormProjectInfos []*gorm_model.ProjectInfo) []*http_model.FullProjectPreview {
+	var httpProjectPreviews []*http_model.FullProjectPreview
+	for _, gormProjectInfo := range gormProjectInfos {
+		httpProjectPreview := GormFullProjectToHttpFullProjectPreview(gormProjectInfo)
+		httpProjectPreviews = append(httpProjectPreviews, httpProjectPreview)
+	}
+	return httpProjectPreviews
+}
+func GormFullProjectToHttpFullProjectPreview(gormProjectInfo *gorm_model.ProjectInfo) *http_model.FullProjectPreview {
+	updatedTime := conv.MustString(gormProjectInfo.UpdatedAt,"")
+	updatedTime = updatedTime[0:19]
+	return &http_model.FullProjectPreview{
+		ProjectId: 			conv.MustString(gormProjectInfo.ProjectID, ""),
+		ProjectName:        gormProjectInfo.ProjectName,
+		EnterpriseID: 		gormProjectInfo.EnterpriseID,
+		ProjectStatus:      consts.GetProjectStatus(gormProjectInfo.ProjectStatus),
+		ProjectPlatform:    consts.GetProjectPlatform(gormProjectInfo.ProjectPlatform),
+		ProjectForm:        consts.GetProjectForm(gormProjectInfo.ProjectForm),
+		ProjectContentType: consts.GetProjectContentType(gormProjectInfo.ContentType),
+		ProjectUpdated:     updatedTime,
+	}
+}

+ 21 - 0
pack/full_project_condition.go

@@ -0,0 +1,21 @@
+package pack
+
+import (
+	"github.com/caixw/lib.go/conv"
+	"youngee_m_api/model/common_model"
+	"youngee_m_api/model/http_model"
+)
+
+func HttpFullProjectRequestToCondition(req *http_model.FullProjectListRequest) *common_model.ProjectCondition {
+	projectUpdated := conv.MustString(req.ProjectUpdated,"")
+	projectName := req.ProjectName
+	return &common_model.ProjectCondition{
+		ProjectId:          conv.MustInt64(req.ProjectId,0),
+		ProjectName:        projectName,
+		ProjectStatus:      conv.MustInt64(req.ProjectStatus,0),
+		ProjectPlatform:    conv.MustInt64(req.ProjectPlatform,0),
+		ProjectForm:        conv.MustInt64(req.ProjectForm,0),
+		ProjectContentType: conv.MustInt64(req.ProjectContentType,0),
+		ProjectUpdated:     projectUpdated,
+	}
+}

+ 19 - 0
redis/init.go

@@ -0,0 +1,19 @@
+package redis
+
+import (
+	"fmt"
+	"youngee_m_api/model/system_model"
+
+	"github.com/go-redis/redis/v8"
+)
+
+var client *redis.Client
+
+func Init(config *system_model.Redis) {
+	rdb := redis.NewClient(&redis.Options{
+		Addr:     fmt.Sprintf("%v:%v", config.Host, config.Port),
+		Password: config.Auth,          // no password set
+		DB:       int(config.Database), // use default DB
+	})
+	client = rdb
+}

+ 27 - 0
redis/operation.go

@@ -0,0 +1,27 @@
+package redis
+
+import (
+	"context"
+	"time"
+)
+
+func Get(ctx context.Context, key string) (string, error) {
+	val, err := client.Get(ctx, key).Result()
+	if err != nil {
+		return "", err
+	}
+	return val, nil
+}
+
+func GetOrDefault(ctx context.Context, key, defaultValue string) string {
+	val, err := client.Get(ctx, key).Result()
+	if err != nil {
+		return defaultValue
+	}
+	return val
+}
+
+func Set(ctx context.Context, key, value string, expiration time.Duration) error {
+	err := client.Set(ctx, key, value, expiration).Err()
+	return err
+}

+ 49 - 0
route/init.go

@@ -0,0 +1,49 @@
+package route
+
+import (
+	"github.com/gin-gonic/gin"
+	"youngee_m_api/handler"
+	"youngee_m_api/model/http_model"
+)
+
+func InitRoute(r *gin.Engine) {
+
+	r.POST("/login", handler.WrapCodeLoginHandler)
+	r.GET("/getLoginUser", handler.WrapGetLoginUserHandler)
+	r.GET("/test/ping", func(c *gin.Context) {
+		resp := http_model.CommonResponse{
+			Status:  0,
+			Message: "",
+			Data:    "ping",
+		}
+		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) {
+			resp := http_model.CommonResponse{
+				Status:  0,
+				Message: "",
+				Data:    "ping",
+			}
+			c.JSON(200, resp)
+		})
+		m.POST("/product/list", handler.WrapFullProjectListHandler)
+		m.POST("/project/show", handler.WrapShowProjectHandler)
+		//m.POST("/product/findall", handler.WrapFindAllProductHandler)
+		m.POST("/product/find", handler.WrapFindProductHandler)
+		m.POST("/pay/paysum", handler.WrapPaySumHandler)
+		m.POST("/project/update", handler.WrapUpdateProjectHandler)
+		m.POST("/project/approve", handler.WrapApproveProjectHandler)
+	}
+
+}

+ 142 - 0
service/login_auth.go

@@ -0,0 +1,142 @@
+package service
+
+import (
+	"context"
+	"encoding/json"
+	"errors"
+	"fmt"
+	"github.com/sirupsen/logrus"
+	"strconv"
+	"strings"
+	"time"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/redis_model"
+	"youngee_m_api/model/system_model"
+	"youngee_m_api/redis"
+	"youngee_m_api/util"
+)
+
+var LoginAuth *loginAuth
+
+func LoginAuthInit(config *system_model.Session) {
+	auth := new(loginAuth)
+	auth.sessionTTL = time.Duration(config.TTL) * time.Minute
+	LoginAuth = auth
+}
+
+type loginAuth struct {
+	sessionTTL time.Duration
+}
+
+func (l *loginAuth) AuthToken(ctx context.Context, token string) (*redis_model.Auth, error) {
+	user, err := l.parseToken(ctx, token)
+	if err != nil {
+		logrus.Debug("token格式错误:%+v", token)
+		return nil, err
+	}
+	auth, err := l.getSessionAuth(ctx, user)
+	if err != nil {
+		logrus.Debug("获取session redis错误: token:%+v,err:%+v", token, err)
+		return nil, err
+	}
+	if auth.Token != token {
+		logrus.Debug("获取session time过期错误: token:%+v", token)
+		return nil, errors.New("auth failed")
+	}
+	return auth, nil
+}
+
+func (l *loginAuth) AuthCode(ctx context.Context, User string, password string) (string, error) {
+	user, err := db.GetUser(ctx, User)
+	if err != nil {
+		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{
+		// 账号权限有误
+		logrus.Debugf("[AuthCode] auth fail,User:%+v", User)
+		return "权限错误,请登录管理账号", errors.New("auth fail")
+	}
+	var token string
+	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,
+		}
+		if err := l.setSession(ctx, user.User, auth); err != nil {
+			fmt.Printf("setSession error\n")
+			return "", err
+		}
+	}
+	return token, nil
+}
+
+func (l *loginAuth) setSession(ctx context.Context, user string, auth *redis_model.Auth) error {
+	if authJson, err := json.Marshal(auth); err == nil {
+		err = redis.Set(ctx, l.getRedisKey(user), string(authJson), l.sessionTTL)
+		if err == nil {
+			return err
+		}
+	}
+	return nil
+}
+
+//func (l *loginAuth) getSessionCode(ctx context.Context, phone string) (*string, error) {
+//	value, err := redis.Get(ctx, l.getRedisKey(phone))
+//	if err != nil {
+//		if err == consts.RedisNil {
+//			return nil, fmt.Errorf("not found in redis,phone:%+v", phone)
+//		}
+//		return nil, err
+//	}
+//	return &value, nil
+//}
+
+func (l *loginAuth) getSessionAuth(ctx context.Context, user string) (*redis_model.Auth, error) {
+	value, err := redis.Get(ctx, l.getRedisKey(user))
+	if err != nil {
+		if err == consts.RedisNil {
+			return nil, fmt.Errorf("not found in redis,user:%+v", user)
+		}
+		return nil, err
+	}
+	auth := new(redis_model.Auth)
+	if err = json.Unmarshal([]byte(value), auth); err != nil {
+		return nil, err
+	}
+	return auth, nil
+}
+
+func (l *loginAuth) getToken(ctx context.Context, user string) string {
+	timeSeed := strconv.FormatInt(time.Now().Unix(), 10)
+	token := user + "." + timeSeed + "." + util.MD5(user, timeSeed, consts.AuthSalt)
+	return token
+}
+
+func (l *loginAuth) parseToken(ctx context.Context, token string) (string, error) {
+	parts := strings.Split(token, ".")
+	if len(parts) == 3 {
+		user := parts[0]
+		timeSeed := parts[1]
+		if parts[2] == util.MD5(user, timeSeed, consts.AuthSalt) {
+			return user, nil
+		}
+	}
+	return "", errors.New("token invalid")
+}
+func (l *loginAuth) encryptPassword(password string) string {
+	return util.MD5(password)
+}
+func (l *loginAuth) getRedisKey(key string) string {
+	return fmt.Sprintf("%s%s", consts.SessionRedisPrefix, key)
+}

+ 35 - 0
service/pay.go

@@ -0,0 +1,35 @@
+package service
+
+import (
+	"context"
+	"github.com/caixw/lib.go/conv"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+)
+
+var Pay *pay
+
+type pay struct {
+}
+
+func (*pay) GetPaysum(ctx context.Context, project http_model.PaySumRequest) (*http_model.PaySumResponce, error) {
+	projectId := conv.MustInt64(project.ProjectId,0)
+	tasks, err := db.GetTaskList(ctx, projectId)
+	if err != nil {
+		logrus.Infof("[GetPayTasklist] fail,err:%+v", err)
+		return nil, err
+	}
+	payMap := make(map[int]float64)
+	PaySum := http_model.PaySumResponce{}
+	if tasks != nil {
+		for _, task := range tasks {
+			payMap[task.StrategyId] += task.AllPayment
+		}
+		for k, v := range payMap {
+			ps := http_model.PaySum{k, v}
+			PaySum.PaySum = append(PaySum.PaySum, ps)
+		}
+	}
+	return &PaySum, nil
+}

+ 46 - 0
service/product.go

@@ -0,0 +1,46 @@
+package service
+
+import (
+	"context"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+)
+
+var Product *product
+
+type product struct {
+}
+
+func (*product) FindByID(ctx context.Context, productID int64) (*http_model.FindProductData, error) {
+	product, err := db.GetProductByID(ctx, productID)
+	if err != nil {
+		return nil, err
+	}
+	if product == nil {
+		return nil, nil
+	}
+	productPhotos, err := db.GetProductPhotoByProductID(ctx, productID)
+	if err != nil {
+		return nil, err
+	}
+	findProductData := http_model.FindProductData{
+		ProductID:     product.ProductID,
+		ProductName:   product.ProductName,
+		ProductType:   product.ProductType,
+		ShopAddress:   product.ShopAddress,
+		ProductPrice:  product.ProductPrice,
+		ProductDetail: product.ProductDetail,
+		ProductUrl:    product.ProductUrl,
+		EnterpriseID:  product.EnterpriseID,
+		BrandName:     product.BrandName,
+	}
+	for _, photo := range productPhotos {
+		productPhoto := http_model.ProductPhoto{
+			PhotoUrl: photo.PhotoUrl,
+			PhotoUid: photo.PhotoUid,
+			Symbol:   photo.Symbol,
+		}
+		findProductData.ProductPhotos = append(findProductData.ProductPhotos, productPhoto)
+	}
+	return &findProductData, nil
+}

+ 180 - 0
service/project.go

@@ -0,0 +1,180 @@
+package service
+
+import (
+	"context"
+	"fmt"
+	"github.com/caixw/lib.go/conv"
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/db"
+	"youngee_m_api/model/common_model"
+	"youngee_m_api/model/gorm_model"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/pack"
+)
+
+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)
+	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,"")
+	return fullProjectListData, nil
+}
+
+func (*project) GetPorjectDetail(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)
+		return nil, err
+	}
+	enterprise, err := db.GetEnterpriseByEnterpriseID(ctx, project.EnterpriseID)
+	fmt.Println("%+v", enterprise.UserID)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[project service] call GetEnterpriseByEnterpriseID error,err:%+v", err)
+		return nil, err
+	}
+	user, err := db.GetUserByID(ctx, enterprise.UserID)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[project service] call GetUserByID error,err:%+v", err)
+		return nil, err
+	}
+	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,""),
+		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,""),
+		CreateAt:        project.CreatedAt,
+		UpdateAt:        project.UpdatedAt,
+		Phone:           user.Phone,
+	}
+	Strategys, err := db.GetRecruitStrategys(ctx, projectID)
+	if err != nil {
+		logrus.WithContext(ctx).Error()
+		return nil, err
+	}
+	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,""),
+		}
+		ProjectDetail.RecruitStrategys = append(ProjectDetail.RecruitStrategys, RecruitStrategy)
+	}
+	Photos, err := db.GetProjectPhoto(ctx, projectID)
+	if err != nil {
+		logrus.WithContext(ctx).Error()
+		return nil, err
+	}
+	for _, Photo := range Photos {
+		ProjectPhoto := http_model.ShowProjectPhoto{
+			PhotoUrl: Photo.PhotoUrl,
+			PhotoUid: Photo.PhotoUid,
+		}
+		ProjectDetail.ProjectPhotos = append(ProjectDetail.ProjectPhotos, ProjectPhoto)
+	}
+	return &ProjectDetail, nil
+}
+
+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),
+		RecruitDdl:    newProject.RecruitDdl,
+		TalentType:    newProject.TalentType,
+		ContentType:   conv.MustInt64(newProject.ContentType,0),
+		ProjectDetail: newProject.ProjectDetail,
+		ProjectForm:   conv.MustInt64(newProject.ProjectForm,0),
+		EnterpriseID:  conv.MustInt64(enterpriseID,0),
+		ProjectStatus: 4,
+	}
+	projectID, err := db.UpdateProject(ctx, project)
+	if err != nil {
+		return nil, err
+	}
+	// 删除该项目之前的所有图片
+	err = db.DeleteProjectPhotoByProjecttID(ctx, *projectID)
+	if err != nil {
+		return nil, err
+	}
+	fmt.Printf("照片:\t %+v", newProject.ProjectPhotos)
+	if newProject.ProjectPhotos != nil {
+		// 新增图片
+		projectPhotos := []gorm_model.ProjectPhoto{}
+		for _, photo := range newProject.ProjectPhotos {
+			projectPhoto := gorm_model.ProjectPhoto{
+				ProjectID: project.ProjectID,
+				PhotoUrl:  photo.PhotoUrl,
+				PhotoUid:  photo.PhotoUid,
+			}
+			projectPhotos = append(projectPhotos, projectPhoto)
+		}
+		err = db.CreateProjectPhoto(ctx, projectPhotos)
+		if err != nil {
+			return nil, err
+		}
+	}
+	// 删除该项目之前的所有策略
+	err = db.DeleteRecruitStrategyByProjectID(ctx, *projectID)
+	if err != nil {
+		return nil, err
+	}
+	fmt.Printf("策略:\t %+v", newProject.RecruitStrategys)
+	if newProject.RecruitStrategys != nil {
+		// 新增策略
+		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),
+				ProjectID:     project.ProjectID,
+			}
+			fmt.Printf("Offer:\t %+v", Strategy.Offer)
+			RecruitStrategys = append(RecruitStrategys, RecruitStrategy)
+		}
+		err = db.CreateRecruitStrategy(ctx, RecruitStrategys)
+		if err != nil {
+			return nil, err
+		}
+	}
+	res := &http_model.UpdateProjectData{
+		ProjectID: *projectID,
+	}
+	return res, nil
+}
+
+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)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[project service] call ChangeTaskStatus error,err:%+v", err)
+		return err,""
+	}
+	return nil,message
+}

+ 16 - 0
util/encoding.go

@@ -0,0 +1,16 @@
+package util
+
+import (
+	"crypto/md5"
+	"encoding/hex"
+)
+
+func MD5(keys ...string) string {
+	finalKey := ""
+	for _, key := range keys {
+		finalKey += key
+	}
+	s := md5.New()
+	s.Write([]byte(finalKey))
+	return hex.EncodeToString(s.Sum(nil))
+}

+ 27 - 0
util/resp.go

@@ -0,0 +1,27 @@
+package util
+
+import (
+	"net/http"
+	"youngee_m_api/consts"
+
+	"youngee_m_api/model/http_model"
+
+	"github.com/gin-gonic/gin"
+)
+
+func PackErrorResp(c *gin.Context, status int32) {
+	resp := http_model.CommonResponse{
+		Status:  status,
+		Message: consts.GetErrorToast(status),
+		Data:    nil,
+	}
+	c.JSON(http.StatusOK, resp)
+}
+func HandlerPackErrorResp(resp *http_model.CommonResponse, status int32, message string) {
+	resp.Status = status
+	if message != consts.DefaultToast {
+		resp.Message = message
+	} else {
+		resp.Message = consts.GetErrorToast(status)
+	}
+}

+ 30 - 0
util/type.go

@@ -0,0 +1,30 @@
+package util
+
+import "reflect"
+
+// 判断是否为空字符串
+func IsNull(s string) string {
+	if s == ""{
+		return "0"
+	}
+	return s
+}
+
+// 判断 reflect.Value 是否为空
+func IsBlank(value reflect.Value) bool {
+	switch value.Kind() {
+	case reflect.String:
+		return value.Len() == 0
+	case reflect.Bool:
+		return !value.Bool()
+	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+		return value.Int() == 0
+	case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+		return value.Uint() == 0
+	case reflect.Float32, reflect.Float64:
+		return value.Float() == 0
+	case reflect.Interface, reflect.Ptr:
+		return value.IsNil()
+	}
+	return reflect.DeepEqual(value.Interface(), reflect.Zero(value.Type()).Interface())
+}