MCPcopy
hub / github.com/YMFE/yapi / solveConflict

Method solveConflict

server/controllers/interface.js:852–885  ·  view source on GitHub ↗
(ctx)

Source from the content-addressed store, hash-verified

850 }
851 // 处理编辑冲突
852 async solveConflict(ctx) {
853 try {
854 let id = parseInt(ctx.query.id, 10),
855 result,
856 userInst,
857 userinfo,
858 data;
859 if (!id) {
860 return ctx.websocket.send('id 参数有误');
861 }
862 result = await this.Model.get(id);
863
864 if (result.edit_uid !== 0 && result.edit_uid !== this.getUid()) {
865 userInst = yapi.getInst(userModel);
866 userinfo = await userInst.findById(result.edit_uid);
867 data = {
868 errno: result.edit_uid,
869 data: { uid: result.edit_uid, username: userinfo.username }
870 };
871 } else {
872 this.Model.upEditUid(id, this.getUid()).then();
873 data = {
874 errno: 0,
875 data: result
876 };
877 }
878 ctx.websocket.send(JSON.stringify(data));
879 ctx.websocket.on('close', () => {
880 this.Model.upEditUid(id, 0).then();
881 });
882 } catch (err) {
883 yapi.commons.log(err, 'error');
884 }
885 }
886
887 async addCat(ctx) {
888 try {

Callers

nothing calls this directly

Calls 4

getMethod · 0.45
getUidMethod · 0.45
findByIdMethod · 0.45
upEditUidMethod · 0.45

Tested by

no test coverage detected