作者 yangfu

增加工厂日历

... ... @@ -2,6 +2,7 @@ package command
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils"
"reflect"
"strings"
... ... @@ -34,7 +35,15 @@ type CreateProductCalendarCommand struct {
}
func (createProductCalendarCommand *CreateProductCalendarCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
//validation.SetError("CustomValid", "未实现的自定义认证")
if err := utils.ValidWorkTime(createProductCalendarCommand.InWorkAt); err != nil {
validation.Error(err.Error())
return
}
if err := utils.ValidWorkTime(createProductCalendarCommand.OutWorkAt); err != nil {
validation.Error(err.Error())
return
}
}
func (createProductCalendarCommand *CreateProductCalendarCommand) ValidateCommand() error {
... ...
... ... @@ -14,7 +14,7 @@ type RemoveProductCalendarCommand struct {
}
func (removeProductCalendarCommand *RemoveProductCalendarCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (removeProductCalendarCommand *RemoveProductCalendarCommand) ValidateCommand() error {
... ...
... ... @@ -32,7 +32,7 @@ type UpdateProductCalendarCommand struct {
}
func (updateProductCalendarCommand *UpdateProductCalendarCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (updateProductCalendarCommand *UpdateProductCalendarCommand) ValidateCommand() error {
... ...
package dto
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain"
"strings"
)
type ProductCalendarDto struct {
// 工厂日历ID
ProductCalendarId int `json:"productCalendarId,omitempty"`
// 企业id
//CompanyId int `json:"companyId,omitempty"`
// 组织ID
//OrgId int `json:"orgId,omitempty"`
// 工作位置
*domain.WorkStation
// 上班班次 1:全天 2:白班 4:中班 8:夜班
WorkOn int `json:"workOn,omitempty"`
// 日历选择
CalendarSelected []string `json:"calendarSelected,omitempty"`
// 上岗时间
InWorkAt string `json:"inWorkAt,omitempty"`
// 下岗时间
OutWorkAt string `json:"outWorkAt,omitempty"`
// 休息时间 (单位 h)
BreakTime float64 `json:"breakTime,omitempty"`
// 工时 (单位 h)
WorkTime float64 `json:"workTime,omitempty"`
// 已选择日历
CalendarSelectedString string `json:"calendarSelectedString,omitempty"`
}
func (d *ProductCalendarDto) LoadDto(m *domain.ProductCalendar) *ProductCalendarDto {
d.ProductCalendarId = m.ProductCalendarId
d.WorkStation = m.WorkStation
d.WorkOn = m.WorkOn
d.CalendarSelected = m.CalendarSelected
d.InWorkAt = m.InWorkAt
d.OutWorkAt = m.OutWorkAt
d.BreakTime = m.BreakTime
d.WorkTime = m.WorkTime
d.CalendarSelectedString = strings.Join(m.CalendarSelected, "/")
return d
}
... ...
... ... @@ -14,7 +14,7 @@ type GetProductCalendarQuery struct {
}
func (getProductCalendarQuery *GetProductCalendarQuery) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (getProductCalendarQuery *GetProductCalendarQuery) ValidateQuery() error {
... ...
... ... @@ -16,7 +16,7 @@ type ListProductCalendarQuery struct {
}
func (listProductCalendarQuery *ListProductCalendarQuery) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (listProductCalendarQuery *ListProductCalendarQuery) ValidateQuery() error {
... ...
package query
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type SearchProductCalendarQuery struct {
// 查询偏离量
Offset int `cname:"查询偏离量" json:"offset"`
// 查询限制
Limit int `cname:"查询限制" json:"limit"`
// 当前公司
CompanyId int `cname:"当前公司" json:"companyId,omitempty" valid:"Required"`
// 当前登录的组织
OrgId int `cname:"当前登录的组织" json:"orgId,omitempty" valid:"Required"`
// 页码
PageNumber int `cname:"页码" json:"pageNumber,omitempty"`
// 页数
PageSize int `cname:"页数" json:"pageSize,omitempty"`
// 车间名称
WorkshopName string `cname:"车间名称" json:"workshopName,omitempty"`
// 生产线名称
//LineName string `cname:"生产线名称" json:"lineName,omitempty"`
// 工段名称
//SectionName string `cname:"工段名称" json:"sectionName,omitempty"`
// 班次
WorkOn int `cname:"班次" json:"workOn,omitempty"`
}
func (cmd *SearchProductCalendarQuery) Valid(validation *validation.Validation) {
cmd.Offset, cmd.Limit = domain.Pagination(cmd.PageNumber, cmd.PageSize)
}
func (cmd *SearchProductCalendarQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(cmd)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(cmd).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
... ... @@ -6,8 +6,11 @@ import (
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productCalendar/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productCalendar/dto"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/productCalendar/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils"
"time"
)
// 工厂日历服务
... ... @@ -15,8 +18,10 @@ type ProductCalendarService struct {
}
// 创建工厂日历服务
func (productCalendarService *ProductCalendarService) CreateProductCalendar(createProductCalendarCommand *command.CreateProductCalendarCommand) (interface{}, error) {
if err := createProductCalendarCommand.ValidateCommand(); err != nil {
func (productCalendarService *ProductCalendarService) CreateProductCalendar(operateInfo *domain.OperateInfo, cmd *command.CreateProductCalendarCommand) (interface{}, error) {
cmd.CompanyId = operateInfo.CompanyId
cmd.OrgId = operateInfo.OrgId
if err := cmd.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
... ... @@ -29,27 +34,42 @@ func (productCalendarService *ProductCalendarService) CreateProductCalendar(crea
defer func() {
transactionContext.RollbackTransaction()
}()
newProductCalendar := &domain.ProductCalendar{
CompanyId: createProductCalendarCommand.CompanyId,
OrgId: createProductCalendarCommand.OrgId,
//WorkshopId: createProductCalendarCommand.WorkshopId,
//LineId: createProductCalendarCommand.LineId,
//SectionId: createProductCalendarCommand.SectionId,
//WorkOn: createProductCalendarCommand.WorkOn,
CalendarSelected: createProductCalendarCommand.CalendarSelected,
InWorkAt: createProductCalendarCommand.InWorkAt,
OutWorkAt: createProductCalendarCommand.OutWorkAt,
BreakTime: createProductCalendarCommand.BreakTime,
WorkTime: createProductCalendarCommand.WorkTime,
var workStation *domain.WorkStation
_, workStation, err = factory.FastPgWorkstation(transactionContext, cmd.WorkshopId, cmd.LineId, cmd.SectionId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
var productCalendarRepository domain.ProductCalendarRepository
if value, err := factory.CreateProductCalendarRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
// 判断同一个工作位置班次下,是否已重复排班
productCalendarRepository, _, _ := factory.FastPgProductCalendar(transactionContext, 0)
if total, _, err := productCalendarRepository.Find(map[string]interface{}{
"companyId": cmd.CompanyId,
"orgId": cmd.OrgId,
"workStationId": workStation.WorkStationId,
"workOn": cmd.WorkOn,
"limit": 1,
}); err == nil && total > 0 {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "工厂日历已存在")
}
newProductCalendar := &domain.ProductCalendar{
CompanyId: cmd.CompanyId,
OrgId: cmd.OrgId,
WorkStation: workStation,
WorkOn: cmd.WorkOn,
CalendarSelected: cmd.CalendarSelected,
InWorkAt: cmd.InWorkAt,
OutWorkAt: cmd.OutWorkAt,
BreakTime: cmd.BreakTime,
//WorkTime: cmd.WorkTime,
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
}
if err = newProductCalendar.ResetWorkTime(cmd.WorkTime); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
productCalendarRepository = value
}
if productCalendar, err := productCalendarRepository.Save(newProductCalendar); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -93,7 +113,10 @@ func (productCalendarService *ProductCalendarService) GetProductCalendar(getProd
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return productCalendar, nil
result := &dto.ProductCalendarDto{}
result.LoadDto(productCalendar)
return result, nil
}
}
... ... @@ -174,8 +197,8 @@ func (productCalendarService *ProductCalendarService) RemoveProductCalendar(remo
}
// 更新工厂日历服务
func (productCalendarService *ProductCalendarService) UpdateProductCalendar(updateProductCalendarCommand *command.UpdateProductCalendarCommand) (interface{}, error) {
if err := updateProductCalendarCommand.ValidateCommand(); err != nil {
func (productCalendarService *ProductCalendarService) UpdateProductCalendar(cmd *command.UpdateProductCalendarCommand) (interface{}, error) {
if err := cmd.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
... ... @@ -189,21 +212,42 @@ func (productCalendarService *ProductCalendarService) UpdateProductCalendar(upda
transactionContext.RollbackTransaction()
}()
var productCalendarRepository domain.ProductCalendarRepository
if value, err := factory.CreateProductCalendarRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
var productCalendar *domain.ProductCalendar
productCalendarRepository, productCalendar, err = factory.FastPgProductCalendar(transactionContext, cmd.ProductCalendarId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
productCalendarRepository = value
}
productCalendar, err := productCalendarRepository.FindOne(map[string]interface{}{"productCalendarId": updateProductCalendarCommand.ProductCalendarId})
var workStation *domain.WorkStation
_, workStation, err = factory.FastPgWorkstation(transactionContext, cmd.WorkshopId, cmd.LineId, cmd.SectionId, factory.WithSetPrincipal())
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if productCalendar == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateProductCalendarCommand.ProductCalendarId)))
// 判断同一个工作位置班次下,是否已重复排班
if productCalendar.WorkOn != cmd.WorkOn || productCalendar.WorkStation.WorkStationId != workStation.WorkStationId {
if total, _, err := productCalendarRepository.Find(map[string]interface{}{
"companyId": productCalendar.CompanyId,
"orgId": productCalendar.OrgId,
"workStationId": workStation.WorkStationId,
"workOn": cmd.WorkOn,
"limit": 1,
}); err == nil && total > 0 {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "工厂日历已存在")
}
}
if err := productCalendar.Update(tool_funs.SimpleStructToMap(updateProductCalendarCommand)); err != nil {
productCalendar.WorkStation = workStation
productCalendar.WorkOn = cmd.WorkOn
productCalendar.CalendarSelected = cmd.CalendarSelected
productCalendar.InWorkAt = cmd.InWorkAt
productCalendar.OutWorkAt = cmd.OutWorkAt
productCalendar.BreakTime = cmd.BreakTime
if err = productCalendar.ResetWorkTime(cmd.WorkTime); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if err := productCalendar.Update(tool_funs.SimpleStructToMap(cmd)); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if productCalendar, err := productCalendarRepository.Save(productCalendar); err != nil {
... ... @@ -216,6 +260,45 @@ func (productCalendarService *ProductCalendarService) UpdateProductCalendar(upda
}
}
// 返回工厂日历服务列表
func (productCalendarService *ProductCalendarService) SearchProductCalendar(operateInfo *domain.OperateInfo, listProductCalendarQuery *query.SearchProductCalendarQuery) (int64, interface{}, error) {
listProductCalendarQuery.OrgId = operateInfo.OrgId
listProductCalendarQuery.CompanyId = operateInfo.CompanyId
if err := listProductCalendarQuery.ValidateQuery(); err != nil {
return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var productCalendarRepository domain.ProductCalendarRepository
productCalendarRepository, _, _ = factory.FastPgProductCalendar(transactionContext, 0)
count, productCalendars, err := productCalendarRepository.Find(utils.ObjectToMap(listProductCalendarQuery))
if err != nil {
return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
var result = make([]*dto.ProductCalendarDto, 0)
for i := range productCalendars {
item := productCalendars[i]
newJobDto := &dto.ProductCalendarDto{}
newJobDto.LoadDto(item)
result = append(result, newJobDto)
}
return count, result, nil
}
func NewProductCalendarService(options map[string]interface{}) *ProductCalendarService {
newProductCalendarService := &ProductCalendarService{}
return newProductCalendarService
... ...
package domain
import "time"
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils"
"time"
)
// 工厂日历
type ProductCalendar struct {
... ... @@ -47,62 +50,24 @@ func (productCalendar *ProductCalendar) Identify() interface{} {
}
func (productCalendar *ProductCalendar) Update(data map[string]interface{}) error {
if productCalendarId, ok := data["productCalendarId"]; ok {
productCalendar.ProductCalendarId = productCalendarId.(int)
}
if companyId, ok := data["companyId"]; ok {
productCalendar.CompanyId = companyId.(int)
}
if orgId, ok := data["orgId"]; ok {
productCalendar.OrgId = orgId.(int)
}
if workStationId, ok := data["workStationId"]; ok {
productCalendar.WorkStation.WorkStationId = workStationId.(string)
}
if workshopId, ok := data["workshopId"]; ok {
productCalendar.WorkStation.WorkshopId = workshopId.(int)
}
if workshopName, ok := data["workshopName"]; ok {
productCalendar.WorkStation.WorkshopName = workshopName.(string)
}
if lineId, ok := data["lineId"]; ok {
productCalendar.WorkStation.LineId = lineId.(int)
}
if lineName, ok := data["lineName"]; ok {
productCalendar.WorkStation.LineName = lineName.(string)
}
if sectionId, ok := data["sectionId"]; ok {
productCalendar.WorkStation.SectionId = sectionId.(int)
}
if sectionName, ok := data["sectionName"]; ok {
productCalendar.WorkStation.SectionName = sectionName.(string)
}
if workOn, ok := data["workOn"]; ok {
productCalendar.WorkOn = workOn.(int)
}
//if calendarSelected, ok := data["calendarSelected"]; ok {
// productCalendar.CalendarSelected = calendarSelected.(array)
//}
if inWorkAt, ok := data["inWorkAt"]; ok {
productCalendar.InWorkAt = inWorkAt.(string)
}
if outWorkAt, ok := data["outWorkAt"]; ok {
productCalendar.OutWorkAt = outWorkAt.(string)
}
if breakTime, ok := data["breakTime"]; ok {
productCalendar.BreakTime = breakTime.(float64)
}
if workTime, ok := data["workTime"]; ok {
productCalendar.WorkTime = workTime.(float64)
}
if createdAt, ok := data["createdAt"]; ok {
productCalendar.CreatedAt = createdAt.(time.Time)
productCalendar.UpdatedAt = time.Now()
return nil
}
func (productCalendar *ProductCalendar) ResetWorkTime(v float64) error {
if v != 0 {
productCalendar.WorkTime = v
return nil
}
if updatedAt, ok := data["updatedAt"]; ok {
productCalendar.UpdatedAt = updatedAt.(time.Time)
td, err := utils.ComputeTimeDuration(productCalendar.InWorkAt, productCalendar.OutWorkAt)
if err != nil {
return err
}
if deletedAt, ok := data["deletedAt"]; ok {
productCalendar.DeletedAt = deletedAt.(time.Time)
if td.Hours() <= productCalendar.BreakTime {
productCalendar.WorkTime = 0
return nil
}
// 工作时长 = (上班时间-下班时间)- 休息时间
productCalendar.WorkTime = td.Hours() - productCalendar.BreakTime
return nil
}
... ...
... ... @@ -18,7 +18,7 @@ type ProductCalendar struct {
// 上班班次 1:全天 2:白班 4:中班 8:夜班
WorkOn int `comment:"上班班次 1:全天 2:白班 4:中班 8:夜班"`
// 日历选择
CalendarSelected []string `comment:"日历选择" pg:",array"`
CalendarSelected []string `comment:"日历选择"`
// 上岗时间
InWorkAt string `comment:"上岗时间"`
// 下岗时间
... ...
... ... @@ -63,7 +63,7 @@ func (repository *ProductCalendarRepository) Save(productCalendar *domain.Produc
&productCalendar.UpdatedAt,
&productCalendar.DeletedAt,
),
fmt.Sprintf("INSERT INTO product_calendars (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
fmt.Sprintf("INSERT INTO manufacture.product_calendar (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
productCalendar.CompanyId,
productCalendar.OrgId,
productCalendar.WorkStation,
... ... @@ -95,7 +95,7 @@ func (repository *ProductCalendarRepository) Save(productCalendar *domain.Produc
&productCalendar.UpdatedAt,
&productCalendar.DeletedAt,
),
fmt.Sprintf("UPDATE product_calendars SET %s WHERE product_calendar_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
fmt.Sprintf("UPDATE manufacture.product_calendar SET %s WHERE product_calendar_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
productCalendar.CompanyId,
productCalendar.OrgId,
productCalendar.WorkStation,
... ... @@ -146,7 +146,14 @@ func (repository *ProductCalendarRepository) Find(queryOptions map[string]interf
var productCalendarModels []*models.ProductCalendar
productCalendars := make([]*domain.ProductCalendar, 0)
query := sqlbuilder.BuildQuery(tx.Model(&productCalendarModels), queryOptions)
query.SetOffsetAndLimit(20)
query.SetWhereByQueryOption("company_id = ?", "companyId")
query.SetWhereByQueryOption("org_id = ?", "orgId")
query.SetWhereByQueryOption("work_station->>'workStationId'=?", "workStationId")
query.SetWhereByQueryOption("work_on & ? >0", "workOn")
if v, ok := queryOptions["workshopName"]; ok && len(v.(string)) > 0 {
query.Where(fmt.Sprintf(`work_station->>'workshopName' like '%%%v%%'`, v))
}
query.SetOffsetAndLimit(domain.MaxQueryRow)
query.SetOrderDirect("product_calendar_id", "DESC")
if count, err := query.SelectAndCount(); err != nil {
return 0, productCalendars, err
... ...
... ... @@ -288,3 +288,30 @@ func ValidWorkTime(t string) error {
}
return nil
}
// 计算两个时间间隔的时间
func ComputeTimeDuration(t1, t2 string) (result time.Duration, err error) {
if err = ValidWorkTime(t1); err != nil {
return
}
if err = ValidWorkTime(t2); err != nil {
return
}
t1s := strings.Split(t1, ":")
t1sHour, _ := strconv.Atoi(t1s[0])
t1sMin, _ := strconv.Atoi(t1s[1])
t2s := strings.Split(t2, ":")
t2sHour, _ := strconv.Atoi(t2s[0])
t2sMin, _ := strconv.Atoi(t2s[1])
var t1t, t2t time.Time
if t1sHour < t2sHour {
t1t = time.Date(2006, 1, 1, t1sHour, t1sMin, 0, 0, time.Local)
t2t = time.Date(2006, 1, 1, t2sHour, t2sMin, 0, 0, time.Local)
} else {
t1t = time.Date(2006, 1, 1, t1sHour, t1sMin, 0, 0, time.Local)
t2t = time.Date(2006, 1, 2, t2sHour, t2sMin, 0, 0, time.Local)
}
ts := t2t.Sub(t1t)
return ts, nil
}
... ...
... ... @@ -3,6 +3,7 @@ package utils
import (
"github.com/stretchr/testify/assert"
"testing"
"time"
)
func TestTimeSpan(t *testing.T) {
... ... @@ -26,3 +27,28 @@ func TestTimeSpan(t *testing.T) {
}
}
}
func TestComputeTimeDuration(t *testing.T) {
assertDuration := func(s string) time.Duration {
t, _ := time.ParseDuration(s)
return t
}
inputs := []struct {
t1 string
t2 string
ts time.Duration
}{
{
"9:00", "18:00", assertDuration("9h"),
},
{
"23:00", "6:00", assertDuration("7h"),
},
}
for i := range inputs {
input := inputs[i]
out, err := ComputeTimeDuration(input.t1, input.t2)
assert.Nil(t, err)
assert.Equal(t, input.ts, out)
}
}
... ...
... ... @@ -15,7 +15,7 @@ func (controller *ProductCalendarController) CreateProductCalendar() {
productCalendarService := service.NewProductCalendarService(nil)
createProductCalendarCommand := &command.CreateProductCalendarCommand{}
controller.Unmarshal(createProductCalendarCommand)
data, err := productCalendarService.CreateProductCalendar(createProductCalendarCommand)
data, err := productCalendarService.CreateProductCalendar(ParseOperateInfo(controller.BaseController), createProductCalendarCommand)
controller.Response(data, err)
}
... ... @@ -58,3 +58,11 @@ func (controller *ProductCalendarController) ListProductCalendar() {
data, err := productCalendarService.ListProductCalendar(listProductCalendarQuery)
controller.Response(data, err)
}
func (controller *ProductCalendarController) SearchProductCalendar() {
productCalendarService := service.NewProductCalendarService(nil)
cmd := &query.SearchProductCalendarQuery{}
Must(controller.Unmarshal(cmd))
total, data, err := productCalendarService.SearchProductCalendar(ParseOperateInfo(controller.BaseController), cmd)
ResponseGrid(controller.BaseController, total, data, err)
}
... ...
... ... @@ -11,4 +11,6 @@ func init() {
web.Router("/product-calendars/:productCalendarId", &controllers.ProductCalendarController{}, "Get:GetProductCalendar")
web.Router("/product-calendars/:productCalendarId", &controllers.ProductCalendarController{}, "Delete:RemoveProductCalendar")
web.Router("/product-calendars/", &controllers.ProductCalendarController{}, "Get:ListProductCalendar")
web.Router("/product-calendars/search", &controllers.ProductCalendarController{}, "Post:SearchProductCalendar")
}
... ...