作者 yangfu

组织机构、数据权限

正在显示 58 个修改的文件 包含 320 行增加31 行删除
... ... @@ -23,9 +23,14 @@ type DeviceDto struct {
RiskLevel int `json:"riskLevel,omitempty"`
// 所属位置
*domain.WorkStation
// 组织名称
OrgName string `json:"orgName"`
// 权限标识 (当前登录组织匹配为true,否则false)
AuthFlag bool `json:"authFlag"`
}
func (d *DeviceDto) LoadDto(m *domain.Device) *DeviceDto {
func (d *DeviceDto) LoadDto(m *domain.Device, orgId int) *DeviceDto {
d.DeviceId = m.DeviceId
d.DeviceCode = m.DeviceCode
d.DeviceName = m.DeviceName
... ... @@ -34,5 +39,9 @@ func (d *DeviceDto) LoadDto(m *domain.Device) *DeviceDto {
d.DeviceStatus = m.DeviceStatus
d.RiskLevel = m.RiskLevel
d.WorkStation = m.WorkStation
d.AuthFlag = domain.CheckOrgAuth(orgId, m.OrgId)
if m.Ext != nil {
d.OrgName = m.Ext.OrgName
}
return d
}
... ...
... ... @@ -43,6 +43,13 @@ func (deviceService *DeviceService) CreateDevice(operateInfo *domain.OperateInfo
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
var userService = domainService.NewUserService()
var org *domain.Org
org, err = userService.Organization(operateInfo.OrgId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
newDevice := &domain.Device{
CompanyId: cmd.CompanyId,
OrgId: cmd.OrgId,
... ... @@ -56,6 +63,7 @@ func (deviceService *DeviceService) CreateDevice(operateInfo *domain.OperateInfo
RiskLevel: cmd.RiskLevel,
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
Ext: domain.NewExt(org.OrgName),
}
deviceRepository, _, _ := factory.FastPgDevice(transactionContext, 0)
... ... @@ -116,7 +124,7 @@ func (deviceService *DeviceService) GetDevice(getDeviceQuery *query.GetDeviceQue
}
result := &dto.DeviceDto{}
result.LoadDto(device)
result.LoadDto(device, 0)
return result, nil
}
}
... ... @@ -280,7 +288,17 @@ func (deviceService *DeviceService) UpdateDevice(cmd *command.UpdateDeviceComman
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "设备编号重复")
}
}
if err := device.Update(tool_funs.SimpleStructToMap(cmd)); err != nil {
var userService = domainService.NewUserService()
var org *domain.Org
org, err = userService.Organization(device.OrgId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
data := tool_funs.SimpleStructToMap(cmd)
data["orgName"] = org.OrgName
if err := device.Update(data); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if err := device.Valid(); err != nil {
... ... @@ -327,7 +345,7 @@ func (deviceService *DeviceService) SearchDevice(operateInfo *domain.OperateInfo
for i := range devices {
item := devices[i]
newJobDto := &dto.DeviceDto{}
newJobDto.LoadDto(item)
newJobDto.LoadDto(item, operateInfo.OrgId)
result = append(result, newJobDto)
}
return count, result, nil
... ...
... ... @@ -13,13 +13,21 @@ type ProductDto struct {
ProductCategory string `json:"productCategory,omitempty"`
// 产品规格
*domain.UnitQuantity
// 组织名称
OrgName string `json:"orgName"`
// 权限标识 (当前登录组织匹配为true,否则false)
AuthFlag bool `json:"authFlag"`
}
func (d *ProductDto) LoadDto(m *domain.Product) *ProductDto {
func (d *ProductDto) LoadDto(m *domain.Product, orgId int) *ProductDto {
d.ProductId = m.ProductId
d.ProductCode = m.ProductCode
d.ProductName = m.ProductName
d.ProductCategory = m.ProductCategory
d.UnitQuantity = m.ProductSpec
d.AuthFlag = domain.CheckOrgAuth(orgId, m.OrgId)
if m.Ext != nil {
d.OrgName = m.Ext.OrgName
}
return d
}
... ...
... ... @@ -46,6 +46,12 @@ func (productService *ProductService) CreateProduct(createProductCommand *comman
}
createProductCommand.ProductCode = code
}
var userService = domainService.NewUserService()
var org *domain.Org
org, err = userService.Organization(createProductCommand.OrgId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
newProduct := &domain.Product{
CompanyId: createProductCommand.CompanyId,
... ... @@ -59,6 +65,7 @@ func (productService *ProductService) CreateProduct(createProductCommand *comman
},
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
Ext: domain.NewExt(org.OrgName),
}
productRepository, _, _ := factory.FastPgProduct(transactionContext, 0)
... ... @@ -110,7 +117,7 @@ func (productService *ProductService) GetProduct(getProductQuery *query.GetProdu
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
result := &dto.ProductDto{}
return result.LoadDto(product), nil
return result.LoadDto(product, 0), nil
}
}
... ... @@ -267,7 +274,16 @@ func (productService *ProductService) UpdateProduct(updateProductCommand *comman
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "产品编号重复,请重新提交")
}
}
if err := product.Update(tool_funs.SimpleStructToMap(updateProductCommand)); err != nil {
var userService = domainService.NewUserService()
var org *domain.Org
org, err = userService.Organization(product.OrgId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
data := tool_funs.SimpleStructToMap(updateProductCommand)
data["orgName"] = org.OrgName
if err := product.Update(data); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if product, err := productRepository.Save(product); err != nil {
... ... @@ -315,7 +331,7 @@ func (productService *ProductService) SearchProduct(operateInfo *domain.OperateI
var result = make([]*dto.ProductDto, 0)
for i := range products {
newItem := &dto.ProductDto{}
result = append(result, newItem.LoadDto(products[i]))
result = append(result, newItem.LoadDto(products[i], operateInfo.OrgId))
}
return count, result, nil
... ...
... ... @@ -28,9 +28,13 @@ type ProductCalendarDto struct {
WorkTime float64 `json:"workTime,omitempty"`
// 已选择日历
CalendarSelectedString string `json:"calendarSelectedString,omitempty"`
// 组织名称
OrgName string `json:"orgName"`
// 权限标识 (当前登录组织匹配为true,否则false)
AuthFlag bool `json:"authFlag"`
}
func (d *ProductCalendarDto) LoadDto(m *domain.ProductCalendar) *ProductCalendarDto {
func (d *ProductCalendarDto) LoadDto(m *domain.ProductCalendar, orgId int) *ProductCalendarDto {
d.ProductCalendarId = m.ProductCalendarId
d.WorkStation = m.WorkStation
d.WorkOn = m.WorkOn
... ... @@ -40,5 +44,9 @@ func (d *ProductCalendarDto) LoadDto(m *domain.ProductCalendar) *ProductCalendar
d.BreakTime = m.BreakTime
d.WorkTime = m.WorkTime
d.CalendarSelectedString = strings.Join(m.CalendarSelected, "/")
d.AuthFlag = domain.CheckOrgAuth(orgId, m.OrgId)
if m.Ext != nil {
d.OrgName = m.Ext.OrgName
}
return d
}
... ...
... ... @@ -9,6 +9,7 @@ import (
"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/domainService"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils"
"time"
)
... ... @@ -53,6 +54,13 @@ func (productCalendarService *ProductCalendarService) CreateProductCalendar(oper
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "工厂日历已存在")
}
var userService = domainService.NewUserService()
var org *domain.Org
org, err = userService.Organization(cmd.OrgId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
newProductCalendar := &domain.ProductCalendar{
CompanyId: cmd.CompanyId,
OrgId: cmd.OrgId,
... ... @@ -65,6 +73,7 @@ func (productCalendarService *ProductCalendarService) CreateProductCalendar(oper
//WorkTime: cmd.WorkTime,
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
Ext: domain.NewExt(org.OrgName),
}
if err = newProductCalendar.ResetWorkTime(cmd.WorkTime); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -115,7 +124,7 @@ func (productCalendarService *ProductCalendarService) GetProductCalendar(getProd
}
result := &dto.ProductCalendarDto{}
result.LoadDto(productCalendar)
result.LoadDto(productCalendar, 0)
return result, nil
}
}
... ... @@ -281,12 +290,20 @@ func (productCalendarService *ProductCalendarService) UpdateProductCalendar(cmd
}
}
var userService = domainService.NewUserService()
var org *domain.Org
org, err = userService.Organization(productCalendar.OrgId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
productCalendar.WorkStation = workStation
productCalendar.WorkOn = cmd.WorkOn
productCalendar.CalendarSelected = cmd.CalendarSelected
productCalendar.InWorkAt = cmd.InWorkAt
productCalendar.OutWorkAt = cmd.OutWorkAt
productCalendar.BreakTime = cmd.BreakTime
productCalendar.Ext = domain.NewExt(org.OrgName)
if err = productCalendar.ResetWorkTime(cmd.WorkTime); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
... ... @@ -336,7 +353,7 @@ func (productCalendarService *ProductCalendarService) SearchProductCalendar(oper
for i := range productCalendars {
item := productCalendars[i]
newJobDto := &dto.ProductCalendarDto{}
newJobDto.LoadDto(item)
newJobDto.LoadDto(item, operateInfo.OrgId)
result = append(result, newJobDto)
}
... ...
... ... @@ -23,15 +23,13 @@ type ProductGroupDto struct {
WorkOn int `json:"workOn,omitempty"`
// 工作位置
*domain.WorkStation
// 创建时间
//CreatedAt time.Time `json:"createdAt,omitempty"`
// 更新时间
//UpdatedAt time.Time `json:"updatedAt,omitempty"`
// 删除时间
//DeletedAt time.Time `json:"deletedAt,omitempty"`
// 组织名称
OrgName string `json:"orgName"`
// 权限标识 (当前登录组织匹配为true,否则false)
AuthFlag bool `json:"authFlag"`
}
func (d *ProductGroupDto) LoadDto(m *domain.ProductGroup) *ProductGroupDto {
func (d *ProductGroupDto) LoadDto(m *domain.ProductGroup, orgId int) *ProductGroupDto {
d.ProductGroupId = m.ProductGroupId
d.GroupName = m.GroupName
d.GroupLeader = m.GroupLeader.UserName
... ... @@ -42,5 +40,9 @@ func (d *ProductGroupDto) LoadDto(m *domain.ProductGroup) *ProductGroupDto {
d.GroupMembers = strings.Join(members, ",")
d.WorkOn = m.WorkOn
d.WorkStation = m.WorkStation
d.AuthFlag = domain.CheckOrgAuth(orgId, m.OrgId)
if m.Ext != nil {
d.OrgName = m.Ext.OrgName
}
return d
}
... ...
... ... @@ -55,6 +55,11 @@ func (productGroupService *ProductGroupService) CreateProductGroup(operateInfo *
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
var org *domain.Org
org, err = userService.Organization(operateInfo.OrgId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
newProductGroup := &domain.ProductGroup{
CompanyId: operateInfo.CompanyId,
OrgId: operateInfo.OrgId,
... ... @@ -65,6 +70,7 @@ func (productGroupService *ProductGroupService) CreateProductGroup(operateInfo *
WorkOn: cmd.WorkOn,
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
Ext: domain.NewExt(org.OrgName),
}
if group, err := productGroupRepository.FindOne(map[string]interface{}{
"groupName": cmd.GroupName,
... ... @@ -296,6 +302,13 @@ func (productGroupService *ProductGroupService) UpdateProductGroup(cmd *command.
productGroup.WorkStation = workStation
productGroup.GroupName = cmd.GroupName
var org *domain.Org
org, err = userService.Organization(productGroup.OrgId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
productGroup.Ext = domain.NewExt(org.OrgName)
if err := productGroup.Update(tool_funs.SimpleStructToMap(cmd)); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
... ... @@ -335,7 +348,7 @@ func (productGroupService *ProductGroupService) SearchProductGroup(operateInfo *
var results = make([]*dto.ProductGroupDto, 0)
for i := range productGroups {
newItem := &dto.ProductGroupDto{}
results = append(results, newItem.LoadDto(productGroups[i]))
results = append(results, newItem.LoadDto(productGroups[i], operateInfo.OrgId))
}
if err := transactionContext.CommitTransaction(); err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ...
... ... @@ -30,6 +30,12 @@ type SearchProductJobQuery struct {
LineName string `cname:"生产线名称" json:"lineName,omitempty"`
// 工段名称
SectionName string `cname:"工段名称" json:"sectionName,omitempty"`
// 车间ID
WorkshopId int `cname:"车间ID" json: workshopId,omitempty"`
// 生产线ID
LineId int `cname:"生产线ID" json:"lineId,omitempty"`
// 工段ID
SectionId int `json:"sectionId,omitempty"`
}
func (cmd *SearchProductJobQuery) Valid(validation *validation.Validation) {
... ...
... ... @@ -19,14 +19,22 @@ type UnitConversionDto struct {
ToUnitQuantity *domain.UnitQuantity `json:"toUnitQuantity,omitempty"`
// 智能称重标识 1:是 2:否
IntelligentWeighingFlag int `json:"intelligentWeighingFlag,omitempty"`
// 组织名称
OrgName string `json:"orgName"`
// 权限标识 (当前登录组织匹配为true,否则false)
AuthFlag bool `json:"authFlag"`
}
func (d *UnitConversionDto) LoadDto(m *domain.UnitConversion) *UnitConversionDto {
func (d *UnitConversionDto) LoadDto(m *domain.UnitConversion, orgId int) *UnitConversionDto {
d.UnitConversionId = m.UnitConversionId
d.WorkStation = m.WorkStation
d.Material = m.Material
d.FromUnitQuantity = m.FromUnitQuantity
d.ToUnitQuantity = m.ToUnitQuantity
d.IntelligentWeighingFlag = m.IntelligentWeighingFlag
d.AuthFlag = domain.CheckOrgAuth(orgId, m.OrgId)
if m.Ext != nil {
d.OrgName = m.Ext.OrgName
}
return d
}
... ...
... ... @@ -9,6 +9,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/unitConversion/dto"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/unitConversion/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/domainService"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils"
"time"
)
... ... @@ -41,6 +42,13 @@ func (unitConversionService *UnitConversionService) CreateUnitConversion(operate
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
var userService = domainService.NewUserService()
var org *domain.Org
org, err = userService.Organization(cmd.OrgId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
newUnitConversion := &domain.UnitConversion{
CompanyId: cmd.CompanyId,
OrgId: cmd.OrgId,
... ... @@ -51,6 +59,7 @@ func (unitConversionService *UnitConversionService) CreateUnitConversion(operate
WorkStation: workStation,
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
Ext: domain.NewExt(org.OrgName),
}
unitConversionRepository, _, _ := factory.FastPgUnitConversion(transactionContext, 0)
... ... @@ -87,7 +96,7 @@ func (unitConversionService *UnitConversionService) GetUnitConversion(getUnitCon
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
result := &dto.UnitConversionDto{}
result.LoadDto(unitConversion)
result.LoadDto(unitConversion, 0)
return result, nil
}
... ... @@ -236,11 +245,20 @@ func (unitConversionService *UnitConversionService) UpdateUnitConversion(cmd *co
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
var userService = domainService.NewUserService()
var org *domain.Org
org, err = userService.Organization(unitConversion.OrgId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
unitConversion.WorkStation = workStation
unitConversion.Material = cmd.Material
unitConversion.FromUnitQuantity = cmd.FromUnitQuantity
unitConversion.ToUnitQuantity = cmd.ToUnitQuantity
unitConversion.IntelligentWeighingFlag = cmd.IntelligentWeighingFlag
unitConversion.Ext = domain.NewExt(org.OrgName)
if err := unitConversion.Update(utils.ObjectToMap(cmd)); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
... ... @@ -285,7 +303,7 @@ func (unitConversionService *UnitConversionService) SearchUnitConversion(operate
for i := range unitConversions {
item := unitConversions[i]
newItem := &dto.UnitConversionDto{}
newItem.LoadDto(item)
newItem.LoadDto(item, operateInfo.OrgId)
result = append(result, newItem)
}
return count, result, nil
... ...
... ... @@ -14,6 +14,8 @@ type WorkshopDto struct {
WorkshopId int `json:"workshopId,omitempty"`
// 车间名称
WorkshopName string `json:"workshopName,omitempty"`
// 负责人ID
//PrincipalId int `cname:"负责人" json:"principalId" valid:"Required"`
// 负责人 (用户对象)
Principal *domain.User `json:"principal,omitempty"`
// 生产线
... ... @@ -31,5 +33,6 @@ func (dto *WorkshopDto) LoadDto(m *domain.Workshop) *WorkshopDto {
dto.WorkshopName = m.WorkshopName
dto.Principal = m.Principal
dto.ProductLines = m.GetProductLines(domain.NotDeleted)
//dto.PrincipalId = m.Principal.UserId
return dto
}
... ...
... ... @@ -104,7 +104,9 @@ func (workshopService *WorkshopService) GetWorkshop(getWorkshopQuery *query.GetW
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return workshop, nil
result := &dto.WorkshopDto{}
result.LoadDto(workshop)
return result, nil
}
}
... ... @@ -232,7 +234,9 @@ func (workshopService *WorkshopService) UpdateWorkshop(updateWorkshopCommand *co
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return workshop, nil
result := &dto.WorkshopDto{}
result.LoadDto(workshop)
return result, nil
}
}
... ...
... ... @@ -61,6 +61,8 @@ type Device struct {
DeletedAt time.Time `json:"deletedAt,omitempty"`
// 所属位置
WorkStation *WorkStation `json:"workStation,omitempty"`
// 扩展数据
Ext *Ext `json:"ext,omitempty"`
}
type DeviceRepository interface {
... ... @@ -99,6 +101,12 @@ func (device *Device) Update(data map[string]interface{}) error {
if riskLevel, ok := data["riskLevel"]; ok {
device.RiskLevel = riskLevel.(int)
}
if device.Ext == nil {
device.Ext = &Ext{}
}
if orgName, ok := data["orgName"]; ok {
device.Ext.OrgName = orgName.(string)
}
device.UpdatedAt = time.Now()
return nil
}
... ...
package domain
// 冗余附加数据
type Ext struct {
// 组织名称
OrgName string `json:"orgName,omitempty"`
}
func NewExt(orgName string) *Ext {
return &Ext{
OrgName: orgName,
}
}
... ...
... ... @@ -7,3 +7,10 @@ type Org struct {
// 组织名称
OrgName string `json:"orgName,omitempty"`
}
func CheckOrgAuth(currentOrg int, belongOrg int) bool {
if currentOrg == belongOrg {
return true
}
return false
}
... ...
... ... @@ -28,6 +28,8 @@ type Product struct {
UpdatedAt time.Time `json:"updatedAt,omitempty"`
// 删除时间
DeletedAt time.Time `json:"deletedAt,omitempty"`
// 扩展数据
Ext *Ext `json:"ext,omitempty"`
}
type ProductRepository interface {
... ... @@ -63,6 +65,12 @@ func (product *Product) Update(data map[string]interface{}) error {
if unitWeight, ok := data["unitWeight"]; ok {
product.ProductSpec.UnitWeight = unitWeight.(float64)
}
if product.Ext == nil {
product.Ext = &Ext{}
}
if orgName, ok := data["orgName"]; ok {
product.Ext.OrgName = orgName.(string)
}
product.UpdatedAt = time.Now()
return nil
}
... ...
... ... @@ -32,6 +32,8 @@ type ProductAttendanceRecord struct {
UpdatedAt time.Time `json:"updatedAt,omitempty"`
// 删除时间
DeletedAt time.Time `json:"deletedAt,omitempty"`
// 扩展数据
Ext *Ext `json:"ext,omitempty"`
}
type ProductAttendanceRecordRepository interface {
... ...
... ... @@ -33,6 +33,8 @@ type ProductCalendar struct {
UpdatedAt time.Time `json:"updatedAt,omitempty"`
// 删除时间
DeletedAt time.Time `json:"deletedAt,omitempty"`
// 扩展数据
Ext *Ext `json:"ext,omitempty"`
}
type ProductCalendarRepository interface {
... ...
... ... @@ -26,6 +26,8 @@ type ProductGroup struct {
UpdatedAt time.Time `json:"updatedAt,omitempty"`
// 删除时间
DeletedAt time.Time `json:"deletedAt,omitempty"`
// 扩展数据
Ext *Ext `json:"ext,omitempty"`
}
type ProductGroupRepository interface {
... ...
... ... @@ -24,6 +24,8 @@ type ProductJob struct {
WorkStation *WorkStation `json:"workStation,omitempty"`
// 关联设备列表
RelatedDevices []int `json:"relatedDevices,omitempty"`
// 扩展数据
Ext *Ext `json:"ext,omitempty"`
}
type ProductJobRepository interface {
... ...
... ... @@ -36,6 +36,8 @@ type ProductPlan struct {
UpdatedAt time.Time `json:"updatedAt,omitempty"`
// 删除时间
DeletedAt time.Time `json:"deletedAt,omitempty"`
// 扩展数据
Ext *Ext `json:"ext,omitempty"`
}
type ProductPlanRepository interface {
... ...
... ... @@ -24,6 +24,8 @@ type ProductRecord struct {
DeletedAt time.Time `json:"deletedAt,omitempty"`
// 生产记录信息
ProductRecordInfo *ProductRecordInfo `json:"productRecordInfo,omitempty"`
// 扩展数据
Ext *Ext `json:"ext,omitempty"`
}
type ProductRecordRepository interface {
... ...
... ... @@ -26,6 +26,8 @@ type UnitConversion struct {
UpdatedAt time.Time `json:"updatedAt,omitempty"`
// 删除时间
DeletedAt time.Time `json:"deletedAt,omitempty"`
// 扩展数据
Ext *Ext `json:"ext,omitempty"`
}
type UnitConversionRepository interface {
... ...
... ... @@ -32,6 +32,8 @@ type Workshop struct {
UpdatedAt time.Time `json:"updatedAt,omitempty"`
// 删除时间
DeletedAt time.Time `json:"deletedAt,omitempty"`
// 扩展数据
Ext *Ext `json:"ext,omitempty"`
}
type WorkshopRepository interface {
... ...
... ... @@ -31,13 +31,13 @@ func (svr *UserService) Users(id []int) ([]*domain.User, error) {
return result, nil
}
//func(svr *UserService)Organization(id int)(*domain.Org,error){
// rsp,err:= svr.internalUserService.Organization(id)
// if err!=nil{
// return nil, err
// }
// return svr.ToUser(rsp), nil
//}
func (svr *UserService) Organization(id int) (*domain.Org, error) {
rsp, err := svr.internalUserService.Organization(id)
if err != nil {
return nil, err
}
return svr.ToOrg(rsp), nil
}
func (svr *UserService) ToUser(from *models.User) *domain.User {
return &domain.User{
... ... @@ -50,6 +50,13 @@ func (svr *UserService) ToUser(from *models.User) *domain.User {
}
}
func (svr *UserService) ToOrg(from *models.Organization) *domain.Org {
return &domain.Org{
OrgId: from.OrgId,
OrgName: from.OrgName,
}
}
//func(svr *UserService) ToOrg(from *models.Organization)*domain.Org{
//
//}
... ...
... ... @@ -17,6 +17,13 @@ type PGBatchAddDeviceService struct {
func (ptr *PGBatchAddDeviceService) BatchAddDevice(opt *domain.OperateInfo, list []*domain.ImportDeviceItem) ([]interface{}, error) {
var failRows = make([]interface{}, 0)
var userService = NewUserService()
var org *domain.Org
org, err := userService.Organization(opt.OrgId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
deviceRepository, _ := repository.NewDeviceRepository(ptr.transactionContext)
_, devices, _ := deviceRepository.Find(map[string]interface{}{"companyId": opt.CompanyId, "orgId": opt.OrgId})
var mapProduct = make(map[string]*domain.Device)
... ... @@ -44,6 +51,7 @@ func (ptr *PGBatchAddDeviceService) BatchAddDevice(opt *domain.OperateInfo, list
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
WorkStation: &domain.WorkStation{},
Ext: domain.NewExt(org.OrgName),
}
if _, ok := mapProduct[newItem.DeviceCode]; !ok {
mapProduct[newItem.DeviceCode] = newItem
... ...
... ... @@ -30,6 +30,13 @@ func (ptr *PGBatchAddProductService) BatchAddProduct(opt *domain.OperateInfo, li
mapProduct[products[i].ProductCode] = products[i]
}
var userService = NewUserService()
var org *domain.Org
org, err := userService.Organization(opt.OrgId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
var generator = redis.NewProductCodeCache(opt.CompanyId)
for i := range list {
item := list[i]
... ... @@ -51,6 +58,7 @@ func (ptr *PGBatchAddProductService) BatchAddProduct(opt *domain.OperateInfo, li
},
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
Ext: domain.NewExt(org.OrgName),
}
// 存在旧数据->>覆盖
if replaceOld {
... ...
... ... @@ -35,4 +35,6 @@ type Device struct {
UpdatedAt time.Time `comment:"更新时间"`
// 删除时间
DeletedAt time.Time `pg:",soft_delete" comment:"删除时间"`
// 扩展数据
Ext *domain.Ext `comment:"扩展数据"`
}
... ...
... ... @@ -27,4 +27,6 @@ type Product struct {
UpdatedAt time.Time `comment:"更新时间"`
// 删除时间
DeletedAt time.Time `pg:",soft_delete" comment:"删除时间"`
// 扩展数据
Ext *domain.Ext `comment:"扩展数据"`
}
... ...
... ... @@ -37,4 +37,6 @@ type ProductAttendanceRecord struct {
UpdatedAt time.Time `comment:"更新时间"`
// 删除时间
DeletedAt time.Time `pg:",soft_delete" comment:"删除时间"`
// 扩展数据
Ext *domain.Ext `comment:"扩展数据"`
}
... ...
... ... @@ -33,4 +33,6 @@ type ProductCalendar struct {
UpdatedAt time.Time `comment:"更新时间"`
// 删除时间
DeletedAt time.Time `pg:",soft_delete" comment:"删除时间"`
// 扩展数据
Ext *domain.Ext `comment:"扩展数据"`
}
... ...
... ... @@ -29,4 +29,6 @@ type ProductGroup struct {
UpdatedAt time.Time `comment:"更新时间"`
// 删除时间
DeletedAt time.Time `pg:",soft_delete" comment:"删除时间"`
// 扩展数据
Ext *domain.Ext `comment:"扩展数据"`
}
... ...
... ... @@ -27,4 +27,6 @@ type ProductJob struct {
RelatedDevices []int ` comment:"关联设备列表"`
// 工序名称
ProcessName string ` comment:"工序名称"`
// 扩展数据
Ext *domain.Ext `comment:"扩展数据"`
}
... ...
... ... @@ -39,4 +39,6 @@ type ProductPlan struct {
UpdatedAt time.Time `comment:"更新时间"`
// 删除时间
DeletedAt time.Time `pg:",soft_delete" comment:"删除时间"`
// 扩展数据
Ext *domain.Ext `comment:"扩展数据"`
}
... ...
... ... @@ -27,4 +27,6 @@ type ProductRecord struct {
DeletedAt time.Time `pg:",soft_delete" comment:"删除时间"`
// 生产记录信息
ProductRecordInfo *domain.ProductRecordInfo `comment:"生产记录信息"`
// 扩展数据
Ext *domain.Ext `comment:"扩展数据"`
}
... ...
... ... @@ -29,4 +29,6 @@ type UnitConversion struct {
UpdatedAt time.Time `comment:"更新时间"`
// 删除时间
DeletedAt time.Time `pg:",soft_delete" comment:"删除时间"`
// 扩展数据
Ext *domain.Ext `comment:"扩展数据"`
}
... ...
... ... @@ -25,4 +25,6 @@ type Workshop struct {
UpdatedAt time.Time `comment:"更新时间"`
// 删除时间
DeletedAt time.Time `pg:",soft_delete" comment:"删除时间"`
// 扩展数据
Ext *domain.Ext `comment:"扩展数据"`
}
... ...
... ... @@ -21,5 +21,6 @@ func TransformToDeviceDomainModelFromPgModels(deviceModel *models.Device) (*doma
UpdatedAt: deviceModel.UpdatedAt,
DeletedAt: deviceModel.DeletedAt,
WorkStation: deviceModel.WorkStation,
Ext: deviceModel.Ext,
}, nil
}
... ...
... ... @@ -17,5 +17,6 @@ func TransformToProductDomainModelFromPgModels(productModel *models.Product) (*d
CreatedAt: productModel.CreatedAt,
UpdatedAt: productModel.UpdatedAt,
DeletedAt: productModel.DeletedAt,
Ext: productModel.Ext,
}, nil
}
... ...
... ... @@ -21,5 +21,6 @@ func TransformToProductAttendanceRecordDomainModelFromPgModels(productAttendance
CreatedAt: productAttendanceRecordModel.CreatedAt,
UpdatedAt: productAttendanceRecordModel.UpdatedAt,
DeletedAt: productAttendanceRecordModel.DeletedAt,
Ext: productAttendanceRecordModel.Ext,
}, nil
}
... ...
... ... @@ -20,5 +20,6 @@ func TransformToProductCalendarDomainModelFromPgModels(productCalendarModel *mod
CreatedAt: productCalendarModel.CreatedAt,
UpdatedAt: productCalendarModel.UpdatedAt,
DeletedAt: productCalendarModel.DeletedAt,
Ext: productCalendarModel.Ext,
}, nil
}
... ...
... ... @@ -18,5 +18,6 @@ func TransformToProductGroupDomainModelFromPgModels(productGroupModel *models.Pr
CreatedAt: productGroupModel.CreatedAt,
UpdatedAt: productGroupModel.UpdatedAt,
DeletedAt: productGroupModel.DeletedAt,
Ext: productGroupModel.Ext,
}, nil
}
... ...
... ... @@ -17,5 +17,6 @@ func TransformToProductJobDomainModelFromPgModels(productJobModel *models.Produc
WorkStation: productJobModel.WorkStation,
RelatedDevices: productJobModel.RelatedDevices,
ProcessName: productJobModel.ProcessName,
Ext: productJobModel.Ext,
}, nil
}
... ...
... ... @@ -23,5 +23,6 @@ func TransformToProductPlanDomainModelFromPgModels(productPlanModel *models.Prod
CreatedAt: productPlanModel.CreatedAt,
UpdatedAt: productPlanModel.UpdatedAt,
DeletedAt: productPlanModel.DeletedAt,
Ext: productPlanModel.Ext,
}, nil
}
... ...
... ... @@ -17,5 +17,6 @@ func TransformToProductRecordDomainModelFromPgModels(productRecordModel *models.
UpdatedAt: productRecordModel.UpdatedAt,
DeletedAt: productRecordModel.DeletedAt,
ProductRecordInfo: productRecordModel.ProductRecordInfo,
Ext: productRecordModel.Ext,
}, nil
}
... ...
... ... @@ -18,5 +18,6 @@ func TransformToUnitConversionDomainModelFromPgModels(unitConversionModel *model
CreatedAt: unitConversionModel.CreatedAt,
UpdatedAt: unitConversionModel.UpdatedAt,
DeletedAt: unitConversionModel.DeletedAt,
Ext: unitConversionModel.Ext,
}, nil
}
... ...
... ... @@ -16,5 +16,6 @@ func TransformToWorkshopDomainModelFromPgModels(workshopModel *models.Workshop)
CreatedAt: workshopModel.CreatedAt,
UpdatedAt: workshopModel.UpdatedAt,
DeletedAt: workshopModel.DeletedAt,
Ext: workshopModel.Ext,
}, nil
}
... ...
... ... @@ -40,6 +40,7 @@ func (repository *DeviceRepository) Save(device *domain.Device) (*domain.Device,
"updated_at",
"deleted_at",
"work_station",
"ext",
}
insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "device_id", "deleted_at"))
insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "device_id", "deleted_at"))
... ... @@ -64,6 +65,7 @@ func (repository *DeviceRepository) Save(device *domain.Device) (*domain.Device,
&device.UpdatedAt,
&device.DeletedAt,
&device.WorkStation,
&device.Ext,
),
fmt.Sprintf("INSERT INTO manufacture.device (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
//device.DeviceId,
... ... @@ -80,6 +82,7 @@ func (repository *DeviceRepository) Save(device *domain.Device) (*domain.Device,
device.UpdatedAt,
//device.DeletedAt,
device.WorkStation,
device.Ext,
); err != nil {
return device, err
}
... ... @@ -100,6 +103,7 @@ func (repository *DeviceRepository) Save(device *domain.Device) (*domain.Device,
&device.UpdatedAt,
&device.DeletedAt,
&device.WorkStation,
&device.Ext,
),
fmt.Sprintf("UPDATE manufacture.device SET %s WHERE device_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
device.CompanyId,
... ... @@ -114,6 +118,7 @@ func (repository *DeviceRepository) Save(device *domain.Device) (*domain.Device,
device.CreatedAt,
device.UpdatedAt,
device.WorkStation,
device.Ext,
device.Identify(),
); err != nil {
return device, err
... ...
... ... @@ -40,6 +40,7 @@ func (repository *ProductAttendanceRecordRepository) Save(productAttendanceRecor
"created_at",
"updated_at",
"deleted_at",
"ext",
}
insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields)
insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlBuildFields)
... ... @@ -70,6 +71,7 @@ func (repository *ProductAttendanceRecordRepository) Save(productAttendanceRecor
&productAttendanceRecord.CreatedAt,
&productAttendanceRecord.UpdatedAt,
&productAttendanceRecord.DeletedAt,
&productAttendanceRecord.Ext,
),
fmt.Sprintf("INSERT INTO product_attendance_records (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
productAttendanceRecord.ProductAttendanceId,
... ... @@ -86,6 +88,7 @@ func (repository *ProductAttendanceRecordRepository) Save(productAttendanceRecor
productAttendanceRecord.CreatedAt,
productAttendanceRecord.UpdatedAt,
productAttendanceRecord.DeletedAt,
productAttendanceRecord.Ext,
); err != nil {
return productAttendanceRecord, err
}
... ... @@ -106,6 +109,7 @@ func (repository *ProductAttendanceRecordRepository) Save(productAttendanceRecor
&productAttendanceRecord.CreatedAt,
&productAttendanceRecord.UpdatedAt,
&productAttendanceRecord.DeletedAt,
&productAttendanceRecord.Ext,
),
fmt.Sprintf("UPDATE product_attendance_records SET %s WHERE product_attendance_record_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
productAttendanceRecord.ProductAttendanceId,
... ... @@ -122,6 +126,7 @@ func (repository *ProductAttendanceRecordRepository) Save(productAttendanceRecor
productAttendanceRecord.CreatedAt,
productAttendanceRecord.UpdatedAt,
productAttendanceRecord.DeletedAt,
productAttendanceRecord.Ext,
productAttendanceRecord.Identify(),
); err != nil {
return productAttendanceRecord, err
... ...
... ... @@ -39,6 +39,7 @@ func (repository *ProductCalendarRepository) Save(productCalendar *domain.Produc
"created_at",
"updated_at",
"deleted_at",
"ext",
}
insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "product_calendar_id", "deleted_at"))
insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "product_calendar_id", "deleted_at"))
... ... @@ -62,6 +63,7 @@ func (repository *ProductCalendarRepository) Save(productCalendar *domain.Produc
&productCalendar.CreatedAt,
&productCalendar.UpdatedAt,
&productCalendar.DeletedAt,
&productCalendar.Ext,
),
fmt.Sprintf("INSERT INTO manufacture.product_calendar (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
productCalendar.CompanyId,
... ... @@ -75,6 +77,7 @@ func (repository *ProductCalendarRepository) Save(productCalendar *domain.Produc
productCalendar.WorkTime,
productCalendar.CreatedAt,
productCalendar.UpdatedAt,
productCalendar.Ext,
); err != nil {
return productCalendar, err
}
... ... @@ -94,6 +97,7 @@ func (repository *ProductCalendarRepository) Save(productCalendar *domain.Produc
&productCalendar.CreatedAt,
&productCalendar.UpdatedAt,
&productCalendar.DeletedAt,
&productCalendar.Ext,
),
fmt.Sprintf("UPDATE manufacture.product_calendar SET %s WHERE product_calendar_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
productCalendar.CompanyId,
... ... @@ -107,6 +111,7 @@ func (repository *ProductCalendarRepository) Save(productCalendar *domain.Produc
productCalendar.WorkTime,
productCalendar.CreatedAt,
productCalendar.UpdatedAt,
productCalendar.Ext,
productCalendar.Identify(),
); err != nil {
return productCalendar, err
... ...
... ... @@ -37,6 +37,7 @@ func (repository *ProductGroupRepository) Save(productGroup *domain.ProductGroup
"created_at",
"updated_at",
"deleted_at",
"ext",
}
insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "product_group_id", "deleted_at"))
insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "product_group_id", "deleted_at"))
... ... @@ -58,6 +59,7 @@ func (repository *ProductGroupRepository) Save(productGroup *domain.ProductGroup
&productGroup.CreatedAt,
&productGroup.UpdatedAt,
&productGroup.DeletedAt,
&productGroup.Ext,
),
fmt.Sprintf("INSERT INTO manufacture.product_group (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
productGroup.CompanyId,
... ... @@ -69,6 +71,7 @@ func (repository *ProductGroupRepository) Save(productGroup *domain.ProductGroup
productGroup.WorkStation,
productGroup.CreatedAt,
productGroup.UpdatedAt,
productGroup.Ext,
); err != nil {
return productGroup, err
}
... ... @@ -86,6 +89,7 @@ func (repository *ProductGroupRepository) Save(productGroup *domain.ProductGroup
&productGroup.CreatedAt,
&productGroup.UpdatedAt,
&productGroup.DeletedAt,
&productGroup.Ext,
),
fmt.Sprintf("UPDATE manufacture.product_group SET %s WHERE product_group_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
productGroup.CompanyId,
... ... @@ -97,6 +101,7 @@ func (repository *ProductGroupRepository) Save(productGroup *domain.ProductGroup
productGroup.WorkStation,
productGroup.CreatedAt,
productGroup.UpdatedAt,
productGroup.Ext,
productGroup.Identify(),
); err != nil {
return productGroup, err
... ...
... ... @@ -36,6 +36,7 @@ func (repository *ProductJobRepository) Save(productJob *domain.ProductJob) (*do
"work_station",
"related_devices",
"process_name",
"ext",
}
insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "product_job_id", "deleted_at"))
insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "product_job_id", "deleted_at"))
... ... @@ -56,6 +57,7 @@ func (repository *ProductJobRepository) Save(productJob *domain.ProductJob) (*do
&productJob.WorkStation,
&productJob.RelatedDevices,
&productJob.ProcessName,
&productJob.Ext,
),
fmt.Sprintf("INSERT INTO manufacture.product_job (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
productJob.CompanyId,
... ... @@ -66,6 +68,7 @@ func (repository *ProductJobRepository) Save(productJob *domain.ProductJob) (*do
productJob.WorkStation,
productJob.RelatedDevices,
productJob.ProcessName,
productJob.Ext,
); err != nil {
return productJob, err
}
... ... @@ -82,6 +85,7 @@ func (repository *ProductJobRepository) Save(productJob *domain.ProductJob) (*do
&productJob.WorkStation,
&productJob.RelatedDevices,
&productJob.ProcessName,
&productJob.Ext,
),
fmt.Sprintf("UPDATE manufacture.product_job SET %s WHERE product_job_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
productJob.CompanyId,
... ... @@ -92,6 +96,7 @@ func (repository *ProductJobRepository) Save(productJob *domain.ProductJob) (*do
productJob.WorkStation,
productJob.RelatedDevices,
productJob.ProcessName,
productJob.Ext,
productJob.Identify(),
); err != nil {
return productJob, err
... ... @@ -140,6 +145,10 @@ func (repository *ProductJobRepository) Find(queryOptions map[string]interface{}
query.SetWhereByQueryOption("company_id = ?", "companyId")
query.SetWhereByQueryOption("org_id = ?", "orgId")
query.SetWhereByQueryOption("work_station->>'workStationId'=?", "workStationId")
query.SetWhereByQueryOption("work_station->>'workshopId'='?'", "workshopId")
query.SetWhereByQueryOption("work_station->>'lineId'='?'", "lineId")
query.SetWhereByQueryOption("work_station->>'sectionId'='?'", "sectionId")
if v, ok := queryOptions["jobName"]; ok && len(v.(string)) > 0 {
query.Where(fmt.Sprintf(`job_name like '%%%v%%'`, v))
}
... ...
... ... @@ -42,6 +42,7 @@ func (repository *ProductPlanRepository) Save(productPlan *domain.ProductPlan) (
"created_at",
"updated_at",
"deleted_at",
"ext",
}
insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields)
insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlBuildFields)
... ... @@ -74,6 +75,7 @@ func (repository *ProductPlanRepository) Save(productPlan *domain.ProductPlan) (
&productPlan.CreatedAt,
&productPlan.UpdatedAt,
&productPlan.DeletedAt,
&productPlan.Ext,
),
fmt.Sprintf("INSERT INTO product_plans (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
productPlan.ProductPlanId,
... ... @@ -92,6 +94,7 @@ func (repository *ProductPlanRepository) Save(productPlan *domain.ProductPlan) (
productPlan.CreatedAt,
productPlan.UpdatedAt,
productPlan.DeletedAt,
productPlan.Ext,
); err != nil {
return productPlan, err
}
... ... @@ -114,6 +117,7 @@ func (repository *ProductPlanRepository) Save(productPlan *domain.ProductPlan) (
&productPlan.CreatedAt,
&productPlan.UpdatedAt,
&productPlan.DeletedAt,
&productPlan.Ext,
),
fmt.Sprintf("UPDATE product_plans SET %s WHERE product_plan_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
productPlan.ProductPlanId,
... ... @@ -132,6 +136,7 @@ func (repository *ProductPlanRepository) Save(productPlan *domain.ProductPlan) (
productPlan.CreatedAt,
productPlan.UpdatedAt,
productPlan.DeletedAt,
productPlan.Ext,
productPlan.Identify(),
); err != nil {
return productPlan, err
... ...
... ... @@ -36,6 +36,7 @@ func (repository *ProductRecordRepository) Save(productRecord *domain.ProductRec
"updated_at",
"deleted_at",
"product_record_info",
"ext",
}
insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields)
insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlBuildFields)
... ... @@ -62,6 +63,7 @@ func (repository *ProductRecordRepository) Save(productRecord *domain.ProductRec
&productRecord.UpdatedAt,
&productRecord.DeletedAt,
&productRecord.ProductRecordInfo,
&productRecord.Ext,
),
fmt.Sprintf("INSERT INTO product_records (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
productRecord.ProductRecordId,
... ... @@ -74,6 +76,7 @@ func (repository *ProductRecordRepository) Save(productRecord *domain.ProductRec
productRecord.UpdatedAt,
productRecord.DeletedAt,
productRecord.ProductRecordInfo,
productRecord.Ext,
); err != nil {
return productRecord, err
}
... ... @@ -90,6 +93,7 @@ func (repository *ProductRecordRepository) Save(productRecord *domain.ProductRec
&productRecord.UpdatedAt,
&productRecord.DeletedAt,
&productRecord.ProductRecordInfo,
&productRecord.Ext,
),
fmt.Sprintf("UPDATE product_records SET %s WHERE product_record_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
productRecord.ProductRecordId,
... ... @@ -102,6 +106,7 @@ func (repository *ProductRecordRepository) Save(productRecord *domain.ProductRec
productRecord.UpdatedAt,
productRecord.DeletedAt,
productRecord.ProductRecordInfo,
productRecord.Ext,
productRecord.Identify(),
); err != nil {
return productRecord, err
... ...
... ... @@ -36,6 +36,7 @@ func (repository *ProductRepository) Save(product *domain.Product) (*domain.Prod
"created_at",
"updated_at",
"deleted_at",
"ext",
}
insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "product_id", "deleted_at"))
insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "product_id", "deleted_at"))
... ... @@ -56,6 +57,7 @@ func (repository *ProductRepository) Save(product *domain.Product) (*domain.Prod
&product.CreatedAt,
&product.UpdatedAt,
&product.DeletedAt,
&product.Ext,
),
fmt.Sprintf("INSERT INTO manufacture.product (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
product.CompanyId,
... ... @@ -67,6 +69,7 @@ func (repository *ProductRepository) Save(product *domain.Product) (*domain.Prod
product.ProductSpec,
product.CreatedAt,
product.UpdatedAt,
&product.Ext,
//product.DeletedAt,
); err != nil {
return product, err
... ... @@ -84,6 +87,7 @@ func (repository *ProductRepository) Save(product *domain.Product) (*domain.Prod
&product.CreatedAt,
&product.UpdatedAt,
&product.DeletedAt,
&product.Ext,
),
fmt.Sprintf("UPDATE manufacture.product SET %s WHERE product_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
product.CompanyId,
... ... @@ -96,6 +100,7 @@ func (repository *ProductRepository) Save(product *domain.Product) (*domain.Prod
product.CreatedAt,
product.UpdatedAt,
//product.DeletedAt,
product.Ext,
product.Identify(),
); err != nil {
return product, err
... ...
... ... @@ -37,6 +37,7 @@ func (repository *UnitConversionRepository) Save(unitConversion *domain.UnitConv
"created_at",
"updated_at",
"deleted_at",
"ext",
}
insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "unit_conversion_id", "deleted_at"))
insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "unit_conversion_id", "deleted_at"))
... ... @@ -58,6 +59,7 @@ func (repository *UnitConversionRepository) Save(unitConversion *domain.UnitConv
&unitConversion.CreatedAt,
&unitConversion.UpdatedAt,
&unitConversion.DeletedAt,
&unitConversion.Ext,
),
fmt.Sprintf("INSERT INTO manufacture.unit_conversion (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
unitConversion.CompanyId,
... ... @@ -69,6 +71,7 @@ func (repository *UnitConversionRepository) Save(unitConversion *domain.UnitConv
unitConversion.IntelligentWeighingFlag,
unitConversion.CreatedAt,
unitConversion.UpdatedAt,
unitConversion.Ext,
); err != nil {
return unitConversion, err
}
... ... @@ -86,6 +89,7 @@ func (repository *UnitConversionRepository) Save(unitConversion *domain.UnitConv
&unitConversion.CreatedAt,
&unitConversion.UpdatedAt,
&unitConversion.DeletedAt,
&unitConversion.Ext,
),
fmt.Sprintf("UPDATE manufacture.unit_conversion SET %s WHERE unit_conversion_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
unitConversion.CompanyId,
... ... @@ -97,6 +101,7 @@ func (repository *UnitConversionRepository) Save(unitConversion *domain.UnitConv
unitConversion.IntelligentWeighingFlag,
unitConversion.CreatedAt,
unitConversion.UpdatedAt,
unitConversion.Ext,
unitConversion.Identify(),
); err != nil {
return unitConversion, err
... ...
... ... @@ -35,6 +35,7 @@ func (repository *WorkshopRepository) Save(workshop *domain.Workshop) (*domain.W
"created_at",
"updated_at",
"deleted_at",
"ext",
}
insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "workshop_id", "deleted_at"))
insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlbuilder.RemoveSqlFields(sqlBuildFields, "workshop_id", "deleted_at"))
... ... @@ -54,6 +55,7 @@ func (repository *WorkshopRepository) Save(workshop *domain.Workshop) (*domain.W
&workshop.CreatedAt,
&workshop.UpdatedAt,
&workshop.DeletedAt,
&workshop.Ext,
),
fmt.Sprintf("INSERT INTO manufacture.workshop (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
workshop.CompanyId,
... ... @@ -63,6 +65,7 @@ func (repository *WorkshopRepository) Save(workshop *domain.Workshop) (*domain.W
workshop.ProductLines,
workshop.CreatedAt,
workshop.UpdatedAt,
workshop.Ext,
); err != nil {
return workshop, err
}
... ... @@ -78,6 +81,7 @@ func (repository *WorkshopRepository) Save(workshop *domain.Workshop) (*domain.W
&workshop.CreatedAt,
&workshop.UpdatedAt,
&workshop.DeletedAt,
&workshop.Ext,
),
fmt.Sprintf("UPDATE manufacture.workshop SET %s WHERE workshop_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
workshop.CompanyId,
... ... @@ -87,6 +91,7 @@ func (repository *WorkshopRepository) Save(workshop *domain.Workshop) (*domain.W
workshop.ProductLines,
workshop.CreatedAt,
workshop.UpdatedAt,
workshop.Ext,
workshop.Identify(),
); err != nil {
return workshop, err
... ...