Ver código fonte

add level task

master
shenjiachi 5 dias atrás
pai
commit
e5842e3aad
6 arquivos alterados com 100 adições e 7 exclusões
  1. +1
    -0
      src/dao/user_level_dao.go
  2. +11
    -0
      src/dao/user_level_task_dao.go
  3. +8
    -0
      src/implement/user_level_implement.go
  4. +58
    -0
      src/implement/user_level_task_implement.go
  5. +9
    -7
      src/model/user_level.go
  6. +13
    -0
      src/model/user_level_task.go

+ 1
- 0
src/dao/user_level_dao.go Ver arquivo

@@ -16,4 +16,5 @@ type UserLevelDao interface {
UserLevelAllByAscByPage(page, limit int) ([]*model.UserLevel, int64, error)
UserLevelUpdate(id interface{}, level *model.UserLevel, forceColumns ...string) (int64, error)
UserLevelDeleteBySession(session *xorm.Session, id interface{}) (int64, error)
UserLevelInsert(userLevel *model.UserLevel) (int, error)
}

+ 11
- 0
src/dao/user_level_task_dao.go Ver arquivo

@@ -0,0 +1,11 @@
package dao

import "code.fnuoos.com/EggPlanet/egg_models.git/src/model"

type UserLevelTaskDao interface {
//TODO:: You can add specific method definitions here
UserLevelTaskFindByParams(params map[string]interface{}) ([]model.UserLevelTask, error)
UserLevelTaskInsert(userLevelTask *model.UserLevelTask) (int, error)
UserLevelTaskUpdate(userLevelTask *model.UserLevelTask, forceColumns ...string) (int64, error)
UserLevelTaskDelete(id interface{}) (int64, error)
}

+ 8
- 0
src/implement/user_level_implement.go Ver arquivo

@@ -82,3 +82,11 @@ func (u UserLevelDb) UserLevelDeleteBySession(session *xorm.Session, id interfac
}
return affected, nil
}

func (u UserLevelDb) UserLevelInsert(userLevel *model.UserLevel) (int, error) {
_, err := u.Db.InsertOne(userLevel)
if err != nil {
return 0, zhios_order_relate_logx.Error(err)
}
return userLevel.Id, nil
}

+ 58
- 0
src/implement/user_level_task_implement.go Ver arquivo

@@ -0,0 +1,58 @@
package implement

import (
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx"
"fmt"
"xorm.io/xorm"
)

func NewUserLevelTaskDb(engine *xorm.Engine) dao.UserLevelTaskDao {
return &UserLevelTaskDb{Db: engine}
}

type UserLevelTaskDb struct {
Db *xorm.Engine
}

func (u UserLevelTaskDb) UserLevelTaskFindByParams(params map[string]interface{}) ([]model.UserLevelTask, error) {
var m []model.UserLevelTask
var query = fmt.Sprintf("%s = ?", params["key"])
if err := u.Db.Where(query, params["value"]).Find(&m); err != nil {
return nil, zhios_order_relate_logx.Error(err)
}
return m, nil
}

func (u UserLevelTaskDb) UserLevelTaskInsert(userLevelTask *model.UserLevelTask) (int, error) {
_, err := u.Db.InsertOne(userLevelTask)
if err != nil {
return 0, zhios_order_relate_logx.Error(err)
}
return userLevelTask.Id, nil
}

func (u UserLevelTaskDb) UserLevelTaskUpdate(userLevelTask *model.UserLevelTask, forceColumns ...string) (int64, error) {
var (
affected int64
err error
)
if forceColumns != nil {
affected, err = u.Db.Where("id=?", userLevelTask.Id).MustCols(forceColumns...).Update(userLevelTask)
} else {
affected, err = u.Db.Where("id=?", userLevelTask.Id).Update(userLevelTask)
}
if err != nil {
return 0, zhios_order_relate_logx.Error(err.Error())
}
return affected, nil
}

func (u UserLevelTaskDb) UserLevelTaskDelete(id interface{}) (int64, error) {
affected, err := u.Db.Where("id = ?", id).Delete(&model.UserLevelTask{})
if err != nil {
return 0, err
}
return affected, nil
}

+ 9
- 7
src/model/user_level.go Ver arquivo

@@ -1,11 +1,13 @@
package model

type UserLevel struct {
Id int `json:"id" xorm:"not null pk autoincr comment('等级id') INT(11)"`
LevelName string `json:"level_name" xorm:"not null default '' comment('等级名称') CHAR(50)"`
LevelWeight int `json:"level_weight" xorm:"not null default 0 comment('等级权重') INT(11)"`
IsUse int `json:"is_use" xorm:"not null default 1 comment('是否开启(0否,1是)') TINYINT(1)"`
Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(255)"`
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
Id int `json:"id" xorm:"not null pk autoincr comment('等级id') INT(11)"`
LevelName string `json:"level_name" xorm:"not null default '' comment('等级名称') VARCHAR(255)"`
LevelWeight int `json:"level_weight" xorm:"not null default 0 comment('等级权重') INT(11)"`
ChoosableNum int `json:"choosable_num" xorm:"default 0 comment('可选任务数量') INT(6)"`
AutoUpdate int `json:"auto_update" xorm:"default 0 comment('自动升级 0关闭,1开启') INT(1)"`
IsUse int `json:"is_use" xorm:"not null default 1 comment('是否开启(0否,1是)') TINYINT(1)"`
Memo string `json:"memo" xorm:"default '' comment('备注') VARCHAR(255)"`
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
}

+ 13
- 0
src/model/user_level_task.go Ver arquivo

@@ -0,0 +1,13 @@
package model

type UserLevelTask struct {
Id int `json:"id" xorm:"not null pk autoincr comment('主键id') INT(11)"`
LevelId int `json:"level_id" xorm:"not null default 0 comment('等级id') INT(11)"`
IsMustTask int `json:"is_must_task" xorm:"not null default 0 comment('是否必做(0,1)') TINYINT(1)"`
TaskType int `json:"task_type" xorm:"not null default 0 comment('1:直推会员人数,2:直推会员活跃天数,3:直推会员等级') TINYINT(2)"`
WithinDays int `json:"within_days" xorm:"not null default 0 comment('多少天内完成') INT(11)"`
FinishCount int `json:"finish_count" xorm:"not null default 0 comment('多少天内完成的指标数') INT(11)"`
TaskTypeLevelId int `json:"task_type_level_id" xorm:"not null default 0 comment('会员等级id(task_type=3时生效)') INT(11)"`
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') TIMESTAMP"`
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('更新时间') TIMESTAMP"`
}

Carregando…
Cancelar
Salvar