添加修改SN号数量功能
This commit is contained in:
@@ -66,6 +66,34 @@ class SNAdminController extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
// 修改可管理的SN号数量
|
||||
async editSNCount() {
|
||||
const { ctx } = this;
|
||||
try {
|
||||
let rdmcode = await this.checkUid(ctx);
|
||||
if (!rdmcode) {
|
||||
this.setResponse(ctx, 401, 'token过期或错误', "none");
|
||||
return;
|
||||
}
|
||||
const uid = JSON.parse(rdmcode).uid;
|
||||
const body = ctx.request.body;
|
||||
const result = await ctx.service.sNAdmin.editSNCount(uid, body);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result) {
|
||||
this.setResponse(ctx, 200, '修改可管理的SN号数量成功', "none");
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '修改可管理的SN号数量失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "editSNCount";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
|
||||
// B端分配SN号
|
||||
async allocationSN() {
|
||||
const { ctx } = this;
|
||||
|
||||
@@ -162,6 +162,8 @@ module.exports = app => {
|
||||
router.post("/searchAllocationSN", controller.sNAdmin.searchAllocationSN);
|
||||
// 搜索可分配的单位用户
|
||||
router.post("/searchAllocationUser", controller.sNAdmin.searchAllocationUser);
|
||||
// 修改可管理的SN号数量
|
||||
router.post("/editSNCount", controller.sNAdmin.editSNCount);
|
||||
// B端分配SN号
|
||||
router.post("/allocationSN", controller.sNAdmin.allocationSN);
|
||||
// 查看B端SN号分配记录
|
||||
|
||||
@@ -64,6 +64,28 @@ class SNAdminService extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
// 修改可管理的SN号数量
|
||||
async editSNCount(uid, body) {
|
||||
const { ctx } = this;
|
||||
try {
|
||||
const result = await ctx.model3.Insiders.findOne({ where: { uid } });
|
||||
if (!result || result.dataValues.role < 6) return false;
|
||||
const { user_uid, length } = body;
|
||||
const existence = await ctx.model.BuserSNAdmin.findOne({ attributes: ['length'], where: { user_uid: user_uid } });
|
||||
if (existence) {
|
||||
const adminResult = await ctx.model.BuserSNAdmin.update({ length }, { where: { user_uid: user_uid } });
|
||||
return adminResult[0] == 0 ? false : adminResult;
|
||||
} else {
|
||||
const adminResult = await ctx.model.BuserSNAdmin.create({ user_uid, length, sn_set: '' });
|
||||
return adminResult == 0 ? false : adminResult;
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "editSNCount";
|
||||
ctx.app.middleware.log('../../serviceLog', blockName + ">>>>" + error);
|
||||
return 'error';
|
||||
}
|
||||
}
|
||||
|
||||
// B端分配SN号
|
||||
async allocationSN(uid, body) {
|
||||
const { ctx } = this;
|
||||
@@ -135,42 +157,9 @@ class SNAdminService extends Service {
|
||||
order.push([element, 'DESC']);
|
||||
}
|
||||
});
|
||||
// const [bside, bsideSNRecord] = await Promise.all([
|
||||
// ctx.model.BSide.findAll({ attributes: ['uid', 'account_name'] }),
|
||||
// ctx.model.BindBSNrecord.findAll({ attributes: ['user_uid', 'sn_number', 'type'] })
|
||||
// ]);
|
||||
// if (searchOptions.account_name) {
|
||||
// if (searchOptions.account_name == '*空') {
|
||||
// where.user_uid = [null, ''];
|
||||
// } else {
|
||||
// let userArr = [], lengthArr = [], SNArr = [];
|
||||
// bside.filter(item => {
|
||||
// if (item.dataValues.account_name.includes(searchOptions.account_name)) {
|
||||
// bsideSNRecord.filter(item2 => {
|
||||
// if (item2.dataValues.user_uid == item.dataValues.uid) {
|
||||
// userArr.push(item2.dataValues.user_uid);
|
||||
// lengthArr.push(item2.dataValues.length);
|
||||
// SNArr.push(item2.dataValues.sn_set);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// where.user_uid = [...userArr];
|
||||
// where.length = [...lengthArr];
|
||||
// where.sn_set = [...SNArr];
|
||||
// }
|
||||
// }
|
||||
dbOptions = { attributes, offset, limit, where, order };
|
||||
// let result;
|
||||
dbOptions.limit = Math.floor(limit / 2);
|
||||
dbOptions.offset = Math.floor(offset / 2);
|
||||
// const [bresult] = await Promise.all([
|
||||
// ctx.model.BuserSNAdmin.findAndCountAll(dbOptions)
|
||||
// ]);
|
||||
// result = {
|
||||
// count: bresult.count,
|
||||
// rows: bresult.rows
|
||||
// };
|
||||
const bside = await ctx.model.BSide.findAll({ attributes: ['uid', 'account_name'] });
|
||||
const result = await ctx.model.BuserSNAdmin.findAndCountAll(dbOptions);
|
||||
result.rows.forEach(element => {
|
||||
|
||||
1
serviceLog/2026/6/11.txt
Normal file
1
serviceLog/2026/6/11.txt
Normal file
@@ -0,0 +1 @@
|
||||
[2026-6-11>>>11:24:34]>>>SNAdmin--allocationSN>>>>Error: WHERE parameter "sn_number" has invalid "undefined" value
|
||||
Reference in New Issue
Block a user