| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- package logic
- import (
- "context"
- "git.i2edu.net/i2/go-zero/core/stores/sqlx"
- "git.i2edu.net/i2/i2-bill-api/internal/utils"
- "git.i2edu.net/i2/i2-bill-api/model"
- "time"
- "git.i2edu.net/i2/i2-bill-api/internal/svc"
- "git.i2edu.net/i2/i2-bill-api/internal/types"
- "git.i2edu.net/i2/go-zero/core/logx"
- )
- type PartTimeUserAddLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
- func NewPartTimeUserAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) PartTimeUserAddLogic {
- return PartTimeUserAddLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx,
- }
- }
- func (l *PartTimeUserAddLogic) PartTimeUserAdd(req types.PartTimeUserAddRequest) (*types.Response, error) {
- // todo: add your logic here and delete this line
- userId := utils.GetUserIdByJwt(l.ctx)
- var bean = new(model.I2billMktPartTimeUser)
- err := l.svcCtx.SqlConn.QueryRow(bean, "select * from i2bill_mkt_part_time_user where user_id = ? and del_flag = 0", userId)
- if err != nil && err != sqlx.ErrNotFound {
- return &types.Response{Code: 500, Msg: err.Error(), Data: nil}, nil
- }
- if bean.Id != 0 {
- if bean.CheckState == 54 {
- return &types.Response{Code: 500, Msg: "你的申请兼职人员的个人信息已提交,请等待审核!", Data: nil}, nil
- }
- if bean.CheckState == 58 {
- return &types.Response{Code: 500, Msg: "你的申请兼职人员的个人信息不通过原因:" + bean.CheckDesc, Data: nil}, nil
- }
- if bean.CheckState == 57 {
- return &types.Response{Code: 500, Msg: "你已经是兼职人员:", Data: nil}, nil
- }
- }
- bean = &model.I2billMktPartTimeUser{
- CreateTime: time.Now(),
- LastUpdateTime: time.Now(),
- DelFlag: 0,
- MkId: req.MkId,
- CreateBy: 1,
- CheckState: 54,
- CheckDesc: "",
- CityId: req.CityId,
- IponeNumber: "",
- Sex: req.Sex,
- Target: 0,
- UserId: userId,
- LastUpdateBy: 0,
- Name: req.Name,
- }
- res, err := model.NewI2billMktPartTimeUserModel(l.svcCtx.SqlConn).Insert(*bean)
- if err != nil {
- return &types.Response{Code: 500, Msg: err.Error(), Data: nil}, nil
- }
- id, _ := res.LastInsertId()
- return &types.Response{Code: 200, Msg: "", Data: id}, nil
- }
|