Skip to content

Commit

Permalink
feat: 同步后端代码
Browse files Browse the repository at this point in the history
  • Loading branch information
JackySoft committed Oct 27, 2024
1 parent 70d145e commit dcbecb3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 3 additions & 3 deletions backend/koa/controller/workflow.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ module.exports = {
},

async update(ctx) {
const { form_name, form_desc, page_id, template_data } = ctx.request.body;
if (!util.isNumber(form_name)) {
const { id, form_name, form_desc, page_id, template_data } = ctx.request.body;
if (!util.isNumber(id)) {
return ctx.throw(400, '组件id不正确');
}

const { userId } = util.decodeToken(ctx);

await workflow.updateTemplate(form_name, form_desc, page_id, template_data, userId);
await workflow.updateTemplate(id, form_name, form_desc, page_id, template_data, userId);
util.success(ctx);
},
};
2 changes: 1 addition & 1 deletion backend/koa/router/user.router.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ router.post('/sendEmail', async (ctx) => {
await keyv.set(email, random, 3 * 60 * 1000);
util.success(ctx, '发送成功');
} catch (error) {
util.fail(ctx, '发送失败,请重试');
util.fail(ctx, error.message);
}
});

Expand Down
10 changes: 8 additions & 2 deletions backend/koa/service/workflow.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ class PagesService {
const limit = pageSize;
const statement = `
SELECT
*
id,
form_name,
form_desc,
page_id,
user_name,
updated_at
FROM
workflows
WHERE
Expand Down Expand Up @@ -42,7 +47,7 @@ class PagesService {
return result;
}

async updateTemplate(form_name, form_desc, page_id, template_data, user_id) {
async updateTemplate(id, form_name, form_desc, page_id, template_data, user_id) {
let statement = `UPDATE workflows SET updated_at = ?`;
let sql_params = [new Date()];
if (form_name) {
Expand All @@ -66,6 +71,7 @@ class PagesService {
}

statement += ` WHERE id = ? and user_id = ?;`;
sql_params.push(id);
sql_params.push(user_id);
const [result] = await connection.execute(statement, sql_params);
return result;
Expand Down

0 comments on commit dcbecb3

Please sign in to comment.