Browse Source

Update:用户添加手机号

zoie 10 months ago
parent
commit
26f0b0274c

+ 2 - 2
app/admin/controller/sys_user.go

@@ -206,9 +206,9 @@ func (e SysUser) Delete(c *gin.Context) {
 	// 设置编辑人
 	req.SetUpdateBy(userId)
 	//数据权限检查
-	//p := actions.GetPermissionFromContext(c)
+	p := actions.GetPermissionFromContext(c)
 
-	err = s.Remove(&req, nil)
+	err = s.Remove(&req, p)
 	if err != nil {
 		e.Error(500, err, err.Error())
 		return

+ 4 - 2
app/admin/model/car.go

@@ -19,8 +19,10 @@ type Car struct {
 }
 
 type CarOmit struct {
-	Id    int    `json:"id,omitempty"`    // 主键编码
-	CarNo string `json:"carNo,omitempty"` // 商品名称
+	Id     int         `json:"id,omitempty"`     // 主键编码
+	CarNo  string      `json:"carNo,omitempty"`  // 商品名称
+	UserId int         `json:"userId,omitempty"` // 仓管id
+	User   SysUserOmit `json:"user,omitempty"`
 }
 
 func (Car) TableName() string {

+ 1 - 0
app/admin/model/sys_user.go

@@ -90,6 +90,7 @@ func GetUserCacheKey(id int) string {
 type SysUserOmit struct {
 	Id       int    `json:"id,omitempty"`       // 主键编码
 	NickName string `json:"nickName,omitempty"` // 昵称
+	Phone    string `json:"phone,omitempty"`    // 昵称
 }
 
 func (SysUserOmit) TableName() string {

+ 4 - 2
app/admin/model/warehouse.go

@@ -18,8 +18,10 @@ type Warehouse struct {
 	model2.DeptBy
 }
 type WarehouseOmit struct {
-	Id   int    `json:"id,omitempty"`   // 主键编码
-	Name string `json:"name,omitempty"` // 商品名称
+	Id     int         `json:"id,omitempty"`     // 主键编码
+	Name   string      `json:"name,omitempty"`   // 商品名称
+	UserId int         `json:"userId,omitempty"` // 仓管id
+	User   SysUserOmit `json:"user,omitempty"`
 }
 
 func (Warehouse) TableName() string {

+ 6 - 4
app/admin/service/dto/sys_user.go

@@ -75,7 +75,7 @@ type SysUserInsertReq struct {
 	Username         string `json:"username" example:"username" vd:"@:len($)>0;msg:'用户名不能为空'"` // 用户名
 	Password         string `json:"password" example:"123456" vd:"@:len($)>5;msg:'密码格式不正确'"`   // 密码
 	Name             string `json:"name" vd:"@:len($)>0;msg:'姓名不能为空'"`                         // 姓名
-	Phone            string `json:"phone" swaggerignore:"true"`                                // 手机号
+	Phone            string `json:"phone"`                                                     // 电话号码
 	RoleId           int    `json:"roleId" example:"1" swaggerignore:"true"`                   // 角色id
 	DeptId           int    `json:"deptId" example:"1"`                                        // 机构id
 	Status           string `json:"status" example:"2" swaggerignore:"true"`                   // 状态 	// 货车司机绑定《道路运输从业人员从业资格证》信息
@@ -110,9 +110,10 @@ func (s *SysUserInsertReq) GetId() interface{} {
 }
 
 type SysUserUpdateReq struct {
-	Id   int    `json:"id"  comment:"用户ID"`                // 用户ID
-	Name string `json:"name" vd:"@:len($)>0;msg:'姓名不能为空'"` // 姓名
-	Type int    `json:"type" example:"2"`                  // 管理员1 仓管2 司机3
+	Id    int    `json:"id"  comment:"用户ID"`                // 用户ID
+	Name  string `json:"name" vd:"@:len($)>0;msg:'姓名不能为空'"` // 姓名
+	Phone string `json:"phone"`                             // 电话号码
+	Type  int    `json:"type" example:"2"`                  // 管理员1 仓管2 司机3
 
 	model2.ControlBy `swaggerignore:"true"`
 }
@@ -122,6 +123,7 @@ func (s *SysUserUpdateReq) Generate(userModel *model.SysUser) {
 		userModel.Id = s.Id
 	}
 	userModel.NickName = s.Name
+	userModel.Phone = s.Phone
 	userModel.Type = s.Type
 	if s.ControlBy.UpdateBy != 0 {
 		userModel.UpdateBy = s.UpdateBy

+ 0 - 2
app/admin/service/dto/waybill_logistics.go

@@ -3,14 +3,12 @@ package dto
 // 运单
 
 type WaybillLogisticsGetPageReq struct {
-	//dto.Pagination `search:"-"`
 	WaybillNo string `form:"waybillNo" search:"type:contains;column:waybill_no;table:waybill_logistics" vd:"len($)>0;msg:'订单编号不能为空'"` // 运单编号-必填
 	Status    int    `form:"status" search:"type:exact;column:status;table:waybill_logistics"`                                        // 状态
 	WaybillLogisticsOrder
 }
 
 type WaybillLogisticsOrder struct {
-	CreatedAtOrder string `search:"type:order;column:created_at;table:waybill_logistics" form:"createdAtOrder" default:"desc"`
 	IdOrder        string `search:"type:order;column:id;table:waybill_logistics" form:"idOrder" default:"desc"`
 }
 

+ 16 - 4
app/admin/service/waybill.go

@@ -566,19 +566,25 @@ func (e *Waybill) WarehouseIn(c *dto.WaybillInOutReq, p *actions.DataPermission)
 		}
 
 		if waybillModel.Status == model.WaybillStatusTruck {
+			var car model.Car
+			err = e.Orm.First(&car, waybillModel.CarId).Error
+			if err != nil {
+				e.Log.Errorf("db error: %s", err)
+				return errors.New(fmt.Sprintf("查询仓库信息失败:%s", err))
+			}
 			// 添加物流
 			Logistics := model.WaybillLogistics{
 				WaybillNo: waybillNo,
 				Status:    model.WaybillStatusTruckOut,
 				CarId:     waybillModel.CarId,
-				UserId:    p.UserId,
+				UserId:    car.UserId,
 				Lng:       lng,
 				Lat:       lat,
 				ControlBy: model2.ControlBy{
 					CreateBy: p.UserId,
 				},
 				DeptBy: model2.DeptBy{
-					DeptId: p.DeptId,
+					DeptId: car.DeptId,
 				},
 				ModelTime: model2.ModelTime{
 					CreatedAt: c.StartTime,
@@ -828,19 +834,25 @@ func (e *Waybill) CarIn(c *dto.WaybillInOutReq, p *actions.DataPermission) error
 		}
 		// 如果上一个状态为入库,则自动出库
 		if waybillModel.Status == model.WaybillStatusStorage {
+			var warehouse model.Warehouse
+			err = e.Orm.First(&warehouse, waybillModel.WarehouseId).Error
+			if err != nil {
+				e.Log.Errorf("db error: %s", err)
+				return errors.New(fmt.Sprintf("查询仓库信息失败:%s", err))
+			}
 			// 添加物流
 			Logistics := model.WaybillLogistics{
 				WaybillNo:   waybillNo,
 				Status:      model.WaybillStatusStorageOut,
 				WarehouseId: waybillModel.WarehouseId,
-				UserId:      p.UserId,
+				UserId:      warehouse.UserId,
 				Lng:         lng,
 				Lat:         lat,
 				ControlBy: model2.ControlBy{
 					CreateBy: p.UserId,
 				},
 				DeptBy: model2.DeptBy{
-					DeptId: p.DeptId,
+					DeptId: warehouse.DeptId,
 				},
 				ModelTime: model2.ModelTime{
 					CreatedAt: c.StartTime,

+ 2 - 2
app/admin/service/waybill_logistics.go

@@ -29,8 +29,8 @@ func (e *WaybillLogistics) GetPage(c *dto.WaybillLogisticsGetPageReq, list *[]mo
 			cDto.MakeCondition(c.GetNeedSearch()),
 		).
 		Where("status in (?)", status).
-		Preload("Warehouse").Preload("Car").
-		Find(list).Limit(-1).Offset(-1).
+		Preload("Warehouse.User").Preload("Car.User").
+		Find(list).
 		Count(count).Error
 	if err != nil {
 		e.Log.Errorf("db error: %s", err)