Browse Source

新增出差审批模块

tuoling805 2 years ago
parent
commit
bd0de9e477

+ 471 - 0
controllers/business_trip/business_apply.go

@@ -0,0 +1,471 @@
+package business_trip
+
+import (
+	"encoding/json"
+	"fmt"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"hongze/hongze_mobile_admin/controllers"
+	"hongze/hongze_mobile_admin/models/tables/admin"
+	"hongze/hongze_mobile_admin/models/tables/business_trip"
+	"hongze/hongze_mobile_admin/models/tables/company_approval_message"
+	"hongze/hongze_mobile_admin/services"
+	"hongze/hongze_mobile_admin/utils"
+	"strconv"
+	"time"
+)
+
+// 出差
+type BusinessTrip struct {
+	controllers.BaseAuth
+}
+
+// @Title 出差申请接口
+// @Description 出差申请接口
+// @Param	request	body business_trip.BusinessApplyReq true "type json string"
+// @Success Ret=200 保存成功
+// @router /apply/add [post]
+func (this *BusinessTrip) ApplyAdd() {
+	sysUser := this.AdminWx
+	sysUserId := sysUser.AdminId
+	var req business_trip.BusinessApplyReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		this.FailWithMessage("解析参数失败", "解析参数失败,Err:"+err.Error())
+		return
+	}
+
+	if req.ArriveDate == "" {
+		this.FailWithMessage("请填写到达日期", "请填写到达日期")
+		return
+	}
+
+	if req.ReturnDate == "" {
+		this.FailWithMessage("请填写返程日期", "请填写返程日期")
+		return
+	}
+
+	if req.Province == "" {
+		this.FailWithMessage("请填写目的地省", "请填写目的地省")
+		return
+	}
+
+	if req.City == "" {
+		this.FailWithMessage("请填写目的地市", "请填写目的地市")
+		return
+	}
+
+	if req.Reason == "" {
+		this.FailWithMessage("请填写出差事由", "请填写出差事由")
+		return
+	}
+
+	if req.Transportation == "" {
+		this.FailWithMessage("请填写交通工具", "请填写交通工具")
+		return
+	}
+
+	startP, _ := time.ParseInLocation(utils.FormatDate, req.ArriveDate, time.Local)
+	endP, _ := time.ParseInLocation(utils.FormatDate, req.ReturnDate, time.Local)
+	nowDate, _ := time.ParseInLocation(utils.FormatDate, time.Now().Format(utils.FormatDate), time.Local)
+
+	if startP.Before(nowDate) {
+		fmt.Println("出差开始日期不能小于当前日期!")
+		return
+	}
+
+	if !endP.Equal(nowDate) && endP.Before(nowDate) {
+		fmt.Println("出差结束时间不能小于当前时间!")
+		return
+	}
+
+	if !startP.Equal(endP) && (startP.After(endP) || startP.Equal(endP)) {
+		fmt.Println("出差开始日期应小于结束日期!")
+		return
+	}
+
+	approveItem, err := admin.GetAdminById(66)
+	if err != nil {
+		this.FailWithMessage("获取审批人信息失败", "获取审批人信息失败,Err:"+err.Error())
+		return
+	}
+	item := new(business_trip.BusinessApply)
+	item.ApplyAdminId = sysUser.AdminId
+	item.ApplyRealName = sysUser.RealName
+	item.ArriveDate = req.ArriveDate
+	item.ReturnDate = req.ReturnDate
+	item.Province = req.Province
+	item.City = req.City
+	item.Reason = req.Reason
+	item.Transportation = req.Transportation
+	item.PeerPeopleId = req.PeerPeopleId
+	item.PeerPeopleName = req.PeerPeopleName
+	item.Status = "待审批"
+	item.ApproveId = approveItem.AdminId
+	item.ApproveName = approveItem.RealName
+	item.CreateTime = time.Now()
+	item.ModifyTime = time.Now()
+	applyId, err := business_trip.AddBusinessApply(item)
+	if err != nil {
+		this.FailWithMessage("申请失败", "申请失败,Err:"+err.Error())
+		return
+	}
+
+	{
+		//系统消息
+		sourceType := 10
+		content := sysUser.RealName + " " + req.Province + req.City + req.Reason + "出差申请"
+		go services.AddCompanyApprovalMessage(sysUserId, approveItem.AdminId, 0, int(applyId), 1, sourceType, 2, "", content, content, "", "")
+	}
+
+	//模板消息
+	{
+		wxAppPath := ""
+		first := "您好,有新的申请待处理"
+		keyword1 := sysUser.RealName
+		keyword2 := sysUser.Mobile
+		keyword3 := time.Now().Format(utils.FormatDateTime)
+		var keyword4 string
+		if req.PeerPeopleId != "" {
+			keyword4 = req.ArriveDate + "----" + req.ReturnDate + "," + req.Transportation + "前往" + req.Province + req.City + "," + "同行人" + req.PeerPeopleName
+		} else {
+			keyword4 = req.ArriveDate + "----" + req.ReturnDate + "," + req.Transportation + "前往" + req.Province + req.City
+		}
+		remark := "请尽快完成审批"
+		go services.SendWxMsgWithRoadshowPending(first, keyword1, keyword2, keyword3, keyword4, remark, wxAppPath, approveItem.Mobile)
+	}
+	this.OkWithMessage("保存成功")
+}
+
+// @Title 出差重新申请接口
+// @Description 出差重新申请接口
+// @Param	request	body business_trip.BusinessApplyEditReq true "type json string"
+// @Success Ret=200 保存成功
+// @router /apply/edit [post]
+func (this *BusinessTrip) ApplyEdit() {
+	sysUser := this.AdminWx
+	sysUserId := sysUser.AdminId
+
+	var req business_trip.BusinessApplyEditReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		this.FailWithMessage("解析参数失败", "解析参数失败,Err:"+err.Error())
+		return
+	}
+
+	if req.ArriveDate == "" {
+		this.FailWithMessage("请填写到达日期", "请填写到达日期")
+		return
+	}
+
+	if req.ReturnDate == "" {
+		this.FailWithMessage("请填写返程日期", "请填写返程日期")
+		return
+	}
+
+	if req.Province == "" {
+		this.FailWithMessage("请填写目的地省", "请填写目的地省")
+		return
+	}
+
+	if req.City == "" {
+		this.FailWithMessage("请填写目的地市", "请填写目的地市")
+		return
+	}
+
+	if req.Reason == "" {
+		this.FailWithMessage("请填写出差事由", "请填写出差事由")
+		return
+	}
+
+	if req.Transportation == "" {
+		this.FailWithMessage("请填写交通工具", "请填写交通工具")
+		return
+	}
+
+	startP, _ := time.ParseInLocation(utils.FormatDate, req.ArriveDate, time.Local)
+	endP, _ := time.ParseInLocation(utils.FormatDate, req.ReturnDate, time.Local)
+	nowDate, _ := time.ParseInLocation(utils.FormatDate, time.Now().Format(utils.FormatDate), time.Local)
+
+	if startP.Before(nowDate) {
+		fmt.Println("出差开始日期不能小于当前日期!")
+		return
+	}
+
+	if !endP.Equal(nowDate) && endP.Before(nowDate) {
+		fmt.Println("出差结束时间不能小于当前时间!")
+		return
+	}
+
+	if !startP.Equal(endP) && (startP.After(endP) || startP.Equal(endP)) {
+		fmt.Println("出差开始日期应小于结束日期!")
+		return
+	}
+
+	if req.BusinessApplyId <= 0 {
+		this.FailWithMessage("参数错误", "参数错误!BusinessApplyId:"+strconv.Itoa(req.BusinessApplyId))
+		return
+	}
+	businessApplyItem, err := business_trip.GetBusinessApplyById(req.BusinessApplyId)
+	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			this.FailWithMessage("出差申请已被删除,请刷新页面", "出差申请已被删除,请刷新页面")
+			return
+		}
+		this.FailWithMessage("获取数据失败!", "获取数据失败!GetBusinessApplyById:"+err.Error())
+		return
+	}
+
+	if businessApplyItem.Status == "已审批" {
+		this.FailWithMessage("已审批,不可进行重新申请操作!", "已审批,不可进行重新申请操作!")
+		return
+	} else if businessApplyItem.Status == "已过期" {
+		this.FailWithMessage("已过期,不可进行重新申请操作!", "已过期,不可进行重新申请操作!")
+		return
+	}
+
+	whereParams := make(map[string]interface{})
+	updateParams := make(map[string]interface{})
+
+	whereParams["business_apply_id"] = req.BusinessApplyId
+
+	updateParams["arrive_date"] = req.ArriveDate
+	updateParams["return_date"] = req.ReturnDate
+	updateParams["province"] = req.Province
+	updateParams["city"] = req.City
+	updateParams["reason"] = req.Reason
+	updateParams["transportation"] = req.Transportation
+	updateParams["peer_people_id"] = req.PeerPeopleId
+	updateParams["peer_people_name"] = req.PeerPeopleName
+	updateParams["status"] = "待审批"
+	updateParams["refuse_reason"] = ""
+	updateParams["modify_time"] = time.Now()
+
+	err = business_trip.UpdateBusinessApply(whereParams, updateParams)
+	if err != nil {
+		this.FailWithMessage("重新申请失败", "重新申请失败,Err:"+err.Error())
+		return
+	}
+
+	approveItem, err := admin.GetAdminById(66)
+	if err != nil {
+		this.FailWithMessage("获取审批人信息失败!", "获取审批人信息失败,Err:"+err.Error())
+		return
+	}
+	{
+		//系统消息
+		sourceType := 10
+		content := sysUser.RealName + " " + req.Province + req.City + req.Reason + "出差申请"
+		go services.AddCompanyApprovalMessage(sysUserId, approveItem.AdminId, 0, req.BusinessApplyId, 1, sourceType, 2, "", content, content, "", "")
+	}
+
+	//模板消息
+	{
+		wxAppPath := ""
+		first := "您好,有新的申请待处理"
+		keyword1 := sysUser.RealName
+		keyword2 := sysUser.Mobile
+		keyword3 := time.Now().Format(utils.FormatDateTime)
+		var keyword4 string
+		if req.PeerPeopleId != "" {
+			keyword4 = req.ArriveDate + "----" + req.ReturnDate + "," + req.Transportation + "前往" + req.Province + req.City + "," + "同行人" + req.PeerPeopleName
+		} else {
+			keyword4 = req.ArriveDate + "----" + req.ReturnDate + "," + req.Transportation + "前往" + req.Province + req.City
+		}
+		remark := "请尽快完成审批"
+		go services.SendWxMsgWithRoadshowPending(first, keyword1, keyword2, keyword3, keyword4, remark, wxAppPath, approveItem.Mobile)
+	}
+	this.OkWithMessage("申请成功")
+}
+
+// @Title 出差申请列表
+// @Description 出差申请列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   Reason   query   string  true       "出差事由"
+// @Param   Status   query   string  true       "状态"
+// @Success 200 {object} business_trip.BusinessApplyListResp
+// @router /apply/list [get]
+func (this *BusinessTrip) ApplyList() {
+	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)
+	}
+
+	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.BusinessApplyDeleteReq true "type json string"
+// @Success Ret=200 删除成功
+// @router /apply/delete [post]
+func (this *BusinessTrip) Delete() {
+	//sysUser := this.AdminWx
+	//sysUserId := sysUser.AdminId
+
+	var req business_trip.BusinessApplyDeleteReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		this.FailWithMessage("参数解析异常!", "参数解析失败,Err:"+err.Error())
+		return
+	}
+
+	if req.BusinessApplyId <= 0 {
+		this.FailWithMessage("参数错误!", "参数错误!BusinessApplyId:"+strconv.Itoa(req.BusinessApplyId))
+		return
+	}
+	businessApplyItem, err := business_trip.GetBusinessApplyById(req.BusinessApplyId)
+	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			this.FailWithMessage("出差申请信息已被删除,请刷新页面!", "出差申请信息已被删除,请刷新页面!")
+			return
+		}
+		this.FailWithMessage("获取数据失败!", "获取数据失败!GetBusinessApplyById:"+err.Error())
+		return
+	}
+	err = business_trip.DeleteBusinessApply(businessApplyItem.BusinessApplyId)
+	if err != nil {
+		this.FailWithMessage("删除失败!", "删除失败!DeleteBusinessApply:"+err.Error())
+		return
+	}
+	//删除系统消息
+	go company_approval_message.DeleteCompanyApprovalMessage(req.BusinessApplyId, 10)
+	this.OkWithMessage("删除成功")
+}
+
+// @Title 撤回出差申请接口
+// @Description 撤回出差申请接口
+// @Param	request	body business_trip.BusinessApplyBackReq true "type json string"
+// @Success Ret=200 保存成功
+// @router /apply/back [post]
+func (this *BusinessTrip) Back() {
+	//sysUser := this.AdminWx
+	//sysUserId := sysUser.AdminId
+
+	var req business_trip.BusinessApplyBackReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		this.FailWithMessage("参数解析异常!", "参数解析失败,Err:"+err.Error())
+		return
+	}
+
+	if req.BusinessApplyId <= 0 {
+		this.FailWithMessage("参数错误!", "参数错误!BusinessApplyId:"+strconv.Itoa(req.BusinessApplyId))
+		return
+	}
+	businessApplyItem, err := business_trip.GetBusinessApplyById(req.BusinessApplyId)
+	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			this.FailWithMessage("出差申请已被删除,请刷新页面", "出差申请已被删除,请刷新页面")
+			return
+		}
+		this.FailWithMessage("获取数据失败!", "获取数据失败!GetBusinessApplyById:"+err.Error())
+		return
+	}
+
+	if businessApplyItem.Status == "已审批" {
+		this.FailWithMessage("已审批,不可进行撤回操作!", "已审批,不可进行撤回操作!")
+		return
+	} else if businessApplyItem.Status == "已驳回" {
+		this.FailWithMessage("已驳回,不可进行撤回操作!", "已驳回,不可进行撤回操作!")
+		return
+	} else if businessApplyItem.Status == "已撤回" {
+		this.FailWithMessage("已撤回,不可重复操作!", "已撤回,不可重复操作!")
+		return
+	} else if businessApplyItem.Status == "已过期" {
+		this.FailWithMessage("已过期,不可进行重复操作!", "已过期,不可进行重复操作!")
+		return
+	}
+
+	whereParams := make(map[string]interface{})
+	updateParams := make(map[string]interface{})
+
+	whereParams["business_apply_id"] = req.BusinessApplyId
+
+	updateParams["status"] = "已撤回"
+	updateParams["modify_time"] = time.Now()
+
+	err = business_trip.UpdateBusinessApply(whereParams, updateParams)
+
+	if err != nil {
+		this.FailWithMessage("撤回失败", "撤回失败!UpdateBusinessApply:"+err.Error())
+		return
+	}
+
+	//删除系统消息
+	go company_approval_message.DeleteCompanyApprovalMessage(req.BusinessApplyId, 10)
+
+	this.OkWithMessage("撤回成功")
+}
+
+// @Title 出差申请详情
+// @Description 出差申请详情接口
+// @Param   BusinessApplyId   query   int  true       "出差申请id"
+// @Success 200 {object} business_trip.BusinessApplyView
+// @router /apply/detail [get]
+func (this *BusinessTrip) ApplyDetail() {
+
+	businessApplyId, _ := this.GetInt("BusinessApplyId")
+	if businessApplyId <= 0 {
+		this.FailWithMessage("参数错误", "出差申请id错误:"+strconv.Itoa(businessApplyId))
+		return
+	}
+	item, err := business_trip.GetBusinessApplyById(businessApplyId)
+	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			this.FailWithMessage("该出差申请已被删除", "该出差申请已被删除")
+			return
+		}
+		this.FailWithMessage("获取数据失败", "获取数据失败:"+err.Error())
+		return
+	}
+	this.OkDetailed(item, "获取成功")
+}

+ 3 - 3
controllers/message.go

@@ -19,7 +19,7 @@ import (
 	"time"
 )
 
-//消息模块
+// 消息模块
 type MessageCommon struct {
 	BaseAuth
 }
@@ -34,7 +34,7 @@ func (c *MessageCommon) SummaryMessageList() {
 
 	//SummaryMessageListResp := message.SummaryMessageListResp{}
 	//sourceTypeList := [...]int{1, 2, 3, 5, 6}
-	sourceTypeList := [...]int{1, 2, 3, 6}	// 问答的暂时不要了
+	sourceTypeList := [...]int{1, 2, 3, 6, 10} // 问答的暂时不要了
 	messageMap := make(map[int]message.SummaryMessage)
 	timeList := make([]int, 0)
 	var err error
@@ -137,7 +137,7 @@ func (c *MessageCommon) SummaryMessageList() {
 	c.OkDetailed(messageList, "获取成功")
 }
 
-//切片数据反转
+// 切片数据反转
 func rotate(s []message.SummaryMessage) {
 	left, rigth := 0, 0
 	if len(s)%2 == 0 { //判断长度是奇数还是偶数,根据这个来确定旋转的中心

+ 148 - 0
models/tables/business_trip/business_apply.go

@@ -0,0 +1,148 @@
+package business_trip
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"time"
+)
+
+type BusinessApply struct {
+	BusinessApplyId int       `orm:"column(business_apply_id);pk;auto" description:"ID"`
+	ApplyAdminId    int       `description:"申请人id"`
+	ApplyRealName   string    `description:"申请人姓名"`
+	ArriveDate      string    `description:"到达日期"`
+	ReturnDate      string    `description:"返程日期"`
+	Province        string    `description:"目的地省"`
+	City            string    `description:"目的地市"`
+	Reason          string    `description:"出差事由"`
+	Transportation  string    `description:"交通工具"`
+	PeerPeopleId    string    `description:"同行人id"`
+	PeerPeopleName  string    `description:"同行人"`
+	Status          string    `description:"状态:'待审批','已审批','已驳回','已撤回','已过期'"`
+	ApproveId       int       `description:"审批人id"`
+	ApproveName     string    `description:"审批人姓名"`
+	RefuseReason    string    `description:"拒绝理由"`
+	RefuseTime      time.Time `description:"拒绝时间"`
+	ApproveTime     time.Time `description:"审批时间"`
+	CreateTime      time.Time `description:"创建时间"`
+	ModifyTime      time.Time `description:"修改时间"`
+}
+
+// 添加出差申请
+func AddBusinessApply(item *BusinessApply) (applyId int64, err error) {
+	o := orm.NewOrm()
+	applyId, err = o.Insert(item)
+	if err != nil {
+		return
+	}
+	return
+}
+
+type BusinessApplyReq struct {
+	ArriveDate     string `description:"到达日期"`
+	ReturnDate     string `description:"返程日期"`
+	Province       string `description:"目的地省"`
+	City           string `description:"目的地市"`
+	Reason         string `description:"出差事由"`
+	Transportation string `description:"交通工具"`
+	PeerPeopleId   string `description:"同行人id"`
+	PeerPeopleName string `description:"同行人"`
+}
+
+type BusinessApplyView struct {
+	BusinessApplyId int    `description:"出差申请id"`
+	ApplyAdminId    int    `description:"申请人id"`
+	ApplyRealName   string `description:"申请人姓名"`
+	ArriveDate      string `description:"到达日期"`
+	ReturnDate      string `description:"返程日期"`
+	Province        string `description:"目的地省"`
+	City            string `description:"目的地市"`
+	Reason          string `description:"出差事由"`
+	Transportation  string `description:"交通工具"`
+	PeerPeopleId    string `description:"同行人id"`
+	PeerPeopleName  string `description:"同行人"`
+	Status          string `description:"状态:'待审批','已审批','已驳回','已撤回','已过期'"`
+	ApproveId       int    `description:"审批人id"`
+	ApproveName     string `description:"审批人姓名"`
+	RefuseReason    string `description:"拒绝理由"`
+	RefuseTime      string `description:"拒绝时间"`
+	ApproveTime     string `description:"审批时间"`
+	CreateTime      string `description:"创建时间"`
+	ModifyTime      string `description:"修改时间"`
+}
+
+func GetBusinessApplyListCount(condition string, pars []interface{}) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT COUNT(1) AS count FROM  business_apply AS a WHERE 1=1  `
+	if condition != "" {
+		sql += condition
+	}
+	err = o.Raw(sql, pars).QueryRow(&count)
+	return
+}
+
+func GetBusinessApplyList(condition string, pars []interface{}, startSize, pageSize int) (list []*BusinessApplyView, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM business_apply AS a WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` ORDER BY a.create_time ASC LIMIT ?,? `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
+	return
+}
+
+type BusinessApplyListResp struct {
+	Paging *paging.PagingItem
+	List   []*BusinessApplyView
+}
+
+type BusinessApplyDeleteReq struct {
+	BusinessApplyId int `description:"出差申请id"`
+}
+
+func GetBusinessApplyById(businessApplyId int) (item *BusinessApplyView, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM business_apply WHERE business_apply_id=? `
+	err = o.Raw(sql, businessApplyId).QueryRow(&item)
+	return
+}
+
+// 删除
+func DeleteBusinessApply(businessApplyId int) (err error) {
+	o := orm.NewOrm()
+	sql := ` DELETE FROM business_apply WHERE business_apply_id=? `
+	_, err = o.Raw(sql, businessApplyId).Exec()
+	if err != nil {
+		return err
+	}
+	return err
+}
+
+type BusinessApplyBackReq struct {
+	BusinessApplyId int `description:"出差申请id"`
+}
+
+// 更新
+func UpdateBusinessApply(where, updateParams map[string]interface{}) error {
+	o := orm.NewOrm()
+	ptrStructOrTableName := "business_apply"
+	qs := o.QueryTable(ptrStructOrTableName)
+	for expr, exprV := range where {
+		qs = qs.Filter(expr, exprV)
+	}
+	_, err := qs.Update(updateParams)
+	return err
+}
+
+type BusinessApplyEditReq struct {
+	BusinessApplyId int    `description:"出差申请id"`
+	ArriveDate      string `description:"到达日期"`
+	ReturnDate      string `description:"返程日期"`
+	Province        string `description:"目的地省"`
+	City            string `description:"目的地市"`
+	Reason          string `description:"出差事由"`
+	Transportation  string `description:"交通工具"`
+	PeerPeopleId    string `description:"同行人id"`
+	PeerPeopleName  string `description:"同行人"`
+}

+ 21 - 13
models/tables/company_approval_message/company_approval_message.go

@@ -25,14 +25,14 @@ type CompanyApprovalMessage struct {
 	MessageInfo       string    `description:"消息主要内容,json数据"`
 }
 
-//添加审批消息
+// 添加审批消息
 func AddCompanyApprovalMessage(item *CompanyApprovalMessage) (err error) {
 	o := orm.NewOrm()
 	_, err = o.Insert(item)
 	return
 }
 
-//修改审批消息
+// 修改审批消息
 func ModifyCompanyApprovalMessage(companyApprovalId, sourceType int) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE company_approval_message SET operation_status=2,modify_time=NOW() 
@@ -41,7 +41,7 @@ WHERE company_approval_id=? AND source_type=?  AND message_type=1 AND operation_
 	return
 }
 
-//消息列表结果
+// 消息列表结果
 type CompanyApprovalMessageList struct {
 	Id                int          `orm:"column(id);pk"`
 	CreateUserId      int          `description:"申请者id"`
@@ -59,7 +59,7 @@ type CompanyApprovalMessageList struct {
 	ApprovalInfo      ApprovalInfo `description:"审批单信息"`
 }
 
-//消息审批单信息
+// 消息审批单信息
 type ApprovalInfo struct {
 	ApplyName     string    `description:"申请人姓名"`
 	Type          string    `description:"类型"`
@@ -77,13 +77,13 @@ type CompanyApprovalMessageListResp struct {
 	Total int `description:"总数据条数"`
 }
 
-//待办消息列表
+// 待办消息列表
 type CompanyApprovalMessageListV2Resp struct {
 	Company  CompanyApprovalMessageListResp `description:"客户"`
 	Contract CompanyApprovalMessageListResp `description:"合同"`
 }
 
-//获取消息列表总数据
+// 获取消息列表总数据
 func GetCompanyApprovalMessageCount(sysUserId, sourceType int) (count int, err error) {
 	sql := `SELECT COUNT(1) AS count FROM company_approval_message AS a
 			INNER JOIN admin AS b ON a.create_user_id=b.admin_id
@@ -93,7 +93,7 @@ func GetCompanyApprovalMessageCount(sysUserId, sourceType int) (count int, err e
 	return
 }
 
-//消息列表页
+// 消息列表页
 func GetCompanyApprovalMessageList(sysUserId, startSize, pageSize int, sourceTypes []int) (items []*CompanyApprovalMessageList, err error) {
 	sql := `SELECT
 				a.*, b.real_name
@@ -108,7 +108,7 @@ func GetCompanyApprovalMessageList(sysUserId, startSize, pageSize int, sourceTyp
 	return
 }
 
-//获取最近一条消息
+// 获取最近一条消息
 func GetLastMessage(sysUserId, sourceType int) (item *CompanyApprovalMessageList, err error) {
 	sql := `SELECT a.*,b.real_name FROM company_approval_message AS a
 			INNER JOIN admin AS b ON a.create_user_id=b.admin_id
@@ -119,7 +119,7 @@ func GetLastMessage(sysUserId, sourceType int) (item *CompanyApprovalMessageList
 	return
 }
 
-//获取最近一条消息
+// 获取最近一条消息
 func GetLastMessageBySourceTypes(sysUserId int, sourceType []int) (item *CompanyApprovalMessageList, err error) {
 	sql := `SELECT
 				a.*, b.real_name
@@ -135,7 +135,7 @@ func GetLastMessageBySourceTypes(sysUserId int, sourceType []int) (item *Company
 	return
 }
 
-//获取未读消息数
+// 获取未读消息数
 func GetNotReadMessageTotal(sysUserId, sourceType int) (total int64, err error) {
 	sql := `SELECT count(*) total FROM company_approval_message AS a
 			INNER JOIN admin AS b ON a.create_user_id=b.admin_id
@@ -155,12 +155,12 @@ func GetCommentNotReadMessageTotal(sysUserId int, types []int) (total int64, err
 	return
 }
 
-//申请服务更新请求参数
+// 申请服务更新请求参数
 type CompanyApprovalMessageReadReq struct {
 	Id int `description:"消息id"`
 }
 
-//变更为消息已读状态
+// 变更为消息已读状态
 func ModifyCompanyApprovalMessageStatus(companyApprovalMessageId int) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE company_approval_message SET message_status=1,modify_time=NOW() WHERE id=?`
@@ -168,7 +168,7 @@ func ModifyCompanyApprovalMessageStatus(companyApprovalMessageId int) (err error
 	return
 }
 
-//变更当前类型下所有未读消息为消息已读状态
+// 变更当前类型下所有未读消息为消息已读状态
 func ModifyAllCompanyApprovalMessageStatus(receiveUserId int, sourceTypes []int) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE company_approval_message SET message_status=1,modify_time=NOW() WHERE receive_user_id = ? and source_type IN (` + utils.GetOrmInReplace(len(sourceTypes)) + `) and message_status=0`
@@ -185,3 +185,11 @@ WHERE company_approval_id=? AND source_type=?  AND message_type=1 AND operation_
 	_, err = o.Raw(sql, companyApprovalId, sourceType).Exec()
 	return
 }
+
+// 消息删除
+func DeleteCompanyApprovalMessage(companyApprovalId, sourceType int) (err error) {
+	o := orm.NewOrm()
+	sql := `DELETE FROM company_approval_message WHERE company_approval_id=? AND source_type=? `
+	_, err = o.Raw(sql, companyApprovalId, sourceType).Exec()
+	return
+}

+ 54 - 0
routers/commentsRouter.go

@@ -7,6 +7,60 @@ import (
 
 func init() {
 
+    beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/business_trip:BusinessTrip"] = append(beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers/business_trip:BusinessTrip"],
+        beego.ControllerComments{
+            Method: "ApplyAdd",
+            Router: `/apply/add`,
+            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",
+            Router: `/apply/back`,
+            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: "Delete",
+            Router: `/apply/delete`,
+            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: "ApplyDetail",
+            Router: `/apply/detail`,
+            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: "ApplyEdit",
+            Router: `/apply/edit`,
+            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: "ApplyList",
+            Router: `/apply/list`,
+            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",

+ 6 - 0
routers/router.go

@@ -11,6 +11,7 @@ package routers
 import (
 	"github.com/beego/beego/v2/server/web/filter/cors"
 	"hongze/hongze_mobile_admin/controllers"
+	"hongze/hongze_mobile_admin/controllers/business_trip"
 	"hongze/hongze_mobile_admin/controllers/roadshow"
 	"hongze/hongze_mobile_admin/controllers/yb"
 
@@ -98,6 +99,11 @@ func init() {
 				&controllers.VarietyTagController{},
 			),
 		),
+		web.NSNamespace("/business_trip",
+			web.NSInclude(
+				&business_trip.BusinessTrip{},
+			),
+		),
 	)
 	web.AddNamespace(ns)
 }