This commit is contained in:
桀尼龟 2025-02-20 19:43:50 +08:00
parent beec72296e
commit 77539466f8
22 changed files with 14131 additions and 4 deletions

9852
api/account/account.pb.go Normal file

File diff suppressed because it is too large Load Diff

778
api/account/account.proto Normal file
View File

@ -0,0 +1,778 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
syntax = "proto3";
package account;
import "github.com/mwitkow/go-proto-validators@v0.3.2/validator.proto";
option go_package = "./;account";
service Account {
rpc Login (LoginRequest) returns (TokenInfo) {}
rpc RefreshToken (RefreshTokenRequest) returns (TokenInfo) {} //token
rpc Logout (DecryptJwtRequest) returns (CommonResponse) {}
rpc OffLine (CommonRequest) returns (CommonResponse) {}
rpc OnlineLog (LoginInfosByUserIdRequest) returns (LoginLogsResponse) {}//id获取登录的信息
rpc OnlineLogById (OnlineLogByIdRequest) returns (LoginLog) {}//id获取登录的信息
rpc CheckPwd (CheckPwdRequest) returns (UpdateResponse) {}//
// rpc RegisterOrExist (RegistRequest) returns (RequestStatus) {}
rpc SendMsg (SendMsgRequest) returns (SendMsgStatusResponse) {} //
rpc SendCustomMsg (SendCustomMsgRequest) returns (SendMsgStatusResponse) {}//
rpc SendExCustomMsg (SendCustomMsgRequest) returns (SendMsgStatusResponse) {}//
rpc SendMsgRegister (SendMsgRequest) returns (SendMsgStatusResponse) {}//
rpc CheckMsg (CheckMsgRequest) returns (SendMsgStatusResponse) {}
rpc SendNewTelNumMsg (SendNewTelNumMsgRequest) returns (SendMsgStatusResponse) {}//,
rpc UpdateTelNum (SendNewTelNumMsgRequest) returns (SendMsgStatusResponse) {}//
rpc Authentication (AuthenticationRequest) returns (RequestStatus) {}
rpc DecryptJwt (DecryptJwtRequest) returns (DecryptJwtResponse) {}//
rpc Info (InfoRequest) returns (UserInfoResponse) {}
rpc JobNumGetInfo (JobNumGetInfoRequest) returns (InfoResponse) {}
rpc List (ListRequest) returns (ListResponse) {}
rpc RandList (ListRequest) returns (ListResponse) {}
rpc ListByIDs (ListByIDsRequest) returns (ListResponse) {}
rpc Remove (RemoveRequest) returns (RemoveResponse) {}
rpc Update (UpdateRequest) returns (UpdateResponse) {}
rpc UsersByTel (UsersByTelRequest) returns (ListResponse) {}
rpc UserByTel (UserByTelRequest) returns (InfoResponse) {}
rpc OnlySendMsg (SendMsgRequest) returns (SendMsgStatusResponse) {} //
rpc OnlyCheckMsg (CheckMsgRequest) returns (SendMsgStatusResponse) {}//
rpc MailAccountByNickName(MailAccountByNickNameRequest) returns(MaiAccountResponse){} //
rpc ListV2 (ListV2Request) returns (ListResponse) {}//
rpc QueryPersonnelWithTheSameName (QueryPersonnelWithTheSameNameRequest) returns (QueryPersonnelWithTheSameNameResponse) {}//
rpc UsersByJobNum (UsersByJobNumRequest) returns (ListResponse) {}
rpc RealName (RealNameRequest) returns (RealNameResponse) {}//
rpc Register (RegistRequest) returns (RegisterResponse) {}//
rpc UserList (UserListRequest) returns (UserListResponse) {}//
rpc CheckRealName (CheckRealNameRequest) returns (CheckRealNameResponse) {}//
}
message CheckRealNameResponse{
uint64 id =1;
string status =2;
}
message CheckRealNameRequest{
uint64 id = 1;
bool pass = 2;
string notPassRemarks = 3;
}
message UserListResponse{
uint64 count = 1;
uint64 page = 2;
uint64 pageSize = 3;
repeated UserListInfo userList = 4;
}
message UserListInfo{
uint64 id = 1;
int32 status = 2;
string name = 3;
int32 sex = 4;
string nationality = 5;
int32 documentType =6;
string certificatePicture = 7;
string validity = 8;
string placeOfResidence = 9;
string groupPhoto = 10;
string attachment = 11;
string registrationTime = 12;
string auditTime = 13;
string subNum = 14;
string notPassRemarks = 15;
string telNum = 16;
}
message UserListRequest{
string domain = 1;
string subNum = 2;
int32 realNameOrNot = 3;
string name = 4;
int32 sex = 5;
int32 documentType = 6;
int32 auditStatus = 7;
uint64 page = 8;
uint64 pageSize = 9;
}
message UserInfoResponse{
uint64 id = 1;
int32 status = 2;
string name = 3;
int32 sex = 4;
string nationality = 5;
int32 documentType =6;
string certificatePicture = 7;
string validity = 8;
string placeOfResidence = 9;
string groupPhoto = 10;
string attachment = 11;
string subNum = 12;
string notPassRemarks = 13;
}
message RealNameResponse{
uint64 id = 1;
string status = 2;
}
message RealNameRequest{
uint64 id = 1;
string name = 2;
int32 sex = 3;
string nationality = 4;
int32 documentType = 5;
string certificatePicture = 6;
string validity = 7;
string placeOfResidence = 8;
string groupPhoto = 9;
string attachment = 10;
}
message RegisterResponse{
uint64 ID = 1;
uint64 status = 2;
string token = 3;
}
message UsersByJobNumRequest{
string domain = 1 ;
repeated string jobNum =2 ;
}
message QueryPersonnelWithTheSameNameRequest{
repeated string names = 1 ;
string domain = 2 ;
string status = 3 ;
}
message QueryPersonnelWithTheSameNameResponse{
repeated string names = 1 ;
uint64 count = 2 ;
}
message ListV2Request {
string domain = 1 [json_name = "domain",(validator.field) = {string_not_empty: true,human_error: "70001"} ];
uint64 pageSize = 2 ;
uint64 page = 3 ;
string key = 4 ;
string nickName = 5;
string telNum = 6 ;
string status = 7 ;
string positionName = 8 ;
string jobNum = 9 ;
string mailAccount = 10 ;
string startEnterDate = 11 ;
string endEnterDate = 12 ;
uint32 positionId = 13 ;
uint32 departmentId = 14 ;
string departmentName =15 ;
repeated string departmentNames =16 ;
repeated uint32 positionIds =17 ;
repeated uint32 departmentIds =18 ;
}
message SendClockInWechatRequest {
string domain = 1;
string telNum =2;
string operatedAt =3;
string clockType =4;
uint32 userId =5;
string ghId =6;
string address =7;
uint64 logId = 8;
}
message MailAccountByNickNameRequest {
string Domain = 1 [json_name = "domain",(validator.field) = {string_not_empty: true,human_error: "70001"}];
string NickName = 2 [json_name = "nickName",(validator.field) = {length_lt: 20,string_not_empty: true,human_error: "70005"}];
uint32 ID = 3 ;
}
message CreateMaiAccountRequest {
uint32 ID = 1 ;
string nickName = 2;
string domain = 3 ;
}
message MaiAccountResponse {
string englishName = 1 ;
string mailAccount = 2;
}
message FddCreateUserRequest {
string openid = 1 ;
uint32 wxUserId = 2;
//string UserId = 3;
string customerId = 4;
bool isVerify = 5;
string transactionNo = 6;
}
message WxBoxUserInfoRequest {
string openid = 2 ;
string ghId = 3;
}
message WxGetOpenIdByCodeRequest {
string code = 1 ;
string state = 2 ;
string ghId = 3;
}
message WxGetOpenIdByCodeResponse {
string openId = 1 ;
}
message WxBoxTelNumByCodeResponse {
string telNum = 1 ;
}
message WxBoxUserInfo {
string openId = 1 ;
string ghId = 2 ;
bool isNew = 3 ;
UserInfo user = 4 ;
uint32 wxUserId = 5 ;
FddInfo fdd = 6 ;
}
message FddInfo {
uint64 ID = 1 ;
string customerId = 2 ;
bool isVerify = 3 ;
string transactionNo = 4;
}
message UserInfo {
uint64 ID = 1 ;
string nickName = 3 ;
string telNum = 5 ;
string avatar = 7 ;
string createAt = 8 ;
uint64 realNameID = 9 ;
string realName = 10;
string iDNum = 11;
string domain = 12;
string realIDImgA = 17;
string realIDImgB = 18;
string realNameIDName = 19;
string video = 20;
}
message CommonRequest {
uint64 ID = 1 [json_name = "ID"];
}
message WxAppRequest {
string GhId = 1 [json_name = "ID"];
}
message WxAppResponse {
string AppID = 1 [json_name = "appID"];
string AppSecret = 2 [json_name = "appSecret"];
}
message WxUserUpdateRequest {
uint32 wxID = 1 [json_name = "wxId" ,(validator.field) = {string_not_empty: true,human_error: "缺少参数wxID"} ];
uint32 userID = 2 [json_name = "userID"];
}
message WxUserOrCreateRequest {
string OpenID = 1 [json_name = "openID" ,(validator.field) = {string_not_empty: true,human_error: "缺少openid"} ];
string GhID = 2 [json_name = "ghID" ,(validator.field) = {string_not_empty: true,human_error: "缺少参数ghid"} ];
}
message WxUserResponse {
string OpenID = 1 [json_name = "openID"];
uint32 UserID = 2 [json_name = "userID"];
string GhID = 3 [json_name = "ghID"];
string RoleAuth = 4 [json_name = "roleAuth"];
uint32 ID = 5 [json_name = "ID"];
}
message LoginLogsResponse {
repeated LoginLog Data = 1 [json_name = "data"];
}
message LoginLog {
string Domain = 1 [json_name = "domain"];
uint64 ID = 2 [json_name = "ID"];
uint64 UserId = 3 [json_name = "userId"];
string Ip = 4 [json_name = "ip"];
string Token = 5 [json_name = "token"];
uint64 Status = 6 [json_name = "status"];
string ExpireDate = 7 [json_name = "expireDate"];
string LastDate = 8 [json_name = "lastDate"];
string LogoutDate = 9 [json_name = "logoutDate"];
string CreatedAt = 10 [json_name = "createdAt"];
string Address = 11 [json_name = "address"];
}
message OnlineLogByIdRequest {
string Domain = 1 [json_name = "domain"];
uint64 ID = 2 [json_name = "ID"];
}
message LoginInfosByUserIdRequest {
string Domain = 1 [json_name = "domain"];
uint64 UserId = 2 [json_name = "userId"];
}
message SendNewTelNumMsgRequest {
string Domain = 1 [json_name = "domain",(validator.field) = {string_not_empty: true,human_error: "70001"} ];
uint64 ID = 2 [json_name = "ID",(validator.field) = {string_not_empty: true,human_error: "缺少参数"} ];
string NewTelNum = 3 [json_name = "newTelNum"];
string Code = 4 [json_name = "code"];
string Project = 5 [json_name = "project"];
uint32 signNo = 6 ;
}
message UserByTelRequest {
string Domain = 1 [json_name = "domain",(validator.field) = {string_not_empty: true,human_error: "70001"} ];
string Tel =2 [json_name = "tel"];
}
message CommonResponse {
}
message UsersByTelRequest {
string Domain = 1 [json_name = "domain",(validator.field) = {string_not_empty: true,human_error: "70001"} ];
repeated string Tels =2 [json_name = "tels"];
}
message ListByIDsRequest {
string Domain = 1 [json_name = "domain",(validator.field) = {string_not_empty: true,human_error: "70001"} ];
repeated uint64 IDs = 2 [json_name = "IDs"];
uint64 OrderType = 3 [json_name = "OrderType"];
uint64 Page = 4 [json_name = "page"];
uint64 PageSize = 5 [json_name = "pageSize"];
string NickName = 6 [json_name = "nickName"];
repeated string InvitationCode = 7 [json_name = "invitationCode"];
}
message SendMsgRequest {
string Domain = 1 [json_name = "domain",(validator.field) = {string_not_empty: true,human_error: "70001"} ];
string TelNum = 2 [json_name = "telNum",(validator.field) = {regex: "^1\\d{10}$",human_error: "70002"}];
string Project = 3 [json_name = "project"];
uint32 signNo = 4;
uint32 mId = 5;
string scope = 6;//
}
message SendCustomMsgRequest {
string Domain = 1 [json_name = "domain",(validator.field) = {string_not_empty: true,human_error: "70001"} ];
string TelNum = 2 [json_name = "telNum",(validator.field) = {regex: "^1\\d{10}$",human_error: "70002"}];
string Project = 3 [json_name = "project"];
string Url = 4 [json_name = "Url"];
uint64 ID = 5 [json_name = "ID"];
uint64 MId = 6 [json_name = "mId"];
uint64 Location = 7 [json_name = "location"];
uint32 SigNo = 8 [json_name = "sigNo"];
}
message CheckMsgRequest {
string Domain = 1 [json_name = "domain",(validator.field) = {string_not_empty: true,human_error: "70001"} ];
string TelNum = 2 [json_name = "telNum",(validator.field) = {regex: "^1\\d{10}$",human_error: "70002"}];
string Code = 3 [json_name = "code",(validator.field) = {string_not_empty: true,human_error: "70003"} ];
string scope = 4;//
}
message SendMsgStatusResponse {
}
message RemoveRequest {
string Domain = 1 [json_name = "domain",(validator.field) = {string_not_empty: true,human_error: "70001"} ];
uint64 ID = 2 [json_name = "ID",(validator.field) = {int_gt: 0,human_error: "70004"} ];
string code = 3;
}
message WriteOffRequest{
uint64 id = 1;
string domain = 2;
uint64 userId = 3;
string tel = 4;
string jonNum = 5;
string userName = 6;
string enterDate = 7;
string positionName =8;
uint64 positionId = 9;
string siteName = 10;
uint64 siteId =11;
string authUrl =12;
string type =13;
uint32 status =14;
string submitDate=15;
}
message WriteOffListRequest{
uint64 page = 1;
uint64 pageSize =2;
string domain = 3;
string userName =4;
uint64 userId = 5;
uint64 siteId =6;
string type =7;
uint32 status =8;
}
message WriteOffApproveRequest{
uint64 id = 1;
uint32 status = 2;
}
message WriteOffListResponse{
int64 total = 1;
repeated WriteOffRequest writeOffList = 2;
}
message RemoveResponse {
}
message UpdateRequest {
uint64 ID = 1 [json_name = "ID"]; //ID
string Domain = 2 [json_name = "domain",(validator.field) = {string_not_empty: true,human_error: "70001"} ];
string NickName = 3 [json_name = "nickName"];
string Password = 4 [json_name = "password"]; //
string Avatar = 5 [json_name = "avatar"]; //
string Status = 7 [json_name = "status"];
string TelNum = 8 [json_name = "telNum"];
string EnterDate = 14 [json_name = "enterDate"];
Extend Extend = 17 [json_name = "extend"];
string Title = 18 [json_name = "title"];
string JobNum = 19 [json_name = "jobNum"];
string BirthDate = 20 [json_name = "birthDate"];
uint64 Sex = 21 [json_name = "sex"];
string IdNum = 22 [json_name = "idNum"];
string RealName = 23 [json_name = "realName"];
string InvitationCode = 24 [json_name = "invitationCode"];
string LeftDate = 25 [json_name = "leftDate"];
string Remark = 26 [json_name = "remark"];
string RecentImg = 27 [json_name = "recentImg"];
string ICNum = 28 [json_name = "icNum"];
string Train = 29 [json_name = "train"];
string Certificate = 30 [json_name = "certificate"];
repeated trainVideo TrainVideos = 31 [json_name = "trainVideos"];
Operator operator = 32;
string SecurityCode = 33 [json_name = "securityCode"];
}
message Operator {
uint32 ID = 1;
string Name = 2;
}
message trainVideo {
string trainUUID = 1 [json_name = "trainUUID"];
string trainDesc = 2 [json_name = "trainDesc"];
string video = 3 [json_name = "video"];
string SecurityCode = 31 [json_name = "securityCode"];
}
message UpdateResponse {
}
message PrivacyInfoRequest {
uint64 ID = 1 [json_name = "ID"]; //ID
string Domain = 2 [json_name = "domain",(validator.field) = {string_not_empty: true,human_error: "70001"} ];
string SecurityCode = 3 [json_name = "securityCode"];
}
message ListRequest {
string Domain = 1 [json_name = "domain",(validator.field) = {string_not_empty: true,human_error: "70001"} ];
uint64 PageSize = 2 [json_name = "pageSize"];
uint64 Page = 3 [json_name = "page"];
string key = 4 [json_name = "key"];
string status = 5 ;
string telNum = 6;
string startEnterDate = 7;
string endEnterDate = 8;
}
message ListResponse {
string Status = 1 [json_name = "status"];
uint64 Count = 2 [json_name = "count"];
repeated AccountInfo Data = 3 [json_name = "data"];
uint64 AllCount = 4 [json_name = "allCount"];
}
message InfoRequest {
string Domain = 1 [json_name = "domain",(validator.field) = {string_not_empty: true,human_error: "70001"} ];
uint64 ID = 2 [json_name = "id"];
string scene = 3 ;// base-user数据
}
message InfoResponse {
string Status = 1 [json_name = "status"];
AccountInfo Info = 2 [json_name = "accountInfo"];
bool IsExist = 3 [json_name = "isExist"];
}
message DecryptJwtResponse {
string Domain = 1 [json_name = "status"];
uint64 ID = 2 [json_name = "id"];
string Account = 3 [json_name = "account"];
string NickName = 4 [json_name = "nickName"];
bool IsOffline = 5 [json_name = "isOffline"];
}
message DecryptJwtRequest {
string token = 1 [json_name = "token"];
string Domain = 2 [json_name = "Domain"];
}
message CheckPwdRequest {
string Token = 1 [json_name = "token"];
string Password = 2 [json_name = "password"];
}
message AuthenticationRequest {
string Name = 1 [json_name = "name"];
string IDNum = 2 [json_name = "idNum",(validator.field) = {length_eq: 18,human_error: "70006"}];
string Token = 3 [json_name = "token"];
}
message RequestStatus {
string Status = 1 [json_name = "status"];
uint64 ID = 2 [json_name = "ID"];
bool isExist = 3;
}
message RegistRequest {
string domain = 1;
string telNum = 2;
string code = 3;
string address = 4;
string telAreaCode = 5;
}
message LoginRequest {
string Domain = 1 [json_name = "domain",(validator.field) = {string_not_empty: true,human_error: "70001"} ];
string TelNum = 2 [json_name = "telNum",(validator.field) = {regex: "^1\\d{10}$",human_error: "70002"}];
string Code = 3 [json_name = "code"];
string Password = 4 [json_name = "password"];
string Ip = 5 [json_name = "ip"];
bool passCheckIp = 6 ;
}
message TokenInfo {
AccountInfo AccountInfo = 1 [json_name = "accountInfo"];
string Token = 2 [json_name = "token"];
string RefreshToken = 4 [json_name = "refresh"];
bool IsSampleAddress = 3 [json_name = "isSampleAddress"];
string nowAddress = 5 [json_name = "nowAddress"];
}
message Extend {
string JumpTo = 1 [json_name = "jumpTo"];
string Lang = 2 [json_name = "lang"];
bool CanScan = 3 [json_name = "canScan"];
bool ResolutionRatio = 4 [json_name = "resolutionRatio"];
}
message Department {
uint64 ID = 1 [json_name = "ID"];
string Name = 2 [json_name = "name"];
}
// The response message containing the greetings
message AccountInfo {
uint64 ID = 1 [json_name = "id"];
string Account = 2 [json_name = "account"];
string NickName = 3 [json_name = "nickName"];
int64 Type = 4 [json_name = "type"];
string TelNum = 5 [json_name = "telNum"];
int32 Status = 6 [json_name = "status"];
string Avatar = 7 [json_name = "avatar"];
string CreateAt = 8 [json_name = "createAt"];
uint64 RealNameID = 9 [json_name = "realNameID"];
string RealName = 10 [json_name = "realName"];
string IDNum = 11 [json_name = "iDNum"];
string MnemonicWords = 12 [json_name = "mnemonicWords"];
uint64 IsNeedChange = 13 [json_name = "isNeedChange"];
string EnterDate = 14 [json_name = "enterDate"];
float WorkYear = 15 [json_name = "workYear"];
string Domain = 16 [json_name = "domain"];
Extend Extend = 17 [json_name = "extend"];
string JobNum = 18 [json_name = "jobNum"];
string BirthDate = 19 [json_name = "birth_date"];
uint64 Age = 20 [json_name = "age"];
uint64 Sex = 21 [json_name = "sex"];
string Title = 22 [json_name = "title"];
repeated Department Departments = 23 [json_name = "departments"];
string Ip = 24 [json_name = "ip"];
string LoginDate = 25 [json_name = "loginDate"];
string InvitationCode = 26 [json_name = "invitationCode"];
uint64 NowLogId = 27 [json_name = "nowLogId"];
bool CanScan = 28 [json_name = "canScan"];
string LeftDate = 29 [json_name = "leftDate"];
repeated PositionUser Positions = 30 [json_name = "positions"];
string Remark = 31 [json_name = "remark"];
string recentImg =32;
repeated ClockUser clocks = 33;
string mailAccount = 34;
string ICNum = 35 [json_name = "icNum"];
string englishName = 36;
string Train = 37 [json_name = "train"];
string Certificate = 38 [json_name = "certificate"];
repeated trainVideo TrainVideos = 39 [json_name = "trainVideos"];
Operator operator = 40;
string updatedAt = 41;
string SecurityCode = 42 [json_name = "securityCode"];
string BlockAddr = 43 [json_name = "blockAddr"];
}
message UserInfoV2 {
uint64 ID = 1 ;
string Account = 2 ;
string NickName = 3 ;
string TelNum = 4 ;
string Status = 5 ;
string Avatar = 6 ;
string CreateAt = 7 ;
string RealName = 8;
string IDNum = 9;
string EnterDate = 10;
Extend Extend = 11;
string JobNum = 12;
string recentImg = 13;
string mailAccount = 14;
Operator operator = 15;
string updatedAt = 16;
}
message RefreshTokenRequest {
string refreshToken = 1 ;
string domain = 2;
string ip = 3 ;
}
message PositionUser {
uint64 PositionID = 1 [json_name = "positionID"];
string PositionName = 2 [json_name = "positionName"];
uint64 DepartmentId = 3 [json_name = "departmentId"];
string DepartmentCode = 4 [json_name = "departmentCode"];
string DepartmentName = 5 [json_name = "departmentName"];
uint64 UserId = 6 [json_name = "userId"];
string UserName = 7 [json_name = "userName"];
}
message JobNumGetInfoRequest{
string jobNum = 1;
string domain = 2;
}
message CreateClockDeviceRequest{
string deviceNum =1;
string deviceName =2;
string deviceSite = 3;
}
message UpdateClockDeviceRequest{
uint64 id = 1;
string deviceNum =2;
string deviceName =3;
string deviceSite = 4;
}
message ClockDeviceResponse{
uint64 id = 1;
}
message RemoveClockDeviceRequest{
uint64 id = 1;
}
message ClockDeviceListRequest{
uint64 id =1;
string deviceSite = 2;
string deviceNum = 3;
string deviceName = 4;
uint64 page = 5 ;
uint64 pageSize = 6 ;
repeated uint64 ids = 7;
}
message ClockDeviceListResponse{
uint64 count =1;
repeated ClockDeviceInfo data = 2;
}
message ClockUser{
uint64 id =1;
string createdAt =2;
string updatedAt =3;
string deletedAt =4;
uint64 deviceID =5;
uint64 userId =6;
uint64 status =7;
ClockDeviceInfo device = 8;
}
message ClockDeviceInfo {
uint64 id = 1 ;
string createAt = 2 ;
string updateAt = 3 ;
string deviceSite = 4;
string deviceNum = 5;
string deviceName = 6;
uint64 userNum = 7;
repeated ClockUserRel data = 8 ;
}
message ClockDeviceInfoResponse{
uint64 count = 1;
repeated ClockUserRel data = 2 ;
}
message ClockUserRel {
uint64 id = 1 ;
string createAt = 2 ;
string updateAt = 3;
string nickName = 4 ;
string jobNum = 5 ;
string icNum = 6;
}
message ClockDeviceInfoRequest{
uint64 id = 1;
uint64 page = 2 ;
uint64 pageSize = 3 ;
}
message ClockBatchBindRequest{
uint64 id = 1;
repeated uint64 userId = 2;
repeated uint64 deviceId =3;
}
message ClockBatchListResponse{
repeated ClockUserDeviceBatch data = 1;
}
message ClockUserDeviceBatch{
uint64 userId = 1;
uint64 deviceId = 2;
string JobNum = 3;
string deviceNum = 4;
string deviceName = 5;
string workStatus = 6;
}
message ClockLogInfo{
uint64 id = 1;
string sn = 2;
string userId =3;
string recogType =4;
string recogTime =5;
float gender =6;
string photo =7;
float passStatus =8;
string userName =9;
float userType =10;
string confidence =11;
float reflectivity =12;
string cardNumber =13;
string passWord =14;
string qrCode =15;
string tel = 16;
string reasonVisit = 17;
string receiverTel = 18;
uint64 numOfPeople = 19;
}
message ClockLogReq{
uint64 id = 1;
uint64 page = 2;
uint64 pageSize = 3;
string userName = 4;
string recogType = 5;
string deviceNum = 6;
string recogDate = 7;
uint64 userId = 8;
}
message ClockLogListResponse{
repeated ClockLogInfo data =1;
uint64 count = 2;
}

View File

@ -0,0 +1,535 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: api/account/account.proto
package account
import (
fmt "fmt"
math "math"
proto "github.com/golang/protobuf/proto"
_ "github.com/mwitkow/go-proto-validators"
regexp "regexp"
github_com_mwitkow_go_proto_validators "github.com/mwitkow/go-proto-validators"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
func (this *CheckRealNameResponse) Validate() error {
return nil
}
func (this *CheckRealNameRequest) Validate() error {
return nil
}
func (this *UserListResponse) Validate() error {
for _, item := range this.UserList {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("UserList", err)
}
}
}
return nil
}
func (this *UserListInfo) Validate() error {
return nil
}
func (this *UserListRequest) Validate() error {
return nil
}
func (this *UserInfoResponse) Validate() error {
return nil
}
func (this *RealNameResponse) Validate() error {
return nil
}
func (this *RealNameRequest) Validate() error {
return nil
}
func (this *RegisterResponse) Validate() error {
return nil
}
func (this *UsersByJobNumRequest) Validate() error {
return nil
}
func (this *QueryPersonnelWithTheSameNameRequest) Validate() error {
return nil
}
func (this *QueryPersonnelWithTheSameNameResponse) Validate() error {
return nil
}
func (this *ListV2Request) Validate() error {
if this.Domain == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Domain", fmt.Errorf(`70001`))
}
return nil
}
func (this *SendClockInWechatRequest) Validate() error {
return nil
}
func (this *MailAccountByNickNameRequest) Validate() error {
if this.Domain == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Domain", fmt.Errorf(`70001`))
}
if this.NickName == "" {
return github_com_mwitkow_go_proto_validators.FieldError("NickName", fmt.Errorf(`70005`))
}
if !(len(this.NickName) < 20) {
return github_com_mwitkow_go_proto_validators.FieldError("NickName", fmt.Errorf(`70005`))
}
return nil
}
func (this *CreateMaiAccountRequest) Validate() error {
return nil
}
func (this *MaiAccountResponse) Validate() error {
return nil
}
func (this *FddCreateUserRequest) Validate() error {
return nil
}
func (this *WxBoxUserInfoRequest) Validate() error {
return nil
}
func (this *WxGetOpenIdByCodeRequest) Validate() error {
return nil
}
func (this *WxGetOpenIdByCodeResponse) Validate() error {
return nil
}
func (this *WxBoxTelNumByCodeResponse) Validate() error {
return nil
}
func (this *WxBoxUserInfo) Validate() error {
if this.User != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.User); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("User", err)
}
}
if this.Fdd != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Fdd); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Fdd", err)
}
}
return nil
}
func (this *FddInfo) Validate() error {
return nil
}
func (this *UserInfo) Validate() error {
return nil
}
func (this *CommonRequest) Validate() error {
return nil
}
func (this *WxAppRequest) Validate() error {
return nil
}
func (this *WxAppResponse) Validate() error {
return nil
}
func (this *WxUserUpdateRequest) Validate() error {
return nil
}
func (this *WxUserOrCreateRequest) Validate() error {
if this.OpenID == "" {
return github_com_mwitkow_go_proto_validators.FieldError("OpenID", fmt.Errorf(`缺少openid`))
}
if this.GhID == "" {
return github_com_mwitkow_go_proto_validators.FieldError("GhID", fmt.Errorf(`缺少参数ghid`))
}
return nil
}
func (this *WxUserResponse) Validate() error {
return nil
}
func (this *LoginLogsResponse) Validate() error {
for _, item := range this.Data {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Data", err)
}
}
}
return nil
}
func (this *LoginLog) Validate() error {
return nil
}
func (this *OnlineLogByIdRequest) Validate() error {
return nil
}
func (this *LoginInfosByUserIdRequest) Validate() error {
return nil
}
func (this *SendNewTelNumMsgRequest) Validate() error {
if this.Domain == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Domain", fmt.Errorf(`70001`))
}
return nil
}
func (this *UserByTelRequest) Validate() error {
if this.Domain == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Domain", fmt.Errorf(`70001`))
}
return nil
}
func (this *CommonResponse) Validate() error {
return nil
}
func (this *UsersByTelRequest) Validate() error {
if this.Domain == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Domain", fmt.Errorf(`70001`))
}
return nil
}
func (this *ListByIDsRequest) Validate() error {
if this.Domain == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Domain", fmt.Errorf(`70001`))
}
return nil
}
var _regex_SendMsgRequest_TelNum = regexp.MustCompile(`^1\d{10}$`)
func (this *SendMsgRequest) Validate() error {
if this.Domain == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Domain", fmt.Errorf(`70001`))
}
if !_regex_SendMsgRequest_TelNum.MatchString(this.TelNum) {
return github_com_mwitkow_go_proto_validators.FieldError("TelNum", fmt.Errorf(`70002`))
}
return nil
}
var _regex_SendCustomMsgRequest_TelNum = regexp.MustCompile(`^1\d{10}$`)
func (this *SendCustomMsgRequest) Validate() error {
if this.Domain == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Domain", fmt.Errorf(`70001`))
}
if !_regex_SendCustomMsgRequest_TelNum.MatchString(this.TelNum) {
return github_com_mwitkow_go_proto_validators.FieldError("TelNum", fmt.Errorf(`70002`))
}
return nil
}
var _regex_CheckMsgRequest_TelNum = regexp.MustCompile(`^1\d{10}$`)
func (this *CheckMsgRequest) Validate() error {
if this.Domain == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Domain", fmt.Errorf(`70001`))
}
if !_regex_CheckMsgRequest_TelNum.MatchString(this.TelNum) {
return github_com_mwitkow_go_proto_validators.FieldError("TelNum", fmt.Errorf(`70002`))
}
if this.Code == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Code", fmt.Errorf(`70003`))
}
return nil
}
func (this *SendMsgStatusResponse) Validate() error {
return nil
}
func (this *RemoveRequest) Validate() error {
if this.Domain == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Domain", fmt.Errorf(`70001`))
}
if !(this.ID > 0) {
return github_com_mwitkow_go_proto_validators.FieldError("ID", fmt.Errorf(`70004`))
}
return nil
}
func (this *WriteOffRequest) Validate() error {
return nil
}
func (this *WriteOffListRequest) Validate() error {
return nil
}
func (this *WriteOffApproveRequest) Validate() error {
return nil
}
func (this *WriteOffListResponse) Validate() error {
for _, item := range this.WriteOffList {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("WriteOffList", err)
}
}
}
return nil
}
func (this *RemoveResponse) Validate() error {
return nil
}
func (this *UpdateRequest) Validate() error {
if this.Domain == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Domain", fmt.Errorf(`70001`))
}
if this.Extend != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Extend); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Extend", err)
}
}
for _, item := range this.TrainVideos {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("TrainVideos", err)
}
}
}
if this.Operator != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Operator); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Operator", err)
}
}
return nil
}
func (this *Operator) Validate() error {
return nil
}
func (this *TrainVideo) Validate() error {
return nil
}
func (this *UpdateResponse) Validate() error {
return nil
}
func (this *PrivacyInfoRequest) Validate() error {
if this.Domain == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Domain", fmt.Errorf(`70001`))
}
return nil
}
func (this *ListRequest) Validate() error {
if this.Domain == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Domain", fmt.Errorf(`70001`))
}
return nil
}
func (this *ListResponse) Validate() error {
for _, item := range this.Data {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Data", err)
}
}
}
return nil
}
func (this *InfoRequest) Validate() error {
if this.Domain == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Domain", fmt.Errorf(`70001`))
}
return nil
}
func (this *InfoResponse) Validate() error {
if this.Info != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Info); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Info", err)
}
}
return nil
}
func (this *DecryptJwtResponse) Validate() error {
return nil
}
func (this *DecryptJwtRequest) Validate() error {
return nil
}
func (this *CheckPwdRequest) Validate() error {
return nil
}
func (this *AuthenticationRequest) Validate() error {
if !(len(this.IDNum) == 18) {
return github_com_mwitkow_go_proto_validators.FieldError("IDNum", fmt.Errorf(`70006`))
}
return nil
}
func (this *RequestStatus) Validate() error {
return nil
}
func (this *RegistRequest) Validate() error {
return nil
}
var _regex_LoginRequest_TelNum = regexp.MustCompile(`^1\d{10}$`)
func (this *LoginRequest) Validate() error {
if this.Domain == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Domain", fmt.Errorf(`70001`))
}
if !_regex_LoginRequest_TelNum.MatchString(this.TelNum) {
return github_com_mwitkow_go_proto_validators.FieldError("TelNum", fmt.Errorf(`70002`))
}
return nil
}
func (this *TokenInfo) Validate() error {
if this.AccountInfo != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.AccountInfo); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("AccountInfo", err)
}
}
return nil
}
func (this *Extend) Validate() error {
return nil
}
func (this *Department) Validate() error {
return nil
}
func (this *AccountInfo) Validate() error {
if this.Extend != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Extend); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Extend", err)
}
}
for _, item := range this.Departments {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Departments", err)
}
}
}
for _, item := range this.Positions {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Positions", err)
}
}
}
for _, item := range this.Clocks {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Clocks", err)
}
}
}
for _, item := range this.TrainVideos {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("TrainVideos", err)
}
}
}
if this.Operator != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Operator); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Operator", err)
}
}
return nil
}
func (this *UserInfoV2) Validate() error {
if this.Extend != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Extend); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Extend", err)
}
}
if this.Operator != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Operator); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Operator", err)
}
}
return nil
}
func (this *RefreshTokenRequest) Validate() error {
return nil
}
func (this *PositionUser) Validate() error {
return nil
}
func (this *JobNumGetInfoRequest) Validate() error {
return nil
}
func (this *CreateClockDeviceRequest) Validate() error {
return nil
}
func (this *UpdateClockDeviceRequest) Validate() error {
return nil
}
func (this *ClockDeviceResponse) Validate() error {
return nil
}
func (this *RemoveClockDeviceRequest) Validate() error {
return nil
}
func (this *ClockDeviceListRequest) Validate() error {
return nil
}
func (this *ClockDeviceListResponse) Validate() error {
for _, item := range this.Data {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Data", err)
}
}
}
return nil
}
func (this *ClockUser) Validate() error {
if this.Device != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Device); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Device", err)
}
}
return nil
}
func (this *ClockDeviceInfo) Validate() error {
for _, item := range this.Data {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Data", err)
}
}
}
return nil
}
func (this *ClockDeviceInfoResponse) Validate() error {
for _, item := range this.Data {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Data", err)
}
}
}
return nil
}
func (this *ClockUserRel) Validate() error {
return nil
}
func (this *ClockDeviceInfoRequest) Validate() error {
return nil
}
func (this *ClockBatchBindRequest) Validate() error {
return nil
}
func (this *ClockBatchListResponse) Validate() error {
for _, item := range this.Data {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Data", err)
}
}
}
return nil
}
func (this *ClockUserDeviceBatch) Validate() error {
return nil
}
func (this *ClockLogInfo) Validate() error {
return nil
}
func (this *ClockLogReq) Validate() error {
return nil
}
func (this *ClockLogListResponse) Validate() error {
for _, item := range this.Data {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Data", err)
}
}
}
return nil
}

File diff suppressed because it is too large Load Diff

View File

@ -19,6 +19,10 @@ package main
import ( import (
"fmt" "fmt"
"fonchain-fiee/cmd/config"
"fonchain-fiee/pkg/cache"
"fonchain-fiee/pkg/common/gpt"
"fonchain-fiee/pkg/router"
) )
func main() { func main() {

View File

@ -3,13 +3,15 @@ package config
import ( import (
"errors" "errors"
"fmt" "fmt"
"fonchain-fiee/pkg/common"
"github.com/BurntSushi/toml" "github.com/BurntSushi/toml"
"gopkg.in/ini.v1"
"os" "os"
) )
/********start-配置信息*********/ /********start-配置信息*********/
//Baiduco 百度上链 // Baiduco 百度上链
type Mysql struct { type Mysql struct {
Db string Db string
DbHost string DbHost string
@ -90,3 +92,17 @@ func LoadEnvFromFileInfo(data string) (*Config, error) {
return AppConfig, nil return AppConfig, nil
} }
func GetOptions() {
iniConf, err := common.GetConf()
if err != nil {
panic("iniConf error")
}
file, err := ini.Load(iniConf)
if err != nil {
fmt.Println("服务器配置文件读取错误,请检查文件路径:", err)
}
LoadServer(file)
}
func LoadServer(file *ini.File) {
}

4
go.mod
View File

@ -1,6 +1,8 @@
module fonchain-fiee module fonchain-fiee
go 1.20 go 1.21.0
toolchain go1.22rc1
require ( require (
dubbo.apache.org/dubbo-go/v3 v3.1.1 dubbo.apache.org/dubbo-go/v3 v3.1.1

1
go.sum
View File

@ -1506,6 +1506,7 @@ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=

114
pkg/common/jwt/jwt.go Normal file
View File

@ -0,0 +1,114 @@
package jwt
import (
"github.com/fonchain_enterprise/blockchain-main/pkg/common/m"
"github.com/fonchain_enterprise/blockchain-main/pkg/service/wxOpnid"
"math/rand"
"time"
"github.com/dgrijalva/jwt-go"
)
type Claims struct {
ID uint `json:"id"`
Account string `json:"account"`
Domain string `json:"domain"`
NickName string `json:"nickName"`
Phone string `json:"phone"`
jwt.StandardClaims
}
type RefreshClaims struct {
ID uint `json:"id"`
RId int `json:"rid"`
jwt.StandardClaims
}
func GenerateTotalToken(id uint, account string, domain string, nickName string, hour int, phone string, jwtSecret []byte) (string, string, error) {
token, err := GenerateToken(id, account, domain, nickName, hour, phone, jwtSecret)
if err != nil {
return "", "", err
}
refreshToken, err := GenerateRefreshToken(id, domain, m.RefreshTokenTime, jwtSecret)
if err != nil {
return "", "", err
}
return token, refreshToken, err
}
// GenerateToken 签发用户Token
func GenerateToken(id uint, account string, domain string, nickName string, hour int, phone string, jwtSecret []byte) (string, error) {
nowTime := time.Now()
expireTime := nowTime.Add(time.Duration(hour) * time.Hour)
claims := Claims{
ID: id,
Account: account,
Domain: domain,
NickName: nickName,
Phone: phone,
StandardClaims: jwt.StandardClaims{
ExpiresAt: expireTime.Unix(),
Issuer: domain,
},
}
tokenClaims := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
token, err := tokenClaims.SignedString(jwtSecret)
return token, err
}
// ParseToken 验证用户token
func ParseToken(token string, jwtSecret []byte) (*Claims, error) {
tokenClaims, err := jwt.ParseWithClaims(token, &Claims{}, func(token *jwt.Token) (interface{}, error) {
return jwtSecret, nil
})
if tokenClaims != nil {
if claims, ok := tokenClaims.Claims.(*Claims); ok && tokenClaims.Valid {
return claims, nil
}
}
return nil, err
}
// GenerateRefreshToken 签发用户Token
func GenerateRefreshToken(id uint, domain string, hour int, jwtSecret []byte) (string, error) {
nowTime := time.Now()
expireTime := nowTime.Add(time.Duration(hour) * time.Hour)
claims := RefreshClaims{
ID: id,
RId: rand.Intn(999),
StandardClaims: jwt.StandardClaims{
ExpiresAt: expireTime.Unix(),
Issuer: domain,
},
}
tokenClaims := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
token, err := tokenClaims.SignedString(jwtSecret)
return token, err
}
// ParseRefreshToken 验证用户token
func ParseRefreshToken(token string, jwtSecret []byte) (*RefreshClaims, error) {
tokenClaims, err := jwt.ParseWithClaims(token, &RefreshClaims{}, func(token *jwt.Token) (interface{}, error) {
return jwtSecret, nil
})
if tokenClaims != nil {
if claims, ok := tokenClaims.Claims.(*RefreshClaims); ok && tokenClaims.Valid {
return claims, nil
}
}
return nil, err
}
// ParseOpenidToken 验证wx用户
func ParseOpenidToken(token string) (*wxOpnid.Claims, error) {
tokenClaims, err := jwt.ParseWithClaims(token, &Claims{}, func(token *jwt.Token) (interface{}, error) {
return m.JWTSecret, nil
})
if tokenClaims != nil {
if claims, ok := tokenClaims.Claims.(*wxOpnid.Claims); ok && tokenClaims.Valid {
return claims, nil
}
}
return nil, err
}

View File

@ -0,0 +1,52 @@
package jwt
import (
"fmt"
"github.com/fonchain_enterprise/blockchain-main/pkg/common/m"
"math/rand"
"testing"
"time"
)
func TestParseToken(t *testing.T) {
// 获取当前时间戳,精确到纳秒
nanoTimestamp := time.Now().UnixNano()
// 将纳秒时间戳转换为毫秒
milliTimestamp := nanoTimestamp / 1e6
// 生成一个随机数,可以根据需要调整随机数的位数
rand.NewSource(time.Now().UnixNano())
randomNumber := rand.Intn(999)
// 格式化订单编号(确保格式化后的位数固定)
orderID := fmt.Sprintf("%d%03d", milliTimestamp, randomNumber)
fmt.Println(orderID)
str := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MjMzLCJhY2NvdW50IjoiVU1jektDWDVTRHpnZm43eDZkNTFLMTYxaThZNlhjdWVNIiwiZG9tYWluIjoiYXJ0aXN0aW5mbyIsIm5pY2tOYW1lIjoiMTM5NjIzMTA3NjUiLCJwaG9uZSI6IjEzOTYyMzEwNzY1IiwiZXhwIjoxNjg0NzYyMjY2LCJpc3MiOiJtYWxsIn0.8zG3OA9uRJnzxYorQ2_cK6FhQuMlsi7WF8zkIic1ggM"
str = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NzAsImFjY291bnQiOiIiLCJkb21haW4iOiJmb250cmVlIiwibmlja05hbWUiOiLogL_pmLMiLCJwaG9uZSI6IjE4MjA1MDUyNjI3IiwiZXhwIjoxNzAxOTMwNjY5LCJpc3MiOiJtYWxsIn0.l9Swlap-e0VWXQK3vtFUVC0nx6gYjUuCGDLezoEni6Q"
claims, err := ParseToken(str, m.JWTSecret)
fmt.Println(err)
fmt.Println(claims)
}
func TestParseToken2(t *testing.T) {
ss, _ := GenerateToken(70, "", "fontree", "耿阳"+
"", m.TokenTime, "18205052627", m.JWTSecret)
//fmt.Println(ss, err)
claims, err := ParseToken(ss, m.JWTSecret)
fmt.Println(claims, err)
fmt.Println("1------------")
}
func TestRefreshToken(t *testing.T) {
str1, err := GenerateRefreshToken(70, "fontree", 20, m.JWTSecret)
fmt.Println(str1, err)
//str := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MjMzLCJhY2NvdW50IjoiVU1jektDWDVTRHpnZm43eDZkNTFLMTYxaThZNlhjdWVNIiwiZG9tYWluIjoiYXJ0aXN0aW5mbyIsIm5pY2tOYW1lIjoiMTM5NjIzMTA3NjUiLCJwaG9uZSI6IjEzOTYyMzEwNzY1IiwiZXhwIjoxNjg0NzYyMjY2LCJpc3MiOiJtYWxsIn0.8zG3OA9uRJnzxYorQ2_cK6FhQuMlsi7WF8zkIic1ggM"
//claims, err := ParseRefreshToken(str1, m.JWTSecret)
claims, err := ParseToken(str1, m.JWTSecret)
fmt.Println(err)
fmt.Println(claims)
}

74
pkg/common/m/msg.go Normal file
View File

@ -0,0 +1,74 @@
package m
var JWTSecret = []byte("asdfqwer1234")
const (
SERVER_CONFIG = "../conf/conf.ini"
LOG_CONFIG = "../conf/log.yaml"
Domain = "blockchain"
)
const (
TokenTime = 24
StatusInDoor = 1
RefreshTokenTime = 720
)
const (
DateNormalYMDFormat = "2006-01-02"
)
const (
SUCCESS = "success"
FAILED = "failed"
)
const (
ERRORCONFIG = "配置文件读取错误,请检查文件路径:"
ERRORAUTH = "没有权限"
)
const (
//丰链编号为20开头
FC = iota + 200
FONCHAIN //丰链商城
)
const (
LineStatusRun = 1
LineStatusStop = 2
CircuitStatusOpen = 1
CircuitStatusClose = 2
)
// 订单状态参数
const (
ORDER_STATUS_NEED_PUBLIC = iota + 1 //待发布
ORDER_STATUS_NEED_CONFIRM //待确认
ORDER_STATUS_APPEAL //申诉状态
ORDER_STATUS_CONFIRMED //已确认
)
const (
Order_Doing = iota + 1 //待总监确认 待发布
Order_Need_Seller_Sure //待销售确认
Order_Status_Que //申诉订单
Order_Done //完成
Order_Need_Cashier_Sure //待出纳确认
Order_Need_Control_Sure //待内控确认
Order_Need_Finance_Sure //待财务确认
)
const (
REPORT_STATUS_NEED_PUBLIC = iota + 1 //待发布
REPORT_PUBLISH //已发布
REPORT_NEED_CASHIER_SURE //待出纳补充
REPORT_NEED_BOSS_SURE //带最后总价确认
REPORT_CASHIER_FINAL_OPTION //待出纳确认 重置
)
const (
TYPE_WEEK = iota + 1 //周
TYPE_MOUNTH //月
TYPE_QUARTER //日期
)

64
pkg/common/tools.go Normal file
View File

@ -0,0 +1,64 @@
package common
import (
"dubbo.apache.org/dubbo-go/v3/common/constant"
"fmt"
"fonchain-fiee/pkg/e"
"os"
)
type Result struct {
IP string `json:"ip"`
Location Location `json:"location"`
AdInfo AdInfo `json:"ad_info"`
}
type Location struct {
Lat float64 `json:"lat"`
Lng float64 `json:"lng"`
}
type AdInfo struct {
Nation string `json:"nation"`
Province string `json:"province"`
City string `json:"city"`
District string `json:"district"`
AdcodE int `json:"adcode"`
}
type IpResult struct {
Status int `json:"status"`
Message string `json:"message"`
RequestID string `json:"request_id"`
Result Result `json:"result"`
}
type IPDict struct {
fileData []byte //文件数据
offset uint32 //当前下标定位
firstOffset uint32 //第一条IP记录的偏移地址
lastOffset uint32 //最后一条IP记录的偏移地址
totalIPNum uint32 //IP记录的总条数不包含版本信息记录
}
type IPLocation struct {
IP string `json:"ip"`
BeginIP string `json:"begin_ip"`
EndIP string `json:"end_ip"`
Country string `json:"country"`
Area string `json:"area"`
}
func GetConf() (iniConf string, err error) {
if os.Getenv(e.MODE_ENV) != "" {
if err = os.Setenv(constant.ConfigFileEnvKey, fmt.Sprintf("./conf/%s/%s", os.Getenv(e.MODE_ENV), e.SERVER_DUBBOGO_CONFIG)); err != nil {
return
}
}
if os.Getenv(e.MODE_ENV) == "" {
iniConf = fmt.Sprintf("../conf/%s", e.SERVER_CONFIG)
} else {
iniConf = fmt.Sprintf("./conf/%s/%s", os.Getenv(e.MODE_ENV), e.SERVER_CONFIG)
}
return
}

256
pkg/config/config.go Normal file
View File

@ -0,0 +1,256 @@
package config
import (
"fmt"
"fonchain-fiee/pkg/common"
"github.com/spf13/viper"
"gopkg.in/ini.v1"
"os"
"strconv"
)
var (
AppMode string
HttpPort string
Key string
Cert string
IsHttps bool
RunHttps bool
Domain string
OssDomain string
ServerDM string
Env string
DriverUrl string
AppointUrl string
MaterialHost string
//TODO
//BosAk string
//BosSk string
//BosBucketName string
//BosBaseDir string
//BosUrl string
//BosHttp string
//BosDomain string
//TODO
ProjectMapDir string
JaegerHost string
JaegerOpen bool
Cron bool
DingAccessToken string
DingUrl string
HolidayID string
HolidaySecret string
HolidaySingleUrl string
HolidayMultiUrl string
ErpAk string
ErpSk string
// rabbitmq
RabbitmqUser string
RabbitmqPassword string
RabbitmqHost string
RabbitmqPort int
RabbitmqVhost string
RabbitmqVhostArtwork string
RedisDB int
RedisAddr string
RedisPw string
//shop配置
ShopHost string
//ShopDetail string
// 地图
MapAppCode string
//百度地图的ak
BaiduMapAK string
// es
ElasticHost string
SendIndexesUrl string
ChatGptHost string
ApiHost string
Level string
Filename string
MaxSize string
MaxAge string
MaxBackups string
YearGiftCheckHost string
IsOut bool
OutUrl string
Aliyun struct {
AccessKeyId string
AccessKeySecret string
}
SendTime int
XMChannelId string
OPChannelId string
OPNotifyLevel int
Route string
PdfHost string
DefaultSignNo uint64
// 审批 es index
ApprovalIndex string
)
var ConfigData = new(AppConfig)
type AppConfig struct {
Oss struct {
AccessKeyId string
AccessKeySecret string
Endpoint string
BucketName string
BaseDir string
CdnHost string
}
Rabbitmq struct {
User string
Password string
Host string
Port int
Vhost string
VhostArtwork string
VhostCopyright string
}
}
func GetOptions() {
iniConf, err := common.GetConf()
if err != nil {
panic("iniConf error")
}
file, err := ini.Load(iniConf)
if err != nil {
fmt.Println("服务器配置文件读取错误,请检查文件路径:", err)
}
_ = os.MkdirAll("runtime", os.ModePerm)
LoadServer(file)
_ = Viper(iniConf)
}
func LoadServer(file *ini.File) {
AppMode = file.Section("service").Key("AppMode").String()
IsHttps, _ = file.Section("service").Key("IsHTTPS").Bool()
RunHttps, _ = file.Section("service").Key("RunHTTPS").Bool()
Key = file.Section("service").Key("Key").String()
Cert = file.Section("service").Key("Cert").String()
HttpPort = file.Section("service").Key("HttpPort").String()
Domain = file.Section("service").Key("Domain").String()
OssDomain = file.Section("service").Key("OssDomain").String()
ServerDM = file.Section("service").Key("ServerDM").String()
DriverUrl = file.Section("service").Key("DriverUrl").String()
Env = file.Section("service").Key("Env").String()
JaegerHost = file.Section("service").Key("JaegerHost").String()
JaegerOpen, _ = file.Section("service").Key("JaegerOpen").Bool()
Cron, _ = file.Section("service").Key("Cron").Bool()
YearGiftCheckHost = file.Section("service").Key("YearGiftCheckHost").String()
IsOut, _ = file.Section("service").Key("IsOut").Bool()
OutUrl = file.Section("service").Key("OutUrl").String()
ProjectMapDir = file.Section("file").Key("ProjectMapDir").String()
AppointUrl = file.Section("service").Key("AppointUrl").String()
MaterialHost = file.Section("service").Key("MaterialHost").String()
//TODO
//BosAk = file.Section("bos").Key("Ak").String()
//BosSk = file.Section("bos").Key("Sk").String()
//BosBucketName = file.Section("bos").Key("BucketName").String()
//BosBaseDir = file.Section("bos").Key("BosBaseDir").String()
//BosUrl = file.Section("bos").Key("BosUrl").String()
//BosHttp = file.Section("bos").Key("BosHttp").String()
//BosDomain = file.Section("bos").Key("BosDomain").String()
//TODO
DingUrl = file.Section("ding").Key("Url").String()
DingAccessToken = file.Section("ding").Key("AccessToken").String()
//加载获取万年历配置
HolidayID = file.Section("holiday").Key("ID").String()
HolidaySecret = file.Section("holiday").Key("Secret").String()
HolidaySingleUrl = file.Section("holiday").Key("SingleUrl").String()
HolidayMultiUrl = file.Section("holiday").Key("MultiUrl").String()
// 加载 rabbitmq 配置
RabbitmqUser = file.Section("rabbitmq").Key("User").String()
RabbitmqPassword = file.Section("rabbitmq").Key("Password").String()
RabbitmqHost = file.Section("rabbitmq").Key("Host").String()
RabbitmqPort, _ = file.Section("rabbitmq").Key("Port").Int()
RabbitmqVhost = file.Section("rabbitmq").Key("Vhost").String()
RabbitmqVhostArtwork = file.Section("rabbitmq").Key("VhostArtwork").String()
//加载 redis
dbStr := file.Section("redis").Key("RedisDBNAme").String()
RedisDB, _ = strconv.Atoi(dbStr)
RedisAddr = file.Section("redis").Key("RedisAddr").String()
RedisPw = file.Section("redis").Key("RedisPW").String()
ShopHost = file.Section("shop").Key("ShopHost").String()
//ShopDetail = file.Section("shop").Key("ShopDetail").String()
// 地图
MapAppCode = file.Section("service").Key("MapAppCode").String()
BaiduMapAK = file.Section("service").Key("BaiduMapAK").String()
// 地图
ElasticHost = file.Section("es").Key("ElasticHost").String()
SendIndexesUrl = file.Section("api").Key("SendIndexesUrl").String()
ChatGptHost = file.Section("api").Key("chatGptHost").String()
ErpAk = file.Section("api").Key("erpak").String()
ErpSk = file.Section("api").Key("erpsk").String()
ApiHost = file.Section("service").Key("ApiHost").String()
// zap
Level = file.Section("zap").Key("Level").String()
Filename = file.Section("zap").Key("Filename").String()
MaxSize = file.Section("zap").Key("MaxSize").String()
MaxAge = file.Section("zap").Key("MaxAge").String()
MaxBackups = file.Section("zap").Key("MaxBackups").String()
Aliyun.AccessKeyId = file.Section("aliyun").Key("accessKeyId").String()
Aliyun.AccessKeySecret = file.Section("aliyun").Key("accessKeySecret").String()
Aliyun.AccessKeySecret = file.Section("aliyun").Key("accessKeySecret").String()
//发送次数
SendTime, _ = file.Section("send").Key("SendTime").Int()
OPNotifyLevel, _ = file.Section("send").Key("OPNotifyLevel").Int()
XMChannelId = file.Section("send").Key("XMChannelId").String()
OPChannelId = file.Section("send").Key("OPChannelId").String()
PdfHost = file.Section("pdf").Key("Host").String()
DefaultSignNo, _ = file.Section("msg").Key("defaultSignNo").Uint64()
Route = file.Section("send").Key("Route").String()
// 审批 es index
ApprovalIndex = file.Section("es").Key("ApprovalIndex").String()
}
func Viper(iniConf string) (err error) {
viper.SetConfigFile(iniConf)
err = viper.ReadInConfig()
if err != nil {
panic("viper.ReadInConfig failed" + err.Error())
return
}
if err = viper.Unmarshal(ConfigData); err != nil {
panic("viper.Unmarshal failed" + err.Error())
return
}
if err = viper.UnmarshalKey("mail_artwork.EditReturnArtworkUrl", &MailArtwork.EditReturnArtworkUrl); err != nil {
panic("viper.Unmarshal 'mail_artwork' config failed" + err.Error())
return
}
fmt.Printf("mailartwork:%+v\n", MailArtwork)
return
}

146
pkg/e/code.go Normal file
View File

@ -0,0 +1,146 @@
package e
var (
JWTSecret = []byte("asdfqwer1234")
)
const (
Success = 200
Error = 500
ParamsError = 400
InvalidToken = 501
)
const (
DomainAdmin = "blockchain"
)
const (
InventoryKey = "inventory_auth"
)
const (
ErrNotLogin = "请先登录"
ErrOffline = "您已经下线"
)
const (
Failed = 1
Ok = 0
BindError = 2
JsonUnmarshal = 3
NotLogin = 401
SUCCESS = 200
UpdatePasswordSuccess = 201
DeleteSuccess = 204
NotExistInentifier = 202
ERROR = 500
InvalidParams = 400
//成员错误
ErrorExistNick = 10001
ErrorExistUser = 10002
ErrorNotExistUser = 10003
ErrorNotCompare = 10004
ErrorNotComparePassword = 10005
ErrorFailEncryption = 10006
ErrorNotExistProduct = 10007
ErrorNotExistAddress = 10008
ErrorExistFavorite = 10009
ErrorGetUserInfo = 10010
ErrorGetDepart = 10011
ErrorUpdateAw = 10012
//店家错误
ErrorBossCheckTokenFail = 20001
ErrorBossCheckTokenTimeout = 20002
ErrorBossToken = 20003
ErrorBoss = 20004
ErrorBossInsufficientAuthority = 20005
ErrorBossProduct = 20006
//管理员错误
ErrorAuthCheckTokenFail = 30001 //token 错误
ErrorAuthCheckTokenTimeout = 30002 //token 过期
ErrorAuthToken = 30003
ErrorAuth = 30004
ErrorAuthInsufficientAuthority = 30005
ErrorReadFile = 30006
ErrorSendEmail = 30007
ErrorCallApi = 30008
ErrorUnmarshalJson = 30009
ErrorAdminFindUser = 30010
//数据库错误
ErrorDatabase = 40001
//对象存储错误
ErrorOss = 50001
ErrorUploadFile = 50002
//店铺错误
ErrorExistShopName = 60001
ErrorNotExistShopName = 60002
ErrorNotAdmin = 60003
ErrNoDomain = 70001
ErrTelNum = 70002
ErrNoCode = 70003
ErrNoID = 70004
ErrNickName = 70005
InvalidID = 70006
InvalidPas = 70007
ErrStatus = 70008
ErrNoType = 70009
ErrNoUserID = 70010
ErrNoName = 70011
ErrNoDepCode = 70012
ErrNoTitle = 70013
ErrNoUrl = 70014
ErrNoMethod = 70015
ErrNotDep = 70016
ErrCreateQr = 70017
ErrNotSellerBoss = 70018
ErrWrongDate = 70019
ErrLoginSeller = 70020
//上传
ErrorUploadVideoCover = 80001
ErrorUploadValidParam = 80002
ErrorFileReadErr = 80003
ErrorFileNotExists = 80004
ErrorChunkNotGt = 80005
ErrorChunk = 80006
ErrorUploadBos = 80007
ErrorFileCreate = 80008
ERROR_UID = 80009
//画作
ErrorAllotUids = 90001
//
ErrorExistSecurity = 90001
ErrorSecurity = 90002
ErrorNoSecurity = 90003
ErrorRealName = 90004
ErrorCode = 90005
NOTDATA = 90006
ErrorBaiduChainAlreadyDone = 90007
ErrorBaiduChaining = 90008
ErrorBaiduChainError = 90009
ERROR_BAIDU_IMAGE = 90010
ERROR_BAIDU_FAIL = 90011
ERROR_DOWNLOAD_FILE = 90012
ERROR_Addr_FILE = 90013
ERROR_Amount = 90014
ERROR_Create_Block = 90015
ERROR_Fee_Deduction = 90016
ERROR_Insufficient_Balance = 90017
ERROR_Text_Irregularity = 90018
ERROR_Text_Length = 90019
ERROR_NoPermission = 90020
)
const (
Push = 1
Read = 2
NotFilled = 3
Save = 4
)

158
pkg/e/msg.go Normal file
View File

@ -0,0 +1,158 @@
package e
const (
SERVER_CONFIG = "conf.ini"
SERVER_DUBBOGO_CONFIG = "dubbogo.yaml"
MODE_ENV = "MODE_ENV"
)
const (
Authorization = "Authorization"
BoxAuthorization = "Authorization"
StaffAuthorization = "StaffAuthorization"
AuthMobileInventoryKey = "mobile_inventory_auth"
AuthorizationCookie = "token"
)
const (
Acquire_Daily_Login = "daily_login"
Acquire_Register = "register"
)
const (
VerifierDomain = "fontree"
StaffJwtKey = "jwtStaffInfo"
)
const (
Status_Not_In_House = iota + 1 //未入库
Status_In_House //已入库
Status_Out_House //已出库
Status_Not_Pay //未付款
)
const (
DateNormalFormat = "2006-01-02 15:04:05"
DateNormalYMDFormat = "2006-01-02"
DateNormalPointFormat = "2006.01.02"
DateNormalPointFormatHM = "2006.01.02 15:04"
)
var MsgFlags = map[int]string{
SUCCESS: "操作成功",
UpdatePasswordSuccess: "修改密码成功",
NotExistInentifier: "该第三方账号未绑定",
ERROR: "fail",
InvalidParams: "请求参数错误",
BindError: "参数绑定错误,类型不一致",
JsonUnmarshal: "Json解析错误",
ErrorExistNick: "已存在该昵称",
ErrorExistUser: "已存在该用户名",
ErrorNotExistUser: "该用户不存在",
ErrorNotCompare: "账号密码错误",
ErrorNotComparePassword: "两次密码输入不一致",
ErrorFailEncryption: "加密失败",
ErrorNotExistProduct: "该商品不存在",
ErrorNotExistAddress: "该收获地址不存在",
ErrorExistFavorite: "已收藏该商品",
ErrorGetUserInfo: "获取用户信息错误",
ErrorGetDepart: "获取部门信息错误",
ErrorUpdateAw: "同步画作信息错误",
ErrorBossCheckTokenFail: "商家的Token鉴权失败",
ErrorBossCheckTokenTimeout: "商家TOken已超时",
ErrorBossToken: "商家的Token生成失败",
ErrorBoss: "商家Token错误",
ErrorBossInsufficientAuthority: "商家权限不足",
ErrorBossProduct: "商家读文件错误",
ErrorAuthCheckTokenFail: "Token鉴权失败",
ErrorAuthCheckTokenTimeout: "TOken已超时",
ErrorAuthToken: "Token生成失败",
ErrorAuth: "Token错误",
ErrorAuthInsufficientAuthority: "权限不足",
ErrorReadFile: "读文件失败",
ErrorSendEmail: "发送邮件失败",
ErrorCallApi: "调用接口失败",
ErrorUnmarshalJson: "解码JSON失败",
ErrorUploadFile: "上传失败",
ErrorAdminFindUser: "管理员查询用户失败",
ErrorDatabase: "数据库操作出错,请重试",
ErrorOss: "OSS配置错误",
ErrorExistShopName: "店铺已被注册,请检查店铺名称和统一社会信用码",
ErrorNotExistShopName: "店铺不存在",
ErrorNotAdmin: "非管理员",
InvalidToken: "Token验证失败",
ErrorUploadVideoCover: "视频截取封面错误",
ErrorUploadValidParam: "上传参数非法",
ErrorFileReadErr: "读取文件错误",
ErrorFileNotExists: "文件不存在",
ErrorChunkNotGt: "分块数量不一致",
ErrorChunk: "读取分块错误",
ErrorUploadBos: "上传bos错误",
ErrorFileCreate: "文件创建错误",
ERROR_UID: "uid创建错误",
ErrNoDomain: "环境变量必须要有",
ErrTelNum: "手机号码错误",
ErrNoCode: "验证码必须要有",
ErrNoID: "ID缺少",
ErrNickName: "昵称长度超过了20个字符或者缺失",
InvalidID: "身份证长度18位",
InvalidPas: "密码不小于6位",
ErrStatus: "状态非法",
ErrNoType: "缺少类型",
ErrNoUserID: "缺少用户ID",
ErrNoName: "缺少名称",
ErrNoDepCode: "缺少部门code",
ErrNoTitle: "缺少标题",
ErrNoUrl: "缺少url",
ErrNoMethod: "缺少method",
ErrNotDep: "缺少部门",
ErrCreateQr: "生成二维码错误",
ErrNotSellerBoss: "当前人员身份非销售总监,不能操作",
ErrWrongDate: "时间数据填写错误",
ErrLoginSeller: "您暂时没有权限登录销售宝,请联系管理员",
ErrorExistSecurity: "安全码已存在",
ErrorSecurity: "安全码错误",
ErrorNoSecurity: "安全码不存在",
ErrorRealName: "不可重复实名认证",
ErrorCode: "验证码错误",
NOTDATA: "没有数据",
ErrorBaiduChainAlreadyDone: "百度链已完成",
ErrorBaiduChaining: "百度链未完成",
ErrorBaiduChainError: "百度链错误",
ERROR_BAIDU_IMAGE: "图片审核不通过",
ERROR_BAIDU_FAIL: "图片审核失败",
ERROR_DOWNLOAD_FILE: "下载文件错误",
ERROR_Addr_FILE: "获取区块链地址错误",
ERROR_Amount: "开票金额错误",
ERROR_Create_Block: "上链失败",
ERROR_Fee_Deduction: "扣费失败",
ERROR_Insufficient_Balance: "余额不足",
ERROR_Text_Irregularity: "文字内容不合规",
ERROR_Text_Length: "文本长度超出限制",
ERROR_NoPermission: "您暂无权限,请联系客服",
}
const (
ErrorCreateFeedback = "请勿重复提交"
)
// GetMsg 获取状态码对应信息
func GetMsg(code int) string {
msg, ok := MsgFlags[code]
if ok {
return msg
}
return MsgFlags[ERROR]
}

View File

@ -0,0 +1,66 @@
package middleware
import (
"errors"
"fmt"
api "fonchain-fiee/api/account"
jwt2 "fonchain-fiee/pkg/common/jwt"
"fonchain-fiee/pkg/common/m"
"fonchain-fiee/pkg/e"
"fonchain-fiee/pkg/model/login"
"fonchain-fiee/pkg/service"
"github.com/gin-gonic/gin"
)
// CheckLogin 检测登陆
func CheckLogin(provider *api.AccountClientImpl) gin.HandlerFunc {
return func(ctx *gin.Context) {
//如果没有登录
authorization := ctx.GetHeader(e.BoxAuthorization)
if authorization == "" {
service.Error(ctx, errors.New(e.ErrNotLogin))
return
}
jwt, err := jwt2.ParseToken(authorization, m.JWTSecret)
fmt.Println(jwt)
if err != nil {
service.Error(ctx, errors.New(e.ErrNotLogin))
return
}
//1 获取用户的账号信息
infoReq := &api.UserByTelRequest{
Tel: jwt.Phone,
}
infoRes, err := service.AccountProvider.UserByTel(ctx, infoReq)
if err != nil {
service.Error(ctx, err)
return
}
if infoRes.IsExist == false {
service.Error(ctx, errors.New(e.ErrNotLogin))
return
}
info := infoRes.Info
loginInfo := login.Info{
Domain: info.Domain,
ID: info.ID,
Account: info.Account,
NickName: info.NickName,
TelNum: infoRes.Info.TelNum,
Avatar: infoRes.Info.Avatar,
RealName: infoRes.Info.RealName,
IDNum: infoRes.Info.IDNum,
}
ctx.Set("jwtInfo", loginInfo)
ctx.Next()
}
}

39
pkg/model/login/login.go Normal file
View File

@ -0,0 +1,39 @@
package login
import (
"errors"
"github.com/gin-gonic/gin"
)
type WxUser struct {
OpenID string `json:"openID"`
GHID string `json:"gHID"`
}
type Info struct {
Domain string `json:"domain"`
ID uint64 `json:"ID"`
Account string `json:"account"`
NickName string `json:"nickName"`
TelNum string `json:"telNum"`
Avatar string `json:"avatar"`
RealName string `json:"realName"`
IDNum string `json:"idNum"`
Coin string `json:"coin"` //追加一个余额
}
func GetUserInfoFromC(c *gin.Context) Info {
userInfoAny, _ := c.Get("jwtInfo")
userInfo := userInfoAny.(Info)
return userInfo
}
func GetUserInfoFromCtx(c *gin.Context) (Info, error) {
userInfoAny, _ := c.Get("jwtInfo")
if userInfoAny != nil {
userInfo := userInfoAny.(Info)
return userInfo, nil
} else {
return Info{}, errors.New("not login")
}
}

98
pkg/model/union/user.go Normal file
View File

@ -0,0 +1,98 @@
package union
import (
"fonchain-fiee/api/account"
)
type Extend struct {
JumpTo string `json:"JumpTo"`
Lang string `json:"Lang"`
CanScan bool `json:"CanScan"`
ResolutionRatio bool `json:"ResolutionRatio"`
}
type User struct {
ID uint64 `json:"ID"`
Domain string `json:"Domain"` //环境
NickName string `json:"NickName"` //昵称
TelNum string `json:"TelNum"` //手机号
Password string `json:"Password"` //密码
Avatar string `json:"Avatar"` //头像
Status string `json:"Status"` //头像
EnterDate string `json:"EnterDate"` //头像
WorkYear float32 `json:"WorkYear"` //头像
IsNeedChange uint64 `json:"IsNeedChange"` //是否强制修改密码
JumpTo string `json:"JumpTo"` //是否跳转老平台 origin-老平台 onsite当前
JobNum string `json:"JobNum"`
BirthDate string `json:"BirthDate"`
Sex uint64 `json:"Sex"`
Title string `json:"Title"`
LeftDate string `json:"LeftDate"`
Remark string `json:"Remark"`
RecentImg string `json:"RecentImg"` //近照
ICNum string `json:"ICNum"` //门禁卡号
Extend *account.Extend `json:"Extend"` //设置
Train string `json:"train"` //培训视频
Certificate string `json:"certificate"` //证书
Source string `json:"source"` //来源
Operator *account.Operator `json:"operator"` //来源
}
type UserResponse struct {
ID uint64 `json:"ID"`
Domain string `json:"Domain"` //环境
NickName string `json:"NickName"` //昵称
TelNum string `json:"TelNum"` //手机号
Password string `json:"Password"` //密码
Avatar string `json:"Avatar"`
Status string `json:"Status"`
CreateAt string `json:"CreateAt"`
RealNameID uint64 `json:"RealNameID"`
RealName string `json:"RealName"`
IsAdmin bool `json:"IsAdmin"`
EnterDate string `json:"EnterDate"` //头像
WorkYear float32 `json:"WorkYear"` //头像
IsNeedChange uint64 `json:"IsNeedChange"` //是否强制修改密码
JumpTo string `json:"JumpTo"` //是否跳转老平台 origin-老平台 onsite当前
Extend *account.Extend `json:"Extend"` //附件信息
DepartmentName string `json:"DepartmentName"`
JobNum string `json:"JobNum"`
BirthDate string `json:"BirthDate"`
Age uint64 `json:"Age"`
Sex uint64 `json:"Sex"`
Title string `json:"Title"`
IDNum string `json:"IDNum"`
LeftDate string `json:"LeftDate"`
DriverAuth bool `json:"DriverAuth"`
DriverSupervisorAuth bool `json:"DriverSupervisorAuth"`
Remark string `json:"Remark"`
IdentityKey string `json:"IdentityKey"` //身份
RecentImg string `json:"RecentImg"` //近照
MailAccount string `json:"MailAccount"` //近照
Clocks []*account.ClockUser `json:"clocks"`
ICNum string `json:"ICNum"` //门禁卡号
Train string `json:"train"` //培训视频
Certificate string `json:"certificate"` //证书
Source string `json:"source"` //来源
TrainVideos []*account.TrainVideo `json:"TrainVideos"` //关联用户岗位
}
type AccountInfo struct {
ID uint64 `json:"ID"`
Domain string `json:"Domain"` //环境
NickName string `json:"NickName"` //昵称
Account string `json:"Account"` //昵称
TelNum string `json:"TelNum"` //手机号
Avatar string `json:"Avatar"` //头像
Status string `json:"Status"` //头像
CreatedAt string `json:"CreatedAt"` //头像
IsNeedChange uint64 `json:"IsNeedChange"` //是否强制修改密码
Sex uint64 `json:"Sex"`
}
type Login struct {
AccountInfo *AccountInfo `json:"AccountInfo"`
Token string `json:"Token"` //环境
RefreshToken string `json:"RefreshToken"` //refresh_token
JumpToWhere string `json:"JumpToWhere"` //环境
}

View File

@ -2,6 +2,8 @@ package router
import ( import (
"fonchain-fiee/pkg/middleware" "fonchain-fiee/pkg/middleware"
"fonchain-fiee/pkg/service"
"fonchain-fiee/pkg/service/account"
"fonchain-fiee/pkg/service/auth" "fonchain-fiee/pkg/service/auth"
"fonchain-fiee/pkg/service/lang" "fonchain-fiee/pkg/service/lang"
"fonchain-fiee/pkg/service/qr" "fonchain-fiee/pkg/service/qr"
@ -22,7 +24,8 @@ func NewRouter() *gin.Engine {
r.Use(gzip.Gzip(gzip.BestSpeed)) // 中间件占用绝大部分内存 r.Use(gzip.Gzip(gzip.BestSpeed)) // 中间件占用绝大部分内存
//加入日志中间件,跨域中间件 //加入日志中间件,跨域中间件
r.Use(middleware.NewLogger(), middleware.Cors(), middleware.GinRecovery(true)) r.Use(middleware.NewLogger(), middleware.Cors(), middleware.GinRecovery(true))
privateGroup := r.Group("")
privateGroup.Use(middleware.NewLogger(), middleware.Cors(), middleware.GinRecovery(true))
//加入日志中间件,跨域中间件 //加入日志中间件,跨域中间件
v1 := r.Group("api") v1 := r.Group("api")
GiteaRoute(v1) GiteaRoute(v1)
@ -36,7 +39,19 @@ func NewRouter() *gin.Engine {
{ {
v1.POST("version", version.Version) //版本号公共 v1.POST("version", version.Version) //版本号公共
} }
//账号模块
{
r.POST("user/register", account.UserRegister) //h5注册登录
r.POST("user/login", account.UserLogin) //后台登录
r.POST("user/send", account.SendMsg) //发送验证码
acRoute := r.Group("/user")
acRoute.POST("logout", account.UserLogout) //登出
acRoute.Use(middleware.CheckLogin(service.AccountProvider))
{
acRoute.POST("real-name", account.RealName) //实名
acRoute.POST("check", account.CheckMsg) //校验验证码
}
}
{ {
//图片相关 //图片相关
imageRoute := v1.Group("image") imageRoute := v1.Group("image")

View File

@ -0,0 +1,142 @@
package account
import (
"context"
"fonchain-fiee/api/account"
"fonchain-fiee/pkg/config"
"fonchain-fiee/pkg/e"
"fonchain-fiee/pkg/model/union"
"fonchain-fiee/pkg/service"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
)
// SendMsg 用户登录操作
func SendMsg(c *gin.Context) {
var req account.SendMsgRequest
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
service.Error(c, err)
return
}
req.SignNo = uint32(config.DefaultSignNo)
res, err := service.AccountProvider.SendMsg(context.Background(), &req)
if err != nil {
service.Error(c, err)
return
}
service.Success(c, res)
return
}
func RealName(c *gin.Context) {
var req account.RealNameRequest
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
service.Error(c, err)
return
}
res, err := service.AccountProvider.RealName(context.Background(), &req)
if err != nil {
service.Error(c, err)
return
}
service.Success(c, res)
return
}
// CheckMsg 验证码是否正确
func CheckMsg(c *gin.Context) {
var req account.CheckMsgRequest
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
service.Error(c, err)
return
}
res, err := service.AccountProvider.CheckMsg(context.Background(), &req)
if err != nil {
service.Error(c, err)
return
}
service.Success(c, res)
return
}
func UserLogout(c *gin.Context) {
req := account.DecryptJwtRequest{}
req.Token = c.GetHeader(e.Authorization)
res, err := service.AccountProvider.Logout(c, &req)
if err != nil {
service.Error(c, err)
return
}
service.Success(c, res)
return
}
func UserRegister(c *gin.Context) {
var req account.RegistRequest
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
service.Error(c, err)
return
}
req.Domain = "app"
res, err := service.AccountProvider.Register(context.Background(), &req)
if err != nil {
service.Error(c, err)
}
tokenInfo, err := service.AccountProvider.Login(context.Background(), &account.LoginRequest{
Domain: req.Domain,
TelNum: req.TelNum,
Code: req.Code,
})
if err != nil {
service.Error(c, err)
}
res.Token = tokenInfo.Token
service.Success(c, res)
}
// UserLogin 用户登录操作
func UserLogin(c *gin.Context) {
var req account.LoginRequest
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
service.Error(c, err)
return
}
req.Ip = c.ClientIP()
req.Domain = "fontree"
res, err := service.AccountProvider.Login(c, &req)
if err != nil {
service.Error(c, err)
return
}
accountInfo := &union.AccountInfo{
ID: res.AccountInfo.ID,
Account: res.AccountInfo.Account,
NickName: res.AccountInfo.NickName,
Domain: res.AccountInfo.Domain,
TelNum: res.AccountInfo.TelNum,
Avatar: res.AccountInfo.Avatar,
CreatedAt: res.AccountInfo.CreateAt,
IsNeedChange: res.AccountInfo.IsNeedChange,
Sex: res.AccountInfo.Sex,
}
resInfo := &union.Login{
Token: res.Token,
RefreshToken: res.RefreshToken,
AccountInfo: accountInfo,
//JumpToWhere: jumpToWhere,
}
service.Success(c, resInfo)
return
}

30
pkg/service/init.go Normal file
View File

@ -0,0 +1,30 @@
package service
import (
"dubbo.apache.org/dubbo-go/v3/common/constant"
"dubbo.apache.org/dubbo-go/v3/config"
_ "dubbo.apache.org/dubbo-go/v3/imports"
"fmt"
"fonchain-fiee/api/account"
"fonchain-fiee/api/bundle"
pkConfig "fonchain-fiee/cmd/config"
"os"
)
var AccountProvider = new(account.AccountClientImpl)
var BundleProvider = new(bundle.BundleClientImpl)
func init() {
config.SetConsumerService(AccountProvider)
config.SetConsumerService(BundleProvider)
if err := config.Load(); err != nil {
panic(err)
}
pkConfig.GetOptions()
fmt.Println(os.Getenv(constant.ConfigFileEnvKey))
if err := config.Load(); err != nil {
panic(err)
}
}

View File

@ -3,6 +3,12 @@ package qr
import ( import (
"errors" "errors"
"fmt" "fmt"
"fonchain-fiee/cmd/config"
"fonchain-fiee/pkg/common/utils"
"fonchain-fiee/pkg/service"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
"github.com/skip2/go-qrcode"
"net/url" "net/url"
) )