|
@@ -2,8 +2,13 @@ package user
|
|
|
|
|
|
import (
|
|
|
"errors"
|
|
|
+ "hongze/hongze_yb/models/tables/chart_permission"
|
|
|
+ "hongze/hongze_yb/models/tables/company"
|
|
|
+ "hongze/hongze_yb/models/tables/company_product"
|
|
|
"hongze/hongze_yb/models/tables/rddp/msg_code"
|
|
|
"hongze/hongze_yb/services"
|
|
|
+ companyService "hongze/hongze_yb/services/company"
|
|
|
+ "hongze/hongze_yb/services/user"
|
|
|
"hongze/hongze_yb/utils"
|
|
|
"time"
|
|
|
)
|
|
@@ -74,3 +79,123 @@ func SendEmailCode(openid, email string) (err error, errMsg string) {
|
|
|
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+type CompanyPermission struct {
|
|
|
+ Name string `json:"name" description:"分类名称"`
|
|
|
+ PermissionList []PermissionList `json:"permission_list" description:"权限列表"`
|
|
|
+}
|
|
|
+
|
|
|
+type PermissionList struct {
|
|
|
+ Name string `json:"name" description:"权限名称"`
|
|
|
+ StartDate time.Time `json:"start_date" description:"开始日期"`
|
|
|
+ EndDate time.Time `json:"end_date" description:"结束日期"`
|
|
|
+ Status string `json:"status" description:"状态"`
|
|
|
+}
|
|
|
+
|
|
|
+type Detail struct {
|
|
|
+ CompanyName string `json:"company_name" description:"客户名称(公司名称)"`
|
|
|
+ Status string `json:"status" description:"客户状态"`
|
|
|
+ RealName string `json:"real_name" description:"用户名称"`
|
|
|
+ Mobile string `json:"mobile" description:"手机号"`
|
|
|
+ Email string `json:"email" description:"邮箱"`
|
|
|
+ PermissionList []CompanyPermission `json:"permission_list" description:"权限列表"`
|
|
|
+}
|
|
|
+
|
|
|
+// GetUserInfo 获取用户我的页面详情数据
|
|
|
+func GetUserInfo(userInfo user.UserInfo) (userDetail Detail, err error, errMsg string) {
|
|
|
+ list := make([]CompanyPermission, 0)
|
|
|
+ companyName := userInfo.Note
|
|
|
+ status := ``
|
|
|
+ if userInfo.CompanyID > 1 {
|
|
|
+ companyInfo, tmpErr := company.GetByCompanyId(userInfo.CompanyID)
|
|
|
+ if tmpErr != nil {
|
|
|
+ err = tmpErr
|
|
|
+ if tmpErr == utils.ErrNoRow {
|
|
|
+ err = errors.New("找不到该客户")
|
|
|
+ errMsg = "找不到该客户"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ errMsg = "系统异常"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ companyName = companyInfo.CompanyName
|
|
|
+
|
|
|
+ companyProduct, tmpErr := company_product.GetByCompany2ProductId(userInfo.CompanyID, 1)
|
|
|
+
|
|
|
+ //如果有ficc权限,那么就去查询相关权限
|
|
|
+ if tmpErr == nil {
|
|
|
+ status = companyProduct.Status //产品状态
|
|
|
+ //获取所有的权限分类列表
|
|
|
+ allPermissionList, tmpErr := companyService.GetPermissionListByProductId(1)
|
|
|
+ if tmpErr != nil {
|
|
|
+ err = tmpErr
|
|
|
+ return
|
|
|
+ }
|
|
|
+ permissionClassMap := make(map[int]*chart_permission.ChartPermission)
|
|
|
+
|
|
|
+ for _, chartPermission := range allPermissionList {
|
|
|
+ permissionClassMap[int(chartPermission.ChartPermissionID)] = chartPermission
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取权限列表
|
|
|
+ permissionList, tmpErr := companyService.GetValidPermissionByCompany2ProductId(userInfo.CompanyID, 1)
|
|
|
+ if tmpErr != nil {
|
|
|
+ err = tmpErr
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ permissionMap := make(map[string][]PermissionList)
|
|
|
+ for _, permission := range permissionList {
|
|
|
+ chartPermission, ok := permissionClassMap[permission.ChartPermissionID]
|
|
|
+ if ok {
|
|
|
+ tmpPermission := PermissionList{
|
|
|
+ Name: chartPermission.ChartPermissionName,
|
|
|
+ StartDate: permission.StartDate,
|
|
|
+ EndDate: permission.EndDate,
|
|
|
+ Status: permission.Status,
|
|
|
+ }
|
|
|
+ if tmpPermissionList, ok2 := permissionMap[chartPermission.ClassifyName]; ok2 {
|
|
|
+ permissionMap[chartPermission.ClassifyName] = append(tmpPermissionList, tmpPermission)
|
|
|
+ } else {
|
|
|
+ tmpPermissionList := make([]PermissionList, 0)
|
|
|
+ permissionMap[chartPermission.ClassifyName] = append(tmpPermissionList, tmpPermission)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for name, tmpPermissionList := range permissionMap {
|
|
|
+ list = append(list, CompanyPermission{
|
|
|
+ Name: name,
|
|
|
+ PermissionList: tmpPermissionList,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ //if Note
|
|
|
+ userDetail = Detail{
|
|
|
+ CompanyName: companyName, //客户名称(公司名称)
|
|
|
+ Status: status, //产品状态
|
|
|
+ RealName: userInfo.RealName,
|
|
|
+ Mobile: userInfo.Mobile,
|
|
|
+ Email: userInfo.Email,
|
|
|
+ PermissionList: list, //权限列表
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+type Record struct {
|
|
|
+ //BusinessCardURL string `gorm:"column:business_card_url;type:varchar(255);default:''" json:"businessCardUrl"` // 名片
|
|
|
+ //RealName string `gorm:"column:real_name;type:varchar(100);default:''" json:"realName"` // 姓名
|
|
|
+ //CompanyName string `gorm:"column:company_name;type:varchar(255);default:''" json:"companyName"` // 客户备注的公司名称
|
|
|
+ //Mobile string `gorm:"column:mobile;type:varchar(20);default:''" json:"mobile"` // 手机号
|
|
|
+ BusinessCardURL string `json:"business_card_url"`
|
|
|
+}
|
|
|
+
|
|
|
+//func GetLastApplyInfo(userId int) {
|
|
|
+// record, err := yb_apply_record.GetLastNotOpRecordByUserId(userId)
|
|
|
+// if err != nil {
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+//}
|