소스 검색

test

tags/v1.0.2
huangjiajun 1 년 전
부모
커밋
c8e1c85d01
4개의 변경된 파일117개의 추가작업 그리고 0개의 파일을 삭제
  1. +55
    -0
      db/db_day_luck_draw_period_reward.go
  2. +16
    -0
      db/db_user.go
  3. +27
    -0
      db/model/user.go
  4. +19
    -0
      md/day_luck_draw_period_reward.go

+ 55
- 0
db/db_day_luck_draw_period_reward.go 파일 보기

@@ -0,0 +1,55 @@
package db

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_day_luck_draw.git/db/model"
"code.fnuoos.com/go_rely_warehouse/zyos_go_day_luck_draw.git/md"
zhios_day_luck_draw_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_day_luck_draw.git/utils"
"xorm.io/xorm"
)

func GetDayLuckDrawPeriodRewardList(Db *xorm.Engine, parameter *md.DayLuckDrawPeriodRewardRequest) ([]*model.DayLuckDrawPeriodReward, int, error) {
var list []*model.DayLuckDrawPeriodReward
count := DayLuckDrawPeriodRewardGetCount(Db, parameter)
session := Db.Where("")
DayLuckDrawPeriodRewardSearchCondition(Db, session, parameter)
//分页
if zhios_day_luck_draw_utils.StrToInt(parameter.P) > 0 && zhios_day_luck_draw_utils.StrToInt(parameter.PageSize) > 0 {
session = session.Limit(zhios_day_luck_draw_utils.StrToInt(parameter.PageSize), (zhios_day_luck_draw_utils.StrToInt(parameter.P)-1)*zhios_day_luck_draw_utils.StrToInt(parameter.PageSize))
}
//排序
err := session.Desc("create_time").Find(&list)
if err != nil {
return nil, 0, err
}
return list, count, nil
}
func DayLuckDrawPeriodRewardGetCount(Db *xorm.Engine, parameter *md.DayLuckDrawPeriodRewardRequest) int {
var ord model.DayLuckDrawPeriodReward
session := Db.Where("")
DayLuckDrawPeriodRewardSearchCondition(Db, session, parameter)
count, err := session.Count(&ord)
if err != nil {
return 0
}
return int(count)
}
func DayLuckDrawPeriodRewardSearchCondition(Db *xorm.Engine, session *xorm.Session, parameter *md.DayLuckDrawPeriodRewardRequest) {
if parameter.Uid != "" {
session = session.And("uid = ? ", parameter.Uid)
}
if parameter.Phone != "" {
uid := 0
mobile, _ := UserFindByMobile(Db, parameter.Phone)
if mobile != nil {
uid = mobile.Uid
}
session = session.And("uid = ? ", uid)
}
if parameter.StartTime != "" {
session = session.And("create_time >=?", parameter.StartTime)
}
if parameter.EndTime != "" {
session = session.And("create_time <=?", parameter.EndTime)
}

}

+ 16
- 0
db/db_user.go 파일 보기

@@ -0,0 +1,16 @@
package db

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_day_luck_draw.git/db/model"
"xorm.io/xorm"
)

// UserFindByMobile search user by mobile
func UserFindByMobile(Db *xorm.Engine, mobile string) (*model.User, error) {
var m model.User
if has, err := Db.Where("phone = ? AND delete_at = 0", mobile, mobile).
Get(&m); err != nil || has == false {
return nil, err
}
return &m, nil
}

+ 27
- 0
db/model/user.go 파일 보기

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

import (
"time"
)

type User struct {
Uid int `json:"uid" xorm:"not null pk autoincr comment('主键ID') INT(10)"`
Username string `json:"username" xorm:"not null default '' comment('用户名') index VARCHAR(50)"`
Password string `json:"password" xorm:"not null default '' comment('密码') CHAR(32)"`
Email string `json:"email" xorm:"not null default '' comment('邮箱') VARCHAR(128)"`
Phone string `json:"phone" xorm:"not null default '' comment('联系电话') VARCHAR(20)"`
Nickname string `json:"nickname" xorm:"not null default '' comment('昵称') VARCHAR(20)"`
Level int `json:"level" xorm:"not null default 0 comment('用户等级id') INT(11)"`
InviteTotal int `json:"invite_total" xorm:"not null default 0 comment('直推邀请总人数') INT(11)"`
LevelArriveAt time.Time `json:"level_arrive_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('到达该等级的时间') TIMESTAMP"`
LevelExpireAt time.Time `json:"level_expire_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('该等级过期时间') TIMESTAMP"`
CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') TIMESTAMP"`
UpdateAt time.Time `json:"update_at" xorm:"default 'CURRENT_TIMESTAMP' comment('最后修改资料时间') TIMESTAMP"`
LastLoginAt time.Time `json:"last_login_at" xorm:"default 'CURRENT_TIMESTAMP' comment('最近登录时间') TIMESTAMP"`
DeleteAt int `json:"delete_at" xorm:"not null default 0 comment('是否删除;0未删除;1已删除') TINYINT(1)"`
State int `json:"state" xorm:"not null default 1 comment('0未激活,1正常,2冻结') TINYINT(1)"`
LastLoginIp string `json:"last_login_ip" xorm:"not null default '' comment('最后登录IP') VARCHAR(64)"`
RegisterIp string `json:"register_ip" xorm:"not null default '' comment('注册IP') VARCHAR(64)"`
AdminId string `json:"admin_id" xorm:"not null default '' comment('管理员id') VARCHAR(5000)"`
IsFake int `json:"is_fake" xorm:"not null default 0 comment('0真实 1虚拟') TINYINT(1)"`
}

+ 19
- 0
md/day_luck_draw_period_reward.go 파일 보기

@@ -0,0 +1,19 @@
package md

type DayLuckDrawPeriodRewardRequest struct {
Uid string `json:"uid"`
Oid string `json:"oid"`
Pvd string `json:"pvd"`
Phone string `json:"phone"`
StartTime string `json:"start_time"`
EndTime string `json:"end_time"`
P string `json:"p"` //页
PageSize string `json:"page_size"` //页大小
}
type DayLuckDrawPeriodRewardOrdList struct {
Id string `json:"id" `
Uid string `json:"uid" `
Reward string `json:"reward"`
Period string `json:"period"`
CreateTime string `json:"create_time"`
}

불러오는 중...
취소
저장