sys.js 804 B

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. const Service = require('egg').Service;
  3. const md5 = require('md5-node');
  4. class SysService extends Service {
  5. async duplicateCheckOk( query )
  6. {
  7. console.log( query );
  8. let mysql = this.app.mysql;
  9. // tableName: 'sys_user',
  10. // fieldName: 'username',
  11. // fieldVal: 'test'
  12. let url = `select ${query.fieldName} from ${ query.tableName } where \'${query.fieldName}\'='${query.fieldVal}' limit 0,1`;
  13. // if( query.dataId ) {
  14. // url = `select ${query.fieldName} from ${ query.tableName } where ${query.fieldName}=${query.fieldVal} and id=${query.dataId}`;
  15. // }
  16. let ret = await mysql.query( url );
  17. return ret.length < 1;
  18. }
  19. }
  20. module.exports = SysService;