瀏覽代碼

添加用户、产品ID 返回

kobe6258 5 月之前
父節點
當前提交
45c18c296c
共有 4 個文件被更改,包括 10 次插入7 次删除
  1. 1 0
      controllers/product.go
  2. 6 6
      controllers/user.go
  3. 2 1
      models/user.go
  4. 1 0
      services/product.go

+ 1 - 0
controllers/product.go

@@ -491,6 +491,7 @@ func (this *ProductController) ProductList() {
 	var ListView []*services.ProductView
 	for _, product := range List {
 		view := &services.ProductView{
+			Id:            product.Id,
 			ProductName:   product.Title,
 			ProductType:   CNProductMap[product.Type],
 			PublishedTime: product.CreatedTime.Format(time.DateTime),

+ 6 - 6
controllers/user.go

@@ -56,7 +56,7 @@ func (this *UserController) TemplateList() {
 	sortParamInt, _ := this.GetInt("SortParam", 0)
 	sortTypeInt, _ := this.GetInt("SortType", 0)
 
-	var sortStr = ``
+	var sortCondtion string
 	var condition string
 	var pars []interface{}
 
@@ -74,7 +74,7 @@ func (this *UserController) TemplateList() {
 		br.ErrMsg = fmt.Sprint("错误的排序字段:", sortTypeInt)
 		return
 	}
-	sortStr = fmt.Sprintf("%s %s,updated_time desc ", sortParam, sortType)
+	sortCondtion = fmt.Sprintf("%s %s,updated_time desc ", sortParam, sortType)
 
 	if keyword != "" {
 		condition += ` AND mobile LIKE ? `
@@ -82,7 +82,7 @@ func (this *UserController) TemplateList() {
 	}
 
 	resp := new(response.TemplateUserListResp)
-	total, userList, err := models.GetPageTemplateUserList(condition, pars, sortStr, startSize, pageSize)
+	total, userList, err := models.GetPageTemplateUserList(condition, pars, sortCondtion, startSize, pageSize)
 	if err != nil {
 		br.Msg = "查询用户失败"
 		br.Msg = "查询用户失败,系统错误,Err:" + err.Error()
@@ -147,7 +147,7 @@ func (this *UserController) OfficialList() {
 	sortParamInt, _ := this.GetInt("SortParam", 0)
 	sortTypeInt, _ := this.GetInt("SortType", 0)
 
-	var sortStr = ``
+	var sortCondtion string
 	var condition string
 	var pars []interface{}
 
@@ -165,7 +165,7 @@ func (this *UserController) OfficialList() {
 		br.ErrMsg = fmt.Sprintf("错误的排序字段:%v", sortTypeInt)
 		return
 	}
-	sortStr = fmt.Sprintf("%s %s,updated_time desc ", sortParam, sortType)
+	sortCondtion = fmt.Sprintf("%s %s,updated_time desc ", sortParam, sortType)
 	if FollowingGzh != "" {
 		switch FollowingGzh {
 		case "true":
@@ -223,7 +223,7 @@ func (this *UserController) OfficialList() {
 	}
 
 	resp := new(response.UserListResp)
-	total, userList, err := models.GetPageOfficialUserList(condition, pars, sortStr, startSize, pageSize)
+	total, userList, err := models.GetPageOfficialUserList(condition, pars, sortCondtion, startSize, pageSize)
 	if err != nil {
 		br.Msg = "查询用户失败"
 		br.Msg = "查询用户失败,系统错误,Err:" + err.Error()

+ 2 - 1
models/user.go

@@ -32,6 +32,7 @@ func (u User) FillUserInfo(user *TemplateUser) UserView {
 }
 
 type UserView struct {
+	Id            int
 	RealName      string `description:"姓名"`
 	Mobile        string `description:"手机号码"`
 	FollowingGzh  bool
@@ -52,7 +53,7 @@ func GetPageOfficialUserList(condition string, pars []interface{}, sortStr strin
 	}
 	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 := `SELECT us.id as id, 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 id, 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

+ 1 - 0
services/product.go

@@ -159,6 +159,7 @@ func GetUnsetProductByCondition(productType string, ids []int, sortCondition str
 }
 
 type ProductView struct {
+	Id            int
 	ProductName   string
 	SourceId      int
 	ProductType   string