处罚调整

dev
truthhun 10 months ago
parent b09629b117
commit 006a8f1827

File diff suppressed because it is too large Load Diff

@ -14,18 +14,17 @@ option java_package = "api.v1";
// proto
message Punishment {
google.protobuf.Timestamp start_time = 6 [ (gogoproto.stdtime) = true ];
google.protobuf.Timestamp end_time = 7 [ (gogoproto.stdtime) = true ];
google.protobuf.Timestamp created_at = 8 [ (gogoproto.stdtime) = true ];
google.protobuf.Timestamp updated_at = 9 [ (gogoproto.stdtime) = true ];
int64 id = 1;
int64 user_id = 2;
int32 type = 3;
bool enable = 4;
string operators = 5;
string remark = 10;
string reason = 11;
string username = 12;
google.protobuf.Timestamp end_time = 1 [ (gogoproto.stdtime) = true ];
google.protobuf.Timestamp created_at = 2 [ (gogoproto.stdtime) = true ];
google.protobuf.Timestamp updated_at = 3 [ (gogoproto.stdtime) = true ];
int64 id = 4;
int64 user_id = 5;
int32 type = 6;
bool enable = 7;
string operators = 8;
string remark = 9;
string reason = 10;
string username = 11;
}
message CancelPunishmentRequest { repeated int64 id = 1; }
@ -44,14 +43,13 @@ message ListPunishmentRequest {
}
message CreatePunishmentRequest {
google.protobuf.Timestamp start_time = 1 [ (gogoproto.stdtime) = true ];
google.protobuf.Timestamp end_time = 2 [ (gogoproto.stdtime) = true ];
int64 id = 3;
repeated int64 user_id = 4;
repeated int32 type = 5;
bool enable = 6;
string remark = 7;
string reason = 8;
google.protobuf.Timestamp end_time = 1 [ (gogoproto.stdtime) = true ];
int64 id = 2;
repeated int64 user_id = 3;
repeated int32 type = 4;
bool enable = 5;
string remark = 6;
string reason = 7;
}
message ListPunishmentReply {

@ -3,7 +3,6 @@ package biz
import (
"context"
"strings"
"time"
pb "moredoc/api/v1"
"moredoc/middleware/auth"
@ -45,24 +44,18 @@ func (s *PunishmentAPIService) CreatePunishment(ctx context.Context, req *pb.Cre
return nil, status.Errorf(codes.InvalidArgument, "请选择处罚类型")
}
now := time.Now()
startTime := &now
if req.StartTime != nil {
startTime = req.StartTime
}
for _, userId := range req.UserId {
if userId == 1 {
continue
}
for _, typ := range req.Type {
punishment := &model.Punishment{
UserId: userId,
Type: int(typ),
Enable: req.Enable,
Reason: req.Reason,
Remark: req.Remark,
StartTime: startTime,
EndTime: req.EndTime,
UserId: userId,
Type: int(typ),
Enable: req.Enable,
Reason: req.Reason,
Remark: req.Remark,
EndTime: req.EndTime,
}
s.logger.Debug("CreatePunishment", zap.Any("punishment", punishment), zap.Any("req", req))
punishment.Operators = s.dbModel.MakePunishmentOperators(userClaims.UserId, typ)

@ -24,7 +24,6 @@ type Punishment struct {
Operators string `form:"operators" json:"operators,omitempty" gorm:"column:operators;type:text;comment:操作信息;"`
Reason string `form:"reason" json:"reason,omitempty" gorm:"column:reason;type:text;comment:惩罚原因;"`
Remark string `form:"remark" json:"remark,omitempty" gorm:"column:remark;type:text;comment:惩罚备注;"`
StartTime *time.Time `form:"start_time" json:"start_time,omitempty" gorm:"column:start_time;type:datetime;comment:惩罚开始时间;"`
EndTime *time.Time `form:"end_time" json:"end_time,omitempty" gorm:"column:end_time;type:datetime;comment:惩罚结束时间,没有结束时间,则表示永久;"`
CreatedAt *time.Time `form:"created_at" json:"created_at,omitempty" gorm:"column:created_at;type:datetime;comment:创建时间;"`
UpdatedAt *time.Time `form:"updated_at" json:"updated_at,omitempty" gorm:"column:updated_at;type:datetime;comment:更新时间;"`

@ -56,7 +56,7 @@
</el-select>
</el-form-item>
<el-row :gutter="20">
<el-col :span="6">
<el-col :span="8">
<el-form-item label="是否启用处罚">
<el-switch
v-model="punishment.enable"
@ -68,22 +68,17 @@
>
</el-switch> </el-form-item
></el-col>
<el-col :span="9">
<el-form-item label="起止时间">
<el-date-picker
v-model="punishment.start_time"
type="datetime"
placeholder="请选择处罚开始时间"
>
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="9">
<el-form-item label="截止时间">
<el-col :span="16">
<el-form-item>
<template slot="label">
<ToolTip content="用户被处罚的截止时间,留空则为永久" />
</template>
<el-date-picker
v-model="punishment.end_time"
type="datetime"
placeholder="请选择处罚截止时间"
:picker-options="datetimePickerPunishmentOptions"
>
</el-date-picker>
</el-form-item>
@ -120,7 +115,10 @@
</template>
<script>
import { createPunishment, updatePunishment } from '~/api/punishment'
import { punishmentTypeOptions } from '~/utils/enum'
import {
punishmentTypeOptions,
datetimePickerPunishmentOptions,
} from '~/utils/enum'
import { listUser } from '~/api/user'
export default {
name: 'FormPunishment',
@ -135,6 +133,7 @@ export default {
data() {
return {
punishmentTypeOptions,
datetimePickerPunishmentOptions,
loading: false,
punishment: {
id: 0,

@ -0,0 +1,16 @@
<template>
<el-tooltip class="item" effect="dark" :content="content" placement="top">
<el-button size="small" type="text" icon="el-icon-info"></el-button>
</el-tooltip>
</template>
<script>
export default {
name: 'ToolTip',
props: {
content: {
type: String,
default: '',
},
},
}
</script>

@ -318,10 +318,9 @@ export default {
minWidth: 150,
type: 'html',
},
{ prop: 'end_time', label: '', width: 160, type: 'datetime' },
{ prop: 'reason', label: '', minWidth: 250 },
{ prop: 'remark', label: '', minWidth: 250 },
{ prop: 'start_time', label: '', width: 160, type: 'datetime' },
{ prop: 'end_time', label: '', width: 160, type: 'datetime' },
{ prop: 'created_at', label: '', width: 160, type: 'datetime' },
{ prop: 'updated_at', label: '', width: 160, type: 'datetime' },
]

@ -125,6 +125,75 @@ export const datetimePickerOptions = {
],
}
export const datetimePickerPunishmentOptions = {
shortcuts: [
{
text: '1',
onClick(picker) {
const end = new Date()
end.setTime(end.getTime() + 3600 * 1000)
picker.$emit('pick', end)
},
},
{
text: '12',
onClick(picker) {
const end = new Date()
end.setTime(end.getTime() + 3600 * 1000 * 12)
picker.$emit('pick', end)
},
},
{
text: '1',
onClick(picker) {
const end = new Date()
end.setTime(end.getTime() + 3600 * 1000 * 24)
picker.$emit('pick', end)
},
},
{
text: '2',
onClick(picker) {
const end = new Date()
end.setTime(end.getTime() + 3600 * 1000 * 24 * 2)
picker.$emit('pick', end)
},
},
{
text: '1',
onClick(picker) {
const end = new Date()
end.setTime(end.getTime() + 3600 * 1000 * 24 * 7)
picker.$emit('pick', end)
},
},
{
text: '1',
onClick(picker) {
const end = new Date()
end.setTime(end.getTime() + 3600 * 1000 * 24 * 30)
picker.$emit('pick', end)
},
},
{
text: '',
onClick(picker) {
const end = new Date()
end.setTime(end.getTime() + 3600 * 1000 * 24 * 183)
picker.$emit('pick', [start, end])
},
},
{
text: '1',
onClick(picker) {
const end = new Date()
end.setTime(end.getTime() + 3600 * 1000 * 24 * 365)
picker.$emit('pick', [start, end])
},
},
],
}
export const punishmentTypeOptions = [
{ label: '', value: 1, type: 'danger' },
{ label: '', value: 2, type: 'warning' },

Loading…
Cancel
Save