Browse Source

Merge branch 'debug' of http://8.136.199.33:3000/eta_mini/eta_mini_crm_ht into debug

kobe6258 7 months ago
parent
commit
b3c303478a
6 changed files with 178 additions and 1 deletions
  1. 1 1
      .gitignore
  2. 66 0
      controllers/user.go
  3. 1 0
      models/db.go
  4. 5 0
      models/response/user.go
  5. 96 0
      models/template_users.go
  6. 9 0
      routers/commentsRouter.go

+ 1 - 1
.gitignore

@@ -6,4 +6,4 @@
 go.sum
 scheduler/etalogs/
 scheduler/conf/
-/.idea
+/.idea

+ 66 - 0
controllers/user.go

@@ -1261,3 +1261,69 @@ func (this *UserController) GlobalSearch() {
 	br.Success = true
 	br.Ret = 200
 }
+
+// TemplateList
+// @Title 潜在用户列表
+// @Description 潜在用户列表
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   Keyword   query   string  false       "手机号"
+// @Success 200 {object} response.TemplateUserListResp
+// @router /temporary/list [get]
+func (this *UserController) TemplateList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	keyword := this.GetString("Keyword")
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	} else if pageSize > utils.PageSize100 {
+		pageSize = utils.PageSize100
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	} else if pageSize > utils.PageSize100 {
+		pageSize = utils.PageSize100
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize := utils.StartIndex(currentIndex, pageSize)
+
+	var condition string
+	var pars []interface{}
+
+	if keyword != "" {
+		condition += ` AND mobile LIKE ? `
+		pars = utils.GetLikeKeywordPars(pars, keyword, 1)
+	}
+
+	resp := new(response.TemplateUserListResp)
+	total, userList, err := models.GetPageTemplateUserList(condition, pars, startSize, pageSize)
+	if err != nil {
+		br.Msg = "查询用户失败"
+		br.Msg = "查询用户失败,系统错误,Err:" + err.Error()
+		return
+	}
+
+	list := make([]models.TemplateUsersItem, 0)
+	for _, v := range userList {
+		list = append(list, v.ToItem())
+	}
+
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp.Paging = page
+	resp.List = list
+
+	br.Data = resp
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}

+ 1 - 0
models/db.go

@@ -40,5 +40,6 @@ func init() {
 		new(CrmConfig),
 		new(UserChangeRecord),
 		new(ReportPdf),
+		new(TemplateUsers),
 	)
 }

+ 5 - 0
models/response/user.go

@@ -24,3 +24,8 @@ type UserDetailResp struct {
 	Detail     *models.UserView
 	Permission map[string][]string
 }
+
+type TemplateUserListResp struct {
+	List   []models.TemplateUsersItem
+	Paging *paging.PagingItem `description:"分页数据"`
+}

+ 96 - 0
models/template_users.go

@@ -0,0 +1,96 @@
+package models
+
+import (
+	"eta/eta_mini_crm_ht/utils"
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+// TemplateUsers
+// @Description: 临时用户表
+type TemplateUsers struct {
+	Id           int       `orm:"pk" description:"用户id"`
+	UserName     string    `description:"姓名"`
+	Mobile       string    `description:"手机号"`
+	OpenId       string    `description:"用户openid"`
+	UnionId      string    `description:"用户unionid"`
+	IsDeleted    int       `description:"是否已删除"`
+	GzhOpenId    string    `description:"用户公众号openid"`
+	ReadCount    int       `description:"阅读次数"`
+	LastReadTime time.Time `description:"最近一次阅读时间"`
+	CreatedTime  time.Time `description:"创建时间"`
+	UpdatedTime  time.Time `description:"变更时间"`
+}
+
+// TemplateUsers
+// @Description: 临时用户表
+type TemplateUsersItem struct {
+	Id           int    `orm:"pk" description:"用户id"`
+	UserName     string `description:"姓名"`
+	Mobile       string `description:"手机号"`
+	OpenId       string `description:"用户openid"`
+	UnionId      string `description:"用户unionid"`
+	GzhOpenId    string `description:"用户公众号openid"`
+	ReadCount    int    `description:"阅读次数"`
+	LastReadTime string `description:"最近一次阅读时间"`
+	CreatedTime  string `description:"创建时间"`
+	UpdatedTime  string `description:"变更时间"`
+}
+
+// GetPageTemplateUserList
+// @Description: 获取分页用户数据
+// @author: Roc
+// @datetime 2024-08-09 16:45:15
+// @param condition string
+// @param pars []interface{}
+// @param startSize int
+// @param pageSize int
+// @return total int
+// @return items []*TemplateUsers
+// @return err error
+func GetPageTemplateUserList(condition string, pars []interface{}, startSize, pageSize int) (total int, items []*TemplateUsers, err error) {
+	o := orm.NewOrm()
+	totalSql := `SELECT count(1) ct FROM template_users AS a WHERE is_deleted = 0 `
+	if condition != "" {
+		totalSql += condition
+	}
+	err = o.Raw(totalSql, pars).QueryRow(&total)
+	if err != nil {
+		return
+	}
+
+	sql := `SELECT * FROM template_users AS a WHERE  is_deleted = 0 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` ORDER BY id DESC LIMIT ?,? `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+
+	return
+}
+
+// ToItem
+// @Description: 转结构体返回
+// @author: Roc
+// @receiver m
+// @datetime 2024-08-09 16:50:41
+// @return item TemplateUsersItem
+func (m *TemplateUsers) ToItem() (item TemplateUsersItem) {
+	item = TemplateUsersItem{
+		Id:           m.Id,
+		UserName:     m.UserName,
+		Mobile:       m.Mobile,
+		OpenId:       m.OpenId,
+		UnionId:      m.UnionId,
+		GzhOpenId:    m.GzhOpenId,
+		ReadCount:    m.ReadCount,
+		LastReadTime: "",
+		CreatedTime:  m.CreatedTime.Format(utils.FormatDateTime),
+		UpdatedTime:  m.UpdatedTime.Format(utils.FormatDateTime),
+	}
+	if !m.LastReadTime.IsZero() {
+		item.LastReadTime = m.LastReadTime.Format(utils.FormatDateTime)
+	}
+
+	return
+}

+ 9 - 0
routers/commentsRouter.go

@@ -470,6 +470,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserController"],
+        beego.ControllerComments{
+            Method: "TemplateList",
+            Router: `/temporary/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserLoginController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserLoginController"],
         beego.ControllerComments{
             Method: "AreaCodeList",