Explorar o código

新增获取系统用户接口

tuoling805 %!s(int64=2) %!d(string=hai) anos
pai
achega
0a0b8a1296

+ 127 - 0
controllers/business_trip/business_approve.go

@@ -0,0 +1,127 @@
+package business_trip
+
+import (
+	"encoding/json"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"hongze/hongze_mobile_admin/models/tables/business_trip"
+	"hongze/hongze_mobile_admin/utils"
+	"time"
+)
+
+// @Title 出差审批列表
+// @Description 出差申请列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   Status   query   string  true       "状态"
+// @Success 200 {object} business_trip.BusinessApplyListResp
+// @router /approve/list [get]
+func (this *BusinessTrip) ApproveList() {
+	sysUser := this.AdminWx
+	sysUserId := sysUser.AdminId
+
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+
+	var total int
+	page := paging.GetPaging(currentIndex, pageSize, total)
+
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize10
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = paging.StartIndex(currentIndex, pageSize)
+
+	reason := this.GetString("Reason")
+	status := this.GetString("Status")
+
+	var condition string
+	var pars []interface{}
+
+	condition += ` AND apply_admin_id=? `
+	pars = append(pars, sysUserId)
+
+	if reason != "" {
+		condition += ` AND reason=? `
+		pars = append(pars, reason)
+	}
+
+	if status != "" {
+		condition += ` AND status=? `
+		pars = append(pars, status)
+	}
+
+	condition += ` AND status IN('待审批','已审批') `
+
+	resp := new(business_trip.BusinessApplyListResp)
+	total, err := business_trip.GetBusinessApplyListCount(condition, pars)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		this.FailWithMessage("获取信息失败!", "获取数据总数失败,GetCalendarListCount,Err:"+err.Error())
+		return
+	}
+
+	dataList, err := business_trip.GetBusinessApplyList(condition, pars, startSize, pageSize)
+	if err != nil {
+		this.FailWithMessage("获取指标信息失败!", "获取数据失败,GetBusinessApplyList,Err:"+err.Error())
+		return
+	}
+
+	page = paging.GetPaging(currentIndex, pageSize, total)
+	resp.Paging = page
+	resp.List = dataList
+	this.OkDetailed(resp, "获取成功")
+}
+
+// @Title 出差申请,审批接口
+// @Description 出差申请,审批接口
+// @Param	request	body business_trip.BusinessApplyApproveReq true "type json string"
+// @Success Ret=200 保存成功
+// @router /apply/approve [post]
+func (this *BusinessTrip) ApplyApprove() {
+	//sysUser := this.AdminWx
+	//sysUserId := sysUser.AdminId
+	var req business_trip.BusinessApplyApproveReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		this.FailWithMessage("参数解析异常!", "参数解析失败,Err:"+err.Error())
+		return
+	}
+
+	if req.BusinessApplyId <= 0 {
+		this.FailWithMessage("参数错误!", "参数错误")
+		return
+	}
+
+	if req.ApproveStatus != 1 && req.ApproveStatus != 2 {
+		this.FailWithMessage("审批状态错误!", "审批状态错误")
+		return
+	}
+
+	if req.ApproveStatus == 2 && req.RefuseReason == "" {
+		this.FailWithMessage("请填写驳回理由!", "请填写驳回理由")
+		return
+	}
+
+	whereParams := make(map[string]interface{})
+	updateParams := make(map[string]interface{})
+
+	whereParams["business_apply_id"] = req.BusinessApplyId
+
+	if req.ApproveStatus == 1 {
+		updateParams["status"] = "已审批"
+	} else {
+		updateParams["status"] = "已驳回"
+	}
+	updateParams["modify_time"] = time.Now()
+	updateParams["approve_time"] = time.Now()
+
+	err = business_trip.UpdateBusinessApply(whereParams, updateParams)
+
+	if err != nil {
+		this.FailWithMessage("审批失败!", "审批失败!UpdateBusinessApply:"+err.Error())
+		return
+	}
+	this.OkWithMessage("审批成功")
+}

+ 141 - 0
controllers/business_trip/business_calendar.go

@@ -0,0 +1,141 @@
+package business_trip
+
+import (
+	"fmt"
+	"hongze/hongze_mobile_admin/models/tables/business_trip"
+	"hongze/hongze_mobile_admin/utils"
+	"time"
+)
+
+// ResearcherReportList
+// @Title 出差日历表
+// @Description 出差日历表接口
+// @Param   AdminId   query   int  true       "用户id"
+// @Success 200 {object} roadshow.BusinessTripResp
+// @router /calendar [get]
+func (this *BusinessTrip) BusinessTripCalendar() {
+	//sysUser := this.AdminWx
+	//sysUserId := sysUser.AdminId
+
+	adminId, _ := this.GetInt("AdminId")
+
+	groupList := make([]*business_trip.BusinessTripCalendarGroup, 0)
+	researcherGroup := new(business_trip.BusinessTripCalendarGroup)
+
+	researcherGroup.GroupId = 1
+	researcherGroup.GroupName = "研究员"
+	researcherGroup.DepartmentId = "1"
+	groupList = append(groupList, researcherGroup)
+
+	sellerGroup := new(business_trip.BusinessTripCalendarGroup)
+	sellerGroup.GroupId = 2
+	sellerGroup.GroupName = "销售"
+	if utils.RunMode == "debug" {
+		sellerGroup.DepartmentId = "2,5"
+	} else {
+		sellerGroup.DepartmentId = "2,4,5,9"
+	}
+	groupList = append(groupList, sellerGroup)
+
+	otherGroup := new(business_trip.BusinessTripCalendarGroup)
+	otherGroup.GroupId = 3
+	otherGroup.GroupName = "其他"
+	if utils.RunMode == "debug" {
+		otherGroup.DepartmentId = "3,7"
+	} else {
+		otherGroup.DepartmentId = "3,6,7,8"
+	}
+	groupList = append(groupList, otherGroup)
+
+	groupLen := len(groupList)
+
+	fmt.Println("groupLen:", groupLen)
+
+	for i := 0; i < groupLen; i++ {
+		group := groupList[i]
+		fmt.Println("group:", group.DepartmentId)
+
+		adminList, err := business_trip.GetBusinessTripCalendar(group.DepartmentId)
+		if err != nil {
+			this.FailWithMessage("获取信息失败!", "获取分组信息失败!,GetBusinessTripCalendar Err:"+err.Error())
+			return
+		}
+
+		//获取当天周日期
+		nowWeekStart := utils.GetNowWeekMonday().AddDate(0, 0, -2)
+		//nowWeekEnd := utils.GetNowWeekLastDay()
+		//获取下周日期
+		nextWeekStart := utils.GetNextWeekMonday().AddDate(0, 0, -2)
+		nextWeekEnd := utils.GetNextWeekLastDay().AddDate(0, 0, -2)
+
+		//获取出差信息
+		businessTripList, err := business_trip.GetBusinessTripList(adminId, nowWeekStart.Format(utils.FormatDate), nextWeekEnd.Format(utils.FormatDate))
+		if err != nil {
+			this.FailWithMessage("获取信息失败!", "获取路演信息失败!,GetBusinessTripList Err:"+err.Error())
+			return
+		}
+
+		btMap := make(map[int][]*business_trip.BusinessApplyView)
+
+		for _, v := range businessTripList {
+			if findVals, ok := btMap[v.ApplyAdminId]; ok {
+				findVals = append(findVals, v)
+				btMap[v.ApplyAdminId] = findVals
+			} else {
+				items := make([]*business_trip.BusinessApplyView, 0)
+				items = append(items, v)
+				btMap[v.ApplyAdminId] = items
+			}
+		}
+
+		setAdminList := make([]*business_trip.BusinessTripCalendarAdmin, 0)
+
+		for _, v := range adminList {
+			if findTripList, ok := btMap[v.AdminId]; ok {
+				tripList := make([]*business_trip.BusinessTripCalendar, 0)
+				for i := 0; i < 7; i++ {
+					newDay, _ := time.ParseInLocation(utils.FormatDate, nowWeekStart.AddDate(0, 0, i).Format(utils.FormatDate), time.Local)
+					weekDate := newDay.Format(utils.FormatDate)
+					tripItem := new(business_trip.BusinessTripCalendar)
+					for _, r := range findTripList {
+						startDateT, _ := time.ParseInLocation(utils.FormatDate, r.ArriveDate, time.Local)
+						endDateT, _ := time.ParseInLocation(utils.FormatDate, r.ReturnDate, time.Local)
+						if r != nil && (newDay.Equal(startDateT) || (newDay.Equal(endDateT)) || (newDay.Before(endDateT) && newDay.After(startDateT))) {
+							tripItem.City = r.City
+							tripItem.BusinessApplyId = r.BusinessApplyId
+						}
+					}
+					tripItem.WeekDate = weekDate
+					tripItem.WeekType = "current"
+					tripItem.Week = newDay.Weekday().String()
+					tripList = append(tripList, tripItem)
+				}
+
+				for i := 0; i < 7; i++ {
+					newDay := nextWeekStart.AddDate(0, 0, i)
+					weekDate := newDay.Format(utils.FormatDate)
+					tripItem := new(business_trip.BusinessTripCalendar)
+					for _, r := range findTripList {
+						startDateT, _ := time.ParseInLocation(utils.FormatDate, r.ArriveDate, time.Local)
+						endDateT, _ := time.ParseInLocation(utils.FormatDate, r.ReturnDate, time.Local)
+						if r != nil && (newDay.Equal(startDateT) || (newDay.Equal(endDateT)) || (newDay.Before(endDateT) && newDay.After(startDateT))) {
+							tripItem.City = r.City
+							tripItem.BusinessApplyId = r.BusinessApplyId
+						}
+					}
+					tripItem.WeekDate = weekDate
+					tripItem.WeekType = "next"
+					tripItem.Week = newDay.Weekday().String()
+					tripList = append(tripList, tripItem)
+				}
+				v.BusinessTripList = tripList
+				setAdminList = append(setAdminList, v)
+			}
+		}
+		groupList[i].AdminList = setAdminList
+	}
+	resp := new(business_trip.BusinessTripCalendarResp)
+	resp.GroupList = groupList
+	this.OkDetailed(resp, "获取成功")
+	return
+}

+ 123 - 0
controllers/system.go

@@ -0,0 +1,123 @@
+package controllers
+
+import (
+	"hongze/hongze_mobile_admin/models/tables/system"
+	"strconv"
+)
+
+// SystemCommon 系统模块
+type SystemCommon struct {
+	BaseAuth
+}
+
+// SellerList
+// @Title 获取未配置权限的管理员(根据部门、分组)
+// @Description 获取未配置权限的管理员(根据部门、分组)接口
+// @Success 200 {object} response.DepartmentGroupSellersResp
+// @router /role/seller/list [get]
+func (this *SystemCommon) SellerList() {
+	departmentList, err := system.GetDepartmentList()
+	if err != nil {
+		this.FailWithMessage("获取失败!", "获取部门失败,Err:"+err.Error())
+		return
+	}
+	departmentMap := make(map[int]*system.SysDepartmentList)
+	for _, v := range departmentList {
+		departmentMap[v.DepartmentId] = v
+	}
+	fullGroups, err := system.GetFullGroup()
+	if err != nil {
+		this.FailWithMessage("获取分组失败!", "获取分组失败,Err:"+err.Error())
+		return
+	}
+	fullGroupMap := make(map[int]*system.SysFullGroup)
+	for _, v := range fullGroups {
+		fullGroupMap[v.GroupId] = v
+	}
+	var list []system.DepartmentGroupSellers
+	departmentListMap := make(map[int][]system.DepartmentGroupSellers)
+	groupListMap := make(map[int][]system.DepartmentGroupSellers)
+	teamListMap := make(map[int][]system.DepartmentGroupSellers)
+	departmentHasMap := make(map[int]bool)
+	groupHasMap := make(map[int]bool)
+	teamHasMap := make(map[int]bool)
+
+	condition := " and enabled = 1 "
+	sellerList, err := system.GetSysUserItems(condition, []interface{}{})
+	if err != nil {
+		this.FailWithMessage("获取管理账号失败!", "获取管理账号失败,Err:"+err.Error())
+		return
+	}
+	for _, v := range sellerList {
+		tmp := system.DepartmentGroupSellers{
+			AdminId:  strconv.Itoa(v.AdminId),
+			RealName: v.RealName,
+		}
+		if v.GroupId > 0 {
+			if groupInfo, ok := fullGroupMap[v.GroupId]; ok {
+				if groupInfo.ParentId > 0 {
+					teamListMap[v.GroupId] = append(teamListMap[v.GroupId], tmp)
+				} else {
+					groupListMap[groupInfo.GroupId] = append(groupListMap[groupInfo.GroupId], tmp)
+				}
+			}
+		} else {
+			departmentListMap[v.DepartmentId] = append(departmentListMap[v.DepartmentId], tmp)
+		}
+	}
+	for _, groupInfo := range fullGroups {
+		var team1 system.DepartmentGroupSellers
+		//处理小组
+		if groupInfo.ParentId > 0 {
+			if _, ok2 := teamHasMap[groupInfo.GroupId]; !ok2 {
+				if len(teamListMap[groupInfo.GroupId]) > 0 {
+					team1 = system.DepartmentGroupSellers{
+						AdminId:      "team_" + strconv.Itoa(groupInfo.GroupId),
+						RealName:     groupInfo.GroupName,
+						ChildrenList: teamListMap[groupInfo.GroupId],
+					}
+					teamHasMap[groupInfo.GroupId] = true
+					groupListMap[groupInfo.ParentId] = append(groupListMap[groupInfo.ParentId], team1)
+				}
+			}
+		}
+	}
+
+	for _, groupInfo := range fullGroups {
+		var group1 system.DepartmentGroupSellers
+		//处理大组
+		if groupInfo.ParentId == 0 {
+			if _, ok2 := groupHasMap[groupInfo.GroupId]; !ok2 {
+				if len(groupListMap[groupInfo.GroupId]) > 0 {
+					group1 = system.DepartmentGroupSellers{
+						AdminId:      "group_" + strconv.Itoa(groupInfo.GroupId),
+						RealName:     groupInfo.GroupName,
+						ChildrenList: groupListMap[groupInfo.GroupId],
+					}
+					groupHasMap[groupInfo.GroupId] = true
+					departmentListMap[groupInfo.DepartmentId] = append(departmentListMap[groupInfo.DepartmentId], group1)
+				}
+			}
+		}
+	}
+
+	for _, groupInfo := range departmentList {
+		var department1 system.DepartmentGroupSellers
+		//处理部门
+		if _, ok1 := departmentHasMap[groupInfo.DepartmentId]; !ok1 {
+			if len(departmentListMap[groupInfo.DepartmentId]) > 0 {
+				department1 = system.DepartmentGroupSellers{
+					AdminId:      "department_" + strconv.Itoa(groupInfo.DepartmentId),
+					RealName:     groupInfo.DepartmentName,
+					ChildrenList: departmentListMap[groupInfo.DepartmentId],
+				}
+				departmentHasMap[groupInfo.DepartmentId] = true
+				list = append(list, department1)
+			}
+		}
+	}
+	resp := new(system.DepartmentGroupSellersResp)
+	resp.List = list
+	this.OkDetailed(resp, "获取成功")
+	return
+}

+ 7 - 0
models/tables/business_trip/business_approve.go

@@ -0,0 +1,7 @@
+package business_trip
+
+type BusinessApplyApproveReq struct {
+	BusinessApplyId int    `description:"出差申请id"`
+	ApproveStatus   int    `description:"审批状态:1:通过,2:驳回"`
+	RefuseReason    string `description:"驳回理由"`
+}

+ 60 - 0
models/tables/business_trip/business_calendar.go

@@ -0,0 +1,60 @@
+package business_trip
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+)
+
+type BusinessTripCalendarAdmin struct {
+	AdminId          int    `description:"研究员id"`
+	RealName         string `description:"研究员名称"`
+	BusinessTripList []*BusinessTripCalendar
+}
+
+type BusinessTripCalendar struct {
+	BusinessApplyId int    `description:"出差申请id"`
+	WeekDate        string `description:"开始日期"`
+	City            string `description:"城市"`
+	Week            string `description:"周"`
+	WeekType        string `description:"当前周:current,下一周:next"`
+}
+
+// GetResearcherV2 获取研究员列表(冻结的也要)
+func GetBusinessTripCalendar(departmentId string) (list []*BusinessTripCalendarAdmin, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT a.admin_id,a.real_name 
+			FROM admin AS a
+			INNER JOIN sys_group AS b ON a.group_id=b.group_id
+			WHERE a.enabled=1
+			AND b.department_id IN(?)
+			ORDER BY a.admin_id ASC `
+	_, err = o.Raw(sql, departmentId).QueryRows(&list)
+	return
+}
+
+type BusinessTripCalendarGroup struct {
+	GroupId      int    `description:"分组id"`
+	GroupName    string `description:"分组名称"`
+	DepartmentId string `json:"-" description:"部门id"`
+	AdminList    []*BusinessTripCalendarAdmin
+}
+
+type BusinessTripCalendarResp struct {
+	GroupList []*BusinessTripCalendarGroup
+}
+
+func GetBusinessTripList(adminId int, startDate, endDate string) (list []*BusinessApplyView, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT *
+			FROM  business_apply AS a
+			WHERE a.status IN('待审批','已审批')
+			AND ((a.arrive_date>=? AND a.arrive_date<=?) OR (a.return_date>=? AND a.return_date<=?)) `
+	if adminId > 0 {
+		sql += ` AND a.apply_admin_id=? `
+		sql += ` ORDER BY a.apply_admin_id ASC,a.arrive_date ASC `
+		_, err = o.Raw(sql, startDate, endDate, adminId).QueryRows(&list)
+	} else {
+		sql += ` ORDER BY a.apply_admin_id ASC,a.arrive_date ASC `
+		_, err = o.Raw(sql, startDate, endDate, startDate, endDate).QueryRows(&list)
+	}
+	return
+}

+ 148 - 0
models/tables/system/sys_admin.go

@@ -0,0 +1,148 @@
+package system
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"time"
+)
+
+type AdminItem struct {
+	AdminId                 int    `description:"系统用户id"`
+	AdminName               string `description:"系统用户名称"`
+	RealName                string `description:"系统用户姓名"`
+	Password                string
+	LastUpdatedPasswordTime string `json:"-"`
+	Enabled                 int    `description:"1:有效,0:禁用"`
+	Email                   string `description:"系统用户邮箱"`
+	LastLoginTime           string
+	CreatedTime             time.Time
+	LastUpdatedTime         string
+	Role                    string `description:"系统用户角色"`
+	Mobile                  string `description:"手机号"`
+	RoleType                int    `description:"角色类型:1需要录入指标,0:不需要"`
+	RoleId                  int    `description:"角色id"`
+	RoleName                string `description:"角色名称"`
+	RoleTypeCode            string `description:"角色编码"`
+	DepartmentId            int    `description:"部门id"`
+	DepartmentName          string `json:"-" description:"部门名称"`
+	TeamId                  int    `description:"三级id"`
+	GroupId                 int    `description:"分组id"`
+	GroupName               string `json:"-" description:"分组名称"`
+	Authority               int    `description:"管理权限,0:无,1:部门负责人,2:小组负责人,或者ficc销售主管,4:ficc销售组长"`
+	Position                string `description:"职位"`
+	DepartmentGroup         string `description:"部门分组"`
+	LabelVal                int    `description:"标签:1:超级管理员,2:管理员,3:部门经理,4:组长,5:ficc销售主管"`
+	ResearchGroupName       string `description:"研究方向分组名称"`
+	Province                string `description:"省"`
+	ProvinceCode            string `description:"省编码"`
+	City                    string `description:"市"`
+	CityCode                string `description:"市编码"`
+}
+
+type AdminRespItem struct {
+	AdminId                 int    `description:"系统用户id"`
+	AdminName               string `description:"系统用户名称"`
+	RealName                string `description:"系统用户姓名"`
+	Password                string
+	LastUpdatedPasswordTime string `json:"-"`
+	Enabled                 int    `description:"1:有效,0:禁用"`
+	Email                   string `description:"系统用户邮箱"`
+	LastLoginTime           string
+	CreatedTime             time.Time
+	LastUpdatedTime         string
+	Role                    string `description:"系统用户角色"`
+	Mobile                  string `description:"手机号"`
+	RoleType                int    `description:"角色类型:1需要录入指标,0:不需要"`
+	RoleId                  int    `description:"角色id"`
+	RoleName                string `description:"角色名称"`
+	RoleTypeCode            string `description:"角色编码"`
+	DepartmentId            int    `description:"部门id"`
+	DepartmentName          string `json:"-" description:"部门名称"`
+	parentId                int    `description:"父级id"`
+	GroupId                 int    `description:"分组id"`
+	GroupName               string `json:"-" description:"分组名称"`
+	Authority               int    `description:"管理权限,0:无,1:部门负责人,2:小组负责人,或者ficc销售主管,4:ficc销售组长"`
+	Position                string `description:"职位"`
+	DepartmentGroup         string `description:"部门分组"`
+	LabelVal                int    `description:"标签:1:超级管理员,2:管理员,3:部门经理,4:组长,5:ficc销售主管"`
+}
+
+type SysuserListResp struct {
+	List   []*AdminItem
+	Paging *paging.PagingItem `description:"分页数据"`
+}
+
+type SysuserAddReq struct {
+	AdminName    string `description:"系统用户名称"`
+	AdminAvatar  string `description:"用户头像"`
+	RealName     string `description:"系统用户姓名"`
+	Password     string `description:"密码"`
+	Mobile       string `description:"手机号"`
+	RoleId       int    `description:"角色id"`
+	DepartmentId int    `description:"部门id"`
+	GroupId      int    `description:"分组id"`
+	TeamId       int    `description:"小组id"`
+	//Authority    int    `description:"管理权限,0:无,1:部门负责人,2:小组负责人"`
+	Position         string `description:"职位"`
+	ResearchGroupIds string `description:"研究方向分组IDs"`
+	Province         string `description:"省"`
+	ProvinceCode     string `description:"省编码"`
+	City             string `description:"市"`
+	CityCode         string `description:"市编码"`
+}
+
+type SysuserEditReq struct {
+	AdminId      int    `description:"系统用户id"`
+	AdminName    string `description:"系统用户名称"`
+	AdminAvatar  string `description:"用户头像"`
+	RealName     string `description:"系统用户姓名"`
+	Password     string `description:"密码"`
+	Mobile       string `description:"手机号"`
+	RoleId       int    `description:"角色id"`
+	DepartmentId int    `description:"部门id"`
+	GroupId      int    `description:"分组id"`
+	TeamId       int    `description:"小组id"`
+	Enabled      int    `description:"1:有效,0:禁用"`
+	//Authority    int    `description:"管理权限,0:无,1:部门负责人,2:小组负责人"`
+	Position         string `description:"职位"`
+	ResearchGroupIds string `description:"研究方向分组IDs"`
+	Province         string `description:"省"`
+	ProvinceCode     string `description:"省编码"`
+	City             string `description:"市"`
+	CityCode         string `description:"市编码"`
+}
+
+// 用户状态编辑
+type SysuserEditEnabledReq struct {
+	AdminId int `description:"系统用户id"`
+	Enabled int `description:"1:有效,0:禁用"`
+}
+
+type SysuserDeleteReq struct {
+	AdminId int `description:"系统用户id"`
+}
+
+func GetSysUserItems(condition string, pars []interface{}) (items []*AdminItem, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM admin WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += `ORDER BY last_updated_time DESC `
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
+type OpenIdList struct {
+	OpenId  string
+	AdminId int
+}
+
+// ResearcherAdminAndUser 研究员admin信息及wx_user信息
+type ResearcherAdminAndUser struct {
+	UserId    int    `description:"用户ID"`
+	UserName  string `description:"用户名称"`
+	AdminId   int    `description:"管理员ID"`
+	AdminName string `description:"管理员姓名"`
+	OpenId    string `description:"openid"`
+}

+ 55 - 0
models/tables/system/sys_department.go

@@ -0,0 +1,55 @@
+package system
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type SysDepartmentAddReq struct {
+	DepartmentName string `description:"部门名称"`
+}
+
+type SysDepartment struct {
+	DepartmentId   int       `orm:"column(department_id);pk" description:"部门Id"`
+	DepartmentName string    `description:"部门名称"`
+	CreateTime     time.Time `description:"创建时间"`
+}
+
+type SysDepartmentEditReq struct {
+	DepartmentId   int    `description:"部门Id"`
+	DepartmentName string `description:"部门名称"`
+}
+
+type SysDepartmentDeleteReq struct {
+	DepartmentId int `description:"部门Id"`
+}
+
+type SysDepartmentList struct {
+	DepartmentId   int             `orm:"column(department_id);pk" description:"部门Id"`
+	DepartmentName string          `description:"部门名称"`
+	CreateTime     time.Time       `description:"创建时间"`
+	Child          []*SysGroupList `description:"分组"`
+	IsDepartment   bool            `description:"true:部门,false:分组"`
+}
+
+func GetDepartmentList() (items []*SysDepartmentList, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM sys_department ORDER BY create_time ASC `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+type SysDepartmentListResp struct {
+	List []*SysDepartmentList
+}
+
+type DepartmentGroupSellers struct {
+	AdminId      string                   `description:"系统用户id"`
+	RealName     string                   `description:"用户真实名称"`
+	ChildrenList []DepartmentGroupSellers `description:"销售列表"`
+}
+
+// DepartmentGroupSellersResp 销售列表(根据部门、分组来)
+type DepartmentGroupSellersResp struct {
+	List []DepartmentGroupSellers
+}

+ 67 - 0
models/tables/system/sys_group.go

@@ -0,0 +1,67 @@
+package system
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type SysGroupAddReq struct {
+	DepartmentId int    `description:"部门Id"`
+	GroupName    string `description:"分组名称,多个用英文逗号隔开"`
+}
+
+type SysGroup struct {
+	GroupId      int       `orm:"column(group_id);pk" description:"分组ID"`
+	DepartmentId int       `description:"部门Id"`
+	ParentId     int       `description:"父级Id"`
+	GroupName    string    `description:"分组名称"`
+	CreateTime   time.Time `description:"创建时间"`
+}
+
+type SysGroupEditReq struct {
+	GroupId   int    `description:"分组ID"`
+	GroupName string `description:"分组名称"`
+}
+
+type SysGroupDeleteReq struct {
+	GroupId int `description:"分组ID"`
+}
+
+func DeleteSysGroup(groupId int) (err error) {
+	sql := `DELETE FROM sys_group WHERE group_id=? `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, groupId).Exec()
+	return
+}
+
+// 因前端显示需要,TopId字段用来当做一级部门id,DepartmentId为当前分组id
+type SysGroupList struct {
+	GroupId      int            `orm:"column(group_id);pk" json:"DepartmentId" description:"分组ID"`
+	ParentId     int            `json:"ParentId" description:"父级ID"`
+	DepartmentId int            `json:"TopId" description:"部门Id"`
+	GroupName    string         `json:"DepartmentName" description:"分组名称"`
+	Child        []*SysTeamList `description:"小组"`
+	CreateTime   time.Time      `description:"创建时间"`
+	IsGroup      bool           `description:"是否为二级部门"`
+}
+
+type SysFullGroup struct {
+	GroupId         int       `orm:"column(group_id);pk" description:"分组ID"`
+	DepartmentId    int       `description:"部门Id"`
+	ParentId        int       `description:"父级Id"`
+	GroupName       string    `description:"分组名称"`
+	ParentGroupName string    `description:"父级分组名称"`
+	DepartmentName  string    `description:"部门名称"`
+	CreateTime      time.Time `description:"创建时间"`
+}
+
+// GetFullGroup 获取完整的分组信息
+func GetFullGroup() (list []*SysFullGroup, err error) {
+	sql := `SELECT s.*,g.group_name as parent_group_name , d.department_name
+from sys_group s 
+LEFT JOIN sys_group g on s.parent_id=g.group_id
+LEFT JOIN sys_department d on s.department_id=d.department_id`
+	o := orm.NewOrm()
+	_, err = o.Raw(sql).QueryRows(&list)
+	return
+}

+ 35 - 0
models/tables/system/sys_team.go

@@ -0,0 +1,35 @@
+package system
+
+import (
+	"time"
+)
+
+type SysTeamAddReq struct {
+	GroupId      int    `description:"大组id"`
+	DepartmentId int    `description:"部门id"`
+	TeamName     string `description:"分组名称,多个用英文逗号隔开"`
+}
+
+type SysTeam struct {
+	GroupId      int       `orm:"column(group_id);pk" description:"分组ID"`
+	ParentId     int       `description:"父级Id"`
+	DepartmentId int       `description:"部门id"`
+	GroupName    string    `description:"分组名称"`
+	CreateTime   time.Time `description:"创建时间"`
+}
+
+type SysTeamEditReq struct {
+	TeamId   int    `description:"分组ID"`
+	TeamName string `description:"分组名称"`
+}
+
+type SysTeamDeleteReq struct {
+	TeamId int `description:"小组ID"`
+}
+
+type SysTeamList struct {
+	GroupId    int       `orm:"column(group_id);pk" json:"DepartmentId" description:"小组ID"`
+	ParentId   int       `json:"GroupId" description:"小组Id"`
+	GroupName  string    `json:"DepartmentName" description:"分组名称"`
+	CreateTime time.Time `description:"创建时间"`
+}

+ 36 - 0
routers/commentsRouter.go

@@ -16,6 +16,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/business_trip:BusinessTrip"] = append(beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/business_trip:BusinessTrip"],
+        beego.ControllerComments{
+            Method: "ApplyApprove",
+            Router: `/apply/approve`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/business_trip:BusinessTrip"] = append(beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/business_trip:BusinessTrip"],
         beego.ControllerComments{
             Method: "Back",
@@ -61,6 +70,24 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/business_trip:BusinessTrip"] = append(beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/business_trip:BusinessTrip"],
+        beego.ControllerComments{
+            Method: "ApproveList",
+            Router: `/approve/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/business_trip:BusinessTrip"] = append(beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/business_trip:BusinessTrip"],
+        beego.ControllerComments{
+            Method: "BusinessTripCalendar",
+            Router: `/calendar`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/roadshow:CalendarController"] = append(beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/roadshow:CalendarController"],
         beego.ControllerComments{
             Method: "Accept",
@@ -718,6 +745,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers:SystemCommon"] = append(beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers:SystemCommon"],
+        beego.ControllerComments{
+            Method: "SellerList",
+            Router: `/role/seller/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers:VarietyTagController"] = append(beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers:VarietyTagController"],
         beego.ControllerComments{
             Method: "TagTree",

+ 5 - 0
routers/router.go

@@ -104,6 +104,11 @@ func init() {
 				&business_trip.BusinessTrip{},
 			),
 		),
+		web.NSNamespace("/system",
+			web.NSInclude(
+				&controllers.SystemCommon{},
+			),
+		),
 	)
 	web.AddNamespace(ns)
 }

+ 151 - 22
utils/common.go

@@ -22,7 +22,7 @@ import (
 	"time"
 )
 
-//随机数种子
+// 随机数种子
 var rnd = rand.New(rand.NewSource(time.Now().UnixNano()))
 
 func GetRandString(size int) string {
@@ -59,13 +59,13 @@ func StringsToJSON(str string) string {
 	return jsons
 }
 
-//序列化
+// 序列化
 func ToString(v interface{}) string {
 	data, _ := json.Marshal(v)
 	return string(data)
 }
 
-//md5加密
+// md5加密
 func MD5(data string) string {
 	m := md5.Sum([]byte(data))
 	return hex.EncodeToString(m[:])
@@ -93,7 +93,7 @@ func GetToday(format string) string {
 	return today
 }
 
-//获取今天剩余秒数
+// 获取今天剩余秒数
 func GetTodayLastSecond() time.Duration {
 	today := GetToday(FormatDate) + " 23:59:59"
 	end, _ := time.ParseInLocation(FormatDateTime, today, time.Local)
@@ -115,7 +115,7 @@ func GetBrithDate(idcard string) string {
 	return GetToday(FormatDate)
 }
 
-//处理性别
+// 处理性别
 func WhichSexByIdcard(idcard string) string {
 	var sexs = [2]string{"女", "男"}
 	length := len(idcard)
@@ -129,7 +129,7 @@ func WhichSexByIdcard(idcard string) string {
 	return "男"
 }
 
-//截取小数点后几位
+// 截取小数点后几位
 func SubFloatToString(f float64, m int) string {
 	n := strconv.FormatFloat(f, 'f', -1, 64)
 	if n == "" {
@@ -148,14 +148,14 @@ func SubFloatToString(f float64, m int) string {
 	return newn[0] + "." + newn[1][:m]
 }
 
-//截取小数点后几位
+// 截取小数点后几位
 func SubFloatToFloat(f float64, m int) float64 {
 	newn := SubFloatToString(f, m)
 	newf, _ := strconv.ParseFloat(newn, 64)
 	return newf
 }
 
-//获取相差时间-年
+// 获取相差时间-年
 func GetYearDiffer(start_time, end_time string) int {
 	t1, _ := time.ParseInLocation("2006-01-02", start_time, time.Local)
 	t2, _ := time.ParseInLocation("2006-01-02", end_time, time.Local)
@@ -166,7 +166,7 @@ func GetYearDiffer(start_time, end_time string) int {
 	return age
 }
 
-//获取相差时间-秒
+// 获取相差时间-秒
 func GetSecondDifferByTime(start_time, end_time time.Time) int64 {
 	diff := end_time.Unix() - start_time.Unix()
 	return diff
@@ -193,7 +193,7 @@ func StrListToString(strList []string) (str string) {
 	return ""
 }
 
-//Token
+// Token
 func GetToken() string {
 	randStr := GetRandString(64)
 	token := MD5(randStr + Md5Key)
@@ -201,30 +201,30 @@ func GetToken() string {
 	return strings.ToUpper(token + GetRandString(tokenLen))
 }
 
-//数据没有记录
+// 数据没有记录
 func ErrNoRow() string {
 	return "<QuerySeter> no row found"
 }
 
-//校验邮箱格式
+// 校验邮箱格式
 func ValidateEmailFormatat(email string) bool {
 	reg := regexp.MustCompile(RegularEmail)
 	return reg.MatchString(email)
 }
 
-//验证是否是手机号
+// 验证是否是手机号
 func ValidateMobileFormatat(mobileNum string) bool {
 	reg := regexp.MustCompile(RegularMobile)
 	return reg.MatchString(mobileNum)
 }
 
-//判断文件是否存在
+// 判断文件是否存在
 func FileIsExist(filePath string) bool {
 	_, err := os.Stat(filePath)
 	return err == nil || os.IsExist(err)
 }
 
-//获取图片扩展名
+// 获取图片扩展名
 func GetImgExt(file string) (ext string, err error) {
 	var headerByte []byte
 	headerByte = make([]byte, 8)
@@ -267,7 +267,7 @@ func GetImgExt(file string) (ext string, err error) {
 	return ext, nil
 }
 
-//保存图片
+// 保存图片
 func SaveImage(path string, img image.Image) (err error) {
 	//需要保持的文件
 	imgfile, err := os.Create(path)
@@ -277,7 +277,7 @@ func SaveImage(path string, img image.Image) (err error) {
 	return err
 }
 
-//保存base64数据为文件
+// 保存base64数据为文件
 func SaveBase64ToFile(content, path string) error {
 	data, err := base64.StdEncoding.DecodeString(content)
 	if err != nil {
@@ -407,7 +407,7 @@ func GetWilsonScore(p, n float64) float64 {
 	return toFixed(((p+1.9208)/(p+n)-1.96*math.Sqrt(p*n/(p+n)+0.9604)/(p+n))/(1+3.8416/(p+n)), 2)
 }
 
-//将中文数字转化成数字,比如 第三百四十五章,返回第345章 不支持一亿及以上
+// 将中文数字转化成数字,比如 第三百四十五章,返回第345章 不支持一亿及以上
 func ChangeWordsToNum(str string) (numStr string) {
 	words := ([]rune)(str)
 	num := 0
@@ -554,7 +554,7 @@ func ConvertToFormatDay(excelDaysString string) string {
 	return resultTime
 }
 
-//人民币小写转大写
+// 人民币小写转大写
 func ConvertNumToCny(num float64) (str string, err error) {
 	strNum := strconv.FormatFloat(num*100, 'f', 0, 64)
 	sliceUnit := []string{"仟", "佰", "拾", "亿", "仟", "佰", "拾", "万", "仟", "佰", "拾", "元", "角", "分"}
@@ -735,7 +735,7 @@ func Implode(idIntList []int) (str string) {
 	return
 }
 
-//字符串类型时间转周几
+// 字符串类型时间转周几
 func StrDateTimeToWeek(strTime string) string {
 	var WeekDayMap = map[string]string{
 		"Monday":    "周一",
@@ -752,7 +752,7 @@ func StrDateTimeToWeek(strTime string) string {
 	return WeekDayMap[staweek_int]
 }
 
-//字符串转换为time
+// 字符串转换为time
 func StrTimeToTime(strTime string) time.Time {
 	timeLayout := "2006-01-02 15:04:05"  //转化所需模板
 	loc, _ := time.LoadLocation("Local") //重要:获取时区
@@ -813,4 +813,133 @@ func JoinStr2IntArr(str, sep string) (arr []int) {
 		arr = append(arr, v)
 	}
 	return
-}
+}
+
+// GetNextWeekMonday 获取下一周周一的时间
+func GetNextWeekMonday() time.Time {
+	nowMonday := GetNowWeekMonday()
+	return nowMonday.AddDate(0, 0, 7)
+}
+
+// GetNextWeekLastDay 获取下一周最后一天的时间
+func GetNextWeekLastDay() time.Time {
+	nowSunday := GetNowWeekLastDay()
+	return nowSunday.AddDate(0, 0, 7)
+}
+
+// GetNowWeekMonday 获取本周周一的时间
+func GetNowWeekMonday() time.Time {
+	offset := int(time.Monday - time.Now().Weekday())
+	if offset == 1 { //正好是周日,但是按照中国人的理解,周日是一周最后一天,而不是一周开始的第一天
+		offset = -6
+	}
+	mondayTime := time.Now().AddDate(0, 0, offset)
+	mondayTime = time.Date(mondayTime.Year(), mondayTime.Month(), mondayTime.Day(), 0, 0, 0, 0, mondayTime.Location())
+	return mondayTime
+}
+
+// GetNowWeekLastDay 获取本周最后一天的时间
+func GetNowWeekLastDay() time.Time {
+	offset := int(time.Monday - time.Now().Weekday())
+	if offset == 1 { //正好是周日,但是按照中国人的理解,周日是一周最后一天,而不是一周开始的第一天
+		offset = -6
+	}
+	firstDayTime := time.Now().AddDate(0, 0, offset)
+	firstDayTime = time.Date(firstDayTime.Year(), firstDayTime.Month(), firstDayTime.Day(), 0, 0, 0, 0, firstDayTime.Location()).AddDate(0, 0, 6)
+	lastDayTime := time.Date(firstDayTime.Year(), firstDayTime.Month(), firstDayTime.Day(), 23, 59, 59, 0, firstDayTime.Location())
+
+	return lastDayTime
+}
+
+// GetNowMonthFirstDay 获取本月第一天的时间
+func GetNowMonthFirstDay() time.Time {
+	nowMonthFirstDay := time.Date(time.Now().Year(), time.Now().Month(), 1, 0, 0, 0, 0, time.Now().Location())
+	return nowMonthFirstDay
+}
+
+// GetNowMonthLastDay 获取本月最后一天的时间
+func GetNowMonthLastDay() time.Time {
+	nowMonthLastDay := time.Date(time.Now().Year(), time.Now().Month(), 1, 0, 0, 0, 0, time.Now().Location()).AddDate(0, 1, -1)
+	nowMonthLastDay = time.Date(nowMonthLastDay.Year(), nowMonthLastDay.Month(), nowMonthLastDay.Day(), 23, 59, 59, 0, nowMonthLastDay.Location())
+	return nowMonthLastDay
+}
+
+// GetNowQuarterFirstDay 获取本季度第一天的时间
+func GetNowQuarterFirstDay() time.Time {
+	month := int(time.Now().Month())
+	var nowQuarterFirstDay time.Time
+	if month >= 1 && month <= 3 {
+		//1月1号
+		nowQuarterFirstDay = time.Date(time.Now().Year(), 1, 1, 0, 0, 0, 0, time.Now().Location())
+	} else if month >= 4 && month <= 6 {
+		//4月1号
+		nowQuarterFirstDay = time.Date(time.Now().Year(), 4, 1, 0, 0, 0, 0, time.Now().Location())
+	} else if month >= 7 && month <= 9 {
+		nowQuarterFirstDay = time.Date(time.Now().Year(), 7, 1, 0, 0, 0, 0, time.Now().Location())
+	} else {
+		nowQuarterFirstDay = time.Date(time.Now().Year(), 10, 1, 0, 0, 0, 0, time.Now().Location())
+	}
+	return nowQuarterFirstDay
+}
+
+// GetNowQuarterLastDay 获取本季度最后一天的时间
+func GetNowQuarterLastDay() time.Time {
+	month := int(time.Now().Month())
+	var nowQuarterLastDay time.Time
+	if month >= 1 && month <= 3 {
+		//03-31 23:59:59
+		nowQuarterLastDay = time.Date(time.Now().Year(), 3, 31, 23, 59, 59, 0, time.Now().Location())
+	} else if month >= 4 && month <= 6 {
+		//06-30 23:59:59
+		nowQuarterLastDay = time.Date(time.Now().Year(), 6, 30, 23, 59, 59, 0, time.Now().Location())
+	} else if month >= 7 && month <= 9 {
+		//09-30 23:59:59
+		nowQuarterLastDay = time.Date(time.Now().Year(), 9, 30, 23, 59, 59, 0, time.Now().Location())
+	} else {
+		//12-31 23:59:59
+		nowQuarterLastDay = time.Date(time.Now().Year(), 12, 31, 23, 59, 59, 0, time.Now().Location())
+	}
+	return nowQuarterLastDay
+}
+
+// GetNowHalfYearFirstDay 获取当前半年的第一天的时间
+func GetNowHalfYearFirstDay() time.Time {
+	month := int(time.Now().Month())
+	var nowHalfYearLastDay time.Time
+	if month >= 1 && month <= 6 {
+		//03-31 23:59:59
+		nowHalfYearLastDay = time.Date(time.Now().Year(), 1, 1, 0, 0, 0, 0, time.Now().Location())
+	} else {
+		//12-31 23:59:59
+		nowHalfYearLastDay = time.Date(time.Now().Year(), 7, 1, 0, 0, 0, 0, time.Now().Location())
+	}
+	return nowHalfYearLastDay
+}
+
+// GetNowHalfYearLastDay 获取当前半年的最后一天的时间
+func GetNowHalfYearLastDay() time.Time {
+	month := int(time.Now().Month())
+	var nowHalfYearLastDay time.Time
+	if month >= 1 && month <= 6 {
+		//03-31 23:59:59
+		nowHalfYearLastDay = time.Date(time.Now().Year(), 6, 30, 23, 59, 59, 0, time.Now().Location())
+	} else {
+		//12-31 23:59:59
+		nowHalfYearLastDay = time.Date(time.Now().Year(), 12, 31, 23, 59, 59, 0, time.Now().Location())
+	}
+	return nowHalfYearLastDay
+}
+
+// GetNowYearFirstDay 获取当前年的最后一天的时间
+func GetNowYearFirstDay() time.Time {
+	//12-31 23:59:59
+	nowYearFirstDay := time.Date(time.Now().Year(), 1, 1, 0, 0, 0, 0, time.Now().Location())
+	return nowYearFirstDay
+}
+
+// GetNowYearLastDay 获取当前年的最后一天的时间
+func GetNowYearLastDay() time.Time {
+	//12-31 23:59:59
+	nowYearLastDay := time.Date(time.Now().Year(), 12, 31, 23, 59, 59, 0, time.Now().Location())
+	return nowYearLastDay
+}