diff --git a/api/v1/config.pb.go b/api/v1/config.pb.go index 1033086..8f0a6c2 100644 --- a/api/v1/config.pb.go +++ b/api/v1/config.pb.go @@ -333,6 +333,7 @@ type ConfigSystem struct { LoginBackground string `protobuf:"bytes,12,opt,name=login_background,json=loginBackground,proto3" json:"login_background,omitempty"` RecommendWords []string `protobuf:"bytes,13,rep,name=recommend_words,json=recommendWords,proto3" json:"recommend_words,omitempty"` Version string `protobuf:"bytes,14,opt,name=version,proto3" json:"version,omitempty"` + CreditName string `protobuf:"bytes,15,opt,name=credit_name,json=creditName,proto3" json:"credit_name,omitempty"` } func (m *ConfigSystem) Reset() { *m = ConfigSystem{} } @@ -466,6 +467,13 @@ func (m *ConfigSystem) GetVersion() string { return "" } +func (m *ConfigSystem) GetCreditName() string { + if m != nil { + return m.CreditName + } + return "" +} + // 底链配置项,为跳转的链接地址 type ConfigFooter struct { About string `protobuf:"bytes,1,opt,name=about,proto3" json:"about,omitempty"` @@ -1017,100 +1025,101 @@ func init() { func init() { proto.RegisterFile("api/v1/config.proto", fileDescriptor_321614cd6c9c1b8a) } var fileDescriptor_321614cd6c9c1b8a = []byte{ - // 1487 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x57, 0xcb, 0x6e, 0x1b, 0x37, - 0x17, 0xce, 0x48, 0xd6, 0x8d, 0xba, 0xd8, 0xa6, 0x2f, 0x91, 0x95, 0xfc, 0x8e, 0x33, 0x3f, 0xda, - 0x3a, 0x41, 0x61, 0xc5, 0xee, 0x65, 0xd1, 0x2e, 0x02, 0xc7, 0x71, 0xd2, 0x00, 0x59, 0xa4, 0xe3, - 0x04, 0xbd, 0x6c, 0x06, 0xd4, 0x0c, 0x25, 0x11, 0x1e, 0x91, 0x13, 0x92, 0x52, 0xac, 0x2c, 0xbb, - 0xea, 0x32, 0x40, 0x81, 0x16, 0xe8, 0xfb, 0x14, 0xe8, 0x32, 0x40, 0x37, 0xdd, 0xb5, 0x48, 0xda, - 0x07, 0x28, 0xd0, 0x07, 0x28, 0x78, 0xc8, 0x19, 0x4b, 0x32, 0x0c, 0x64, 0x37, 0xe7, 0x3b, 0x1f, - 0x0f, 0xc9, 0x73, 0xbe, 0x43, 0x72, 0xd0, 0x1a, 0x49, 0x59, 0x77, 0xb2, 0xdf, 0x8d, 0x04, 0xef, - 0xb3, 0xc1, 0x5e, 0x2a, 0x85, 0x16, 0xb8, 0x4c, 0x52, 0xb6, 0x37, 0xd9, 0xef, 0xdc, 0x18, 0x08, - 0x31, 0x48, 0x68, 0x17, 0xd0, 0xde, 0xb8, 0xdf, 0xd5, 0x6c, 0x44, 0x95, 0x26, 0xa3, 0xd4, 0x12, - 0x3b, 0xeb, 0x03, 0x31, 0x10, 0xf0, 0xd9, 0x35, 0x5f, 0x0e, 0xbd, 0xee, 0x86, 0x99, 0xd0, 0x84, - 0x73, 0xa1, 0x89, 0x66, 0x82, 0x2b, 0xe7, 0xbd, 0xb6, 0x18, 0x94, 0x8e, 0x52, 0x3d, 0xb5, 0x4e, - 0xff, 0xef, 0x02, 0x2a, 0x1f, 0xc1, 0x52, 0x70, 0x0b, 0x15, 0x58, 0xdc, 0xf6, 0x76, 0xbc, 0xdd, - 0x62, 0x50, 0x60, 0x31, 0x5e, 0x47, 0xa5, 0x84, 0xf4, 0x68, 0xd2, 0x2e, 0xec, 0x78, 0xbb, 0xb5, - 0xc0, 0x1a, 0x18, 0xa3, 0x25, 0x4e, 0x46, 0xb4, 0x5d, 0x04, 0x10, 0xbe, 0x0d, 0x73, 0x42, 0x92, - 0x31, 0x6d, 0x2f, 0x59, 0x26, 0x18, 0x78, 0x07, 0xd5, 0xd3, 0x84, 0x44, 0x74, 0x28, 0x92, 0x98, - 0xca, 0x76, 0x09, 0x7c, 0xb3, 0x10, 0xfe, 0x1f, 0x42, 0x8c, 0xa7, 0x63, 0x1d, 0xea, 0x69, 0x4a, - 0xdb, 0x65, 0x20, 0xd4, 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8, 0x8f, 0x2d, 0x2e, 0x7c, 0xfb, 0xbf, - 0x14, 0x51, 0xc3, 0xce, 0x75, 0x32, 0x55, 0x9a, 0x8e, 0xcc, 0xe0, 0x58, 0x8c, 0x08, 0xe3, 0x30, - 0x55, 0x2d, 0x70, 0x96, 0x99, 0x4a, 0x33, 0x9d, 0xd0, 0x4c, 0x44, 0x60, 0x98, 0x8d, 0x9f, 0xd2, - 0xe9, 0x0b, 0x21, 0x63, 0xe5, 0x84, 0x94, 0xdb, 0x46, 0x36, 0x31, 0x55, 0x91, 0x64, 0x50, 0x3b, - 0x37, 0xeb, 0x2c, 0x64, 0x16, 0x94, 0x88, 0x81, 0x70, 0x8a, 0x82, 0x6f, 0x53, 0xfb, 0x3e, 0x99, - 0xb0, 0x48, 0x70, 0xa7, 0xa3, 0xcc, 0xc4, 0x2b, 0xa8, 0xc8, 0xa2, 0xd4, 0x09, 0xc8, 0x7c, 0xe2, - 0xeb, 0xa8, 0x46, 0x38, 0x49, 0xa6, 0x9a, 0x45, 0x0a, 0x04, 0x54, 0x0b, 0xce, 0x01, 0xb3, 0x36, - 0xc5, 0x34, 0x05, 0x91, 0x5b, 0x19, 0xe5, 0x36, 0xbe, 0x83, 0xd6, 0x23, 0x91, 0x4e, 0xa5, 0xc9, - 0x4b, 0xa8, 0x34, 0x91, 0x3a, 0x9c, 0x52, 0x22, 0x41, 0x51, 0xb5, 0x00, 0xe7, 0xbe, 0x13, 0xe3, - 0xfa, 0x86, 0x12, 0x89, 0xbb, 0x68, 0x4d, 0xd2, 0x01, 0x53, 0x9a, 0xca, 0xb0, 0x47, 0xa2, 0xd3, - 0x81, 0x14, 0x63, 0x1e, 0x83, 0x82, 0x6a, 0x01, 0xce, 0x5c, 0xf7, 0x72, 0x0f, 0xbe, 0x85, 0x56, - 0x12, 0x31, 0x60, 0x7c, 0x96, 0xdd, 0x00, 0xf6, 0x32, 0xe0, 0x33, 0xd4, 0x0f, 0xd0, 0xb2, 0xa4, - 0x91, 0x18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3f, - 0x1e, 0x6a, 0x1c, 0xf3, 0xc9, 0x7d, 0x9a, 0x52, 0x1e, 0x9b, 0x3a, 0x65, 0xd7, 0xa5, 0x37, 0x73, - 0x5d, 0x2e, 0x9c, 0x70, 0x85, 0x8b, 0x27, 0xdc, 0x4d, 0xd4, 0x60, 0x2a, 0x64, 0x5c, 0x69, 0x92, - 0x24, 0x34, 0x76, 0x1a, 0xad, 0x33, 0xf5, 0x28, 0x83, 0x4c, 0xa3, 0x52, 0x29, 0x85, 0xcc, 0xee, - 0x5c, 0x30, 0xe0, 0xa2, 0x1b, 0xd2, 0xe8, 0xd4, 0xde, 0x53, 0xa5, 0x77, 0xbe, 0xe8, 0xec, 0x98, - 0x43, 0x6d, 0x4e, 0xcb, 0x68, 0x14, 0xbb, 0x33, 0xd4, 0x7c, 0xe2, 0x1b, 0xa8, 0xce, 0xd4, 0x79, - 0x4d, 0xac, 0xb0, 0x10, 0x53, 0x79, 0x41, 0xee, 0xa0, 0xa5, 0x63, 0x3e, 0x51, 0x78, 0x17, 0x2d, - 0x51, 0x3e, 0x51, 0xee, 0x92, 0xca, 0x73, 0x3b, 0x9b, 0x8e, 0x00, 0x18, 0xfe, 0xf7, 0x45, 0x54, - 0x32, 0x3d, 0xa9, 0xcc, 0x0b, 0x60, 0xac, 0xa8, 0x0c, 0x23, 0x31, 0xe6, 0xda, 0xbd, 0x3d, 0x6a, - 0x06, 0x39, 0x32, 0x80, 0x91, 0x44, 0x2e, 0x22, 0x4b, 0x29, 0x00, 0xa5, 0x99, 0xa1, 0x39, 0x2d, - 0xbb, 0x37, 0x1d, 0xad, 0x68, 0x69, 0x19, 0x6a, 0x69, 0xff, 0x47, 0x4d, 0x22, 0x35, 0x8b, 0x8c, - 0xe6, 0x81, 0xb5, 0x04, 0xac, 0x86, 0x03, 0x73, 0x92, 0xeb, 0x3f, 0x47, 0x2a, 0x59, 0x92, 0x03, - 0x2d, 0xe9, 0x26, 0x6a, 0xf4, 0x08, 0xe7, 0xf9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, 0xe6, 0x65, - 0x5b, 0x6f, 0xe6, 0x5b, 0x37, 0x34, 0x7f, 0x03, 0xe2, 0x2d, 0xe3, 0x66, 0xbe, 0x6f, 0x18, 0x7d, - 0x8c, 0x2a, 0x0f, 0xa9, 0x86, 0xae, 0xb8, 0x2c, 0x50, 0x63, 0xa6, 0x3f, 0x94, 0xbf, 0x0e, 0x71, - 0x5a, 0xb8, 0x91, 0xc5, 0x31, 0x7d, 0x82, 0xbf, 0x46, 0x4d, 0x9b, 0xbb, 0x13, 0xa6, 0xe9, 0x88, - 0xa4, 0x97, 0x06, 0xbb, 0x2c, 0x87, 0x57, 0x21, 0xec, 0x6a, 0x67, 0x39, 0x5f, 0x9e, 0x0d, 0x74, - 0xef, 0x93, 0x5f, 0xdf, 0x6c, 0x7b, 0xaf, 0xdf, 0x6c, 0x7b, 0x7f, 0xbe, 0xd9, 0xf6, 0x5e, 0xbd, - 0xdd, 0xbe, 0xf2, 0xfa, 0xed, 0xf6, 0x95, 0xdf, 0xdf, 0x6e, 0x5f, 0x41, 0xee, 0x57, 0xe4, 0x89, - 0xf7, 0xed, 0xea, 0x48, 0x48, 0x1a, 0x8b, 0xc8, 0x8d, 0xfd, 0x7c, 0xb2, 0xdf, 0x2b, 0x43, 0xfc, - 0x8f, 0xfe, 0x0b, 0x00, 0x00, 0xff, 0xff, 0xaf, 0x7c, 0x60, 0x72, 0xc5, 0x0c, 0x00, 0x00, + // 1503 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x57, 0x4b, 0x6f, 0x1b, 0xb7, + 0x16, 0xce, 0xe8, 0x2d, 0xea, 0x65, 0xd3, 0x8f, 0xc8, 0x4a, 0xae, 0xe3, 0xcc, 0xc5, 0xbd, 0x75, + 0x82, 0xc2, 0x8a, 0xdd, 0xc7, 0xa2, 0x5d, 0x04, 0x8e, 0xe3, 0xa4, 0x01, 0x82, 0x22, 0x1d,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6a, 0xd9, 0xb3, 0x96, + 0xae, 0xd7, 0x0b, 0x16, 0xaa, 0x31, 0x54, 0xb6, 0xec, 0x19, 0x43, 0xb3, 0xc7, 0x94, 0x8d, 0xc6, + 0x0a, 0x6a, 0x5b, 0xf6, 0xac, 0xa5, 0x53, 0x0d, 0xf5, 0x31, 0xc5, 0x85, 0x6f, 0xf7, 0xaf, 0x22, + 0x6a, 0x9a, 0xb9, 0x4e, 0x66, 0x52, 0xd1, 0x58, 0x0f, 0x0e, 0x79, 0x4c, 0x58, 0x02, 0x53, 0xd5, + 0x3d, 0x6b, 0xe9, 0xa9, 0x14, 0x53, 0x11, 0xcd, 0x44, 0x04, 0x86, 0xde, 0xf8, 0x29, 0x9d, 0xbd, + 0xe0, 0x22, 0x94, 0x56, 0x48, 0xb9, 0xad, 0x65, 0x13, 0x52, 0x19, 0x08, 0x06, 0xb5, 0xb3, 0xb3, + 0xce, 0x43, 0x7a, 0x41, 0x11, 0x1f, 0x71, 0xab, 0x28, 0xf8, 0xd6, 0xb5, 0x1f, 0x92, 0x29, 0x0b, + 0x78, 0x62, 0x75, 0x94, 0x99, 0x78, 0x05, 0x15, 0x59, 0x90, 0x5a, 0x01, 0xe9, 0x4f, 0x7c, 0x1d, + 0xd5, 0x49, 0x42, 0xa2, 0x99, 0x62, 0x81, 0x04, 0x01, 0xd5, 0xbd, 0x73, 0x40, 0xaf, 0x4d, 0x32, + 0x45, 0x41, 0xe4, 0x46, 0x46, 0xb9, 0x8d, 0xef, 0xa0, 0xf5, 0x80, 0xa7, 0x33, 0xa1, 0xf3, 0xe2, + 0x4b, 0x45, 0x84, 0xf2, 0x67, 0x94, 0x08, 0x50, 0x54, 0xdd, 0xc3, 0xb9, 0xef, 0x44, 0xbb, 0xbe, + 0xa6, 0x44, 0xe0, 0x3e, 0x5a, 0x13, 0x74, 0xc4, 0xa4, 0xa2, 0xc2, 0x1f, 0x90, 0xe0, 0x74, 0x24, + 0xf8, 0x24, 0x09, 0x41, 0x41, 0x75, 0x0f, 0x67, 0xae, 0x7b, 0xb9, 0x07, 0xdf, 0x42, 0x2b, 0x11, + 0x1f, 0xb1, 0x64, 0x9e, 0xdd, 0x04, 0x76, 0x07, 0xf0, 0x39, 0xea, 0x7b, 0xa8, 0x23, 0x68, 0xc0, + 0xe3, 0x98, 0x26, 0xa1, 0x6f, 0x92, 0xd9, 0x02, 0x15, 0xb5, 0x73, 0xf8, 0x4b, 0x48, 0x69, 0x17, + 0x55, 0xa7, 0x54, 0x48, 0x9d, 0xce, 0xb6, 0x49, 0x8e, 0x35, 0xf1, 0x0d, 0xd4, 0x08, 0x04, 0x0d, + 0x99, 0xf2, 0x61, 0xbf, 0x1d, 0xf0, 0x22, 0x03, 0x7d, 0x4e, 0x62, 0xea, 0xfe, 0xe0, 0x64, 0x85, + 0x7e, 0xc0, 0xb9, 0xa2, 0x42, 0x17, 0x94, 0x0c, 0xf8, 0x44, 0xd9, 0x3a, 0x1b, 0x43, 0xcf, 0x10, + 0xf0, 0x44, 0x91, 0x40, 0xd9, 0x42, 0x67, 0x26, 0x24, 0x7b, 0x24, 0x28, 0x8d, 0x69, 0xa2, 0x6c, + 0xad, 0xcf, 0x01, 0xed, 0xcd, 0x93, 0x66, 0x4b, 0x7d, 0x0e, 0xe8, 0x52, 0x0c, 0x29, 0x0d, 0x75, + 0x26, 0x6c, 0xb1, 0x73, 0xdb, 0xfd, 0xb1, 0x84, 0xda, 0x56, 0x81, 0x34, 0x98, 0x08, 0xa6, 0x66, + 0x78, 0x0b, 0xd5, 0x98, 0xf4, 0x83, 0x88, 0x4b, 0x0a, 0xab, 0xab, 0x79, 0x55, 0x26, 0x8f, 0xb4, + 0xa9, 0x53, 0x05, 0xb8, 0x2e, 0x9a, 0x32, 0x6b, 0x31, 0xeb, 0x6c, 0x03, 0x7c, 0x92, 0xa1, 0x9a, + 0x48, 0x13, 0x32, 0x88, 0xa8, 0x9f, 0xd5, 0x06, 0x16, 0x5d, 0xf3, 0xda, 0x06, 0xf6,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x05, 0x8a, 0x68, 0x1c, 0xac, 0x2f, 0x9e, 0x9d, 0xe6, 0xf4, 0xf2, + 0x2c, 0x47, 0xb3, 0x87, 0x20, 0x73, 0x50, 0xc7, 0x05, 0xb6, 0x69, 0x01, 0xcf, 0x72, 0xf0, 0x01, + 0xaa, 0x49, 0xab, 0x3d, 0x10, 0x49, 0xe3, 0x60, 0x73, 0x29, 0xba, 0xf5, 0x7a, 0x39, 0xcf, 0xfd, + 0xdb, 0x41, 0xcd, 0xe3, 0x64, 0x7a, 0x9f, 0xa6, 0x34, 0x09, 0x75, 0x9d, 0xb2, 0xfb, 0xd4, 0x99, + 0xbb, 0x4f, 0x97, 0x8e, 0xc0, 0xc2, 0xc5, 0x23, 0xf0, 0x26, 0x6a, 0x32, 0xe9, 0xb3, 0x44, 0x2a, + 0x12, 0x45, 0x34, 0xb4, 0x1a, 0x6d, 0x30, 0xf9, 0x28, 0x83, 0x74, 0xa3, 0x52, 0x21, 0xb8, 0xc8, + 0x2e, 0x65, 0x30, 0xe0, 0x26, 0x1c, 0xd3, 0xe0, 0xd4, 0x5c, 0x64, 0xe5, 0x77, 0xbe, 0x09, 0xcd, + 0x98, 0x43, 0xa5, 0x8f, 0xd3, 0x20, 0x0e, 0xed, 0x21, 0xab, 0x3f, 0xf5, 0x19, 0xc2, 0xe4, 0x79, + 0x4d, 0x8c, 0xb0, 0x10, 0x93, 0x79, 0x41, 0xee, 0xa0, 0xd2, 0x71, 0x32, 0x95, 0x78, 0x17, 0x95, + 0x68, 0x32, 0x95, 0xf6, 0x16, 0xcb, 0x73, 0x3b, 0x9f, 0x0e, 0x0f, 0x18, 0xee, 0x77, 0x45, 0x54, + 0xd6, 0x3d, 0x29, 0xf5, 0x13, 0x61, 0x22, 0xa9, 0xf0, 0x03, 0x3e, 0x49, 0x94, 0x7d, 0x9c, 0xd4, + 0x35, 0x72, 0xa4, 0x01, 0x2d, 0x89, 0x5c, 0x44, 0x86, 0x52, 0x00, 0x4a, 0x2b, 0x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0x76, 0x7f, 0xe1, 0x49, 0xfd, 0x89, 0x73, 0x1b, 0x3f, 0x43, 0xe8, + 0xfc, 0xb5, 0x85, 0xb7, 0xb2, 0x88, 0x17, 0x5e, 0x60, 0xbd, 0xe5, 0xc9, 0xdc, 0x6b, 0x10, 0x74, + 0x03, 0xaf, 0x2d, 0x06, 0xed, 0x47, 0x4c, 0x2a, 0xfc, 0x19, 0xaa, 0xe9, 0xdd, 0x83, 0x30, 0x2f, + 0xdb, 0x7a, 0x2b, 0xdf, 0xba, 0xa6, 0xb9, 0x1b, 0x10, 0xaf, 0x83, 0x5b, 0xf9, 0xbe, 0x61, 0xf4, + 0x31, 0xaa, 0x3e, 0xa4, 0x0a, 0xba, 0xe2, 0xb2, 0x40, 0xcd, 0xb9, 0xfe, 0x90, 0xee, 0x3a, 0xc4, + 0x69, 0xe3, 0x66, 0x16, 0x47, 0xf7, 0x09, 0xfe, 0x0a, 0xb5, 0x4c, 0xee, 0x4e, 0x98, 0xa2, 0x31, + 0x49, 0x2f, 0x0d, 0x76, 0x59, 0x0e, 0xaf, 0x42, 0xd8, 0xd5, 0x5e, 0x27, 0x5f, 0x9e, 0x09, 0x74, + 0xef, 0xa3, 0x9f, 0xdf, 0x6c, 0x3b, 0xaf, 0xdf, 0x6c, 0x3b, 0xbf, 0xbf, 0xd9, 0x76, 0x5e, 0xbd, + 0xdd, 0xbe, 0xf2, 0xfa, 0xed, 0xf6, 0x95, 0x5f, 0xdf, 0x6e, 0x5f, 0x41, 0xf6, 0x5f, 0xe5, 0x89, + 0xf3, 0xcd, 0x6a, 0xcc, 0x05, 0x0d, 0x79, 0x60, 0xc7, 0x7e, 0x3a, 0xdd, 0x1f, 0x54, 0x20, 0xfe, + 0x07, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0x7d, 0x2f, 0xb7, 0x6b, 0xe6, 0x0c, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1621,6 +1630,13 @@ func (m *ConfigSystem) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.CreditName) > 0 { + i -= len(m.CreditName) + copy(dAtA[i:], m.CreditName) + i = encodeVarintConfig(dAtA, i, uint64(len(m.CreditName))) + i-- + dAtA[i] = 0x7a + } if len(m.Version) > 0 { i -= len(m.Version) copy(dAtA[i:], m.Version) @@ -2352,6 +2368,10 @@ func (m *ConfigSystem) Size() (n int) { if l > 0 { n += 1 + l + sovConfig(uint64(l)) } + l = len(m.CreditName) + if l > 0 { + n += 1 + l + sovConfig(uint64(l)) + } return n } @@ -3722,6 +3742,38 @@ func (m *ConfigSystem) Unmarshal(dAtA []byte) error { } m.Version = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 15: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CreditName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthConfig + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthConfig + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CreditName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipConfig(dAtA[iNdEx:]) diff --git a/api/v1/config.proto b/api/v1/config.proto index 3bd25ee..493b3e3 100644 --- a/api/v1/config.proto +++ b/api/v1/config.proto @@ -62,6 +62,7 @@ message ConfigSystem { string login_background = 12; // 登录页背景图 repeated string recommend_words = 13; // 推荐搜索词,首页展示 string version = 14; // 程序版本号 + string credit_name = 15; // 积分名称 } // 底链配置项,为跳转的链接地址 diff --git a/biz/config.go b/biz/config.go index 9f89b6f..7540a82 100644 --- a/biz/config.go +++ b/biz/config.go @@ -144,6 +144,7 @@ func (s *ConfigAPIService) GetSettings(ctx context.Context, req *emptypb.Empty) } } res.System.Version = util.Version + res.System.CreditName = s.dbModel.GetConfigOfScore(model.ConfigScoreCreditName).CreditName footer := s.dbModel.GetConfigOfFooter() if err := util.CopyStruct(&footer, res.Footer); err != nil { s.logger.Error("util.CopyStruct", zap.Any("footer", footer), zap.Any("res.Footer", res.Footer), zap.Error(err)) diff --git a/biz/document.go b/biz/document.go index c575c60..aeb81d6 100644 --- a/biz/document.go +++ b/biz/document.go @@ -657,7 +657,7 @@ func (s *DocumentAPIService) DownloadDocument(ctx context.Context, req *pb.Docum user, _ := s.dbModel.GetUser(userId) if doc.UserId != userId && user.CreditCount < doc.Price { - return res, status.Errorf(codes.PermissionDenied, "魔豆不足,无法下载") + return res, status.Errorf(codes.PermissionDenied, fmt.Sprintf("%s不足,无法下载", s.dbModel.GetCreditName())) } // 用户可以免费下载自己的文档 diff --git a/biz/user.go b/biz/user.go index 3b34022..b7646bd 100644 --- a/biz/user.go +++ b/biz/user.go @@ -104,7 +104,7 @@ func (s *UserAPIService) Register(ctx context.Context, req *pb.RegisterAndLoginR } // 用户积分 - cfgScore := s.dbModel.GetConfigOfScore(model.ConfigScoreRegister) + cfgScore := s.dbModel.GetConfigOfScore(model.ConfigScoreRegister, model.ConfigScoreCreditName) user.CreditCount = int(cfgScore.Register) if err = s.dbModel.CreateUser(user, group.Id); err != nil { s.logger.Error("CreateUser", zap.Error(err)) @@ -116,7 +116,7 @@ func (s *UserAPIService) Register(ctx context.Context, req *pb.RegisterAndLoginR s.dbModel.CreateDynamic(&model.Dynamic{ UserId: user.Id, Type: model.DynamicTypeRegister, - Content: fmt.Sprintf("成功注册成网站会员,获得 %d 魔豆奖励", cfgScore.Register), + Content: fmt.Sprintf("成功注册成网站会员,获得 %d %s奖励", cfgScore.Register, cfgScore.CreditName), }) } diff --git a/model/config.go b/model/config.go index 89f727e..7d18498 100644 --- a/model/config.go +++ b/model/config.go @@ -38,6 +38,17 @@ const ( ConfigCategoryScore = "score" ) +const ( + InputTypeNumber = "number" // 数字 + InputTypeSwitch = "switch" // switch + InputTypeSelect = "select" // 单选 + InputTypeSelectMulti = "select-multi" // 多选 + InputTypeText = "text" // 文本框 + InputTypeTextarea = "textarea" // 多行文本框 + InputTypePassword = "password" // 密码 + InputTypeImage = "image" // 图片 +) + type Config struct { Id int64 `form:"id" json:"id,omitempty" gorm:"primaryKey;autoIncrement;column:id;comment:;"` Label string `form:"label" json:"label,omitempty" gorm:"column:label;type:varchar(64);size:64;comment:标签名称;"` @@ -331,6 +342,8 @@ type ConfigFooter struct { } const ( + // 积分名称 + ConfigScoreCreditName = "credit_name" // 注册积分 ConfigScoreRegister = "register" // 签到积分 @@ -352,15 +365,16 @@ const ( ) type ConfigScore struct { - Register int32 `json:"register"` // 注册积分 - SignIn int32 `json:"sign_in"` // 签到积分 - UploadDocument int32 `json:"upload_document"` // 上传文档积分 - UploadDocumentLimit int32 `json:"upload_document_limit"` // 每日上传文档积分次数限制 - DeleteDocument int32 `json:"delete_document"` // 删除上传文档积分 - DocumentCollected int32 `json:"document_collected"` // 文档被收藏获得积分 - DocumentCollectedLimit int32 `json:"document_collected_limit"` // 文档被收藏获得积分次数限制 - DocumentCommented int32 `json:"document_commented"` // 文档被评论获得积分 - DocumentCommentedLimit int32 `json:"document_commented_limit"` // 文档被评论获得积分次数限制 + CreditName string `json:"credit_name"` // 积分名称 + Register int32 `json:"register"` // 注册积分 + SignIn int32 `json:"sign_in"` // 签到积分 + UploadDocument int32 `json:"upload_document"` // 上传文档积分 + UploadDocumentLimit int32 `json:"upload_document_limit"` // 每日上传文档积分次数限制 + DeleteDocument int32 `json:"delete_document"` // 删除上传文档积分 + DocumentCollected int32 `json:"document_collected"` // 文档被收藏获得积分 + DocumentCollectedLimit int32 `json:"document_collected_limit"` // 文档被收藏获得积分次数限制 + DocumentCommented int32 `json:"document_commented"` // 文档被评论获得积分 + DocumentCommentedLimit int32 `json:"document_commented_limit"` // 文档被评论获得积分次数限制 } func (m *DBModel) GetConfigOfFooter() (config ConfigFooter) { @@ -370,11 +384,7 @@ func (m *DBModel) GetConfigOfFooter() (config ConfigFooter) { m.logger.Error("GetConfigOfFooter", zap.Error(err)) } - var data = make(map[string]interface{}) - - for _, cfg := range configs { - data[cfg.Name] = cfg.Value - } + data := m.convertConfig2Map(configs) bytes, _ := json.Marshal(data) json.Unmarshal(bytes, &config) @@ -394,19 +404,7 @@ func (m *DBModel) GetConfigOfDownload(name ...string) (config ConfigDownload) { m.logger.Error("GetConfigOfDownload", zap.Error(err)) } - var data = make(map[string]interface{}) - - for _, cfg := range configs { - switch cfg.Name { - case ConfigDownloadEnableGuestDownload: - data[cfg.Name], _ = strconv.ParseBool(cfg.Value) - case ConfigDownloadTimesEveryDay, ConfigDownloadUrlDuration, ConfigDownloadFreeDownloadDuration, ConfigDownloadTimesEveryIP: - data[cfg.Name], _ = strconv.ParseInt(cfg.Value, 10, 32) - default: - data[cfg.Name] = cfg.Value - } - } - + data := m.convertConfig2Map(configs) bytes, _ := json.Marshal(data) json.Unmarshal(bytes, &config) @@ -420,28 +418,18 @@ func (m *DBModel) GetConfigOfCaptcha() (config ConfigCaptcha) { if err != nil && err != gorm.ErrRecordNotFound { m.logger.Error("GetConfigOfCaptcha", zap.Error(err)) } + data := m.convertConfig2Map(configs) + bytes, _ := json.Marshal(data) + json.Unmarshal(bytes, &config) - for _, cfg := range configs { - switch cfg.Name { - case ConfigCaptchaLength: - config.Length, _ = strconv.Atoi(cfg.Value) - if config.Length <= 0 { - config.Length = 6 - } - case ConfigCaptchaWidth: - config.Width, _ = strconv.Atoi(cfg.Value) - if config.Width <= 0 { - config.Width = 240 - } - case ConfigCaptchaHeight: - config.Height, _ = strconv.Atoi(cfg.Value) - if config.Height <= 0 { - config.Height = 60 - } - case ConfigCaptchaType: - // 验证码类型 - config.Type = cfg.Value - } + if config.Length <= 0 { + config.Length = 6 + } + if config.Width <= 0 { + config.Width = 240 + } + if config.Height <= 0 { + config.Height = 60 } return } @@ -458,24 +446,7 @@ func (m *DBModel) GetConfigOfSystem(name ...string) (config ConfigSystem) { m.logger.Error("GetConfigOfSystem", zap.Error(err)) } - var data = make(map[string]interface{}) - - for _, cfg := range confgis { - if cfg.Name == ConfigSystemRecommendWords { - words := strings.Split(cfg.Value, ",") - iwords := make([]string, 0) - for _, word := range words { - word = strings.TrimSpace(word) - if word != "" { - iwords = append(iwords, word) - } - } - data[cfg.Name] = iwords - } else { - data[cfg.Name] = cfg.Value - } - } - + data := m.convertConfig2Map(confgis) bytes, _ := json.Marshal(data) json.Unmarshal(bytes, &config) @@ -494,34 +465,7 @@ func (m *DBModel) GetConfigOfSecurity(name ...string) (config ConfigSecurity) { m.logger.Error("GetConfigOfSecurity", zap.Error(err)) } - var data = make(map[string]interface{}) - - for _, cfg := range configs { - switch cfg.Name { - case ConfigSecurityIsClose, - ConfigSecurityEnableRegister, - ConfigSecurityEnableCaptchaLogin, - ConfigSecurityEnableCaptchaRegister, - ConfigSecurityEnableCaptchaComment, - ConfigSecurityLoginRequired, - ConfigSecurityEnableCaptchaFindPassword: - value, _ := strconv.ParseBool(cfg.Value) - data[cfg.Name] = value - case ConfigSecurityMaxDocumentSize, - ConfigSecurityCommentInterval, - ConfigSecurityDocumentRelatedDuration: - data[cfg.Name], _ = strconv.Atoi(cfg.Value) - case ConfigSecurityDocumentAllowedExt: - arr := strings.Split(cfg.Value, ",") - if len(arr) == 1 && arr[0] == "" { - arr = []string{} - } - data[cfg.Name] = arr - default: - data[cfg.Name] = cfg.Value - } - } - + data := m.convertConfig2Map(configs) bytes, _ := json.Marshal(data) json.Unmarshal(bytes, &config) @@ -535,20 +479,7 @@ func (m *DBModel) GetConfigOfConverter() (config ConfigConverter) { m.logger.Error("GetConfigOfConverter", zap.Error(err)) } - var data = make(map[string]interface{}) - - for _, cfg := range configs { - switch cfg.Name { - case ConfigConverterMaxPreview, ConfigConverterTimeout: - data[cfg.Name], _ = strconv.Atoi(cfg.Value) - case ConfigConverterEnableSVGO, ConfigConverterEnableGZIP, ConfigConverterEnableConvertRepeatedDocument: - value, _ := strconv.ParseBool(cfg.Value) - data[cfg.Name] = value - default: - data[cfg.Name] = cfg.Value - } - } - + data := m.convertConfig2Map(configs) bytes, _ := json.Marshal(data) json.Unmarshal(bytes, &config) @@ -566,17 +497,7 @@ func (m *DBModel) GetConfigOfEmail(name ...string) (config ConfigEmail) { m.logger.Error("GetConfigOfEmail", zap.Error(err)) } - var data = make(map[string]interface{}) - for _, cfg := range configs { - switch cfg.Name { - case ConfigEmailEnable, ConfigEmailIsTLS: - data[cfg.Name], _ = strconv.ParseBool(cfg.Value) - case ConfigEmailPort, ConfigEmailDuration: - data[cfg.Name], _ = strconv.Atoi(cfg.Value) - default: - data[cfg.Name] = cfg.Value - } - } + data := m.convertConfig2Map(configs) bytes, _ := json.Marshal(data) json.Unmarshal(bytes, &config) m.logger.Debug("GetConfigOfEmail", zap.Any("data", data), zap.Any("config", config)) @@ -595,12 +516,7 @@ func (m *DBModel) GetConfigOfScore(name ...string) (config ConfigScore) { m.logger.Error("GetConfigOfScore", zap.Error(err)) } - var data = make(map[string]interface{}) - - for _, cfg := range configs { - data[cfg.Name], _ = strconv.Atoi(cfg.Value) - } - + data := m.convertConfig2Map(configs) bytes, _ := json.Marshal(data) json.Unmarshal(bytes, &config) @@ -632,6 +548,38 @@ func (m *DBModel) SendMail(subject, email string, body string) error { } return mail.DialAndSend(message) } +func (m *DBModel) GetCreditName() string { + creditName := m.GetConfigOfScore(ConfigScoreCreditName).CreditName + if creditName == "" { + creditName = "魔豆" + } + return creditName +} + +func (m *DBModel) convertConfig2Map(cfgs []Config) (data map[string]interface{}) { + data = make(map[string]interface{}) + for _, cfg := range cfgs { + switch strings.TrimSpace(cfg.InputType) { + case InputTypeNumber: + data[cfg.Name], _ = strconv.Atoi(cfg.Value) + case InputTypeSwitch: + data[cfg.Name], _ = strconv.ParseBool(cfg.Value) + case InputTypeSelectMulti: + arr := strings.Split(cfg.Value, ",") + if len(arr) == 1 && arr[0] == "" { + arr = []string{} + } + data[cfg.Name] = arr + case InputTypeSelect, InputTypeText, InputTypeTextarea, InputTypePassword, InputTypeImage: + data[cfg.Name] = cfg.Value + default: + // 这里只是做一个兼容处理。报错是为了提醒开发者,如果有新的输入类型,需要增加 InptType 的枚举常量,并在相应的表单进行处理 + m.logger.Error("convertConfig2Map", zap.Error(errors.New("未知的输入类型,请在枚举常量InputType中进行定义")), zap.String("inputType", cfg.InputType), zap.String("name", cfg.Name), zap.String("value", cfg.Value)) + data[cfg.Name] = cfg.Value + } + } + return +} func (m *DBModel) initConfig() (err error) { closeStatement := `