处罚调整

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

@ -3,7 +3,6 @@ package biz
import ( import (
"context" "context"
"strings" "strings"
"time"
pb "moredoc/api/v1" pb "moredoc/api/v1"
"moredoc/middleware/auth" "moredoc/middleware/auth"
@ -45,24 +44,18 @@ func (s *PunishmentAPIService) CreatePunishment(ctx context.Context, req *pb.Cre
return nil, status.Errorf(codes.InvalidArgument, "请选择处罚类型") return nil, status.Errorf(codes.InvalidArgument, "请选择处罚类型")
} }
now := time.Now()
startTime := &now
if req.StartTime != nil {
startTime = req.StartTime
}
for _, userId := range req.UserId { for _, userId := range req.UserId {
if userId == 1 { if userId == 1 {
continue continue
} }
for _, typ := range req.Type { for _, typ := range req.Type {
punishment := &model.Punishment{ punishment := &model.Punishment{
UserId: userId, UserId: userId,
Type: int(typ), Type: int(typ),
Enable: req.Enable, Enable: req.Enable,
Reason: req.Reason, Reason: req.Reason,
Remark: req.Remark, Remark: req.Remark,
StartTime: startTime, EndTime: req.EndTime,
EndTime: req.EndTime,
} }
s.logger.Debug("CreatePunishment", zap.Any("punishment", punishment), zap.Any("req", req)) s.logger.Debug("CreatePunishment", zap.Any("punishment", punishment), zap.Any("req", req))
punishment.Operators = s.dbModel.MakePunishmentOperators(userClaims.UserId, typ) 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:操作信息;"` 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:惩罚原因;"` 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:惩罚备注;"` 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:惩罚结束时间,没有结束时间,则表示永久;"` 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:创建时间;"` 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:更新时间;"` UpdatedAt *time.Time `form:"updated_at" json:"updated_at,omitempty" gorm:"column:updated_at;type:datetime;comment:更新时间;"`

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

Loading…
Cancel
Save