kobe6258 6 місяців тому
батько
коміт
5d2d6077e7
5 змінених файлів з 224 додано та 327 видалено
  1. 153 5
      controllers/user.go
  2. 1 1
      models/db.go
  3. 15 5
      models/template_users.go
  4. 45 315
      models/user.go
  5. 10 1
      routers/commentsRouter.go

+ 153 - 5
controllers/user.go

@@ -9,15 +9,16 @@ import (
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"strconv"
 	"strings"
+	"time"
 )
 
 type UserController struct {
 	BaseAuthController
 }
 
-// TemporaryList
-// @Title 潜在用户列表
-// @Description 潜在用户列表
+// TemplateList
+// @Title 临时用户列表
+// @Description 临时用户列表
 // @Param   PageSize   query   int  true       "每页数据条数"
 // @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
 // @Param   Keyword   query   string  false       "手机号"
@@ -25,7 +26,7 @@ type UserController struct {
 // @Param   SortType   query   string  true       "如何排序,是正序还是倒序,0:倒序,1:正序"
 // @Success 200 {object} response.TemplateUserListResp
 // @router /temporary/list [get]
-func (this *UserController) TemporaryList() {
+func (this *UserController) TemplateList() {
 	br := new(models.BaseResponse).Init()
 	defer func() {
 		this.Data["json"] = br
@@ -103,6 +104,153 @@ func (this *UserController) TemporaryList() {
 	br.Msg = "获取成功"
 }
 
+// OfficialList
+// @Title 正式用户列表
+// @Description 正式用户列表
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   Keyword   query   string  false       "手机号"
+// @Param   SortParam   query   string  false       "排序字段参数,用来排序的字段, 枚举值:0:注册时间,1:阅读数,2:最近一次阅读时间"
+// @Param   SortType   query   string  true       "如何排序,是正序还是倒序,0:倒序,1:正序"
+// @Success 200 {object} response.TemplateUserListResp
+// @router /official/list [get]
+func (this *UserController) OfficialList() {
+	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")
+	FollowingGzh := this.GetString("FollowingGzh")
+	RegisterBeginDate := this.GetString("RegisterBeginDate")
+	RegisterEndDate := this.GetString("RegisterEndDate")
+	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)
+
+	sortParamInt, _ := this.GetInt("SortParam", 0)
+	sortTypeInt, _ := this.GetInt("SortType", 0)
+
+	var sortStr = ``
+	var condition string
+	var pars []interface{}
+
+	sortParamMap := map[int]string{0: "created_time", 1: "read_count", 2: "last_read_time"}
+	sortTypeMap := map[int]string{0: "desc", 1: "asc"}
+	sortParam, ok := sortParamMap[sortParamInt]
+	if !ok {
+		br.Msg = "错误的排序字段参数"
+		br.ErrMsg = fmt.Sprint("错误的排序字段:", sortParamInt)
+		return
+	}
+	sortType, ok := sortTypeMap[sortTypeInt]
+	if !ok {
+		br.Msg = "错误的排序字段"
+		br.ErrMsg = fmt.Sprintf("错误的排序字段:%v", sortTypeInt)
+		return
+	}
+	sortStr = fmt.Sprintf("%s %s,updated_time desc ", sortParam, sortType)
+	if FollowingGzh != "" {
+		switch FollowingGzh {
+		case "true":
+			condition += ` AND following_gzh=1 `
+		case "false":
+			condition += ` AND following_gzh=0 `
+		default:
+			br.Msg = "关注公众号字段非法字段"
+			br.ErrMsg = fmt.Sprintf("错误的关注公众号字段:%s", FollowingGzh)
+			return
+		}
+	}
+	if RegisterBeginDate != "" || RegisterEndDate != "" {
+		var beginDate, endDate time.Time
+		var parseErr error
+		if RegisterBeginDate != "" {
+			beginDate, parseErr = time.Parse(time.DateOnly, RegisterBeginDate)
+			if parseErr != nil {
+				br.Msg = "注册时间开始字段非法字段"
+				br.ErrMsg = fmt.Sprintf("错误的注册时间开始字段:%s", RegisterBeginDate)
+				return
+			}
+		}
+		if RegisterEndDate != "" {
+			endDate, parseErr = time.Parse(time.DateOnly, RegisterEndDate)
+			if parseErr != nil {
+				br.Msg = "注册时间结束字段非法字段"
+				br.ErrMsg = fmt.Sprintf("错误的注册时间结束字段:%s", RegisterEndDate)
+
+				return
+			}
+		}
+
+		if RegisterBeginDate != "" {
+			if RegisterEndDate != "" {
+				if beginDate.After(endDate) {
+					br.Msg = "结束时间不能早于开始时间"
+					br.ErrMsg = fmt.Sprintf("错误的注册时间结束字段:开始时间:%s,结束时间:%s", RegisterBeginDate, RegisterEndDate)
+					return
+				}
+				condition += ` AND DATE_FORMAT(created_time,'%Y-%m-%d') BETWEEN ? AND ?`
+				pars = append(pars, RegisterBeginDate, RegisterEndDate)
+			} else {
+				condition += ` AND DATE_FORMAT(created_time,'%Y-%m-%d') >= ?`
+				pars = append(pars, RegisterBeginDate)
+			}
+		} else {
+			condition += ` AND DATE_FORMAT(created_time,'%Y-%m-%d') <= ?`
+			pars = append(pars, RegisterEndDate)
+		}
+	}
+	if keyword != "" {
+		condition += ` AND ( mobile LIKE ? or real_name like ?)`
+		pars = utils.GetLikeKeywordPars(pars, keyword, 2)
+	}
+
+	resp := new(response.UserListResp)
+	total, userList, err := models.GetPageOfficialUserList(condition, pars, sortStr, startSize, pageSize)
+	if err != nil {
+		br.Msg = "查询用户失败"
+		br.Msg = "查询用户失败,系统错误,Err:" + err.Error()
+		return
+	}
+
+	//list := make([]*models.UserView, 0)
+	//var wg sync.WaitGroup
+	//wg.Add(len(userList))
+	//for _, v := range userList {
+	//	go func(v *models.User) {
+	//		defer wg.Done()
+	//		tempUser, _ := models.GetTemplateUser(v.TemplateUserId)
+	//		userView := v.FillUserInfo(tempUser)
+	//		list = append(list, &userView)
+	//	}(&v)
+	//}
+	//wg.Wait()
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp.Paging = page
+	resp.List = userList
+	br.Data = resp
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}
+
 // readRecordList
 // @Title 用户阅读记录
 // @Description 用户阅读记录
@@ -136,7 +284,7 @@ func (this *UserController) ReadRecordList() {
 		currentIndex = 1
 	}
 	startSize := utils.StartIndex(currentIndex, pageSize)
-	user, err := models.GetUserById(UserId)
+	user, err := models.GetTemplateUser(UserId)
 	if err != nil {
 		if err.Error() == utils.ErrNoRow() {
 			br.Msg = "用户不存在或已删除,请刷新页面"

+ 1 - 1
models/db.go

@@ -40,7 +40,7 @@ func init() {
 		new(User),
 		new(CrmConfig),
 		new(ReportPdf),
-		new(TemplateUsers),
+		new(TemplateUser),
 		new(CrmFinancialAnalyst),
 		new(Media),
 		new(MetaInfo),

+ 15 - 5
models/template_users.go

@@ -23,7 +23,7 @@ type AccountStatus string
 
 // TemplateUsers
 // @Description: 临时用户表
-type TemplateUsers struct {
+type TemplateUser struct {
 	Id            int           `orm:"pk" description:"用户id"`
 	UserName      string        `description:"姓名"`
 	Mobile        string        `description:"手机号"`
@@ -55,6 +55,10 @@ type TemplateUsersItem struct {
 	UpdatedTime   string `description:"变更时间"`
 }
 
+func (u *TemplateUser) TableName() string {
+	return "template_users"
+}
+
 // GetPageTemplateUserList
 // @Description: 获取分页用户数据
 // @author: Roc
@@ -66,7 +70,7 @@ type TemplateUsersItem struct {
 // @return total int
 // @return items []*TemplateUsers
 // @return err error
-func GetPageTemplateUserList(condition string, pars []interface{}, sortStr string, startSize, pageSize int) (total int, items []*TemplateUsers, err error) {
+func GetPageTemplateUserList(condition string, pars []interface{}, sortStr string, startSize, pageSize int) (total int, items []*TemplateUser, err error) {
 	o := orm.NewOrm()
 	totalSql := `SELECT count(1) ct FROM template_users AS a WHERE is_deleted = 0 `
 	if condition != "" {
@@ -90,21 +94,27 @@ func GetPageTemplateUserList(condition string, pars []interface{}, sortStr strin
 
 	return
 }
-func GetTemplateUserList() (items []*TemplateUsers, err error) {
+func GetTemplateUserList() (items []*TemplateUser, err error) {
 	o := orm.NewOrm()
-
 	sql := `SELECT * FROM template_users WHERE  is_deleted = 0 `
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
 
+func GetTemplateUser(id int) (item *TemplateUser, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM template_users WHERE id=? and  is_deleted = 0 `
+	err = o.Raw(sql, id).QueryRow(&item)
+	return
+}
+
 // ToItem
 // @Description: 转结构体返回
 // @author: Roc
 // @receiver m
 // @datetime 2024-08-09 16:50:41
 // @return item TemplateUsersItem
-func (m *TemplateUsers) ToItem() (item TemplateUsersItem) {
+func (m *TemplateUser) ToItem() (item TemplateUsersItem) {
 	item = TemplateUsersItem{
 		Id:            m.Id,
 		UserName:      m.UserName,

+ 45 - 315
models/user.go

@@ -1,341 +1,71 @@
 package models
 
 import (
-	"context"
 	"eta/eta_mini_crm_ht/utils"
-	"fmt"
-	"strings"
-	"time"
-
 	"github.com/beego/beego/v2/client/orm"
+	"time"
 )
 
 type User struct {
-	UserId         int       `orm:"pk" description:"用户id"`
-	RealName       string    `description:"姓名"`
-	Phone          string    `description:"手机号"`
-	AreaCode       string    `description:"区号"`
-	Email          string    `description:"邮箱"`
-	SellerId       int       `description:"销售id(SysUserId)"`
-	Company        string    `description:"所属公司"`
-	ValidStartTime time.Time `description:"有效期开始时间"`
-	ValidEndTime   time.Time `description:"有效期结束时间"`
-	Status         int       `description:"用户类型: 0表示禁用,1表示潜在客户,2表示正式客户"`
-	CreateTime     time.Time `description:"系统中首次新增用户的时间"`
-	ModifyTime     time.Time `description:"系统中用户信息变更的时间"`
-	RegisterTime   time.Time `description:"用户首次登录小程序的时间"`
-	IsSubscribed   bool      `description:"是否关注公众号: 0表示没有关注,1表示关注"`
-	IsRegistered   bool      `description:"是否注册: 0表示没有注册,1表示注册"`
-}
-
-type UserView struct {
-	UserId         int    `orm:"pk" description:"用户id"`
-	RealName       string `description:"姓名"`
-	Phone          string `description:"手机号"`
-	AreaCode       string `description:"区号"`
-	Email          string `description:"邮箱"`
-	SellerId       int    `description:"销售id(SysUserId)"`
-	SellerName     string `description:"销售姓名"`
-	Company        string `description:"所属公司"`
-	ValidStartTime string `description:"有效期开始时间"`
-	ValidEndTime   string `description:"有效期结束时间"`
-	RestDate       int    `description:"剩余天数"`
-	Status         int    `description:"用户类型: 0表示禁用,1表示潜在客户,2表示正式客户"`
-	ReadCnt        int    `description:"用户阅读量"`
-	CreateTime     string `description:"系统中首次新增用户的时间"`
-	ModifyTime     string `description:"系统中用户信息变更的时间"`
-	LastUpdateTime string `description:"最近一次阅读时间"`
-	RegisterTime   string `description:"用户首次登录小程序的时间"`
-	IsSubscribed   bool   `description:"是否关注公众号: 0表示没有关注,1表示关注"`
-	IsRegistered   bool   `description:"是否注册: 0表示没有注册,1表示注册"`
-}
-
-func (u *User) Save() (err error) {
-	o := orm.NewOrm()
-	_, err = o.InsertOrUpdate(u)
-	return
-}
-
-func (u *User) Update(cols []string) (err error) {
-	o := orm.NewOrm()
-	_, err = o.Update(u, cols...)
-	return
-}
-
-func UpdateUserStatus(condition string, pars []interface{}) (err error) {
-	o := orm.NewOrm()
-	sql := ` UPDATE user SET status=0 WHERE 1=1 `
-	if condition != "" {
-		sql += condition
-	}
-	_, err = o.Raw(sql, pars).Exec()
-	return
-}
-
-func GetUserIdListByCondition(condition string, pars []interface{}) (items []int, err error) {
-	o := orm.NewOrm()
-	sql := ` SELECT user_id FROM user WHERE 1=1 `
-	if condition != "" {
-		sql += condition
-	}
-	_, err = o.Raw(sql, pars).QueryRows(&items)
-	return
-}
-
-func SaveUser(user *User, chartPermissionIds []int) (err error) {
-	o := orm.NewOrm()
-	err = o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
-		insertId, er := txOrm.InsertOrUpdate(user)
-		if er != nil {
-			return er
-		}
-		if user.UserId != 0 {
-			insertId = int64(user.UserId)
-		} else {
-			user.UserId = int(insertId)
-		}
-		// 先删除再增加
-		sql := `DELETE FROM user_chart_permission_mapping WHERE user_id=?`
-		_, er = txOrm.Raw(sql, insertId).Exec()
-		if er != nil {
-			return er
-		}
-		for _, id := range chartPermissionIds {
-			userChartPermissionMapping := new(UserChartPermissionMapping)
-			userChartPermissionMapping.UserId = int(insertId)
-			userChartPermissionMapping.ChartPermissionId = id
-			_, er = txOrm.Insert(userChartPermissionMapping)
-			if er != nil {
-				return er
-
-			}
-		}
-		return nil
-	})
-	return
-}
-
-func GetUserByPhone(phone, areaCode string) (item *User, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT * FROM user WHERE phone=? AND area_code=?`
-	err = o.Raw(sql, phone, areaCode).QueryRow(&item)
-	return
-}
-
-func GetUserByEmail(email string) (item *User, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT * FROM user WHERE email=? `
-	err = o.Raw(sql, email).QueryRow(&item)
-	return
-}
-
-func GetUserById(userId int) (item *User, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT * FROM template_users WHERE id=? and is_deleted=0`
-	err = o.Raw(sql, userId).QueryRow(&item)
-	return
-}
-
-func GetUserViewById(userId int) (item *UserView, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT * FROM user WHERE user_id=? `
-	err = o.Raw(sql, userId).QueryRow(&item)
-	return
-}
-
-func GetUserList(condition string, pars []interface{}, startSize, pageSize int) (items []*UserView, err error) {
-	sql := `SELECT u.*, su.sys_real_name AS seller_name FROM user AS u
-	LEFT JOIN sys_user AS su
-	ON u.seller_id = su.sys_user_id
-	WHERE 1=1 AND (u.phone IS NOT NULL OR u.email IS NOT NULL) `
-	if condition != "" {
-		sql += condition
-	}
-	sql += ` ORDER BY modify_time DESC LIMIT ?,? `
-	o := orm.NewOrm()
-	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
-	return
-}
-
-func GetUserListByConditonSort(condition, sortConditon string, pars []interface{}, startSize, pageSize int) (items []*UserView, err error) {
-	sql := `SELECT u.*, su.sys_real_name AS seller_name
-	FROM user AS u
-	LEFT JOIN sys_user AS su
-	ON u.seller_id = su.sys_user_id
-	WHERE 1=1 AND (u.phone IS NOT NULL OR u.email IS NOT NULL) `
-	if condition != "" {
-		sql += condition
+	Id             int           `orm:"pk" description:"用户id"`
+	TemplateUserId int           `description:"临时用户ID"`
+	RealName       string        `description:"姓名"`
+	IdNo           string        `description:"证件号"`
+	IdKind         int           `description:"证件类型"`
+	IdBeginDate    time.Time     `description:"证件开始日期"`
+	IdEndDate      time.Time     `description:"证件结束日期"`
+	AccountStatus  AccountStatus `description:"账号状态"`
+	CreatedTime    time.Time     `description:"创建时间"`
+	UpdatedTime    time.Time     `description:"更新时间"`
+}
+
+func (u User) FillUserInfo(user *TemplateUser) UserView {
+	return UserView{
+		RealName:      u.RealName,
+		AccountStatus: u.AccountStatus,
+		LastReadTime:  user.LastReadTime.Format(time.DateTime),
+		FollowingGzh:  user.FollowingGzh,
+		ReadCount:     user.ReadCount,
+		Mobile:        user.Mobile,
+		CreatedTime:   u.CreatedTime.Format(time.DateTime),
 	}
-	if sortConditon != "" {
-		sql += sortConditon
-	}
-	sql += ` LIMIT ?,? `
-	o := orm.NewOrm()
-	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
-	return
 }
 
-func GetPotentialUserCountByConditon(condition string, pars []interface{}) (count int, err error) {
-	sql := `SELECT COUNT(DISTINCT u.user_id) AS count
-	FROM user AS u
-	LEFT JOIN user_read_record AS ur
-	ON u.user_id = ur.user_id
-	WHERE 1=1 AND (u.phone IS NOT NULL OR u.email IS NOT NULL) AND u.status=1`
-	if condition != "" {
-		sql += condition
-	}
-	o := orm.NewOrm()
-	err = o.Raw(sql, pars).QueryRow(&count)
-	return
+type UserView struct {
+	RealName      string `description:"姓名"`
+	Mobile        string `description:"手机号码"`
+	FollowingGzh  bool
+	LastReadTime  string
+	ReadCount     int
+	AccountStatus AccountStatus `description:"账号状态"`
+	CreatedTime   string
 }
 
-func GetPotentialUserCountByConditonV2(condition string, pars []interface{}) (count int, err error) {
-	sql := `SELECT COUNT(u.user_id) AS count
-	FROM user AS u
-	LEFT JOIN (
-		SELECT user_id, MAX(create_time) AS create_time
-		FROM user_read_record
-		GROUP BY user_id
-	) AS ur
-	ON u.user_id = ur.user_id
-	WHERE 1=1 AND (u.phone IS NOT NULL OR u.email IS NOT NULL) AND u.status=1`
-	if condition != "" {
-		sql += condition
-	}
+func GetPageOfficialUserList(condition string, pars []interface{}, sortStr string, startSize int, pageSize int) (total int, userList []*UserView, err error) {
 	o := orm.NewOrm()
-	err = o.Raw(sql, pars).QueryRow(&count)
-	return
-}
+	totalSql := `SELECT distinct template_user_id FROM users`
 
-func GetPotentialUserIdsByConditonV2(condition string, pars []interface{}, sortConditon string, startSize, pageSize int) (items []*UserView, err error) {
-	sql := `SELECT DISTINCT u.*, ur.read_cnt, ur.create_time AS last_update_time
-	FROM user AS u
-	LEFT JOIN (
-		SELECT user_id, MAX(create_time) AS create_time, COUNT(user_id) AS read_cnt
-		FROM user_read_record
-		GROUP BY user_id
-	) AS ur
-	ON u.user_id = ur.user_id
-	WHERE 1=1 AND (u.phone IS NOT NULL OR u.email IS NOT NULL) AND u.status=1`
-	if condition != "" {
-		sql += condition
-	}
-	if sortConditon != "" {
-		sql += sortConditon
+	var officialIds []int
+	_, err = o.Raw(totalSql).QueryRows(&officialIds)
+	if err != nil {
+		return
 	}
-	sql += ` LIMIT ?,? `
-	o := orm.NewOrm()
-	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
-	return
-}
-
-func GetPotentialUserIdsByConditon(condition string, pars []interface{}) (userIds []string, err error) {
-	sql := `SELECT DISTINCT u.user_id AS user_id
-	FROM user AS u
-	LEFT JOIN user_read_record AS ur
-	ON u.user_id = ur.user_id
-	WHERE 1=1 AND (u.phone IS NOT NULL OR u.email IS NOT NULL) AND u.status=1`
+	total = len(officialIds)
+	idCondition := " and tus.id in (" + utils.GetOrmReplaceHolder(len(officialIds)) + ")"
+	sql := `SELECT us.real_name as real_name, tus.mobile,tus.following_gzh,tus.created_time,tus.read_count,tus.last_read_time,tus.account_status  FROM template_users tus LEFT JOIN (select real_name,template_user_id from users) us on us.template_user_id=tus.id WHERE  1=1`
+	sql = sql + idCondition
 	if condition != "" {
 		sql += condition
 	}
-	o := orm.NewOrm()
-	_, err = o.Raw(sql, pars).QueryRows(&userIds)
-	return
-}
 
-func GetPotentialUserListByConditonSort(userIds []string, sortConditon string, startSize, pageSize int) (items []*UserView, err error) {
-	sql := `SELECT u.*, COUNT(ur.user_id) AS read_cnt, Max(ur.create_time) AS last_update_time
-	FROM user AS u
-	LEFT JOIN user_read_record AS ur
-	ON u.user_id = ur.user_id
-	WHERE 1=1 AND (u.phone IS NOT NULL OR u.email IS NOT NULL) AND u.status=1`
-	if len(userIds) > 0 {
-		sql += fmt.Sprintf(" AND u.user_id IN (%s)", strings.Join(userIds, ","))
+	if sortStr != `` {
+		sql += ` ORDER BY ` + sortStr
 	}
-	sql += ` GROUP BY u.user_id`
-	if sortConditon != "" {
-		sql += sortConditon
-	}
-	sql += ` LIMIT ?,? `
-	o := orm.NewOrm()
-	_, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
-	return
-}
 
-func GetUserReadList(condition, sortCondition string, pars []interface{}, startSize, pageSize int) (items []*UserView, err error) {
-	sql := `SELECT u.*, su.sys_real_name AS seller_name, COUNT(ur.user_id) AS read_cnt, Max(ur.create_time) AS last_update_time
-	FROM user AS u
-	LEFT JOIN sys_user AS su
-	ON u.seller_id = su.sys_user_id
-	LEFT JOIN user_read_record AS ur
-	ON u.user_id = ur.user_id
-	WHERE 1=1 AND (u.phone IS NOT NULL OR u.email IS NOT NULL) `
-	if condition != "" {
-		sql += condition
-	}
-	sql += ` GROUP BY u.user_id `
-	if sortCondition != "" {
-		sql += sortCondition
-	} else {
-		sql += ` ORDER BY read_cnt DESC `
-	}
 	sql += ` LIMIT ?,? `
-	o := orm.NewOrm()
-	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
-	return
-}
-
-func GetUserReadCount(condition string, pars []interface{}) (count int, err error) {
-	sql := `SELECT COUNT(*) AS count 
-	FROM user  AS u
-	WHERE 1=1 AND (u.phone IS NOT NULL OR u.email IS NOT NULL) `
-	if condition != "" {
-		sql += condition
-	}
-	o := orm.NewOrm()
-	err = o.Raw(sql, pars...).QueryRow(&count)
-	return
-}
-
-func GetUserCount(condition string, pars []interface{}) (count int, err error) {
-	sql := `SELECT COUNT(*) AS count FROM user AS u WHERE 1=1 AND (u.phone IS NOT NULL OR u.email IS NOT NULL) `
-	if condition != "" {
-		sql += condition
+	_, err = o.Raw(sql, officialIds, pars, startSize, pageSize).QueryRows(&userList)
+	if userList == nil {
+		userList = []*UserView{}
 	}
-	o := orm.NewOrm()
-	err = o.Raw(sql, pars...).QueryRow(&count)
-	return
-}
-
-func DeleteUserById(userId int) (err error) {
-	o := orm.NewOrm()
-	err = o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
-		sql := `DELETE FROM user WHERE user_id=?`
-		_, e := txOrm.Raw(sql, userId).Exec()
-		if e != nil {
-			return e
-		}
-		sql = `DELETE FROM user_chart_permission_mapping WHERE user_id=?`
-		_, e = txOrm.Raw(sql, userId).Exec()
-		if e != nil {
-			return e
-		}
-		return nil
-	})
-	return
-}
-
-func GetGlobalUserByCondition(userIds []int, sortCondition string, startSize, pageSize int) (items []*UserView, err error) {
-	if len(userIds) == 0 {
-		return
-	}
-	o := orm.NewOrm()
-	sql := `SELECT u.*, COUNT(ur.user_id) AS read_cnt, MAX(ur.create_time) AS last_update_time
-	FROM user AS u
-	LEFT JOIN user_read_record AS ur
-	ON u.user_id = ur.user_id 
-	WHERE u.user_id IN (` + utils.GetOrmReplaceHolder(len(userIds)) + `)
-	GROUP BY u.user_id ` + sortCondition + ` LIMIT ?,? `
-	_, err = o.Raw(sql, userIds, startSize, pageSize).QueryRows(&items)
 	return
 }

+ 10 - 1
routers/commentsRouter.go

@@ -567,6 +567,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: "OfficialList",
+            Router: `/official/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            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: "ReadRecordList",
@@ -578,7 +587,7 @@ func init() {
 
     beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserController"],
         beego.ControllerComments{
-            Method: "TemporaryList",
+            Method: "TemplateList",
             Router: `/temporary/list`,
             AllowHTTPMethods: []string{"get"},
             MethodParams: param.Make(),