作者 yangfu

批量删除

正在显示 28 个修改的文件 包含 575 行增加28 行删除
package command
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type BatchRemoveDeviceCommand struct {
// ID列表
IdList []int `cname:"ID列表" json:"idList" valid:"Required"`
}
func (removeDeviceCommand *BatchRemoveDeviceCommand) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (removeDeviceCommand *BatchRemoveDeviceCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(removeDeviceCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(removeDeviceCommand).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
}
... ...
... ... @@ -197,6 +197,50 @@ func (deviceService *DeviceService) RemoveDevice(removeDeviceCommand *command.Re
}
}
// 移除设备服务
func (deviceService *DeviceService) BatchRemoveDevice(cmd *command.BatchRemoveDeviceCommand) (interface{}, error) {
if err := cmd.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var deviceRepository domain.DeviceRepository
if value, err := factory.CreateDeviceRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
deviceRepository = value
}
for i := range cmd.IdList {
id := cmd.IdList[i]
device, err := deviceRepository.FindOne(map[string]interface{}{"deviceId": id})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if device == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%d", id))
}
if _, err := deviceRepository.Remove(device); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return struct {
}{}, nil
}
// 更新设备服务
func (deviceService *DeviceService) UpdateDevice(cmd *command.UpdateDeviceCommand) (interface{}, error) {
if err := cmd.ValidateCommand(); err != nil {
... ...
package command
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type BatchRemoveProductCommand struct {
// ID列表
IdList []int `cname:"ID列表" json:"idList" valid:"Required"`
}
func (removeProductCommand *BatchRemoveProductCommand) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (removeProductCommand *BatchRemoveProductCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(removeProductCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(removeProductCommand).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
}
... ...
... ... @@ -190,6 +190,50 @@ func (productService *ProductService) RemoveProduct(removeProductCommand *comman
}
}
// 移除产品服务
func (productService *ProductService) BatchRemoveProduct(cmd *command.BatchRemoveProductCommand) (interface{}, error) {
if err := cmd.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var productRepository domain.ProductRepository
if value, err := factory.CreateProductRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
productRepository = value
}
for i := range cmd.IdList {
id := cmd.IdList[i]
product, err := productRepository.FindOne(map[string]interface{}{"productId": id})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if product == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%d", id))
}
if _, err := productRepository.Remove(product); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return struct {
}{}, nil
}
// 更新产品服务
func (productService *ProductService) UpdateProduct(updateProductCommand *command.UpdateProductCommand) (interface{}, error) {
if err := updateProductCommand.ValidateCommand(); err != nil {
... ...
package command
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type BatchRemoveProductCalendarCommand struct {
// ID列表
IdList []int `cname:"ID列表" json:"idList" valid:"Required"`
}
func (removeProductCalendarCommand *BatchRemoveProductCalendarCommand) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (removeProductCalendarCommand *BatchRemoveProductCalendarCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(removeProductCalendarCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(removeProductCalendarCommand).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
}
... ...
... ... @@ -196,6 +196,50 @@ func (productCalendarService *ProductCalendarService) RemoveProductCalendar(remo
}
}
// 移除工厂日历服务
func (productCalendarService *ProductCalendarService) BatchRemoveProductCalendar(cmd *command.BatchRemoveProductCalendarCommand) (interface{}, error) {
if err := cmd.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var productCalendarRepository domain.ProductCalendarRepository
if value, err := factory.CreateProductCalendarRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
productCalendarRepository = value
}
for i := range cmd.IdList {
id := cmd.IdList[i]
productCalendar, err := productCalendarRepository.FindOne(map[string]interface{}{"productCalendarId": id})
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("%d", id))
}
if _, err := productCalendarRepository.Remove(productCalendar); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return struct {
}{}, nil
}
// 更新工厂日历服务
func (productCalendarService *ProductCalendarService) UpdateProductCalendar(cmd *command.UpdateProductCalendarCommand) (interface{}, error) {
if err := cmd.ValidateCommand(); err != nil {
... ...
package command
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type BatchRemoveProductGroupCommand struct {
// ID列表
IdList []int `cname:"ID列表" json:"idList" valid:"Required"`
}
func (removeProductGroupCommand *BatchRemoveProductGroupCommand) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (removeProductGroupCommand *BatchRemoveProductGroupCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(removeProductGroupCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(removeProductGroupCommand).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
}
... ...
... ... @@ -197,6 +197,52 @@ func (productGroupService *ProductGroupService) RemoveProductGroup(removeProduct
}
}
// 移除生产班组服务
func (productGroupService *ProductGroupService) BatchRemoveProductGroup(cmd *command.BatchRemoveProductGroupCommand) (interface{}, error) {
if err := cmd.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var productGroupRepository domain.ProductGroupRepository
if value, err := factory.CreateProductGroupRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
productGroupRepository = value
}
for i := range cmd.IdList {
id := cmd.IdList[i]
productGroup, err := productGroupRepository.FindOne(map[string]interface{}{"productGroupId": id})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if productGroup == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%v", id))
}
if _, err := productGroupRepository.Remove(productGroup); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return struct {
}{}, nil
}
// 更新生产班组服务
func (productGroupService *ProductGroupService) UpdateProductGroup(cmd *command.UpdateProductGroupCommand) (interface{}, error) {
if err := cmd.ValidateCommand(); err != nil {
... ...
package command
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type BatchRemoveProductJobCommand struct {
// ID列表
IdList []int `cname:"ID列表" json:"idList" valid:"Required"`
}
func (removeProductJobCommand *BatchRemoveProductJobCommand) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (removeProductJobCommand *BatchRemoveProductJobCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(removeProductJobCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(removeProductJobCommand).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
}
... ...
... ... @@ -16,7 +16,7 @@ type CreateProductJobCommand struct {
// 工位名称
JobName string `cname:"工位名称" json:"jobName" valid:"Required"`
// 工位名称
ProcessName string `cname:"工名称" json:"processName" valid:"Required"`
ProcessName string `cname:"工名称" json:"processName" valid:"Required"`
// 车间ID
WorkshopId int `cname:"车间ID" json:"workshopId" valid:"Required"`
// 生产线ID
... ...
... ... @@ -175,6 +175,49 @@ func (productJobService *ProductJobService) RemoveProductJob(removeProductJobCom
}
}
// 移除工位服务
func (productJobService *ProductJobService) BatchRemoveProductJob(cmd *command.BatchRemoveProductJobCommand) (interface{}, error) {
if err := cmd.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var productJobRepository domain.ProductJobRepository
if value, err := factory.CreateProductJobRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
productJobRepository = value
}
for i := range cmd.IdList {
id := cmd.IdList[i]
productJob, err := productJobRepository.FindOne(map[string]interface{}{"productJobId": id})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if productJob == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%d", id))
}
if _, err := productJobRepository.Remove(productJob); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return struct {
}{}, nil
}
// 更新工位服务
func (productJobService *ProductJobService) UpdateProductJob(cmd *command.UpdateProductJobCommand) (interface{}, error) {
if err := cmd.ValidateCommand(); err != nil {
... ...
package command
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type BatchRemoveUnitConversionCommand struct {
// ID列表
IdList []int `cname:"ID列表" json:"idList" valid:"Required"`
}
func (removeUnitConversionCommand *BatchRemoveUnitConversionCommand) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (removeUnitConversionCommand *BatchRemoveUnitConversionCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(removeUnitConversionCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(removeUnitConversionCommand).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
}
... ...
... ... @@ -168,6 +168,50 @@ func (unitConversionService *UnitConversionService) RemoveUnitConversion(removeU
}
}
// 移除单位换算服务
func (unitConversionService *UnitConversionService) BatchRemoveUnitConversion(cmd *command.BatchRemoveUnitConversionCommand) (interface{}, error) {
if err := cmd.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var unitConversionRepository domain.UnitConversionRepository
if value, err := factory.CreateUnitConversionRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
unitConversionRepository = value
}
for i := range cmd.IdList {
id := cmd.IdList[i]
unitConversion, err := unitConversionRepository.FindOne(map[string]interface{}{"unitConversionId": id})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if unitConversion == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%d", id))
}
if _, err := unitConversionRepository.Remove(unitConversion); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return struct {
}{}, nil
}
// 更新单位换算服务
func (unitConversionService *UnitConversionService) UpdateUnitConversion(cmd *command.UpdateUnitConversionCommand) (interface{}, error) {
if err := cmd.ValidateCommand(); err != nil {
... ...
... ... @@ -15,7 +15,7 @@ type DeviceController struct {
func (controller *DeviceController) CreateDevice() {
deviceService := service.NewDeviceService(nil)
createDeviceCommand := &command.CreateDeviceCommand{}
controller.Unmarshal(createDeviceCommand)
Must(controller.Unmarshal(createDeviceCommand))
data, err := deviceService.CreateDevice(ParseOperateInfo(controller.BaseController), createDeviceCommand)
controller.Response(data, err)
}
... ... @@ -23,7 +23,7 @@ func (controller *DeviceController) CreateDevice() {
func (controller *DeviceController) UpdateDevice() {
deviceService := service.NewDeviceService(nil)
updateDeviceCommand := &command.UpdateDeviceCommand{}
controller.Unmarshal(updateDeviceCommand)
Must(controller.Unmarshal(updateDeviceCommand))
deviceId, _ := controller.GetInt(":deviceId")
updateDeviceCommand.DeviceId = deviceId
data, err := deviceService.UpdateDevice(updateDeviceCommand)
... ... @@ -42,13 +42,21 @@ func (controller *DeviceController) GetDevice() {
func (controller *DeviceController) RemoveDevice() {
deviceService := service.NewDeviceService(nil)
removeDeviceCommand := &command.RemoveDeviceCommand{}
controller.Unmarshal(removeDeviceCommand)
Must(controller.Unmarshal(removeDeviceCommand))
deviceId, _ := controller.GetInt(":deviceId")
removeDeviceCommand.DeviceId = deviceId
data, err := deviceService.RemoveDevice(removeDeviceCommand)
controller.Response(data, err)
}
func (controller *DeviceController) BatchRemoveDevice() {
deviceService := service.NewDeviceService(nil)
removeDeviceCommand := &command.BatchRemoveDeviceCommand{}
Must(controller.Unmarshal(removeDeviceCommand))
data, err := deviceService.BatchRemoveDevice(removeDeviceCommand)
controller.Response(data, err)
}
func (controller *DeviceController) ListDevice() {
deviceService := service.NewDeviceService(nil)
listDeviceQuery := &query.ListDeviceQuery{}
... ... @@ -63,7 +71,7 @@ func (controller *DeviceController) ListDevice() {
func (controller *DeviceController) SearchDevice() {
deviceService := service.NewDeviceService(nil)
listDeviceQuery := &query.SearchDeviceQuery{}
controller.Unmarshal(listDeviceQuery)
Must(controller.Unmarshal(listDeviceQuery))
total, data, err := deviceService.SearchDevice(ParseOperateInfo(controller.BaseController), listDeviceQuery)
ResponseGrid(controller.BaseController, total, data, err)
}
... ...
... ... @@ -14,7 +14,7 @@ type ProductCalendarController struct {
func (controller *ProductCalendarController) CreateProductCalendar() {
productCalendarService := service.NewProductCalendarService(nil)
createProductCalendarCommand := &command.CreateProductCalendarCommand{}
controller.Unmarshal(createProductCalendarCommand)
Must(controller.Unmarshal(createProductCalendarCommand))
data, err := productCalendarService.CreateProductCalendar(ParseOperateInfo(controller.BaseController), createProductCalendarCommand)
controller.Response(data, err)
}
... ... @@ -22,7 +22,7 @@ func (controller *ProductCalendarController) CreateProductCalendar() {
func (controller *ProductCalendarController) UpdateProductCalendar() {
productCalendarService := service.NewProductCalendarService(nil)
updateProductCalendarCommand := &command.UpdateProductCalendarCommand{}
controller.Unmarshal(updateProductCalendarCommand)
Must(controller.Unmarshal(updateProductCalendarCommand))
productCalendarId, _ := controller.GetInt(":productCalendarId")
updateProductCalendarCommand.ProductCalendarId = productCalendarId
data, err := productCalendarService.UpdateProductCalendar(updateProductCalendarCommand)
... ... @@ -41,13 +41,21 @@ func (controller *ProductCalendarController) GetProductCalendar() {
func (controller *ProductCalendarController) RemoveProductCalendar() {
productCalendarService := service.NewProductCalendarService(nil)
removeProductCalendarCommand := &command.RemoveProductCalendarCommand{}
controller.Unmarshal(removeProductCalendarCommand)
Must(controller.Unmarshal(removeProductCalendarCommand))
productCalendarId, _ := controller.GetInt(":productCalendarId")
removeProductCalendarCommand.ProductCalendarId = productCalendarId
data, err := productCalendarService.RemoveProductCalendar(removeProductCalendarCommand)
controller.Response(data, err)
}
func (controller *ProductCalendarController) BatchRemoveProductCalendar() {
productCalendarService := service.NewProductCalendarService(nil)
removeProductCalendarCommand := &command.BatchRemoveProductCalendarCommand{}
Must(controller.Unmarshal(removeProductCalendarCommand))
data, err := productCalendarService.BatchRemoveProductCalendar(removeProductCalendarCommand)
controller.Response(data, err)
}
func (controller *ProductCalendarController) ListProductCalendar() {
productCalendarService := service.NewProductCalendarService(nil)
listProductCalendarQuery := &query.ListProductCalendarQuery{}
... ...
... ... @@ -15,7 +15,7 @@ type ProductController struct {
func (controller *ProductController) CreateProduct() {
productService := service.NewProductService(nil)
createProductCommand := &command.CreateProductCommand{}
controller.Unmarshal(createProductCommand)
Must(controller.Unmarshal(createProductCommand))
op := ParseOperateInfo(controller.BaseController)
createProductCommand.CompanyId = op.CompanyId
createProductCommand.OrgId = op.OrgId
... ... @@ -26,7 +26,7 @@ func (controller *ProductController) CreateProduct() {
func (controller *ProductController) UpdateProduct() {
productService := service.NewProductService(nil)
updateProductCommand := &command.UpdateProductCommand{}
controller.Unmarshal(updateProductCommand)
Must(controller.Unmarshal(updateProductCommand))
productId, _ := controller.GetInt(":productId")
updateProductCommand.ProductId = productId
data, err := productService.UpdateProduct(updateProductCommand)
... ... @@ -52,6 +52,14 @@ func (controller *ProductController) RemoveProduct() {
controller.Response(data, err)
}
func (controller *ProductController) BatchRemoveProduct() {
productService := service.NewProductService(nil)
removeProductCommand := &command.BatchRemoveProductCommand{}
Must(controller.Unmarshal(removeProductCommand))
data, err := productService.BatchRemoveProduct(removeProductCommand)
controller.Response(data, err)
}
func (controller *ProductController) ListProduct() {
productService := service.NewProductService(nil)
listProductQuery := &query.ListProductQuery{}
... ... @@ -66,7 +74,7 @@ func (controller *ProductController) ListProduct() {
func (controller *ProductController) SearchProduct() {
productService := service.NewProductService(nil)
listProductQuery := &query.SearchProductQuery{}
controller.Unmarshal(listProductQuery)
Must(controller.Unmarshal(listProductQuery))
total, data, err := productService.SearchProduct(ParseOperateInfo(controller.BaseController), listProductQuery)
ResponseGrid(controller.BaseController, total, data, err)
}
... ... @@ -76,7 +84,7 @@ func (controller *ProductController) BatchAddProduct() {
cmd := &struct {
List []*domain.ImportProductItem `json:"list"`
}{}
controller.Unmarshal(cmd)
Must(controller.Unmarshal(cmd))
data, err := productService.BatchAddProduct(ParseOperateInfo(controller.BaseController), cmd.List)
controller.Response(data, err)
}
... ...
... ... @@ -14,7 +14,7 @@ type ProductGroupController struct {
func (controller *ProductGroupController) CreateProductGroup() {
productGroupService := service.NewProductGroupService(nil)
createProductGroupCommand := &command.CreateProductGroupCommand{}
controller.Unmarshal(createProductGroupCommand)
Must(controller.Unmarshal(createProductGroupCommand))
data, err := productGroupService.CreateProductGroup(ParseOperateInfo(controller.BaseController), createProductGroupCommand)
controller.Response(data, err)
}
... ... @@ -22,7 +22,7 @@ func (controller *ProductGroupController) CreateProductGroup() {
func (controller *ProductGroupController) UpdateProductGroup() {
productGroupService := service.NewProductGroupService(nil)
updateProductGroupCommand := &command.UpdateProductGroupCommand{}
controller.Unmarshal(updateProductGroupCommand)
Must(controller.Unmarshal(updateProductGroupCommand))
productGroupId, _ := controller.GetInt(":productGroupId")
updateProductGroupCommand.ProductGroupId = productGroupId
data, err := productGroupService.UpdateProductGroup(updateProductGroupCommand)
... ... @@ -48,6 +48,14 @@ func (controller *ProductGroupController) RemoveProductGroup() {
controller.Response(data, err)
}
func (controller *ProductGroupController) BatchRemoveProductGroup() {
productGroupService := service.NewProductGroupService(nil)
removeProductGroupCommand := &command.BatchRemoveProductGroupCommand{}
Must(controller.Unmarshal(removeProductGroupCommand))
data, err := productGroupService.BatchRemoveProductGroup(removeProductGroupCommand)
controller.Response(data, err)
}
func (controller *ProductGroupController) ListProductGroup() {
productGroupService := service.NewProductGroupService(nil)
listProductGroupQuery := &query.ListProductGroupQuery{}
... ... @@ -62,7 +70,7 @@ func (controller *ProductGroupController) ListProductGroup() {
func (controller *ProductGroupController) SearchProductGroup() {
productGroupService := service.NewProductGroupService(nil)
listProductGroupQuery := &query.SearchProductGroupQuery{}
controller.Unmarshal(listProductGroupQuery)
Must(controller.Unmarshal(listProductGroupQuery))
total, data, err := productGroupService.SearchProductGroup(ParseOperateInfo(controller.BaseController), listProductGroupQuery)
ResponseGrid(controller.BaseController, total, data, err)
}
... ...
... ... @@ -14,7 +14,7 @@ type ProductJobController struct {
func (controller *ProductJobController) CreateProductJob() {
productJobService := service.NewProductJobService(nil)
createProductJobCommand := &command.CreateProductJobCommand{}
controller.Unmarshal(createProductJobCommand)
Must(controller.Unmarshal(createProductJobCommand))
data, err := productJobService.CreateProductJob(ParseOperateInfo(controller.BaseController), createProductJobCommand)
controller.Response(data, err)
}
... ... @@ -22,7 +22,7 @@ func (controller *ProductJobController) CreateProductJob() {
func (controller *ProductJobController) UpdateProductJob() {
productJobService := service.NewProductJobService(nil)
updateProductJobCommand := &command.UpdateProductJobCommand{}
controller.Unmarshal(updateProductJobCommand)
Must(controller.Unmarshal(updateProductJobCommand))
productJobId, _ := controller.GetInt(":productJobId")
updateProductJobCommand.ProductJobId = productJobId
data, err := productJobService.UpdateProductJob(updateProductJobCommand)
... ... @@ -48,6 +48,14 @@ func (controller *ProductJobController) RemoveProductJob() {
controller.Response(data, err)
}
func (controller *ProductJobController) BatchRemoveProductJob() {
productJobService := service.NewProductJobService(nil)
removeProductJobCommand := &command.BatchRemoveProductJobCommand{}
Must(controller.Unmarshal(removeProductJobCommand))
data, err := productJobService.BatchRemoveProductJob(removeProductJobCommand)
controller.Response(data, err)
}
func (controller *ProductJobController) ListProductJob() {
productJobService := service.NewProductJobService(nil)
listProductJobQuery := &query.ListProductJobQuery{}
... ... @@ -62,7 +70,7 @@ func (controller *ProductJobController) ListProductJob() {
func (controller *ProductJobController) SearchProductJob() {
productJobService := service.NewProductJobService(nil)
listProductJobQuery := &query.SearchProductJobQuery{}
controller.Unmarshal(listProductJobQuery)
Must(controller.Unmarshal(listProductJobQuery))
total, data, err := productJobService.SearchProductJob(ParseOperateInfo(controller.BaseController), listProductJobQuery)
ResponseGrid(controller.BaseController, total, data, err)
}
... ...
... ... @@ -14,7 +14,7 @@ type ProductLineController struct {
func (controller *ProductLineController) CreateProductLine() {
productLineService := service.NewProductLineService(nil)
createProductLineCommand := &command.CreateProductLineCommand{}
controller.Unmarshal(createProductLineCommand)
Must(controller.Unmarshal(createProductLineCommand))
data, err := productLineService.CreateProductLine(createProductLineCommand)
controller.Response(data, err)
}
... ... @@ -22,7 +22,7 @@ func (controller *ProductLineController) CreateProductLine() {
func (controller *ProductLineController) UpdateProductLine() {
productLineService := service.NewProductLineService(nil)
updateProductLineCommand := &command.UpdateProductLineCommand{}
controller.Unmarshal(updateProductLineCommand)
Must(controller.Unmarshal(updateProductLineCommand))
lineId, _ := controller.GetInt(":lineId")
updateProductLineCommand.LineId = lineId
data, err := productLineService.UpdateProductLine(updateProductLineCommand)
... ...
... ... @@ -14,7 +14,7 @@ type ProductSectionController struct {
func (controller *ProductSectionController) CreateProductSection() {
productSectionService := service.NewProductSectionService(nil)
createProductSectionCommand := &command.CreateProductSectionCommand{}
controller.Unmarshal(createProductSectionCommand)
Must(controller.Unmarshal(createProductSectionCommand))
data, err := productSectionService.CreateProductSection(createProductSectionCommand)
controller.Response(data, err)
}
... ... @@ -22,7 +22,7 @@ func (controller *ProductSectionController) CreateProductSection() {
func (controller *ProductSectionController) UpdateProductSection() {
productSectionService := service.NewProductSectionService(nil)
updateProductSectionCommand := &command.UpdateProductSectionCommand{}
controller.Unmarshal(updateProductSectionCommand)
Must(controller.Unmarshal(updateProductSectionCommand))
sectionId, _ := controller.GetInt(":sectionId")
updateProductSectionCommand.SectionId = sectionId
data, err := productSectionService.UpdateProductSection(updateProductSectionCommand)
... ...
... ... @@ -22,7 +22,7 @@ func (controller *UnitConversionController) CreateUnitConversion() {
func (controller *UnitConversionController) UpdateUnitConversion() {
unitConversionService := service.NewUnitConversionService(nil)
updateUnitConversionCommand := &command.UpdateUnitConversionCommand{}
controller.Unmarshal(updateUnitConversionCommand)
Must(controller.Unmarshal(updateUnitConversionCommand))
unitConversionId, _ := controller.GetInt(":unitConversionId")
updateUnitConversionCommand.UnitConversionId = unitConversionId
data, err := unitConversionService.UpdateUnitConversion(updateUnitConversionCommand)
... ... @@ -48,6 +48,14 @@ func (controller *UnitConversionController) RemoveUnitConversion() {
controller.Response(data, err)
}
func (controller *UnitConversionController) BatchRemoveUnitConversion() {
unitConversionService := service.NewUnitConversionService(nil)
removeUnitConversionCommand := &command.BatchRemoveUnitConversionCommand{}
Must(controller.Unmarshal(removeUnitConversionCommand))
data, err := unitConversionService.BatchRemoveUnitConversion(removeUnitConversionCommand)
controller.Response(data, err)
}
func (controller *UnitConversionController) ListUnitConversion() {
unitConversionService := service.NewUnitConversionService(nil)
listUnitConversionQuery := &query.ListUnitConversionQuery{}
... ... @@ -62,7 +70,7 @@ func (controller *UnitConversionController) ListUnitConversion() {
func (controller *UnitConversionController) SearchUnitConversion() {
unitConversionService := service.NewUnitConversionService(nil)
listUnitConversionQuery := &query.SearchUnitConversionQuery{}
controller.Unmarshal(listUnitConversionQuery)
Must(controller.Unmarshal(listUnitConversionQuery))
total, data, err := unitConversionService.SearchUnitConversion(ParseOperateInfo(controller.BaseController), listUnitConversionQuery)
ResponseGrid(controller.BaseController, total, data, err)
}
... ...
... ... @@ -14,7 +14,7 @@ type WorkshopController struct {
func (controller *WorkshopController) CreateWorkshop() {
workshopService := service.NewWorkshopService(nil)
createWorkshopCommand := &command.CreateWorkshopCommand{}
controller.Unmarshal(createWorkshopCommand)
Must(controller.Unmarshal(createWorkshopCommand))
data, err := workshopService.CreateWorkshop(ParseOperateInfo(controller.BaseController), createWorkshopCommand)
controller.Response(data, err)
}
... ... @@ -22,7 +22,7 @@ func (controller *WorkshopController) CreateWorkshop() {
func (controller *WorkshopController) UpdateWorkshop() {
workshopService := service.NewWorkshopService(nil)
updateWorkshopCommand := &command.UpdateWorkshopCommand{}
controller.Unmarshal(updateWorkshopCommand)
Must(controller.Unmarshal(updateWorkshopCommand))
workshopId, _ := controller.GetInt(":workshopId")
updateWorkshopCommand.WorkshopId = workshopId
data, err := workshopService.UpdateWorkshop(updateWorkshopCommand)
... ... @@ -62,7 +62,7 @@ func (controller *WorkshopController) ListWorkshop() {
func (controller *WorkshopController) SearchWorkshop() {
workshopService := service.NewWorkshopService(nil)
listWorkshopQuery := &query.SearchWorkshopQuery{}
controller.Unmarshal(listWorkshopQuery)
Must(controller.Unmarshal(listWorkshopQuery))
data, err := workshopService.SearchWorkshop(ParseOperateInfo(controller.BaseController), listWorkshopQuery)
controller.Response(data, err)
}
... ... @@ -70,7 +70,7 @@ func (controller *WorkshopController) SearchWorkshop() {
func (controller *WorkshopController) SelectorWorkshop() {
workshopService := service.NewWorkshopService(nil)
listWorkshopQuery := &query.SearchWorkshopQuery{}
controller.Unmarshal(listWorkshopQuery)
Must(controller.Unmarshal(listWorkshopQuery))
data, err := workshopService.SearchWorkshop(ParseOperateInfo(controller.BaseController), listWorkshopQuery)
controller.Response(data, err)
}
... ...
... ... @@ -10,6 +10,7 @@ func init() {
web.Router("/devices/:deviceId", &controllers.DeviceController{}, "Put:UpdateDevice")
web.Router("/devices/:deviceId", &controllers.DeviceController{}, "Get:GetDevice")
web.Router("/devices/:deviceId", &controllers.DeviceController{}, "Delete:RemoveDevice")
web.Router("/devices/batch-remove", &controllers.DeviceController{}, "Post:BatchRemoveDevice")
web.Router("/devices/", &controllers.DeviceController{}, "Get:ListDevice")
web.Router("/devices/search", &controllers.DeviceController{}, "Post:SearchDevice")
web.Router("/devices/batch-add", &controllers.DeviceController{}, "Post:BatchAddDevice")
... ...
... ... @@ -10,6 +10,7 @@ func init() {
web.Router("/product-calendars/:productCalendarId", &controllers.ProductCalendarController{}, "Put:UpdateProductCalendar")
web.Router("/product-calendars/:productCalendarId", &controllers.ProductCalendarController{}, "Get:GetProductCalendar")
web.Router("/product-calendars/:productCalendarId", &controllers.ProductCalendarController{}, "Delete:RemoveProductCalendar")
web.Router("/product-calendars/batch-remove", &controllers.ProductCalendarController{}, "Post:BatchRemoveProductCalendar")
web.Router("/product-calendars/", &controllers.ProductCalendarController{}, "Get:ListProductCalendar")
web.Router("/product-calendars/search", &controllers.ProductCalendarController{}, "Post:SearchProductCalendar")
... ...
... ... @@ -10,6 +10,7 @@ func init() {
web.Router("/product-groups/:productGroupId", &controllers.ProductGroupController{}, "Put:UpdateProductGroup")
web.Router("/product-groups/:productGroupId", &controllers.ProductGroupController{}, "Get:GetProductGroup")
web.Router("/product-groups/:productGroupId", &controllers.ProductGroupController{}, "Delete:RemoveProductGroup")
web.Router("/product-groups/batch-remove", &controllers.ProductGroupController{}, "Post:BatchRemoveProductGroup")
web.Router("/product-groups/", &controllers.ProductGroupController{}, "Get:ListProductGroup")
web.Router("/product-groups/search", &controllers.ProductGroupController{}, "Post:SearchProductGroup")
}
... ...
... ... @@ -10,6 +10,7 @@ func init() {
web.Router("/product-jobs/:productJobId", &controllers.ProductJobController{}, "Put:UpdateProductJob")
web.Router("/product-jobs/:productJobId", &controllers.ProductJobController{}, "Get:GetProductJob")
web.Router("/product-jobs/:productJobId", &controllers.ProductJobController{}, "Delete:RemoveProductJob")
web.Router("/product-jobs/batch-remove", &controllers.ProductJobController{}, "Post:BatchRemoveProductJob")
web.Router("/product-jobs/", &controllers.ProductJobController{}, "Get:ListProductJob")
web.Router("/product-jobs/search", &controllers.ProductJobController{}, "Post:SearchProductJob")
}
... ...
... ... @@ -10,6 +10,7 @@ func init() {
web.Router("/products/:productId", &controllers.ProductController{}, "Put:UpdateProduct")
web.Router("/products/:productId", &controllers.ProductController{}, "Get:GetProduct")
web.Router("/products/:productId", &controllers.ProductController{}, "Delete:RemoveProduct")
web.Router("/products/batch-remove", &controllers.ProductController{}, "Post:BatchRemoveProduct")
web.Router("/products/", &controllers.ProductController{}, "Get:ListProduct")
web.Router("/products/search", &controllers.ProductController{}, "Post:SearchProduct")
web.Router("/products/batch-add", &controllers.ProductController{}, "Post:BatchAddProduct")
... ...
... ... @@ -10,6 +10,7 @@ func init() {
web.Router("/unit-conversions/:unitConversionId", &controllers.UnitConversionController{}, "Put:UpdateUnitConversion")
web.Router("/unit-conversions/:unitConversionId", &controllers.UnitConversionController{}, "Get:GetUnitConversion")
web.Router("/unit-conversions/:unitConversionId", &controllers.UnitConversionController{}, "Delete:RemoveUnitConversion")
web.Router("/unit-conversions/batch-remove", &controllers.UnitConversionController{}, "Post:BatchRemoveUnitConversion")
web.Router("/unit-conversions/", &controllers.UnitConversionController{}, "Get:ListUnitConversion")
web.Router("/unit-conversions/search", &controllers.UnitConversionController{}, "Post:SearchUnitConversion")
}
... ...