Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
shanliu committed Dec 31, 2023
1 parent e43c002 commit 570eb25
Show file tree
Hide file tree
Showing 39 changed files with 202 additions and 68 deletions.
2 changes: 1 addition & 1 deletion sdk/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ GET:app_id=1212f&payload=%7B%22client_id%22%3A%221212f%22%7D&request_ip=fe80%3A%

> 生成授权地址
```
http://www.lsys.cc/ui/oauth.html?client_id=1212f&redirect_uri=http%3A%2F%2F127.0.0.1%3A8080%2F&response_type=code&scope=user_info&state=aa
http://www.lsys.cc/oauth.html?client_id=1212f&redirect_uri=http%3A%2F%2F127.0.0.1%3A8080%2F&response_type=code&scope=user_info&state=aa
```

> 授权完成后返回
Expand Down
2 changes: 1 addition & 1 deletion sdk/go/examples/basic/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestGetSubAppInfo(t *testing.T) {
AppSecret: "3f95638a1e07b87df2b64e09c2541dac", //应用Secret
AppHost: "http://www.lsys.cc", //应用HOST
AppOAuthSecret: "2a97bf1b4f075b0ca7467e7c6b223f89", //应用OauthSecret
AppOAuthHost: "http://www.lsys.cc/ui/oauth.html",
AppOAuthHost: "http://www.lsys.cc/oauth.html",
})

//示例1
Expand Down
2 changes: 1 addition & 1 deletion sdk/go/examples/basic/mail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestMail(t *testing.T) {
AppSecret: "3f95638a1e07b87df2b64e09c2541dac", //应用Secret
AppHost: "http://www.lsys.cc", //应用HOST
AppOAuthSecret: "2a97bf1b4f075b0ca7467e7c6b223f89", //应用OauthSecret
AppOAuthHost: "http://www.lsys.cc/ui/oauth.html",
AppOAuthHost: "http://www.lsys.cc/oauth.html",
})
//示例1
//邮件发送示例
Expand Down
2 changes: 1 addition & 1 deletion sdk/go/examples/basic/rbac_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestRbac(t *testing.T) {
AppSecret: "3f95638a1e07b87df2b64e09c2541dac", //应用Secret
AppHost: "http://www.lsys.cc", //应用HOST
AppOAuthSecret: "2a97bf1b4f075b0ca7467e7c6b223f89", //应用OauthSecret
AppOAuthHost: "http://www.lsys.cc/ui/oauth.html",
AppOAuthHost: "http://www.lsys.cc/oauth.html",
})

//示例1
Expand Down
2 changes: 1 addition & 1 deletion sdk/go/examples/basic/sms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestSms(t *testing.T) {
AppSecret: "3f95638a1e07b87df2b64e09c2541dac", //应用Secret
AppHost: "http://www.lsys.cc", //应用HOST
AppOAuthSecret: "2a97bf1b4f075b0ca7467e7c6b223f89", //应用OauthSecret
AppOAuthHost: "http://www.lsys.cc/ui/oauth.html",
AppOAuthHost: "http://www.lsys.cc/oauth.html",
})

//示例1
Expand Down
8 changes: 4 additions & 4 deletions sdk/go/lsysrest/lsys_api_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type SmsCancelResult struct {
// cancelKey 取消句柄,发送时设置
func (receiver *RestApi) SmsCancel(ctx context.Context, cancelKeys []string) (error, []SmsCancelResult) {
data1 := (<-receiver.rest.Do(ctx, SmeCancel, map[string]interface{}{
"id_data": cancelKeys,
"snid_data": cancelKeys,
})).JsonResult()
if data1.Err() != nil {
return data1.Err(), nil
Expand All @@ -56,7 +56,7 @@ func (receiver *RestApi) SmsCancel(ctx context.Context, cancelKeys []string) (er
out = append(out, SmsCancelResult{
Status: tmp.Get("status").Bool(),
Msg: tmp.Get("msg").String(),
Id: tmp.Get("id").String(),
Id: tmp.Get("snid").String(),
})
}
return nil, out
Expand Down Expand Up @@ -90,7 +90,7 @@ func (receiver *RestApi) MailSend(ctx context.Context, to []string, tplId string
for _, tmp := range data1.GetData("response.detail").Array() {
out = append(out, MailSendResult{
Mail: tmp.Get("mail").String(),
Id: tmp.Get("id").String(),
Id: tmp.Get("snid").String(),
})
}
return nil, out
Expand All @@ -106,7 +106,7 @@ type MailCancelResult struct {
// cancelKey 取消句柄,发送时设置
func (receiver *RestApi) MailCancel(ctx context.Context, sendId []string) (error, []MailCancelResult) {
data1 := (<-receiver.rest.Do(ctx, MailCancel, map[string]interface{}{
"id_data": sendId,
"snid_data": sendId,
})).JsonResult()
if data1.Err() != nil {
return data1.Err(), nil
Expand Down
11 changes: 10 additions & 1 deletion server/assets/tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -420,16 +420,20 @@ CREATE TABLE `yaf_sender_mail_body` (
) ENGINE = InnoDB CHARSET = utf8mb4 COMMENT = '发送邮件数据';
CREATE TABLE `yaf_sender_mail_message` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID,由应用生成',
`snid` bigint unsigned NOT NULL COMMENT '消息ID',
`sender_body_id` bigint unsigned NOT NULL DEFAULT 0 COMMENT '邮件内容ID',
`to_mail` varchar(254) NOT NULL COMMENT '邮箱',
`try_num` smallint unsigned NOT NULL DEFAULT 0 COMMENT '发送次数',
`status` tinyint NOT NULL COMMENT '启用状态',
`add_time` bigint unsigned NOT NULL DEFAULT 0 COMMENT '添加时间冗余',
`send_time` bigint unsigned NOT NULL DEFAULT 0 COMMENT '发送时间',
`receive_time` bigint unsigned NOT NULL DEFAULT 0 COMMENT '接收时间',
`setting_id` bigint unsigned NOT NULL DEFAULT 0 COMMENT '发送使用配置ID',
`res_data` varchar(512) NOT NULL COMMENT '返回数据',
PRIMARY KEY (`id`),
UNIQUE KEY(`snid`),
KEY `sender_record_data_IDX` (`sender_body_id`) USING BTREE,
KEY `sender_add_time_IDX` (`add_time`) USING BTREE,
KEY `sender_res_data_IDX` (`setting_id`, `res_data`) USING BTREE
) ENGINE = InnoDB CHARSET = utf8mb4 COMMENT = '发送邮件收件人信息';
CREATE TABLE `yaf_sender_sms_body` (
Expand All @@ -450,17 +454,21 @@ CREATE TABLE `yaf_sender_sms_body` (
) ENGINE = InnoDB CHARSET = utf8mb4 COMMENT = '发送短信数据';
CREATE TABLE `yaf_sender_sms_message` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID,由应用生成',
`snid` bigint unsigned NOT NULL COMMENT '消息ID',
`sender_body_id` bigint unsigned NOT NULL DEFAULT 0 COMMENT '内容ID',
`area` varchar(32) NOT NULL COMMENT '区号',
`mobile` varchar(32) NOT NULL COMMENT '手机号',
`try_num` smallint unsigned NOT NULL DEFAULT 0 COMMENT '发送次数',
`status` tinyint NOT NULL COMMENT '启用状态',
`add_time` bigint unsigned NOT NULL DEFAULT 0 COMMENT '添加时间冗余',
`send_time` bigint unsigned NOT NULL DEFAULT 0 COMMENT '发送时间',
`receive_time` bigint unsigned NOT NULL DEFAULT 0 COMMENT '接收时间',
`setting_id` bigint unsigned NOT NULL DEFAULT 0 COMMENT '发送使用配置ID',
`res_data` varchar(512) NOT NULL COMMENT '返回数据',
PRIMARY KEY (`id`),
UNIQUE KEY(`snid`),
KEY `sender_record_data_IDX` (`sender_body_id`) USING BTREE,
KEY `sender_add_time_IDX` (`add_time`) USING BTREE,
KEY `sender_res_data_IDX` (`setting_id`, `res_data`) USING BTREE
) ENGINE = InnoDB CHARSET = utf8mb4 COMMENT = '发送短信接收手机号';
-- ----------- lsys-sender ---------------
Expand Down Expand Up @@ -557,6 +565,7 @@ INSERT INTO yaf_user_index (
status,
change_time
)
VALUES (1, 5, 'aaaaa', 1, UNIX_TIMESTAMP()),
VALUES (1, 5, 'root', 1, UNIX_TIMESTAMP()),
(1, 6, 'aaaaa', 1, UNIX_TIMESTAMP()),
(1, 7, '2', 1, UNIX_TIMESTAMP());
-- ----------- 初始用户 ---------------
2 changes: 1 addition & 1 deletion server/examples/lsys-actix-web/http/jwt/user_external.http
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Content-Type: application/json
{
"login_type": "wechat",
"login_state":"343444eee",
"callback_url":"http://www.lsys.cc/ui/#/user/info/oauth"
"callback_url":"http://www.lsys.cc/app.html#/user/info/oauth"
}


Expand Down
18 changes: 18 additions & 0 deletions server/lsys-docs/src/dao/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,24 @@ impl GitTask {
{
warn!("update clone succ status fail:{}", err);
}
let host_name = hostname::get()
.unwrap_or_default()
.to_string_lossy()
.to_string();
let message = "clone finish".to_string();
let vdata = model_option_set!(DocLogsModelRef, {
doc_clone_id:clone_id,
host:host_name,
doc_tag_id:git_tag_data.id,
message:message,
add_time:finish_time,
});
if let Err(err) = Insert::<sqlx::MySql, DocLogsModel, _>::new(vdata)
.execute(db)
.await
{
warn!("add git clone succ log fail:{}", err);
}
}
}
*run_size += 1;
Expand Down
4 changes: 2 additions & 2 deletions server/lsys-sender/src/dao/message_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ where
)
.await?)
}
pub async fn find_message_by_id_vec(&self, ids: &[u64]) -> SenderResult<Vec<MM>> {
pub async fn find_message_by_snid_vec(&self, ids: &[u64]) -> SenderResult<Vec<MM>> {
if ids.is_empty() {
return Ok(vec![]);
}
Ok(Select::type_new::<MM>()
.fetch_all_by_where::<MM, _>(
&sqlx_model::WhereOption::Where(sql_format!("id in ({})", ids)),
&sqlx_model::WhereOption::Where(sql_format!("snid in ({})", ids)),
&self.db,
)
.await?)
Expand Down
21 changes: 15 additions & 6 deletions server/lsys-sender/src/dao/sender_mailer/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ impl MailRecord {
pub async fn find_body_by_id(&self, id: &u64) -> SenderResult<SenderMailBodyModel> {
self.message_reader.find_body_by_id(id).await
}
#[allow(clippy::too_many_arguments)]
pub async fn message_count(
&self,
user_id: &Option<u64>,
app_id: &Option<u64>,
tpl_id: &Option<String>,
body_id: &Option<u64>,
msg_snid: &Option<u64>,
status: &Option<SenderMailMessageStatus>,
to_mail: &Option<String>,
) -> SenderResult<i64> {
Expand All @@ -80,6 +82,9 @@ impl MailRecord {
if let Some(s) = body_id {
sqlwhere.push(sql_format!("m.sender_body_id={} ", *s));
}
if let Some(s) = msg_snid {
sqlwhere.push(sql_format!("m.snid={} ", *s));
}
let sql = sql_format!(
"select count(*) as total from {} as m join {} as b on m.sender_body_id=b.id {}",
SenderMailMessageModel::table_name(),
Expand All @@ -101,6 +106,7 @@ impl MailRecord {
app_id: &Option<u64>,
tpl_id: &Option<String>,
body_id: &Option<u64>,
msg_snid: &Option<u64>,
status: &Option<SenderMailMessageStatus>,
to_mail: &Option<String>,
limit: &Option<LimitParam>,
Expand Down Expand Up @@ -128,7 +134,9 @@ impl MailRecord {
if let Some(s) = body_id {
sqlwhere.push(sql_format!("m.sender_body_id={} ", *s));
}

if let Some(s) = msg_snid {
sqlwhere.push(sql_format!("m.snid={} ", *s));
}
let where_sql = if let Some(page) = limit {
let page_where = page.where_sql(
"m.id",
Expand Down Expand Up @@ -259,7 +267,7 @@ impl MailRecord {
.map(|e| e.request_ip.clone().unwrap_or_default())
.unwrap_or_default();

let msg_id = Insert::<sqlx::MySql, SenderMailBodyModel, _>::new(
let body_id = Insert::<sqlx::MySql, SenderMailBodyModel, _>::new(
sqlx_model::model_option_set!(SenderMailBodyModelRef,{
request_id:reqid,
app_id:*app_id,
Expand All @@ -280,12 +288,13 @@ impl MailRecord {
let res_data = "".to_string();
for (aid, _, to) in add_data.iter() {
idata.push(sqlx_model::model_option_set!(SenderMailMessageModelRef,{
id:aid,
sender_body_id:msg_id,
snid:aid,
sender_body_id:body_id,
to_mail:to,
try_num:0,
status:SenderMailMessageStatus::Init as i8,
send_time:0,
add_time:add_time,
res_data:res_data,
}));
}
Expand All @@ -301,11 +310,11 @@ impl MailRecord {
.add(
&LogMessage {
action: "add",
body_id: msg_id,
body_id,
message_id: None,
sender_type: SenderType::Mailer as i8,
},
&Some(msg_id),
&Some(body_id),
&Some(user_id),
&Some(user_id),
None,
Expand Down
9 changes: 6 additions & 3 deletions server/lsys-sender/src/dao/sender_mailer/sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,16 @@ impl MailSender {
}
Ok(out)
}
pub async fn cancal_from_message_id_vec(
pub async fn cancal_from_message_snid_vec(
&self,
msg_data: &[u64],
msg_snid_data: &[u64],
user_id: &u64,
env_data: Option<&RequestEnv>,
) -> SenderResult<Vec<(u64, bool, Option<SenderError>)>> {
let res = self.message_reader.find_message_by_id_vec(msg_data).await?;
let res = self
.message_reader
.find_message_by_snid_vec(msg_snid_data)
.await?;
if res.is_empty() {
return Ok(vec![]);
}
Expand Down
20 changes: 15 additions & 5 deletions server/lsys-sender/src/dao/sender_smser/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ impl SmsRecord {
self.message_reader.find_body_by_id(id).await
}
//消息数量
#[allow(clippy::too_many_arguments)]
pub async fn message_count(
&self,
user_id: &Option<u64>,
app_id: &Option<u64>,
tpl_id: &Option<String>,
body_id: &Option<u64>,
msg_snid: &Option<u64>,
status: &Option<SenderSmsMessageStatus>,
mobile: &Option<String>,
) -> SenderResult<i64> {
Expand All @@ -83,6 +85,9 @@ impl SmsRecord {
if let Some(s) = body_id {
sqlwhere.push(sql_format!("m.sender_body_id={} ", *s));
}
if let Some(s) = msg_snid {
sqlwhere.push(sql_format!("m.snid={} ", *s));
}
let sql = sql_format!(
"select count(*) as total from {} as m join {} as b on m.sender_body_id=b.id {}",
SenderSmsBodyModel::table_name(),
Expand All @@ -105,6 +110,7 @@ impl SmsRecord {
app_id: &Option<u64>,
tpl_id: &Option<String>,
body_id: &Option<u64>,
msg_snid: &Option<u64>,
status: &Option<SenderSmsMessageStatus>,
mobile: &Option<String>,
limit: &Option<LimitParam>,
Expand All @@ -129,6 +135,9 @@ impl SmsRecord {
if let Some(s) = status {
sqlwhere.push(sql_format!("m.status={} ", *s));
}
if let Some(s) = msg_snid {
sqlwhere.push(sql_format!("m.snid={} ", *s));
}
if let Some(s) = body_id {
sqlwhere.push(sql_format!("m.sender_body_id={} ", *s));
}
Expand Down Expand Up @@ -278,7 +287,7 @@ impl SmsRecord {
)
.execute(&mut tran)
.await;
let msg_id = match res {
let body_id = match res {
Ok(e) => e.last_insert_id(),
Err(err) => {
tran.rollback().await?;
Expand All @@ -288,13 +297,14 @@ impl SmsRecord {
let res_data = "".to_string();
for (id, _, _, area, mobile) in add_data.iter() {
idata.push(sqlx_model::model_option_set!(SenderSmsMessageModelRef,{
id:id,
sender_body_id:msg_id,
snid:id,
sender_body_id:body_id,
mobile:*mobile,
area:*area,
try_num:0,
status:SenderSmsMessageStatus::Init as i8,
send_time:0,
add_time:add_time,
res_data:res_data,
}));
}
Expand All @@ -310,10 +320,10 @@ impl SmsRecord {
&LogMessage {
action: "add",
sender_type: SenderType::Smser as i8,
body_id: msg_id,
body_id,
message_id: None,
},
&Some(msg_id),
&Some(body_id),
&Some(user_id),
&Some(user_id),
None,
Expand Down
9 changes: 6 additions & 3 deletions server/lsys-sender/src/dao/sender_smser/sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,16 @@ impl SmsSender {
.collect::<Vec<_>>();
Ok((res.0, tmp))
}
pub async fn cancal_from_message_id_vec(
pub async fn cancal_from_message_snid_vec(
&self,
msg_data: &[u64],
msg_snid_data: &[u64],
user_id: &u64,
env_data: Option<&RequestEnv>,
) -> SenderResult<Vec<(u64, bool, Option<SenderError>)>> {
let res = self.message_reader.find_message_by_id_vec(msg_data).await?;
let res = self
.message_reader
.find_message_by_snid_vec(msg_snid_data)
.await?;
if res.is_empty() {
return Ok(vec![]);
}
Expand Down
Loading

0 comments on commit 570eb25

Please sign in to comment.