var Service = require('../../../../common/Service');
var util = require('util');
var Dao = require('../../dao/user_post');

/**
 * 获得用户职务信息
 */
var GetPost = function () {
  Service.call(this);
};

util.inherits(GetPost, Service);

module.exports = GetPost;

/**
 * 处理服务请求
 * @param {Object} req 服务请求对象
 * @param {Object} res 服务响应对象
 */
GetPost.prototype.process = function (req, res) {
  if (!req.id) {
    this.onLogicError(1, '请提供编号！');
    return;
  }
  var self = this;
  var dao = new Dao(this);
  dao.query({
    where: 'id=' + req.id + ' and org_id=' + req.session.orgId
  }, function (rows) {
    if (rows.length == 0) {
      self.onLogicError(2, '编号不正确！');
      return;
    }
    res.data = rows[0];
    self.emit('end', res);
  });
};