Browse Source

Merge pull request '完善时间和产线数据维护的功能和解决测试出现的bug' (#111) from feature_base into develop

Reviewed-on: http://101.201.121.115:3000/leo/LAPP_GAAS_GFrame_BACKEND/pulls/111
Reviewed-by: 娄文智 <wenzhi.lou@le-it.com.cn>
pull/112/head
娄文智 3 years ago
parent
commit
1e9f842cf7
7 changed files with 92 additions and 22 deletions
  1. +1
    -1
      models/base/WorkCalendar.model.go
  2. +17
    -1
      models/base/base.go
  3. +1
    -1
      services/base/WorkCalendarLst.service.go
  4. +3
    -0
      services/base/implments/WorkCalendar.service.impl.go
  5. +18
    -11
      services/base/implments/WorkCalendarLst.service.impl.go
  6. +46
    -2
      web/controllers/base/WorkCalendarLst.rest.go
  7. +6
    -6
      web/controllers/base/base.go

+ 1
- 1
models/base/WorkCalendar.model.go View File

@ -21,7 +21,7 @@ import (
******************************************************************************/
type WorkCalendar struct {
PlantNr int `xorm:"pk int 'PlantNr'" json:"WorkCalendar-PlantNr"`
WorkCalendarNr int `xorm:"pk int 'WorkCalendarNr'" json:"WorkCalendar-WorkCalendarNr"`
WorkCalendarNr int `xorm:"pk int 'WorkCalendarNr' autoincr" json:"WorkCalendar-WorkCalendarNr"`
Descr string `xorm:"nvarchar(100) 'Descr' not null" json:"WorkCalendar-Descr"`
LastModify grmi.DateTime `xorm:"datetime 'LastModify' not null updated" json:"WorkCalendar-LastModify"`
LastUser string `xorm:"nvarchar(20) 'LastUser' not null" json:"WorkCalendar-LastUser"`


+ 17
- 1
models/base/base.go View File

@ -1,6 +1,5 @@
package base
/******************************************************************************
*
* @Struct Name : WeekModelLstInsertReq
@ -17,3 +16,20 @@ type WeekModelLstInsertReq struct {
WeekModelNr int `json:"weekModelNr"`
Records []WeekModelLst `json:"records"`
}
/******************************************************************************
*
* @Struct Name : WorkCalendarLstInsertReq
*-----------------------------------------------------------------------------
*
* @Description : WorkCalendarLstInsertReq workCalendarLst 批量插入请求体映射
*
* @Author : 张鑫
*
* @Date : 2021-04-15
*
******************************************************************************/
type WorkCalendarLstInsertReq struct {
WorkCalendarNr int `json:"workCalendarNr"`
Records []WorkCalendarLst `json:"records"`
}

+ 1
- 1
services/base/WorkCalendarLst.service.go View File

@ -117,7 +117,7 @@ type WorkCalendarLstService interface {
* @Date : 2021-03-18 23:20:31
*
******************************************************************************/
Insert(*models.Usertab, *[]model.WorkCalendarLst) error
Insert(*models.Usertab, *model.WorkCalendarLstInsertReq) error
/******************************************************************************
*
* @Function Name : Delete


+ 3
- 0
services/base/implments/WorkCalendar.service.impl.go View File

@ -161,6 +161,9 @@ func (impl *WorkCalendarServiceImplement) SelectOne(user *models.Usertab, workCa
if err != nil {
return nil, err
}
if result == nil {
return nil, grmi.NewBusinessError("不存在该条日历,请检查")
}
workCalendarLstDao := dal.NewWorkCalendarLstDAO(session, user.Pid, user.Userid)
li, err := workCalendarLstDao.SelectJoinDayModel(workCalendarNr)
if err != nil {


+ 18
- 11
services/base/implments/WorkCalendarLst.service.impl.go View File

@ -212,29 +212,36 @@ func (impl *WorkCalendarLstServiceImplement) UpdateOne(user *models.Usertab, ent
* @Reference LAPP_GAAS_GFrame_BACKEND/services/base/WorkCalendarLstService.Insert
*
******************************************************************************/
func (impl *WorkCalendarLstServiceImplement) Insert(user *models.Usertab, entities *[]model.WorkCalendarLst) error {
func (impl *WorkCalendarLstServiceImplement) Insert(user *models.Usertab, entities *model.WorkCalendarLstInsertReq) error {
grmi.Log(user, "/services/base/implments/WorkCalendarLst.service.impl.go", "InsertWorkCalendarLst", "插入多个WorkCalendarLst")
engine := db.Eloquent.Master()
session := engine.NewSession()
defer session.Close()
err := session.Begin()
if err != nil {
return err
}
dao := dal.NewWorkCalendarLstDAO(session, user.Pid, user.Userid)
for _, entity := range *entities {
record, err := dao.SelectOne(entity.WorkCalendarNr, entity.WorkDate)
if err != nil {
return err
}
if record != nil {
return grmi.NewBusinessError("已经存在相同主键的记录!")
workCalendarNr := entities.WorkCalendarNr
workCalendarLstLi := entities.Records
for _, entity := range workCalendarLstLi {
if workCalendarNr != entity.WorkCalendarNr {
return grmi.NewBusinessError("与设置的workCalendarNr不一致,请检查")
}
}
err := dao.Insert(entities)
err = dao.DeleteWhere([]grmi.Predicate{meta.WorkCalendarLst_WorkCalendarNr.NewPredicate(grmi.Equal, workCalendarNr)})
if err != nil {
session.Rollback()
return err
}
err = dao.Insert(&workCalendarLstLi)
if err != nil {
session.Rollback()
return err
}
session.Commit()
return nil
}


+ 46
- 2
web/controllers/base/WorkCalendarLst.rest.go View File

@ -294,9 +294,9 @@ func RegisterMultiWorkCalendarLst(party router.Party, httpMethod string, path st
* @Date : 2021-03-18 22:49:12
*
******************************************************************************/
func RegisterInsertWorkCalendarLst(party router.Party, path string, method func(*models.Usertab, *[]model.WorkCalendarLst) error) {
func RegisterInsertWorkCalendarLst(party router.Party, path string, method func(*models.Usertab, *model.WorkCalendarLstInsertReq) error) {
RegisterMultiWorkCalendarLst(party, "POST", path, method)
RegisterMultiInsertWorkCalendarLst(party, "POST", path, method)
}
/******************************************************************************
@ -380,3 +380,47 @@ func RegisterUpdateWorkCalendarLst(party router.Party, path string, method func(
RegisterMultiWorkCalendarLst(party, "PUT", path, method)
}
/******************************************************************************
*
* @Function Name : RegisterMultiInsertWorkCalendarLst
*-----------------------------------------------------------------------------
*
* @Description : 为一个处理插入多条WorkCalendarLst的方法注册路由
*
* @Function Parameters : 路由分组
*
* @Function Parameters : HTTP方法
*
* @Function Parameters : 路径
*
* @Function Parameters : 实际处理请求的方法
*
* @Author : 张鑫
*
* @Date : 2021-04-15
*
******************************************************************************/
func RegisterMultiInsertWorkCalendarLst(party router.Party, httpMethod string, path string, method func(*models.Usertab, *model.WorkCalendarLstInsertReq) error) {
party.Handle(httpMethod, path, func(ctx iris.Context) {
user, ok := jwts.ParseToken(ctx)
if !ok {
supports.Error(ctx, iris.StatusBadRequest, supports.ParseParamsFailur, nil)
return
}
var entities model.WorkCalendarLstInsertReq
err := ctx.ReadJSON(&entities)
if err != nil {
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil)
return
}
err = method(user, &entities)
if err != nil {
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil)
return
}
supports.Ok(ctx, supports.OptionSuccess, nil)
})
}

+ 6
- 6
web/controllers/base/base.go View File

@ -660,19 +660,19 @@ func RegisterRoutes() {
// WorkCalendarLst的服务实例
var serviceOfWorkCalendarLst = svr.NewWorkCalendarLstService()
// WorkCalendarLst插入一条
RegisterInsertOneWorkCalendarLst(workcalendarlst, "/insertone", serviceOfWorkCalendarLst.InsertOne)
//RegisterInsertOneWorkCalendarLst(workcalendarlst, "/insertone", serviceOfWorkCalendarLst.InsertOne)
// WorkCalendarLst插入多条
// RegisterInsertWorkCalendarLst(workcalendarlst, "/insert", serviceOfWorkCalendarLst.Insert)
RegisterInsertWorkCalendarLst(workcalendarlst, "/insert", serviceOfWorkCalendarLst.Insert)
// WorkCalendarLst删除一条
RegisterDeleteOneWorkCalendarLst(workcalendarlst, "/deleteone", serviceOfWorkCalendarLst.DeleteOne)
//RegisterDeleteOneWorkCalendarLst(workcalendarlst, "/deleteone", serviceOfWorkCalendarLst.DeleteOne)
// WorkCalendarLst删除多条
// RegisterDeleteWorkCalendarLst(workcalendarlst, "/delete", serviceOfWorkCalendarLst.Delete)
// WorkCalendarLst查询多条
RegisterSelectWorkCalendarLst(workcalendarlst, "/query", serviceOfWorkCalendarLst.Select)
//RegisterSelectWorkCalendarLst(workcalendarlst, "/query", serviceOfWorkCalendarLst.Select)
// WorkCalendarLst查询一条
RegisterSelectOneWorkCalendarLst(workcalendarlst, "/get", serviceOfWorkCalendarLst.SelectOne)
//RegisterSelectOneWorkCalendarLst(workcalendarlst, "/get", serviceOfWorkCalendarLst.SelectOne)
// WorkCalendarLst修改一条
RegisterUpdateOneWorkCalendarLst(workcalendarlst, "/updateone", serviceOfWorkCalendarLst.UpdateOne)
//RegisterUpdateOneWorkCalendarLst(workcalendarlst, "/updateone", serviceOfWorkCalendarLst.UpdateOne)
// WorkCalendarLst修改多条
// RegisterUpdateWorkCalendarLst(workcalendarlst, "/update", serviceOfWorkCalendarLst.Update)


Loading…
Cancel
Save