1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- package logic
- import (
- "context"
- "fmt"
- "app.yhyue.com/moapp/jyInfo/rpc/model"
- "time"
- "app.yhyue.com/moapp/jyInfo/rpc/consumer/consumer"
- "app.yhyue.com/moapp/jyInfo/rpc/consumer/internal/svc"
- mc "app.yhyue.com/moapp/jybase/common"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type InfoByUserIdLogic struct {
- ctx context.Context
- svcCtx *svc.ServiceContext
- logx.Logger
- }
- func NewInfoByUserIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InfoByUserIdLogic {
- return &InfoByUserIdLogic{
- ctx: ctx,
- svcCtx: svcCtx,
- Logger: logx.WithContext(ctx),
- }
- }
- func GetZeroTime(d time.Time) time.Time {
- return time.Date(d.Year(), d.Month(), d.Day(), 0, 0, 0, 0, d.Location())
- }
- // 根据用户id获取当月已发布信息数量
- func (l *InfoByUserIdLogic) InfoByUserId(in *consumer.UserIdReq) (*consumer.InfoByUserIdResp, error) {
- // todo: add your logic here and delete this line
- //qurey := make(map[string]interface{})
- var data = consumer.InfoByUserIdResp{}
- endTime := time.Now().Format("2006-01-02 15:04:05")
- startTime := time.Date(time.Now().Year(), time.Now().Month(), 1, 0, 0, 0, 0, time.Now().Location())
- //query := fmt.Sprintf("select count(1) from information where user_id = %s and published = 1 and publish_time>='%s' and publish_time<='%s'", in.UserId, startTime, endTime)
- supplyquery := fmt.Sprintf("select count(1) from supply_info where user_id = '%s' and published = 2 and publish_time>='%s' and publish_time<='%s'", in.UserId, startTime, endTime)
- //number := model.Mysql.CountBySql(query) + model.Mysql.CountBySql(supplyquery)
- number := model.Mysql.CountBySql(supplyquery)
- var resp consumer.InfoByUserIdData
- resp.Total = mc.Int64All(model.SupplyTotal)
- resp.Surplus = mc.Int64All(model.SupplyTotal) - number
- data.Results = &resp
- return &data, nil
- }
|