瀏覽代碼

新增 财务

xuwenhao 8 月之前
父節點
當前提交
9160cd284f

+ 2 - 0
server/api/v1/admin/enter.go

@@ -6,10 +6,12 @@ type ApiGroup struct {
 	DepartmentApi
 	ProjectApi
 	FileApi
+	FinanceApi
 }
 
 var (
 	departmentService = service.ServiceGroupApp.AdminServiceGroup.DepartmentService
 	projectService    = service.ServiceGroupApp.AdminServiceGroup.ProjectService
 	fileService       = service.ServiceGroupApp.AdminServiceGroup.FileService
+	financeService    = service.ServiceGroupApp.AdminServiceGroup.FinanceService
 )

+ 364 - 0
server/api/v1/admin/finance.go

@@ -0,0 +1,364 @@
+package admin
+
+import (
+	"github.com/gin-gonic/gin"
+	"os"
+	"server/dao"
+	"server/global"
+	"server/model/common/request"
+	"server/model/common/response"
+	"strconv"
+)
+
+type FinanceApi struct{}
+
+func (fa *FinanceApi) QueryDailyExpensesList(c *gin.Context) {
+	var info request.SearchProject
+	err := c.ShouldBindJSON(&info)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("QueryDailyExpensesList ====== " + err.Error())
+		return
+	}
+	list, total, err := financeService.QueryDailyExpensesList(info)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("QueryDailyExpensesList ====== " + err.Error())
+		return
+	}
+	response.OkWithDetailed(response.PageResult{
+		List:     list,
+		Total:    total,
+		Page:     info.PageInfo.Page,
+		PageSize: info.PageInfo.PageSize,
+	}, "获取成功", c)
+}
+
+func (fa *FinanceApi) QueryDailyExpenses(c *gin.Context) {
+	v := c.Query("id")
+	id, err := strconv.Atoi(v)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("QueryDailyExpenses ====== " + err.Error())
+		return
+	}
+
+	expenses, err := financeService.QueryDailyExpenses(id)
+	if err != nil {
+	}
+	details, err := dao.QueryDailyFeeDetails(int(expenses.ID))
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("QueryDailyExpenses ====== " + err.Error())
+		return
+	}
+	response.OkWithData(details, c)
+}
+
+func (fa *FinanceApi) QueryExpensesGenre(c *gin.Context) {
+	genre, err := financeService.QueryExpensesGenre()
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("QueryExpensesGenre ====== " + err.Error())
+		return
+	}
+	response.OkWithData(genre, c)
+}
+
+func (fa *FinanceApi) QueryBorrowingList(c *gin.Context) {
+	var info request.SearchProject
+	err := c.ShouldBindJSON(&info)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("QueryBorrowingList ====== " + err.Error())
+		return
+	}
+	list, total, err := financeService.QueryBorrowingList(info)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("QueryBorrowingList ====== " + err.Error())
+		return
+	}
+	response.OkWithDetailed(response.PageResult{
+		List:     list,
+		Total:    total,
+		Page:     info.PageInfo.Page,
+		PageSize: info.PageInfo.PageSize,
+	}, "获取成功", c)
+}
+
+func (fa *FinanceApi) QueryBorrowing(c *gin.Context) {
+	v := c.Query("id")
+	id, err := strconv.Atoi(v)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("QueryBorrowing ====== " + err.Error())
+		return
+	}
+	borrowing, err := financeService.QueryBorrowing(id)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("QueryBorrowing ====== " + err.Error())
+		return
+	}
+	response.OkWithData(borrowing, c)
+}
+
+func (fa *FinanceApi) QueryDailyFileList(c *gin.Context) {
+	var info request.SearchIdNameGenre
+	err := c.ShouldBindJSON(&info)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("QueryDailyFileList ====== " + err.Error())
+		return
+	}
+	list, total, err := financeService.QueryDailyFileList(info)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("QueryDailyFileList ====== " + err.Error())
+		return
+	}
+	response.OkWithDetailed(response.PageResult{
+		List:     list,
+		Total:    total,
+		Page:     info.PageInfo.Page,
+		PageSize: info.PageInfo.PageSize,
+	}, "获取成功", c)
+}
+
+func (fa *FinanceApi) CreateDailyExpenses(c *gin.Context) {
+	var expenses dao.DailyExpenses
+	err := c.ShouldBindJSON(&expenses)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("CreateDailyExpenses ====== " + err.Error())
+		return
+	}
+	err = financeService.CreateDailyExpenses(expenses)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("CreateDailyExpenses ====== " + err.Error())
+		return
+	}
+	response.OkWithMessage("新增成功", c)
+}
+
+func (fa *FinanceApi) CreateExpensesGenre(c *gin.Context) {
+	var expensesGenre dao.ExpensesGenre
+	err := c.ShouldBindJSON(&expensesGenre)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("CreateExpensesGenre ====== " + err.Error())
+		return
+	}
+	err = financeService.CreateExpensesGenre(expensesGenre)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("CreateExpensesGenre ====== " + err.Error())
+		return
+	}
+	response.OkWithMessage("新增成功", c)
+}
+
+func (fa *FinanceApi) CreateBorrowing(c *gin.Context) {
+	var borrowing dao.Borrowing
+	err := c.ShouldBindJSON(&borrowing)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("CreateBorrowing ====== " + err.Error())
+		return
+	}
+	err = financeService.CreateBorrowing(borrowing)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("CreateBorrowing ====== " + err.Error())
+		return
+	}
+	response.OkWithMessage("新增成功", c)
+}
+
+func (fa *FinanceApi) CreateDailyFile(c *gin.Context) {
+	form, err := c.MultipartForm()
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		return
+	}
+	files := form.File["file"]
+
+	genre := c.PostForm("genre")
+
+	if len(genre) <= 0 {
+		response.FailWithMessage("类型为空", c)
+		return
+	}
+
+	id := c.PostForm("id")
+	genreId, err := strconv.Atoi(genre)
+	if err != nil {
+		response.FailWithMessage("错误", c)
+		global.GVA_LOG.Error("CreateDailyFile ====== " + err.Error())
+		return
+	}
+	userId, err := strconv.Atoi(id)
+	if err != nil {
+		response.FailWithMessage("错误", c)
+		global.GVA_LOG.Error("CreateDailyFile ====== " + err.Error())
+		return
+	}
+	fileGenre, err := fileService.QueryFileGenreById(genreId)
+	if err != nil {
+		response.FailWithMessage("错误", c)
+		global.GVA_LOG.Error("CreateDailyFile ====== " + err.Error())
+		return
+	}
+	for _, file := range files {
+		dst := file.Filename
+		var path = "./uploads/file/" + id + "/" + fileGenre.Name + "/" + dst
+		dailFile := dao.DailyFile{
+			UserId: userId,
+			Name:   dst,
+			Path:   path,
+		}
+
+		// gin 简单做了封装,拷贝了文件流
+		if err := c.SaveUploadedFile(file, path); err != nil {
+			response.FailWithMessage("上传失败", c)
+			return
+		}
+		err = financeService.CreateDailyFile(dailFile)
+		if err != nil {
+			response.FailWithMessage("上传失败", c)
+			return
+		}
+	}
+
+	response.OkWithMessage("上传成功", c)
+}
+
+func (fa *FinanceApi) UpdateDailyExpenses(c *gin.Context) {
+	var expenses dao.DailyExpenses
+	err := c.ShouldBindJSON(&expenses)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("UpdateDailyExpenses ====== " + err.Error())
+		return
+	}
+	err = financeService.UpdateDailyExpenses(expenses)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("UpdateDailyExpenses ====== " + err.Error())
+		return
+	}
+	response.OkWithMessage("更新成功", c)
+}
+
+func (fa *FinanceApi) UpdateExpensesGenre(c *gin.Context) {
+	var expensesGenre dao.ExpensesGenre
+	err := c.ShouldBindJSON(&expensesGenre)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("UpdateExpensesGenre ====== " + err.Error())
+		return
+	}
+	err = financeService.UpdateExpensesGenre(expensesGenre)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("UpdateExpensesGenre ====== " + err.Error())
+		return
+	}
+	response.OkWithMessage("更新成功", c)
+}
+
+func (fa *FinanceApi) UpdateBorrowing(c *gin.Context) {
+	var borrowing dao.Borrowing
+	err := c.ShouldBindJSON(&borrowing)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("UpdateBorrowing ====== " + err.Error())
+		return
+	}
+	err = financeService.UpdateBorrowing(borrowing)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("UpdateBorrowing ====== " + err.Error())
+		return
+	}
+	response.OkWithMessage("更新成功", c)
+}
+
+func (fa *FinanceApi) DeleteDailyExpenses(c *gin.Context) {
+	var expenses dao.DailyExpenses
+	err := c.ShouldBindJSON(&expenses)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("DeleteDailyExpenses ====== " + err.Error())
+		return
+	}
+	err = financeService.DeleteDailyExpenses(expenses)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("DeleteDailyExpenses ====== " + err.Error())
+		return
+	}
+	response.OkWithMessage("删除成功", c)
+}
+
+func (fa *FinanceApi) DeleteExpensesGenre(c *gin.Context) {
+	var expensesGenre dao.ExpensesGenre
+	err := c.ShouldBindJSON(&expensesGenre)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("DeleteExpensesGenre ====== " + err.Error())
+		return
+	}
+	err = financeService.DeleteExpensesGenre(expensesGenre)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("DeleteExpensesGenre ====== " + err.Error())
+		return
+	}
+	response.OkWithMessage("删除成功", c)
+}
+
+func (fa *FinanceApi) DeleteBorrowing(c *gin.Context) {
+	var borrowing dao.Borrowing
+	err := c.ShouldBindJSON(&borrowing)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("DeleteBorrowing ====== " + err.Error())
+		return
+	}
+	err = financeService.DeleteBorrowing(borrowing)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("DeleteBorrowing ====== " + err.Error())
+		return
+	}
+	response.OkWithMessage("删除成功", c)
+}
+
+func (fa *FinanceApi) DeleteDailyFile(c *gin.Context) {
+	var dailyFile dao.DailyFile
+	err := c.ShouldBindJSON(&dailyFile)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("DeleteDailyFile ====== " + err.Error())
+		return
+	}
+
+	err = os.Remove(dailyFile.Path)
+	if err != nil {
+		// 如果发生错误,打印错误信息
+		response.FailWithMessage("删除文件时发生错误", c)
+		global.GVA_LOG.Error("删除文件时发生错误: " + err.Error())
+		return
+	}
+
+	err = financeService.DeleteDailyFile(dailyFile)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("DeleteDailyFile ====== " + err.Error())
+		return
+	}
+	response.OkWithMessage("删除成功", c)
+}

+ 105 - 15
server/api/v1/admin/project.go

@@ -4,9 +4,9 @@ import (
 	"archive/zip"
 	"bytes"
 	"encoding/json"
-	"fmt"
 	"github.com/gin-gonic/gin"
 	"io"
+	"net/http"
 	"os"
 	"path/filepath"
 	"server/dao"
@@ -103,6 +103,16 @@ func (pa *ProjectApi) QueryProjectsInfo(c *gin.Context) {
 	}, c)
 }
 
+func (pa *ProjectApi) QueryProjectState(c *gin.Context) {
+	states, err := projectService.QueryProjectState()
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("QueryProjectState ====== " + err.Error())
+		return
+	}
+	response.OkWithData(states, c)
+}
+
 func (pa *ProjectApi) QueryWorkingHours(c *gin.Context) {
 	code := c.Query("code")
 	hours, err := projectService.QueryWorkingHours(code)
@@ -172,19 +182,19 @@ func (pa *ProjectApi) CreateProject(c *gin.Context) {
 		response.FailWithMessage("JSON失败", c)
 		return
 	}
-	fmt.Println(files)
 	for _, file := range files {
 		dst := file.Filename
+		var path = "./uploads/file/" + project.Code + "/立项" + "/" + dst
 		projectFile := dao.ProjectFile{
 			ProjectCode: project.Code,
 			Name:        dst,
-			Path:        "./uploads/file/" + project.Code + "/立项" + "/" + dst,
+			Path:        path,
 		}
 
 		project.Files = append(project.Files, projectFile)
 
 		// gin 简单做了封装,拷贝了文件流
-		if err := c.SaveUploadedFile(file, "./uploads/file/"+dst); err != nil {
+		if err := c.SaveUploadedFile(file, path); err != nil {
 			response.FailWithMessage("上传失败", c)
 			return
 		}
@@ -207,6 +217,12 @@ func (pa *ProjectApi) CreateProjectFile(c *gin.Context) {
 	files := form.File["file"]
 
 	genre := c.PostForm("genre")
+
+	if len(genre) <= 0 {
+		response.FailWithMessage("类型为空", c)
+		return
+	}
+
 	code := c.PostForm("code")
 	genreId, err := strconv.Atoi(genre)
 	if err != nil {
@@ -222,14 +238,15 @@ func (pa *ProjectApi) CreateProjectFile(c *gin.Context) {
 	}
 	for _, file := range files {
 		dst := file.Filename
+		var path = "./uploads/file/" + code + "/" + fileGenre.Name + "/" + dst
 		projectFile := dao.ProjectFile{
 			ProjectCode: code,
 			Name:        dst,
-			Path:        "./uploads/file/" + code + "/" + fileGenre.Name + "/" + dst,
+			Path:        path,
 		}
 
 		// gin 简单做了封装,拷贝了文件流
-		if err := c.SaveUploadedFile(file, "./uploads/file/"+dst); err != nil {
+		if err := c.SaveUploadedFile(file, path); err != nil {
 			response.FailWithMessage("上传失败", c)
 			return
 		}
@@ -243,6 +260,23 @@ func (pa *ProjectApi) CreateProjectFile(c *gin.Context) {
 	response.OkWithMessage("上传成功", c)
 }
 
+func (pa *ProjectApi) CreateProjectState(c *gin.Context) {
+	var projectState dao.ProjectState
+	err := c.ShouldBindJSON(&projectState)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("CreateProjectState ====== " + err.Error())
+		return
+	}
+	err = projectService.CreateProjectState(projectState)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("CreateProjectState ====== " + err.Error())
+		return
+	}
+	response.OkWithMessage("新增成功", c)
+}
+
 func (pa *ProjectApi) CreateWorkingHours(c *gin.Context) {
 	var working dao.ProjectWorkingHours
 	err := c.ShouldBindJSON(&working)
@@ -307,6 +341,23 @@ func (pa *ProjectApi) UpdateProject(c *gin.Context) {
 	response.OkWithMessage("更新成功", c)
 }
 
+func (pa *ProjectApi) UpdateProjectState(c *gin.Context) {
+	var projectState dao.ProjectState
+	err := c.ShouldBindJSON(&projectState)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("UpdateProjectState ====== " + err.Error())
+		return
+	}
+	err = projectService.UpdateProjectState(projectState)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("UpdateProjectState ====== " + err.Error())
+		return
+	}
+	response.OkWithMessage("更新成功", c)
+}
+
 func (pa *ProjectApi) UpdateWorkingHours(c *gin.Context) {
 	var working dao.ProjectWorkingHours
 	err := c.ShouldBindJSON(&working)
@@ -371,11 +422,21 @@ func (pa *ProjectApi) DeleteProject(c *gin.Context) {
 
 func (pa *ProjectApi) DeleteProjectFile(c *gin.Context) {
 	id := c.Query("id")
+	path := c.Query("path")
 	i, err := strconv.Atoi(id)
 	if err != nil {
 		response.FailWithMessage(err.Error(), c)
 		return
 	}
+
+	err = os.Remove(path)
+	if err != nil {
+		// 如果发生错误,打印错误信息
+		response.FailWithMessage("删除文件时发生错误", c)
+		global.GVA_LOG.Error("删除文件时发生错误: " + err.Error())
+		return
+	}
+
 	err = projectService.DeleteProjectFile(uint(i))
 	if err != nil {
 		response.FailWithMessage(err.Error(), c)
@@ -384,6 +445,23 @@ func (pa *ProjectApi) DeleteProjectFile(c *gin.Context) {
 	response.OkWithMessage("删除成功", c)
 }
 
+func (pa *ProjectApi) DeleteProjectState(c *gin.Context) {
+	var projectState dao.ProjectState
+	err := c.ShouldBindJSON(&projectState)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("DeleteProjectState ====== " + err.Error())
+		return
+	}
+	err = projectService.DeleteProjectState(projectState)
+	if err != nil {
+		response.FailWithMessage("失败", c)
+		global.GVA_LOG.Error("DeleteProjectState ====== " + err.Error())
+		return
+	}
+	response.OkWithMessage("删除成功", c)
+}
+
 func (pa *ProjectApi) DeleteWorkingHours(c *gin.Context) {
 	var working dao.ProjectWorkingHours
 	err := c.ShouldBindJSON(&working)
@@ -459,27 +537,34 @@ func (pa *ProjectApi) ProjectFilesDownload(c *gin.Context) {
 			return
 		}
 	}
-
+	// 确保所有文件都被写入
 	if err := zipWriter.Close(); err != nil {
 		response.FailWithMessage("错误", c)
 		global.GVA_LOG.Error("ProjectFilesDownload ====== " + err.Error())
 		return
 	}
-	c.Header("Content-Type", "application/zip")                               // 表示是文件流,唤起浏览器下载,一般设置了这个,就要设置文件名
-	c.Header("Content-Disposition", "attachment; filename="+info.Code+".zip") // 用来指定下载下来的文件名
-	c.Header("Content-Transfer-Encoding", "binary")                           // 表示传输过程中的编码形式,乱码问题可能就是因为它
-	c.Data(0, "application/zip", zipBuffer.Bytes())
+	// 设置响应头
+	c.Header("Content-Description", "File Transfer")
+	c.Header("Content-Type", "application/zip")
+	c.Header("Content-Transfer-Encoding", "binary")
+	c.Header("Content-Disposition", "filename=files.zip")
+	c.Header("Cache-Control", "must-revalidate")
+	c.Header("Pragma", "public")
+	// 发送文件
+	c.Data(http.StatusOK, "application/zip", zipBuffer.Bytes())
 }
 
 // 添加文件道zip中
 func addFileToZip(w *zip.Writer, filename string) error {
-	file, err := os.Open(filename)
+	// 打开文件
+	f, err := os.Open(filename)
 	if err != nil {
 		return err
 	}
-	defer file.Close()
+	defer f.Close()
 
-	fileInfo, err := file.Stat()
+	// 获取文件信息
+	fileInfo, err := f.Stat()
 	if err != nil {
 		return err
 	}
@@ -489,13 +574,18 @@ func addFileToZip(w *zip.Writer, filename string) error {
 		return err
 	}
 
+	// 使用文件的实际文件名
 	header.Name = filepath.Base(filename)
 
+	// 写入文件到zip
 	writer, err := w.CreateHeader(header)
 	if err != nil {
 		return err
 	}
 
-	_, err = io.Copy(writer, file)
+	_, err = io.Copy(writer, f)
+	if err != nil {
+		return err
+	}
 	return err
 }

+ 68 - 0
server/dao/borrowing.go

@@ -0,0 +1,68 @@
+package dao
+
+import (
+	"github.com/shopspring/decimal"
+	"server/global"
+)
+
+type Borrowing struct {
+	global.GVA_MODEL
+	Name            string          `json:"name" form:"name" gorm:"comment:支借名称"`
+	Applicant       string          `json:"applicant" form:"applicant" gorm:"comment:申请人"`
+	ApplicationTime string          `json:"applicationTime" form:"applicationTime" gorm:"comment:申请日期"`
+	Charge          int             `json:"charge" form:"charge" gorm:"comment:负责人"`
+	User            SysUser         `json:"user" form:"user" gorm:"foreignKey:Charge;references:id;"`
+	Price           decimal.Decimal `json:"price" form:"price" gorm:"comment:支借金额"`
+}
+
+func (Borrowing) TableName() string {
+	return "borrowing"
+}
+
+// TODO:支借查询
+
+// QueryBorrowingList 查询支借列表
+func QueryBorrowingList(limit, offset int, name, time string) (borrowing []Borrowing, total int64, err error) {
+	// 创建db
+	db := global.GVA_DB.Model(&DailyExpenses{})
+	// 如果有条件搜索 下方会自动创建搜索语句
+	if name != "" {
+		db = db.Where("name LIKE ?", "%"+name+"%")
+	}
+	if time != "" {
+		db = db.Where("DATE_FORMAT(application_time, '%Y-%m-%d') = ?", time)
+	}
+	err = db.Count(&total).Error
+	if err != nil {
+		return
+	}
+	err = db.Order("id desc").Limit(limit).Offset(offset).Preload("User").Find(&borrowing).Error
+	return borrowing, total, err
+}
+
+// QueryBorrowing 查询支借
+func QueryBorrowing(id int) (borrowing Borrowing, err error) {
+	err = global.GVA_DB.Model(&Borrowing{}).Where("id = ?", id).Preload("User").First(&borrowing).Error
+	return borrowing, err
+}
+
+// TODO:支借新增
+
+// CreateBorrowing 新增支借
+func (b Borrowing) CreateBorrowing() error {
+	return global.GVA_DB.Create(&b).Error
+}
+
+// TODO:支借修改
+
+// UpdateBorrowing 更新支借
+func (b Borrowing) UpdateBorrowing() error {
+	return global.GVA_DB.Model(&b).Updates(&b).Error
+}
+
+// TODO:支借删除
+
+// DeleteBorrowing 删除支借
+func (b Borrowing) DeleteBorrowing() error {
+	return global.GVA_DB.Unscoped().Delete(&b).Error
+}

+ 114 - 0
server/dao/dailyExpenses.go

@@ -0,0 +1,114 @@
+package dao
+
+import (
+	"github.com/shopspring/decimal"
+	"gorm.io/gorm"
+	"server/global"
+)
+
+type DailyExpenses struct {
+	global.GVA_MODEL
+	Name            string            `json:"name" form:"name" gorm:"comment:名称"`
+	Genre           int               `json:"genre" form:"genre" gorm:"comment:费用类型"`
+	ExpensesGenre   ExpensesGenre     `json:"expensesGenre" form:"expensesGenre" gorm:"foreignKey:Genre;references:id;"`
+	Applicant       string            `json:"applicant" form:"applicant" gorm:"comment:申请人"`
+	ApplicationTime string            `json:"applicationTime" form:"applicationTime" gorm:"comment:申请日期"`
+	Charge          int               `json:"charge" form:"charge" gorm:"comment:负责人"`
+	User            SysUser           `json:"user" form:"user" gorm:"foreignKey:Charge;references:id;"`
+	TotalAmount     decimal.Decimal   `json:"totalAmount" form:"totalAmount" gorm:"type:decimal(10,2);comment:总金额"`
+	DailyFeeDetails []DailyFeeDetails `json:"dailyFeeDetails" form:"dailyFeeDetails" gorm:"-"`
+}
+
+func (DailyExpenses) TableName() string {
+	return "daily_expenses"
+}
+
+// TODO:日常费用查询
+
+// QueryDailyExpensesList 查询日常费用列表
+func QueryDailyExpensesList(limit, offset, genre int, name, time string) (dailyExpenses []DailyExpenses, total int64, err error) {
+	// 创建db
+	db := global.GVA_DB.Model(&DailyExpenses{})
+	// 如果有条件搜索 下方会自动创建搜索语句
+	if genre != 0 {
+		db = db.Where("genre = ?", genre)
+	}
+	if name != "" {
+		db = db.Where("name LIKE ?", "%"+name+"%")
+	}
+	if time != "" {
+		db = db.Where("DATE_FORMAT(application_time, '%Y-%m-%d') = ?", time)
+	}
+	err = db.Count(&total).Error
+	if err != nil {
+		return
+	}
+	err = db.Order("id desc").Limit(limit).Offset(offset).Preload("ExpensesGenre").Preload("User").Find(&dailyExpenses).Error
+	return dailyExpenses, total, err
+}
+
+// QueryDailyExpenses 查询日常费用详情
+func QueryDailyExpenses(id int) (dailyExpenses DailyExpenses, err error) {
+	err = global.GVA_DB.Model(&DailyExpenses{}).Where("id = ?", id).Preload("ExpensesGenre").Preload("User").First(&dailyExpenses).Error
+	return dailyExpenses, err
+}
+
+// TODO:日常费用新增
+
+// CreateDailyExpenses 新增日常费用
+func (de DailyExpenses) CreateDailyExpenses() error {
+	return global.GVA_DB.Transaction(func(tx *gorm.DB) error {
+		txErr := tx.Create(&de).Error
+		if txErr != nil {
+			return txErr
+		}
+		for _, dailyFeeDetail := range de.DailyFeeDetails {
+			dailyFeeDetail.DailyFeeId = de.ID
+
+			txErr := tx.Create(&dailyFeeDetail).Error
+			if txErr != nil {
+				return txErr
+			}
+		}
+		return txErr
+	})
+}
+
+// TODO:日常费用修改
+
+// UpdateDailyExpenses 修改日常费用
+func (de DailyExpenses) UpdateDailyExpenses() error {
+	return global.GVA_DB.Transaction(func(tx *gorm.DB) error {
+		txErr := tx.Unscoped().Where("daily_fee_id = ?", de.ID).Delete(&DailyFeeDetails{}).Error
+		if txErr != nil {
+			return txErr
+		}
+		txErr = tx.Model(&de).Updates(&de).Error
+		if txErr != nil {
+			return txErr
+		}
+		for _, dailyFeeDetail := range de.DailyFeeDetails {
+			txErr := tx.Create(&dailyFeeDetail).Error
+			if txErr != nil {
+				return txErr
+			}
+		}
+		return txErr
+	})
+}
+
+// TODO:日常费用删除
+
+func (de DailyExpenses) DeleteDailyExpenses() error {
+	return global.GVA_DB.Transaction(func(tx *gorm.DB) error {
+		txErr := tx.Unscoped().Where("daily_fee_id = ?", de.ID).Delete(&DailyFeeDetails{}).Error
+		if txErr != nil {
+			return txErr
+		}
+		txErr = tx.Unscoped().Delete(&de).Error
+		if txErr != nil {
+			return txErr
+		}
+		return txErr
+	})
+}

+ 31 - 0
server/dao/dailyFeeDetails.go

@@ -0,0 +1,31 @@
+package dao
+
+import (
+	"github.com/shopspring/decimal"
+	"server/global"
+)
+
+type DailyFeeDetails struct {
+	global.GVA_MODEL
+	DailyFeeId uint            `json:"dailyFeeId" form:"dailyFeeId" gorm:"comment:日常费用id"`
+	FeeTime    string          `json:"feeTime" form:"feeTime" gorm:"comment:日常费用期"`
+	Illustrate string          `json:"illustrate" form:"illustrate" gorm:"comment:费用说明"`
+	Price      decimal.Decimal `json:"price" form:"price" gorm:"type:decimal(10,2);comment:报销金额"`
+}
+
+func (DailyFeeDetails) TableName() string {
+	return "daily_fee_details"
+}
+
+// TODO:日常费用详情查询
+
+// QueryDailyFeeDetails 查询日常费用详情
+func QueryDailyFeeDetails(id int) (dailyFeeDetails []DailyFeeDetails, err error) {
+	err = global.GVA_DB.Model(&DailyFeeDetails{}).Where("daily_fee_id = ?", id).Find(&dailyFeeDetails).Error
+	return dailyFeeDetails, err
+}
+
+// TODO:日常费用详情新增
+
+// TODO:日常费用详情修改
+// TODO:日常费用详情删除

+ 53 - 0
server/dao/dailyFile.go

@@ -0,0 +1,53 @@
+package dao
+
+import "server/global"
+
+type DailyFile struct {
+	global.GVA_MODEL
+	UserId    int       `json:"userId" form:"userId" gorm:"comment:用户编号"`
+	Name      string    `json:"name" from:"name" gorm:"comment:文件名称"`
+	Genre     int       `json:"genre" form:"genre" gorm:"comment:文件类型"`
+	FileGenre FileGenre `json:"fileGenre" form:"fileGenre" gorm:"foreignKey:genre;references:id;"`
+	Path      string    `json:"path" from:"path" gorm:"comment:路径"`
+}
+
+func (DailyFile) TableName() string {
+	return "daily_file"
+}
+
+// TODO:日常文件查询
+
+// QueryDailyFileList 查询日常文件列表
+func QueryDailyFileList(limit, offset, userId, genre int, name string) (dailyFiles []DailyFile, total int64, err error) {
+	// 创建db
+	db := global.GVA_DB.Model(&DailyFile{}).Where("user_id=?", userId)
+	// 如果有条件搜索 下方会自动创建搜索语句
+	if genre != 0 {
+		db = db.Where("genre = ?", genre)
+	}
+	if name != "" {
+		db = db.Where("name LIKE ?", "%"+name+"%")
+	}
+	err = db.Count(&total).Error
+	if err != nil {
+		return
+	}
+	err = db.Order("id desc").Limit(limit).Offset(offset).Preload("ProjectState").Find(&dailyFiles).Error
+	return dailyFiles, total, err
+}
+
+// TODO:日常文件新增
+
+// CreateDailyFile 新增日常文件
+func (df DailyFile) CreateDailyFile() error {
+	return global.GVA_DB.Create(&df).Error
+}
+
+// TODO:日常文件修改
+
+// TODO:日常文件删除
+
+// DeleteDailyFile 删除日常文件
+func (df DailyFile) DeleteDailyFile() error {
+	return global.GVA_DB.Unscoped().Delete(&df).Error
+}

+ 41 - 0
server/dao/expensesGenre.go

@@ -0,0 +1,41 @@
+package dao
+
+import "server/global"
+
+type ExpensesGenre struct {
+	global.GVA_MODEL
+	Name string `json:"name" form:"name" gorm:"comment:费用类型名称"`
+}
+
+func (ExpensesGenre) TableName() string {
+	return "expenses_genre"
+}
+
+// TODO:费用类型查询
+
+// QueryExpensesGenre 查询费用类型
+func QueryExpensesGenre() (expensesGenre []ExpensesGenre, err error) {
+	err = global.GVA_DB.Model(&ExpensesGenre{}).Find(&expensesGenre).Error
+	return expensesGenre, err
+}
+
+// TODO:费用类型新增
+
+// CreateExpensesGenre 新增费用类型
+func (eg ExpensesGenre) CreateExpensesGenre() error {
+	return global.GVA_DB.Create(&eg).Error
+}
+
+// TODO:费用类型修改
+
+// UpdateExpensesGenre 修改费用类型
+func (eg ExpensesGenre) UpdateExpensesGenre() error {
+	return global.GVA_DB.Model(&eg).Updates(&eg).Error
+}
+
+// TODO:费用类型删除
+
+// DeleteExpensesGenre 删除费用类型
+func (eg ExpensesGenre) DeleteExpensesGenre() error {
+	return global.GVA_DB.Unscoped().Delete(&eg).Error
+}

+ 3 - 3
server/dao/fileGenre.go

@@ -16,13 +16,13 @@ func (FileGenre) TableName() string {
 
 // TODO:文件类型查询
 
-// QueryFileGenre 查询项目类型
+// QueryFileGenre 查询文件类型
 func QueryFileGenre() (fileGenres []FileGenre, err error) {
 	err = global.GVA_DB.Model(&FileGenre{}).Find(&fileGenres).Error
 	return fileGenres, err
 }
 
-// QueryFileGenreById 查询项目类型 按id
+// QueryFileGenreById 查询文件类型 按id
 func QueryFileGenreById(id int) (fileGenre FileGenre, err error) {
 	err = global.GVA_DB.Model(&FileGenre{}).Where("id = ?", id).First(&fileGenre).Error
 	return fileGenre, err
@@ -30,7 +30,7 @@ func QueryFileGenreById(id int) (fileGenre FileGenre, err error) {
 
 // TODO:文件类型新增
 
-// CreateFileGenre 新增项目类型
+// CreateFileGenre 新增文件类型
 func (fg FileGenre) CreateFileGenre() error {
 	return global.GVA_DB.Create(&fg).Error
 }

+ 15 - 13
server/dao/project.go

@@ -8,18 +8,20 @@ import (
 
 type Project struct {
 	global.GVA_MODEL
-	Code         string                `json:"code" form:"code" gorm:"comment:项目编号"`
-	Name         string                `json:"name" form:"name" gorm:"comment:项目名称"`
-	Principal    string                `json:"principal" form:"principal" gorm:"comment:负责人"`
-	Price        decimal.Decimal       `json:"price" form:"price" gorm:"type:decimal(10,2);not null"`
-	Level        int                   `json:"level" form:"level" gorm:"级别"`
-	Customer     string                `json:"customer" form:"customer" gorm:"相关客户"`
-	Illustrate   string                `json:"illustrate" form:"illustrate" gorm:"comment:说明;type:varchar(200)"`
-	State        int                   `json:"state" form:"state" gorm:"comment:状态"`
-	EndTime      string                `json:"endTime" form:"endTime" gorm:"comment:结束时间"`
-	Files        []ProjectFile         `json:"files" form:"files" gorm:"-"`
-	WorkingHours []ProjectWorkingHours `json:"workingHours" form:"workingHours" gorm:"-"`
-	Collection   []Collection          `json:"collection" form:"collection" gorm:"-"`
+	Code           string                `json:"code" form:"code" gorm:"comment:项目编号"`
+	Name           string                `json:"name" form:"name" gorm:"comment:项目名称"`
+	Principal      string                `json:"principal" form:"principal" gorm:"comment:负责人"`
+	Price          decimal.Decimal       `json:"price" form:"price" gorm:"type:decimal(10,2);not null"`
+	Level          int                   `json:"level" form:"level" gorm:"级别"`
+	Customer       string                `json:"customer" form:"customer" gorm:"相关客户"`
+	Illustrate     string                `json:"illustrate" form:"illustrate" gorm:"comment:说明;type:varchar(200)"`
+	State          int                   `json:"state" form:"state" gorm:"comment:状态"`
+	ProjectState   ProjectState          `json:"projectState" form:"projectState" gorm:"foreignKey:State;references:id;"`
+	CollectionTime string                `json:"collectionTime" form:"collectionTime" gorm:"comment:收款时间"`
+	EndTime        string                `json:"endTime" form:"endTime" gorm:"comment:结束时间"`
+	Files          []ProjectFile         `json:"files" form:"files" gorm:"-"`
+	WorkingHours   []ProjectWorkingHours `json:"workingHours" form:"workingHours" gorm:"-"`
+	Collection     []Collection          `json:"collection" form:"collection" gorm:"-"`
 }
 
 func (Project) TableName() string {
@@ -46,7 +48,7 @@ func QueryProjectList(limit, offset, state int, name, time string) (project []Pr
 	if err != nil {
 		return
 	}
-	err = db.Order("id desc").Limit(limit).Offset(offset).Find(&project).Error
+	err = db.Order("id desc").Limit(limit).Offset(offset).Preload("ProjectState").Find(&project).Error
 	return project, total, err
 }
 

+ 48 - 0
server/dao/projectState.go

@@ -0,0 +1,48 @@
+package dao
+
+import "server/global"
+
+type ProjectState struct {
+	global.GVA_MODEL
+	Name    string `json:"name" form:"name" gorm:"comment:项目状态名称"`
+	Remarks string `json:"remarks" form:"remarks" gorm:"comment:备注"`
+}
+
+func (ProjectState) TableName() string {
+	return "project_state"
+}
+
+// TODO:文件类型查询
+
+// QueryProjectState 查询项目类型
+func QueryProjectState() (fileGenres []ProjectState, err error) {
+	err = global.GVA_DB.Model(&ProjectState{}).Find(&fileGenres).Error
+	return fileGenres, err
+}
+
+// QueryProjectStateById 查询项目类型 按id
+func QueryProjectStateById(id int) (fileGenre ProjectState, err error) {
+	err = global.GVA_DB.Model(&ProjectState{}).Where("id = ?", id).First(&fileGenre).Error
+	return fileGenre, err
+}
+
+// TODO:文件类型新增
+
+// CreateProjectState 新增项目类型
+func (ps ProjectState) CreateProjectState() error {
+	return global.GVA_DB.Create(&ps).Error
+}
+
+// TODO:文件类型修改
+
+// UpdateProjectState 修改文件类型
+func (ps ProjectState) UpdateProjectState() error {
+	return global.GVA_DB.Model(&ps).Updates(&ps).Error
+}
+
+// TODO:文件类型删除
+
+// DeleteProjectState 删除文件类型
+func (ps ProjectState) DeleteProjectState() error {
+	return global.GVA_DB.Unscoped().Delete(&ps).Error
+}

+ 6 - 0
server/dao/reimbursement.go

@@ -76,6 +76,12 @@ func (r Reimbursement) UpdateReimbursement() error {
 		if txErr != nil {
 			return txErr
 		}
+		for _, feeDetail := range r.FeeDetails {
+			txErr := tx.Create(&feeDetail).Error
+			if txErr != nil {
+				return txErr
+			}
+		}
 		return txErr
 	})
 }

+ 5 - 0
server/initialize/gorm.go

@@ -48,10 +48,15 @@ func RegisterTables() {
 		dao.ExaFileUploadAndDownload{},
 		dao.Department{},
 		dao.Project{},
+		dao.ProjectState{},
 		dao.ProjectFile{},
 		dao.FileGenre{},
 		dao.ProjectWorkingHours{},
 		dao.Collection{},
+		dao.Borrowing{},
+		dao.ExpensesGenre{},
+		dao.DailyExpenses{},
+		dao.DailyFeeDetails{},
 	)
 	if err != nil {
 		global.GVA_LOG.Error("register table failed", zap.Error(err))

+ 1 - 0
server/initialize/router.go

@@ -90,6 +90,7 @@ func Routers() *gin.Engine {
 		adminRouter.InitDepartmentRouter(PublicGroup)
 		adminRouter.InitProjectRouter(PrivateGroup)
 		adminRouter.InitFileRouter(PrivateGroup)
+		adminRouter.InitFinanceRouter(PrivateGroup)
 	}
 
 	global.GVA_LOG.Info("router register success")

+ 7 - 0
server/model/common/request/common.go

@@ -50,4 +50,11 @@ type SearchProjectFileList struct {
 	Genre    int      `json:"genre" form:"genre"`
 }
 
+type SearchIdNameGenre struct {
+	PageInfo PageInfo `json:"pageInfo" form:"pageInfo"`
+	Id       int      `json:"id" form:"id"`
+	Name     string   `json:"name" form:"name"`
+	Genre    int      `json:"genre" form:"genre"`
+}
+
 type Empty struct{}

+ 38 - 0
server/router/admin/finance.go

@@ -0,0 +1,38 @@
+package admin
+
+import (
+	"github.com/gin-gonic/gin"
+	v1 "server/api/v1"
+	"server/middleware"
+)
+
+type FinanceRouter struct{}
+
+func (s *ProjectRouter) InitFinanceRouter(Router *gin.RouterGroup) {
+	financeRouter := Router.Group("finance").Use(middleware.OperationRecord())
+	financeRouterWithoutRecord := Router.Group("finance")
+	financeApi := v1.ApiGroupApp.AdminApiGroup.FinanceApi
+	{
+		financeRouter.POST("createDailyExpenses", financeApi.CreateDailyExpenses)
+		financeRouter.POST("createExpensesGenre", financeApi.CreateExpensesGenre)
+		financeRouter.POST("createBorrowing", financeApi.CreateBorrowing)
+		financeRouter.POST("createDailyFile", financeApi.CreateDailyFile)
+
+		financeRouter.PUT("updateDailyExpenses", financeApi.UpdateDailyExpenses)
+		financeRouter.PUT("updateExpensesGenre", financeApi.UpdateExpensesGenre)
+		financeRouter.PUT("updateBorrowing", financeApi.UpdateBorrowing)
+
+		financeRouter.DELETE("deleteDailyExpenses", financeApi.DeleteDailyExpenses)
+		financeRouter.DELETE("deleteExpensesGenre", financeApi.DeleteExpensesGenre)
+		financeRouter.DELETE("deleteBorrowing", financeApi.DeleteBorrowing)
+		financeRouter.DELETE("deleteDailyFile", financeApi.DeleteDailyFile)
+	}
+	{
+		financeRouterWithoutRecord.POST("queryDailyExpensesList", financeApi.QueryDailyExpensesList)
+		financeRouterWithoutRecord.GET("queryDailyExpenses", financeApi.QueryDailyExpenses)
+		financeRouterWithoutRecord.GET("queryExpensesGenre", financeApi.QueryExpensesGenre)
+		financeRouterWithoutRecord.POST("queryBorrowingList", financeApi.QueryBorrowingList)
+		financeRouterWithoutRecord.GET("queryBorrowing", financeApi.QueryBorrowing)
+		financeRouterWithoutRecord.POST("queryDailyFileList", financeApi.QueryDailyFileList)
+	}
+}

+ 4 - 0
server/router/admin/project.go

@@ -18,17 +18,20 @@ func (s *ProjectRouter) InitProjectRouter(Router *gin.RouterGroup) {
 		projectRouter.POST("createWorkingHours", projectApi.CreateWorkingHours)
 		projectRouter.POST("createCollection", projectApi.CreateCollection)
 		projectRouter.POST("createReimbursement", projectApi.CreateReimbursement)
+		projectRouter.POST("createProjectState", projectApi.CreateProjectState)
 
 		projectRouter.PUT("updateProject", projectApi.UpdateProject)
 		projectRouter.PUT("updateWorkingHours", projectApi.UpdateWorkingHours)
 		projectRouter.PUT("updateCollection", projectApi.UpdateCollection)
 		projectRouter.PUT("updateReimbursement", projectApi.UpdateReimbursement)
+		projectRouter.PUT("updateProjectState", projectApi.UpdateProjectState)
 
 		projectRouter.DELETE("deleteProject", projectApi.DeleteProject)
 		projectRouter.DELETE("deleteProjectFile", projectApi.DeleteProjectFile)
 		projectRouter.DELETE("deleteWorkingHours", projectApi.DeleteWorkingHours)
 		projectRouter.DELETE("deleteCollection", projectApi.DeleteCollection)
 		projectRouter.DELETE("deleteReimbursement", projectApi.DeleteReimbursement)
+		projectRouter.DELETE("deleteProjectState", projectApi.DeleteProjectState)
 	}
 	{
 		projectRouterWithoutRecord.POST("queryProjectList", projectApi.QueryProjectList)
@@ -41,5 +44,6 @@ func (s *ProjectRouter) InitProjectRouter(Router *gin.RouterGroup) {
 		projectRouterWithoutRecord.GET("queryReimbursementList", projectApi.QueryReimbursementList)
 		projectRouterWithoutRecord.GET("queryReimbursement", projectApi.QueryReimbursement)
 		projectRouterWithoutRecord.POST("projectFilesDownload", projectApi.ProjectFilesDownload)
+		projectRouterWithoutRecord.GET("queryProjectState", projectApi.QueryProjectState)
 	}
 }

+ 1 - 0
server/service/admin/enter.go

@@ -4,4 +4,5 @@ type ServiceGroup struct {
 	DepartmentService
 	ProjectService
 	FileService
+	FinanceService
 }

+ 94 - 0
server/service/admin/finance.go

@@ -0,0 +1,94 @@
+package admin
+
+import (
+	"server/dao"
+	"server/model/common/request"
+)
+
+type FinanceService struct{}
+
+func (fs *FinanceService) QueryDailyExpensesList(info request.SearchProject) (list interface{}, total int64, err error) {
+	limit := info.PageInfo.PageSize
+	offset := info.PageInfo.PageSize * (info.PageInfo.Page - 1)
+	dailyExpenses, total, err := dao.QueryDailyExpensesList(limit, offset, info.State, info.Name, info.Time)
+	return dailyExpenses, total, err
+}
+
+func (fs *FinanceService) QueryDailyExpenses(id int) (dao.DailyExpenses, error) {
+	expenses, err := dao.QueryDailyExpenses(id)
+	if err != nil {
+		return dao.DailyExpenses{}, err
+	}
+	details, err := dao.QueryDailyFeeDetails(int(expenses.ID))
+	if err != nil {
+		return dao.DailyExpenses{}, err
+	}
+	expenses.DailyFeeDetails = details
+	return expenses, err
+}
+
+func (fs *FinanceService) QueryExpensesGenre() ([]dao.ExpensesGenre, error) {
+	return dao.QueryExpensesGenre()
+}
+
+func (fs *FinanceService) QueryBorrowingList(info request.SearchProject) (list interface{}, total int64, err error) {
+	limit := info.PageInfo.PageSize
+	offset := info.PageInfo.PageSize * (info.PageInfo.Page - 1)
+	borrowing, total, err := dao.QueryBorrowingList(limit, offset, info.Name, info.Time)
+	return borrowing, total, err
+}
+
+func (fs *FinanceService) QueryBorrowing(id int) (dao.Borrowing, error) {
+	return dao.QueryBorrowing(id)
+}
+
+func (fs *FinanceService) QueryDailyFileList(info request.SearchIdNameGenre) (list interface{}, total int64, err error) {
+	limit := info.PageInfo.PageSize
+	offset := info.PageInfo.PageSize * (info.PageInfo.Page - 1)
+	dailyFiles, total, err := dao.QueryDailyFileList(limit, offset, info.Id, info.Genre, info.Name)
+	return dailyFiles, total, err
+}
+
+func (fs *FinanceService) CreateDailyExpenses(expenses dao.DailyExpenses) error {
+	return expenses.CreateDailyExpenses()
+}
+
+func (fs *FinanceService) CreateExpensesGenre(genre dao.ExpensesGenre) error {
+	return genre.CreateExpensesGenre()
+}
+
+func (fs *FinanceService) CreateBorrowing(borrowing dao.Borrowing) error {
+	return borrowing.CreateBorrowing()
+}
+
+func (fs *FinanceService) CreateDailyFile(file dao.DailyFile) error {
+	return file.CreateDailyFile()
+}
+
+func (fs *FinanceService) UpdateDailyExpenses(expenses dao.DailyExpenses) error {
+	return expenses.UpdateDailyExpenses()
+}
+
+func (fs *FinanceService) UpdateExpensesGenre(genre dao.ExpensesGenre) error {
+	return genre.UpdateExpensesGenre()
+}
+
+func (fs *FinanceService) UpdateBorrowing(borrowing dao.Borrowing) error {
+	return borrowing.UpdateBorrowing()
+}
+
+func (fs *FinanceService) DeleteDailyExpenses(expenses dao.DailyExpenses) error {
+	return expenses.DeleteDailyExpenses()
+}
+
+func (fs *FinanceService) DeleteExpensesGenre(genre dao.ExpensesGenre) error {
+	return genre.DeleteExpensesGenre()
+}
+
+func (fs *FinanceService) DeleteBorrowing(borrowing dao.Borrowing) error {
+	return borrowing.DeleteBorrowing()
+}
+
+func (fs *FinanceService) DeleteDailyFile(file dao.DailyFile) error {
+	return file.DeleteDailyFile()
+}

+ 22 - 0
server/service/admin/project.go

@@ -5,6 +5,7 @@ import (
 	"github.com/shopspring/decimal"
 	"server/dao"
 	"server/model/common/request"
+	"time"
 )
 
 type ProjectService struct{}
@@ -62,6 +63,10 @@ func (ps *ProjectService) QueryProjectsInfo() (sum decimal.Decimal, totalProject
 	return
 }
 
+func (ps *ProjectService) QueryProjectState() ([]dao.ProjectState, error) {
+	return dao.QueryProjectState()
+}
+
 func (ps *ProjectService) QueryWorkingHours(code string) ([]dao.ProjectWorkingHours, error) {
 	return dao.QueryWorkingHours(code)
 }
@@ -99,6 +104,10 @@ func (ps *ProjectService) CreateProjectFile(projectFile dao.ProjectFile) error {
 	return projectFile.CreateFile()
 }
 
+func (ps *ProjectService) CreateProjectState(projectState dao.ProjectState) error {
+	return projectState.CreateProjectState()
+}
+
 func (ps *ProjectService) CreateOrUpdateWorkingHours(workingHours dao.ProjectWorkingHours) error {
 	// 查询是否已有工时
 	hours, err := dao.QueryWorkingHoursByCode(workingHours.ProjectCode, workingHours.People)
@@ -127,9 +136,18 @@ func (ps *ProjectService) CreateReimbursement(reimbursement dao.Reimbursement) e
 }
 
 func (ps *ProjectService) UpdateProject(project dao.Project) error {
+	if project.State == 3 {
+		project.CollectionTime = time.Now().Format("2006-01-02 15:04:05")
+	} else if project.State == 4 || project.State == 5 {
+		project.EndTime = time.Now().Format("2006-01-02 15:04:05")
+	}
 	return project.UpdateProject()
 }
 
+func (ps *ProjectService) UpdateProjectState(projectState dao.ProjectState) error {
+	return projectState.UpdateProjectState()
+}
+
 func (ps *ProjectService) UpdateWorkingHours(workingHours dao.ProjectWorkingHours) error {
 	return workingHours.UpdateWorkingHours()
 }
@@ -150,6 +168,10 @@ func (ps *ProjectService) DeleteProjectFile(id uint) error {
 	return dao.DeleteFile(id)
 }
 
+func (ps *ProjectService) DeleteProjectState(projectState dao.ProjectState) error {
+	return projectState.DeleteProjectState()
+}
+
 func (ps *ProjectService) DeleteWorkingHours(workingHours dao.ProjectWorkingHours) error {
 	return workingHours.DeleteWorkingHours()
 }

+ 1 - 1
web/src/utils/request.js

@@ -72,7 +72,7 @@ service.interceptors.response.use(
     if (response.headers['new-token']) {
       userStore.setToken(response.headers['new-token'])
     }
-    if (response.data.code === 0 || response.headers.success === 'true') {
+    if (response.data.code === 0 || response.headers.success === 'true' || response.status === 200) {
       if (response.headers.msg) {
         response.data.msg = decodeURI(response.headers.msg)
       }

+ 2 - 28
web/src/view/department/department.vue

@@ -347,7 +347,8 @@ const submitUpload = async() => {
 const xiazai = async() => {
   await xia({ code: 'LCZM202407161229' }).then(res => {
     console.log(res)
-    const url = window.URL.createObjectURL(new Blob([res.data]))
+    const url = window.URL.createObjectURL(res)
+    console.log(url)
     const link = document.createElement('a')
     link.href = url
     link.setAttribute('download', 'LCZM202407161229' + '.zip') // 设置下载文件名
@@ -358,33 +359,6 @@ const xiazai = async() => {
     link.parentNode.removeChild(link)
     window.URL.revokeObjectURL(url)
   })
-  // try {
-  //   const response = await axios({
-  //     method: 'post',
-  //     url: 'http://localhost:8080/api/project/xiazai',
-  //     data: {
-  //       code: 'LCZH202407091055'
-  //     },
-  //     responseType: 'blob'
-  //   })
-  //
-  //   const blob = new Blob([response.data], {
-  //     type: 'application/png' // 根据实际文件类型调整
-  //   })
-  //
-  //   const downloadUrl = window.URL.createObjectURL(blob)
-  //
-  //   const link = document.createElement('a')
-  //   link.href = downloadUrl
-  //   // link.download = response.headers[fileNameHeader] || 'default-filename.png' // 如果没有提供文件名,使用默认名
-  //   link.download = '04-原理篇.zip'
-  //   document.body.appendChild(link)
-  //   link.click()
-  //   document.body.removeChild(link)
-  //   window.URL.revokeObjectURL(downloadUrl)
-  // } catch (error) {
-  //   console.error('Download failed:', error)
-  // }
 }
 
 const depTableData = ref([])