This commit is contained in:
苏尹岚
2020-10-14 13:47:11 +08:00
parent accb629e14
commit eb950f11bf
41 changed files with 3581 additions and 1809 deletions

View File

@@ -5,8 +5,6 @@ import (
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/auth2"
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin"
"git.rosy.net.cn/jx-callback/business/authz"
"git.rosy.net.cn/jx-callback/business/authz/autils"
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
"git.rosy.net.cn/jx-callback/business/jxutils"
"git.rosy.net.cn/jx-callback/business/jxutils/jsonerr"
@@ -85,178 +83,6 @@ func (c *User2Controller) GetUsers() {
})
}
// @Title 得到用户自己的门店列表
// @Description 得到用户自己的门店列表
// @Param token header string true "认证token"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetMyStoreList [get]
func (c *User2Controller) GetMyStoreList() {
c.callGetMyStoreList(func(params *tUser2GetMyStoreListParams) (retVal interface{}, errCode string, err error) {
retVal, errCode, err = cms.GetMyStoreListNew(params.Ctx)
return retVal, errCode, err
})
}
// @Title 得到可用的门店角色列表
// @Description 得到可用的门店角色列表
// @Param token header string true "认证token"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetStoreRoleList [get]
func (c *User2Controller) GetStoreRoleList() {
c.callGetStoreRoleList(func(params *tUser2GetStoreRoleListParams) (retVal interface{}, errCode string, err error) {
retVal, err = cms.GetStoreRoleList(params.Ctx)
return retVal, "", err
})
}
// @Title 得到用户所具有的角色列表
// @Description 得到用户所具有的角色列表
// @Param token header string true "认证token"
// @Param userID query string true "用户i"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetUserRoleList [get]
func (c *User2Controller) GetUserRoleList() {
c.callGetUserRoleList(func(params *tUser2GetUserRoleListParams) (retVal interface{}, errCode string, err error) {
retVal, err = cms.GetUserRoleList(params.Ctx, params.UserID)
return retVal, "", err
})
}
// @Title 得到角色包括的用户列表
// @Description 得到角色包括的用户列表
// @Param token header string true "认证token"
// @Param roleName query string true "角色名"
// @Param storeID query int false "门店ID如果是全局角色不用填"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetRoleUserList [get]
func (c *User2Controller) GetRoleUserList() {
c.callGetRoleUserList(func(params *tUser2GetRoleUserListParams) (retVal interface{}, errCode string, err error) {
retVal, err = cms.GetRoleUserList(params.Ctx, autils.NewRole(params.RoleName, params.StoreID))
return retVal, "", err
})
}
// @Title 批量得到角色包括的用户列表
// @Description 批量得到角色包括的用户列表
// @Param token header string true "认证token"
// @Param roleNames query string true "角色名"
// @Param storeIDs query string false "门店ID如果是全局角色不用填"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetRolesUserList [get]
func (c *User2Controller) GetRolesUserList() {
c.callGetRolesUserList(func(params *tUser2GetRolesUserListParams) (retVal interface{}, errCode string, err error) {
var roleNames []string
var storeIDs []int
if err = jxutils.Strings2Objs(params.RoleNames, &roleNames, params.StoreIDs, &storeIDs); err == nil {
var roleList []*authz.RoleInfo
for _, roleName := range roleNames {
if roleName == authz.StoreRoleBoss {
for _, storeID := range storeIDs {
roleList = append(roleList, autils.NewRole(roleName, storeID))
}
} else {
roleList = append(roleList, autils.NewRole(roleName, 0))
}
}
retVal, err = cms.GetRolesUserList(params.Ctx, roleList)
}
return retVal, "", err
})
}
// @Title 给指定用户添加角色列表
// @Description 给指定用户添加角色列表
// @Param token header string true "认证token"
// @Param userID formData string true "用户ID"
// @Param roleList formData string true "角色列表"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /AddRoles4User [post]
func (c *User2Controller) AddRoles4User() {
c.callAddRoles4User(func(params *tUser2AddRoles4UserParams) (retVal interface{}, errCode string, err error) {
var roleList []*authz.RoleInfo
if err = jxutils.Strings2Objs(params.RoleList, &roleList); err == nil {
err = cms.AddRoles4User(params.Ctx, params.UserID, roleList)
}
return retVal, "", err
})
}
// @Title 给指定用户删除角色列表
// @Description 给指定用户删除角色列表
// @Param token header string true "认证token"
// @Param userID query string true "用户ID"
// @Param roleList query string true "角色列表"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /DeleteRoles4User [delete]
func (c *User2Controller) DeleteRoles4User() {
c.callDeleteRoles4User(func(params *tUser2DeleteRoles4UserParams) (retVal interface{}, errCode string, err error) {
var roleList []*authz.RoleInfo
if err = jxutils.Strings2Objs(params.RoleList, &roleList); err == nil {
err = cms.DeleteRoles4User(params.Ctx, params.UserID, roleList)
}
return retVal, "", err
})
}
// @Title 给指定角色添加用户列表
// @Description 给指定角色添加用户列表
// @Param token header string true "认证token"
// @Param roleName formData string true "角色名"
// @Param storeID formData int false "门店ID"
// @Param userIDs formData string true "用户ID列表"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /AddUsers4Role [post]
func (c *User2Controller) AddUsers4Role() {
c.callAddUsers4Role(func(params *tUser2AddUsers4RoleParams) (retVal interface{}, errCode string, err error) {
var userIDs []string
if err = jxutils.Strings2Objs(params.UserIDs, &userIDs); err == nil {
err = cms.AddUsers4Role(params.Ctx, autils.NewRole(params.RoleName, params.StoreID), userIDs)
}
return retVal, "", err
})
}
// @Title 给指定角色删除用户列表
// @Description 给指定角色删除用户列表
// @Param token header string true "认证token"
// @Param roleName query string true "角色名"
// @Param storeID query int false "门店ID"
// @Param userIDs query string true "用户ID列表"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /DeleteUsers4Role [delete]
func (c *User2Controller) DeleteUsers4Role() {
c.callDeleteUsers4Role(func(params *tUser2DeleteUsers4RoleParams) (retVal interface{}, errCode string, err error) {
var userIDs []string
if err = jxutils.Strings2Objs(params.UserIDs, &userIDs); err == nil {
err = cms.DeleteUsers4Role(params.Ctx, autils.NewRole(params.RoleName, params.StoreID), userIDs)
}
return retVal, "", err
})
}
// @Title 给指定角色添加用户列表
// @Description 给指定角色添加用户列表
// @Param token header string true "认证token"
// @Param mobile formData string false "手机号"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /TransferLegacyWeixins [post]
func (c *User2Controller) TransferLegacyWeixins() {
c.callTransferLegacyWeixins(func(params *tUser2TransferLegacyWeixinsParams) (retVal interface{}, errCode string, err error) {
err = cms.TransferLegacyWeixins(params.Mobile)
return retVal, "", err
})
}
// @Title 用户自己增加配送地址
// @Description 用户自己增加配送地址
// @Param token header string true "认证token"
@@ -438,21 +264,6 @@ func (c *Auth2Controller) UpdateUserByMiniInfo() {
})
}
// @Title 查找京东用户
// @Description 查找京东用户
// @Param token header string true "认证token"
// @Param isAsync formData bool false "是否异步操作"
// @Param isContinueWhenError formData bool false "单个同步失败是否继续缺省false"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetJdUsers [post]
func (c *User2Controller) GetJdUsers() {
c.callGetJdUsers(func(params *tUser2GetJdUsersParams) (retVal interface{}, errCode string, err error) {
retVal, err = cms.GetJdUsers(params.Ctx, params.IsAsync, params.IsContinueWhenError)
return retVal, "", err
})
}
// @Title 更新用户分成比例
// @Description 更新用户分成比例
// @Param token header string true "认证token"
@@ -486,20 +297,6 @@ func (c *User2Controller) DeleteUserInfo() {
})
}
// @Title 得到用户自己的门店列表(商城用)
// @Description 得到用户自己的门店列表(商城用)
// @Param token header string false "认证token"
// @Param mobile query string true "电话"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetMyJxStoreList [get]
func (c *User2Controller) GetMyJxStoreList() {
c.callGetMyJxStoreList(func(params *tUser2GetMyJxStoreListParams) (retVal interface{}, errCode string, err error) {
retVal, err = cms.GetMyJxStoreList(params.Ctx, params.Mobile)
return retVal, "", err
})
}
// @Title 插入用户协议表
// @Description 插入用户协议表
// @Param token header string false "认证token"