完善配送端列表头像展示
This commit is contained in:
@@ -14,21 +14,26 @@ import (
|
||||
|
||||
func scopedStaff(ctx *gin.Context, identity string, point models.DeliveryBasic) (models.StaffAccount, bool) {
|
||||
var staff models.StaffAccount
|
||||
if err := common.ActiveRecords(db()).Where("identity = ? AND gas_basic_id = ? AND delivery_basic_id = ?",
|
||||
identity, point.GasBasicID, point.ID).First(&staff).Error; err != nil {
|
||||
if err := deliveryStaffQuery(db(), point).Where("identity = ?", identity).First(&staff).Error; err != nil {
|
||||
common.RespondRecordError(ctx, err)
|
||||
return staff, false
|
||||
}
|
||||
return staff, true
|
||||
}
|
||||
|
||||
// deliveryStaffQuery 固定配送人员的气站、配送点及角色范围。
|
||||
func deliveryStaffQuery(databaseService *gorm.DB, point models.DeliveryBasic) *gorm.DB {
|
||||
return common.ActiveRecords(databaseService.Model(&models.StaffAccount{})).
|
||||
Where("gas_basic_id = ? AND delivery_basic_id = ? AND role_code = ?",
|
||||
point.GasBasicID, point.ID, "delivery")
|
||||
}
|
||||
|
||||
func ListStaff(ctx *gin.Context) {
|
||||
point, _, ok := currentScope(ctx)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
query := common.ActiveRecords(db().Model(&models.StaffAccount{})).
|
||||
Where("gas_basic_id = ? AND delivery_basic_id = ? AND role_code = ?", point.GasBasicID, point.ID, "delivery")
|
||||
query := deliveryStaffQuery(db(), point)
|
||||
listScoped(ctx, &models.StaffAccount{}, query, "staff_account.created_at desc")
|
||||
}
|
||||
|
||||
@@ -38,8 +43,7 @@ func GetStaff(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
var staff models.StaffAccount
|
||||
respondRecord(ctx, common.ActiveRecords(db()).Where("identity = ? AND gas_basic_id = ? AND delivery_basic_id = ? AND role_code = ?",
|
||||
ctx.Param("identity"), point.GasBasicID, point.ID, "delivery"), &staff)
|
||||
respondRecord(ctx, deliveryStaffQuery(db(), point).Where("identity = ?", ctx.Param("identity")), &staff)
|
||||
}
|
||||
|
||||
// GetStaffAvatar 返回当前配送点范围内配送人员的受保护头像。
|
||||
|
||||
Reference in New Issue
Block a user