From 73169746c9309d4197deb0d3b2672731f5622580 Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 5 Aug 2019 09:38:48 +0800 Subject: [PATCH] + user2/GetUsers --- business/jxstore/cms/cms.go | 5 +++-- business/jxstore/cms/user2.go | 4 ++++ business/model/dao/dao_user2.go | 25 +++++++++++++++++++++++++ business/model/new_config.go | 8 ++++---- business/model/user.go | 11 ++++++++++- controllers/cms_user2.go | 17 +++++++++++++++++ routers/commentsRouter_controllers.go | 9 +++++++++ 7 files changed, 72 insertions(+), 7 deletions(-) diff --git a/business/jxstore/cms/cms.go b/business/jxstore/cms/cms.go index f90d7750d..b81c5ae47 100644 --- a/business/jxstore/cms/cms.go +++ b/business/jxstore/cms/cms.go @@ -85,8 +85,9 @@ func InitServiceInfo(version string, buildTime time.Time, gitCommit string) { "actStatusName": model.ActStatusName, "actCreateTypeName": model.ActCreateTypeName, "storeAuditStatusName": model.StoreAuditStatusName, - "configTypeList": model.ConfigTypeList, + "configTypeName": model.ConfigTypeName, "autoSaleAt": "20:45:00", + "userTypeName": model.UserTypeName, }, } Init() @@ -216,7 +217,7 @@ func checkConfig(configType, value string) (err error) { } } default: - err = fmt.Errorf("当前只支持配置:%s, 传入的配置类型:%s", utils.Format4Output(model.ConfigTypeList, true), configType) + err = fmt.Errorf("当前只支持配置:%s, 传入的配置类型:%s", utils.Format4Output(model.ConfigTypeName, true), configType) } return err } diff --git a/business/jxstore/cms/user2.go b/business/jxstore/cms/user2.go index 4c97b0106..0bb557a2d 100644 --- a/business/jxstore/cms/user2.go +++ b/business/jxstore/cms/user2.go @@ -152,3 +152,7 @@ func OnDingDingMsg(msg map[string]interface{}) (callbackResponse *dingdingapi.Ca } return api.DingDingAPI.Err2CallbackResponse(nil) } + +func GetUsers(ctx *jxcontext.Context, userType int, userID2, mobile, userName string) (userList []*model.User, err error) { + return dao.GetUsers(dao.GetDB(), userType, userID2, mobile, userName) +} diff --git a/business/model/dao/dao_user2.go b/business/model/dao/dao_user2.go index eb84544d8..51ed8c4c8 100644 --- a/business/model/dao/dao_user2.go +++ b/business/model/dao/dao_user2.go @@ -22,3 +22,28 @@ func GetUserByID(db *DaoDB, fieldName, fieldValue string) (user *model.User, err err = GetRow(db, &user, sql, sqlParams...) return user, err } + +func GetUsers(db *DaoDB, userType int, userID2, mobile, userName string) (userList []*model.User, err error) { + sql := ` + SELECT * + FROM user t1 + WHERE t1.deleted_at = ? AND t1.type & ? <> 0` + sqlParams := []interface{}{ + utils.DefaultTimeValue, + userType, + } + if userID2 != "" { + sql += " AND t1.user_id2 = ?" + sqlParams = append(sqlParams, userID2) + } + if mobile != "" { + sql += " AND t1.mobile = ?" + sqlParams = append(sqlParams, mobile) + } + if userName != "" { + sql += " AND t1.name LIKE ?" + sqlParams = append(sqlParams, "%"+userName+"%") + } + err = GetRows(db, &userList, sql, sqlParams...) + return userList, err +} diff --git a/business/model/new_config.go b/business/model/new_config.go index 663664d48..bcac93e60 100644 --- a/business/model/new_config.go +++ b/business/model/new_config.go @@ -7,10 +7,10 @@ const ( ) var ( - ConfigTypeList = []string{ - ConfigTypeSys, - ConfigTypePricePack, - ConfigTypeBank, + ConfigTypeName = map[string]string{ + ConfigTypeSys: "系统", + ConfigTypePricePack: "价格包", + ConfigTypeBank: "银行", } ) diff --git a/business/model/user.go b/business/model/user.go index 3d52ff027..99349af90 100644 --- a/business/model/user.go +++ b/business/model/user.go @@ -12,6 +12,15 @@ const ( UserTypeBoss = 8 ) +var ( + UserTypeName = map[int]string{ + UserTypeConsumer: "消费者", + UserTypeStoreBoss: "门店老板", + UserTypeOperator: "运营", + UserTypeBoss: "老板", + } +) + type User struct { ModelIDCULD UserID string `orm:"size(48);column(user_id)" json:"userID"` // 内部唯一标识 @@ -20,7 +29,7 @@ type User struct { Mobile string `orm:"size(32)" json:"mobile"` Email string `orm:"size(32);index" json:"email"` Status int8 `json:"status"` - Type int8 // 用户类型 + Type int8 `json:"type"` // 用户类型 IDCardNo string `orm:"size(18);column(id_card_no)" json:"idCardNo"` // 身份证号 } diff --git a/controllers/cms_user2.go b/controllers/cms_user2.go index e605dfc80..e435af5eb 100644 --- a/controllers/cms_user2.go +++ b/controllers/cms_user2.go @@ -50,3 +50,20 @@ func (c *User2Controller) GetBindAuthInfo() { return retVal, "", err }) } + +// @Title 得到用户列表 +// @Description 得到用户列表 +// @Param token header string true "认证token" +// @Param userType query int true "用户类型" +// @Param userID2 query string faslse "用户id2" +// @Param mobile query string faslse "用户手机,必须全匹配" +// @Param userName query string faslse "用户名,可以部分匹配" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /GetUsers [get] +func (c *User2Controller) GetUsers() { + c.callGetUsers(func(params *tUser2GetUsersParams) (retVal interface{}, errCode string, err error) { + retVal, err = cms.GetUsers(params.Ctx, params.UserType, params.UserID2, params.Mobile, params.UserName) + return retVal, "", err + }) +} diff --git a/routers/commentsRouter_controllers.go b/routers/commentsRouter_controllers.go index 1a31eaca4..d09946bff 100644 --- a/routers/commentsRouter_controllers.go +++ b/routers/commentsRouter_controllers.go @@ -1717,6 +1717,15 @@ func init() { Filters: nil, Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"], + beego.ControllerComments{ + Method: "GetUsers", + Router: `/GetUsers`, + AllowHTTPMethods: []string{"get"}, + MethodParams: param.Make(), + Filters: nil, + Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"], beego.ControllerComments{ Method: "RegisterUser",