mirror of
https://gitee.com/xiangheng/x_admin.git
synced 2025-12-24 08:12:55 +08:00
改了点Service变量名字
This commit is contained in:
@@ -31,12 +31,12 @@ type ArticleCollectService struct {
|
||||
}
|
||||
|
||||
// List 文章收藏列表
|
||||
func (Service ArticleCollectService) List(page request.PageReq, listReq ArticleCollectListReq) (res response.PageResp, e error) {
|
||||
func (service ArticleCollectService) List(page request.PageReq, listReq ArticleCollectListReq) (res response.PageResp, e error) {
|
||||
// 分页信息
|
||||
limit := page.PageSize
|
||||
offset := page.PageSize * (page.PageNo - 1)
|
||||
// 查询
|
||||
dbModel := Service.db.Model(&model.ArticleCollect{})
|
||||
dbModel := service.db.Model(&model.ArticleCollect{})
|
||||
if listReq.UserId > 0 {
|
||||
dbModel = dbModel.Where("user_id = ?", listReq.UserId)
|
||||
}
|
||||
|
||||
@@ -33,12 +33,12 @@ type flowApplyService struct {
|
||||
}
|
||||
|
||||
// List 申请流程列表
|
||||
func (Service flowApplyService) List(page request.PageReq, listReq FlowApplyListReq) (res response.PageResp, e error) {
|
||||
func (service flowApplyService) List(page request.PageReq, listReq FlowApplyListReq) (res response.PageResp, e error) {
|
||||
// 分页信息
|
||||
limit := page.PageSize
|
||||
offset := page.PageSize * (page.PageNo - 1)
|
||||
// 查询
|
||||
dbModel := Service.db.Model(&model.FlowApply{})
|
||||
dbModel := service.db.Model(&model.FlowApply{})
|
||||
if listReq.TemplateId > 0 {
|
||||
dbModel = dbModel.Where("template_id = ?", listReq.TemplateId)
|
||||
}
|
||||
@@ -90,9 +90,9 @@ func (Service flowApplyService) List(page request.PageReq, listReq FlowApplyList
|
||||
}
|
||||
|
||||
// Detail 申请流程详情
|
||||
func (Service flowApplyService) Detail(id int) (res FlowApplyResp, e error) {
|
||||
func (service flowApplyService) Detail(id int) (res FlowApplyResp, e error) {
|
||||
var obj model.FlowApply
|
||||
err := Service.db.Where("id = ? AND is_delete = ?", id, 0).Limit(1).First(&obj).Error
|
||||
err := service.db.Where("id = ? AND is_delete = ?", id, 0).Limit(1).First(&obj).Error
|
||||
if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
|
||||
return
|
||||
}
|
||||
@@ -104,7 +104,7 @@ func (Service flowApplyService) Detail(id int) (res FlowApplyResp, e error) {
|
||||
}
|
||||
|
||||
// Add 申请流程新增
|
||||
func (Service flowApplyService) Add(addReq FlowApplyAddReq) (e error) {
|
||||
func (service flowApplyService) Add(addReq FlowApplyAddReq) (e error) {
|
||||
var obj model.FlowApply
|
||||
var flow_template_resp, err = flow_template.Service.Detail(addReq.TemplateId)
|
||||
if e = response.CheckErrDBNotRecord(err, "模板不存在!"); e != nil {
|
||||
@@ -118,15 +118,15 @@ func (Service flowApplyService) Add(addReq FlowApplyAddReq) (e error) {
|
||||
obj.FlowProcessData = flow_template_resp.FlowProcessData
|
||||
obj.FlowProcessDataList = flow_template_resp.FlowProcessDataList
|
||||
|
||||
err = Service.db.Create(&obj).Error
|
||||
err = service.db.Create(&obj).Error
|
||||
e = response.CheckErr(err, "添加失败")
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 申请流程编辑
|
||||
func (Service flowApplyService) Edit(editReq FlowApplyEditReq) (e error) {
|
||||
func (service flowApplyService) Edit(editReq FlowApplyEditReq) (e error) {
|
||||
var obj model.FlowApply
|
||||
err := Service.db.Where("id = ? AND is_delete = ?", editReq.Id, 0).Limit(1).First(&obj).Error
|
||||
err := service.db.Where("id = ? AND is_delete = ?", editReq.Id, 0).Limit(1).First(&obj).Error
|
||||
// 校验
|
||||
if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
|
||||
return
|
||||
@@ -136,15 +136,15 @@ func (Service flowApplyService) Edit(editReq FlowApplyEditReq) (e error) {
|
||||
}
|
||||
// 更新
|
||||
response.Copy(&obj, editReq)
|
||||
err = Service.db.Model(&obj).Updates(obj).Error
|
||||
err = service.db.Model(&obj).Updates(obj).Error
|
||||
e = response.CheckErr(err, "编辑失败")
|
||||
return
|
||||
}
|
||||
|
||||
// Del 申请流程删除
|
||||
func (Service flowApplyService) Del(id int) (e error) {
|
||||
func (service flowApplyService) Del(id int) (e error) {
|
||||
var obj model.FlowApply
|
||||
err := Service.db.Where("id = ? AND is_delete = ?", id, 0).Limit(1).First(&obj).Error
|
||||
err := service.db.Where("id = ? AND is_delete = ?", id, 0).Limit(1).First(&obj).Error
|
||||
// 校验
|
||||
if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
|
||||
return
|
||||
@@ -160,7 +160,7 @@ func (Service flowApplyService) Del(id int) (e error) {
|
||||
// 删除
|
||||
obj.IsDelete = 1
|
||||
obj.DeleteTime = core.NowTime()
|
||||
err = Service.db.Save(&obj).Error
|
||||
err = service.db.Save(&obj).Error
|
||||
e = response.CheckErr(err, "Del Save err")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -44,12 +44,12 @@ type flowHistoryService struct {
|
||||
}
|
||||
|
||||
// List 流程历史列表
|
||||
func (Service flowHistoryService) List(page request.PageReq, listReq FlowHistoryListReq) (res response.PageResp, e error) {
|
||||
func (service flowHistoryService) List(page request.PageReq, listReq FlowHistoryListReq) (res response.PageResp, e error) {
|
||||
// 分页信息
|
||||
limit := page.PageSize
|
||||
offset := page.PageSize * (page.PageNo - 1)
|
||||
// 查询
|
||||
dbModel := Service.db.Model(&model.FlowHistory{})
|
||||
dbModel := service.db.Model(&model.FlowHistory{})
|
||||
if listReq.ApplyId > 0 {
|
||||
dbModel = dbModel.Where("apply_id = ?", listReq.ApplyId)
|
||||
}
|
||||
@@ -103,10 +103,10 @@ func (Service flowHistoryService) List(page request.PageReq, listReq FlowHistory
|
||||
}
|
||||
|
||||
// ListAll 流程历史列表
|
||||
func (Service flowHistoryService) ListAll(listReq FlowHistoryListReq) (res []FlowHistoryResp, e error) {
|
||||
func (service flowHistoryService) ListAll(listReq FlowHistoryListReq) (res []FlowHistoryResp, e error) {
|
||||
|
||||
// 查询
|
||||
dbModel := Service.db.Model(&model.FlowHistory{})
|
||||
dbModel := service.db.Model(&model.FlowHistory{})
|
||||
if listReq.ApplyId > 0 {
|
||||
dbModel = dbModel.Where("apply_id = ?", listReq.ApplyId)
|
||||
}
|
||||
@@ -127,9 +127,9 @@ func (Service flowHistoryService) ListAll(listReq FlowHistoryListReq) (res []Flo
|
||||
}
|
||||
|
||||
// Detail 流程历史详情
|
||||
func (Service flowHistoryService) Detail(id int) (res FlowHistoryResp, e error) {
|
||||
func (service flowHistoryService) Detail(id int) (res FlowHistoryResp, e error) {
|
||||
var obj model.FlowHistory
|
||||
err := Service.db.Where("id = ?", id).Limit(1).First(&obj).Error
|
||||
err := service.db.Where("id = ?", id).Limit(1).First(&obj).Error
|
||||
if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
|
||||
return
|
||||
}
|
||||
@@ -141,18 +141,18 @@ func (Service flowHistoryService) Detail(id int) (res FlowHistoryResp, e error)
|
||||
}
|
||||
|
||||
// Add 流程历史新增
|
||||
func (Service flowHistoryService) Add(addReq FlowHistoryAddReq) (e error) {
|
||||
func (service flowHistoryService) Add(addReq FlowHistoryAddReq) (e error) {
|
||||
var obj model.FlowHistory
|
||||
response.Copy(&obj, addReq)
|
||||
err := Service.db.Create(&obj).Error
|
||||
err := service.db.Create(&obj).Error
|
||||
e = response.CheckErr(err, "添加失败")
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 流程历史编辑
|
||||
func (Service flowHistoryService) Edit(editReq FlowHistoryEditReq) (e error) {
|
||||
func (service flowHistoryService) Edit(editReq FlowHistoryEditReq) (e error) {
|
||||
var obj model.FlowHistory
|
||||
err := Service.db.Where("id = ?", editReq.Id).Limit(1).First(&obj).Error
|
||||
err := service.db.Where("id = ?", editReq.Id).Limit(1).First(&obj).Error
|
||||
// 校验
|
||||
if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
|
||||
return
|
||||
@@ -162,15 +162,15 @@ func (Service flowHistoryService) Edit(editReq FlowHistoryEditReq) (e error) {
|
||||
}
|
||||
// 更新
|
||||
response.Copy(&obj, editReq)
|
||||
err = Service.db.Model(&obj).Updates(obj).Error
|
||||
err = service.db.Model(&obj).Updates(obj).Error
|
||||
e = response.CheckErr(err, "编辑失败")
|
||||
return
|
||||
}
|
||||
|
||||
// Del 流程历史删除
|
||||
func (Service flowHistoryService) Del(id int) (e error) {
|
||||
func (service flowHistoryService) Del(id int) (e error) {
|
||||
var obj model.FlowHistory
|
||||
err := Service.db.Where("id = ?", id).Limit(1).First(&obj).Error
|
||||
err := service.db.Where("id = ?", id).Limit(1).First(&obj).Error
|
||||
// 校验
|
||||
if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
|
||||
return
|
||||
@@ -179,7 +179,7 @@ func (Service flowHistoryService) Del(id int) (e error) {
|
||||
return
|
||||
}
|
||||
// 删除
|
||||
err = Service.db.Delete(&obj).Error
|
||||
err = service.db.Delete(&obj).Error
|
||||
e = response.CheckErr(err, "删除失败")
|
||||
return
|
||||
}
|
||||
@@ -187,8 +187,8 @@ func (Service flowHistoryService) Del(id int) (e error) {
|
||||
/**
|
||||
* 获取节点的审批用户
|
||||
*/
|
||||
func (Service flowHistoryService) GetApprover(ApplyId int) (res []admin.SystemAuthAdminResp, e error) {
|
||||
nextNodes, applyDetail, _, err := Service.GetNextNode(ApplyId)
|
||||
func (service flowHistoryService) GetApprover(ApplyId int) (res []admin.SystemAuthAdminResp, e error) {
|
||||
nextNodes, applyDetail, _, err := service.GetNextNode(ApplyId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -216,7 +216,7 @@ func (Service flowHistoryService) GetApprover(ApplyId int) (res []admin.SystemAu
|
||||
}
|
||||
adminTbName := core.DBTableName(&system_model.SystemAuthAdmin{})
|
||||
|
||||
adminModel := Service.db.Table(adminTbName+" AS admin").Where("admin.is_delete = ?", 0)
|
||||
adminModel := service.db.Table(adminTbName+" AS admin").Where("admin.is_delete = ?", 0)
|
||||
|
||||
where := map[string]interface{}{}
|
||||
if userType == 1 {
|
||||
@@ -270,8 +270,8 @@ func (Service flowHistoryService) GetApprover(ApplyId int) (res []admin.SystemAu
|
||||
}
|
||||
|
||||
// 通过审批
|
||||
func (Service flowHistoryService) Pass(pass PassReq) (e error) {
|
||||
nextNodes, applyDetail, LastHistory, err := Service.GetNextNode(pass.ApplyId)
|
||||
func (service flowHistoryService) Pass(pass PassReq) (e error) {
|
||||
nextNodes, applyDetail, LastHistory, err := service.GetNextNode(pass.ApplyId)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -336,7 +336,7 @@ func (Service flowHistoryService) Pass(pass PassReq) (e error) {
|
||||
if !isUserTask && !isEndTask {
|
||||
return errors.New("必须包含审批节点或者结束节点")
|
||||
}
|
||||
err = Service.db.Transaction(func(tx *gorm.DB) error {
|
||||
err = service.db.Transaction(func(tx *gorm.DB) error {
|
||||
// 在事务中执行一些 db 操作(从这里开始,您应该使用 'tx' 而不是 'db')
|
||||
if err := tx.Create(&flows).Error; err != nil {
|
||||
// 返回任何错误都会回滚事务
|
||||
@@ -373,11 +373,11 @@ func (Service flowHistoryService) Pass(pass PassReq) (e error) {
|
||||
}
|
||||
|
||||
// 驳回
|
||||
func (Service flowHistoryService) Back(back BackReq) (e error) {
|
||||
func (service flowHistoryService) Back(back BackReq) (e error) {
|
||||
// 得判断一下驳回的人权限
|
||||
// 获取最后一条历史记录
|
||||
var LastHistory model.FlowHistory
|
||||
err := Service.db.Where(model.FlowHistory{
|
||||
err := service.db.Where(model.FlowHistory{
|
||||
ApplyId: back.ApplyId,
|
||||
}).Limit(1).Last(&LastHistory).Error
|
||||
if err != nil {
|
||||
@@ -391,10 +391,10 @@ func (Service flowHistoryService) Back(back BackReq) (e error) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = Service.db.Transaction(func(tx *gorm.DB) error {
|
||||
err = service.db.Transaction(func(tx *gorm.DB) error {
|
||||
// 获取最早的一条历史记录,nodeType为"bpmn:startEvent"
|
||||
var FirstHistory model.FlowHistory
|
||||
err = Service.db.Where(model.FlowHistory{
|
||||
err = service.db.Where(model.FlowHistory{
|
||||
ApplyId: back.ApplyId,
|
||||
NodeType: "bpmn:startEvent",
|
||||
}).Limit(1).First(&FirstHistory).Error
|
||||
@@ -439,8 +439,8 @@ func (Service flowHistoryService) Back(back BackReq) (e error) {
|
||||
return err
|
||||
} else {
|
||||
|
||||
err = Service.db.Transaction(func(tx *gorm.DB) error {
|
||||
var historyDetail, err = Service.Detail(back.HistoryId)
|
||||
err = service.db.Transaction(func(tx *gorm.DB) error {
|
||||
var historyDetail, err = service.Detail(back.HistoryId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -476,7 +476,7 @@ func (Service flowHistoryService) Back(back BackReq) (e error) {
|
||||
/**
|
||||
* 获取下一批流程,直到审批或结束节点
|
||||
*/
|
||||
func (Service flowHistoryService) GetNextNode(ApplyId int) (res []FlowTree, apply flow_apply.FlowApplyResp, LastHistory model.FlowHistory, e error) {
|
||||
func (service flowHistoryService) GetNextNode(ApplyId int) (res []FlowTree, apply flow_apply.FlowApplyResp, LastHistory model.FlowHistory, e error) {
|
||||
var applyDetail, err = flow_apply.Service.Detail(ApplyId)
|
||||
|
||||
if e = response.CheckErr(err, "获取审批申请失败"); e != nil {
|
||||
@@ -484,7 +484,7 @@ func (Service flowHistoryService) GetNextNode(ApplyId int) (res []FlowTree, appl
|
||||
}
|
||||
// 获取最后一条历史记录
|
||||
// var LastHistory model.FlowHistory
|
||||
result := Service.db.Where(model.FlowHistory{
|
||||
result := service.db.Where(model.FlowHistory{
|
||||
ApplyId: ApplyId,
|
||||
}).Limit(1).Last(&LastHistory)
|
||||
|
||||
|
||||
@@ -32,12 +32,12 @@ type flowTemplateService struct {
|
||||
}
|
||||
|
||||
// List 流程模板列表
|
||||
func (Service flowTemplateService) List(page request.PageReq, listReq FlowTemplateListReq) (res response.PageResp, e error) {
|
||||
func (service flowTemplateService) List(page request.PageReq, listReq FlowTemplateListReq) (res response.PageResp, e error) {
|
||||
// 分页信息
|
||||
limit := page.PageSize
|
||||
offset := page.PageSize * (page.PageNo - 1)
|
||||
// 查询
|
||||
dbModel := Service.db.Model(&model.FlowTemplate{})
|
||||
dbModel := service.db.Model(&model.FlowTemplate{})
|
||||
if listReq.FlowName != "" {
|
||||
dbModel = dbModel.Where("flow_name like ?", "%"+listReq.FlowName+"%")
|
||||
}
|
||||
@@ -76,9 +76,9 @@ func (Service flowTemplateService) List(page request.PageReq, listReq FlowTempla
|
||||
}
|
||||
|
||||
// ListAll 流程模板列表
|
||||
func (Service flowTemplateService) ListAll() (res []FlowTemplateResp, e error) {
|
||||
func (service flowTemplateService) ListAll() (res []FlowTemplateResp, e error) {
|
||||
var modelList []model.FlowTemplate
|
||||
err := Service.db.Find(&modelList).Error
|
||||
err := service.db.Find(&modelList).Error
|
||||
if e = response.CheckErr(err, "获取列表失败"); e != nil {
|
||||
return
|
||||
}
|
||||
@@ -87,9 +87,9 @@ func (Service flowTemplateService) ListAll() (res []FlowTemplateResp, e error) {
|
||||
}
|
||||
|
||||
// Detail 流程模板详情
|
||||
func (Service flowTemplateService) Detail(id int) (res FlowTemplateResp, e error) {
|
||||
func (service flowTemplateService) Detail(id int) (res FlowTemplateResp, e error) {
|
||||
var obj model.FlowTemplate
|
||||
err := Service.db.Where("id = ?", id).Limit(1).First(&obj).Error
|
||||
err := service.db.Where("id = ?", id).Limit(1).First(&obj).Error
|
||||
if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
|
||||
return
|
||||
}
|
||||
@@ -101,18 +101,18 @@ func (Service flowTemplateService) Detail(id int) (res FlowTemplateResp, e error
|
||||
}
|
||||
|
||||
// Add 流程模板新增
|
||||
func (Service flowTemplateService) Add(addReq FlowTemplateAddReq) (e error) {
|
||||
func (service flowTemplateService) Add(addReq FlowTemplateAddReq) (e error) {
|
||||
var obj model.FlowTemplate
|
||||
response.Copy(&obj, addReq)
|
||||
err := Service.db.Create(&obj).Error
|
||||
err := service.db.Create(&obj).Error
|
||||
e = response.CheckErr(err, "添加失败")
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 流程模板编辑
|
||||
func (Service flowTemplateService) Edit(editReq FlowTemplateEditReq) (e error) {
|
||||
func (service flowTemplateService) Edit(editReq FlowTemplateEditReq) (e error) {
|
||||
var obj model.FlowTemplate
|
||||
err := Service.db.Where("id = ?", editReq.Id).Limit(1).First(&obj).Error
|
||||
err := service.db.Where("id = ?", editReq.Id).Limit(1).First(&obj).Error
|
||||
// 校验
|
||||
if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
|
||||
return
|
||||
@@ -122,15 +122,15 @@ func (Service flowTemplateService) Edit(editReq FlowTemplateEditReq) (e error) {
|
||||
}
|
||||
// 更新
|
||||
response.Copy(&obj, editReq)
|
||||
err = Service.db.Model(&obj).Updates(obj).Error
|
||||
err = service.db.Model(&obj).Updates(obj).Error
|
||||
e = response.CheckErr(err, "编辑失败")
|
||||
return
|
||||
}
|
||||
|
||||
// Del 流程模板删除
|
||||
func (Service flowTemplateService) Del(id int) (e error) {
|
||||
func (service flowTemplateService) Del(id int) (e error) {
|
||||
var obj model.FlowTemplate
|
||||
err := Service.db.Where("id = ?", id).Limit(1).First(&obj).Error
|
||||
err := service.db.Where("id = ?", id).Limit(1).First(&obj).Error
|
||||
// 校验
|
||||
if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
|
||||
return
|
||||
@@ -139,7 +139,7 @@ func (Service flowTemplateService) Del(id int) (e error) {
|
||||
return
|
||||
}
|
||||
// 删除
|
||||
err = Service.db.Delete(&obj).Error
|
||||
err = service.db.Delete(&obj).Error
|
||||
e = response.CheckErr(err, "删除失败")
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user