'更新JS直接操作数据库'

This commit is contained in:
ForeverSmiYng 2024-06-28 16:13:46 +08:00
parent 1ade4f8447
commit 3cfa76f659

View File

@ -3,28 +3,33 @@
前端执行SQL查询语句
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
*/
function SelectByGSL() {
// let SQL_sentence = `SELECT loginid as id,password as pw FROM hrmresource`;
// let cols = "id,pw";
function SelectByGSL(SQL_sentence, cols) {
const getUrl = '/api/gSl/GSl/gsl';
const Query1 = `SELECT loginid as id,password as pw FROM hrmresource`;//编写SQL语句
const Query1 = SQL_sentence;//编写SQL语句
const jiami = ecCom.WeaTools.Base64.encode(Query1);
const result1 = ecCom.WeaTools.Base64.encode("id,pw");//编写查询内容
const result1 = ecCom.WeaTools.Base64.encode(cols);//编写查询内容
const mynewJSON = `{
"expression": "${jiami}",
"result": "${result1}"
}`;
const result = await ecCom.WeaTools.callApi(getUrl, 'POST', JSON.parse(mynewJSON));
return result;
}
/*
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
前端执行SQL增改语句
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
*/
function insertOrDeleteOrUpdateByGSL() {
// let SQL_sentence = `update hrmresource set fieldname='123' where id='43' `;
function insertOrDeleteOrUpdateByGSL(SQL_sentence) {
const getUrl = '/api/gSl/GSl/setTable';
const Query1 = `update hrmresource set fieldname='123' where id='43' `;//编写SQL语句
const Query1 = SQL_sentence;//编写SQL语句
const jiami = ecCom.WeaTools.Base64.encode(Query1);
const mynewJSON = `{
"expression": "${jiami}",
}`;
const result = await ecCom.WeaTools.callApi(getUrl, 'POST', JSON.parse(mynewJSON));
return result;
}