'use strict'; const Service = require('egg').Service; const md5 = require('md5-node'); class SysService extends Service { async duplicateCheckOk( query ) { console.log( query ); let mysql = this.app.mysql; // tableName: 'sys_user', // fieldName: 'username', // fieldVal: 'test' let url = `select ${query.fieldName} from ${ query.tableName } where \'${query.fieldName}\'='${query.fieldVal}' limit 0,1`; // if( query.dataId ) { // url = `select ${query.fieldName} from ${ query.tableName } where ${query.fieldName}=${query.fieldVal} and id=${query.dataId}`; // } let ret = await mysql.query( url ); return ret.length < 1; } } module.exports = SysService;