SystemOptionLog.js 1010 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /**
  2. * Created by Administrator on 2015/9/28.
  3. * 系统操作日志
  4. */
  5. var mongoose = require('mongoose');
  6. var shortid = require('shortid');
  7. var Schema = mongoose.Schema;
  8. var adminFunc = require('./db/adminFunc');
  9. var SystemOptionLogSchema = new Schema({
  10. _id: {
  11. type: String,
  12. unique: true,
  13. 'default': shortid.generate
  14. },
  15. type : String,
  16. date: { type: Date, default: Date.now },
  17. logs : String
  18. });
  19. SystemOptionLogSchema.statics = {
  20. //添加用户登录日志
  21. addUserLoginLogs : function(req,res,targetIp){
  22. var loginLog = new SystemOptionLog();
  23. loginLog.type = 'login';
  24. loginLog.logs = req.session.adminUserInfo.userName + ' 登录,IP:' + targetIp;
  25. loginLog.save(function (err) {
  26. if (err) {
  27. res.end(err);
  28. }
  29. });
  30. }
  31. }
  32. var SystemOptionLog = mongoose.model("SystemOptionLog",SystemOptionLogSchema);
  33. module.exports = SystemOptionLog;