Commit 74314a32 by 王昆

gsb

parent 7f931ff4
...@@ -432,7 +432,6 @@ class LaoActionApi extends APIBase { ...@@ -432,7 +432,6 @@ class LaoActionApi extends APIBase {
} catch { } catch {
return system.getResult(null, "获取数据失败"); return system.getResult(null, "获取数据失败");
} }
} }
async FindUserInfoByWhere(obj) { //根据条件获取用户或者企业信息 async FindUserInfoByWhere(obj) { //根据条件获取用户或者企业信息
...@@ -475,6 +474,25 @@ class LaoActionApi extends APIBase { ...@@ -475,6 +474,25 @@ class LaoActionApi extends APIBase {
return await this.labourSve.findlabourByWhere(parm); return await this.labourSve.findlabourByWhere(parm);
} }
async notifyInterview(obj) {
if(!obj.userId) {
return system.getResult(null, "用户id不存在");
}
if (!obj.id) {
return system.getResult(null, "人才id不存在");
}
try {
let rs = await this.labourSve.notifyInterview(obj);
return system.getResultSuccess(rs);
} catch (e) {
console.log(e);
return system.getErrResult2("您的网络不稳, 请稍后重试")
}
}
async FindRecruitByWhere(obj) { //根据条件获取招聘信息 async FindRecruitByWhere(obj) { //根据条件获取招聘信息
var parm = obj; var parm = obj;
if (obj.page_size) { if (obj.page_size) {
......
const system=require("../../../system"); const system = require("../../../system");
const Dao=require("../../dao.base"); const Dao = require("../../dao.base");
class UsersDao extends Dao{
constructor(){
super(Dao.getModelName(UsersDao));
}
async nameList() { class UserlabourDao extends Dao {
var sql = "SELECT * FROM user_info"; constructor() {
return await this.customQuery(sql); super(Dao.getModelName(UserlabourDao));
} }
async findUserInfoByPhone(phone_no){ async findLabourIdsByUserId(userId) {
var sql = "select * from user_info where phone_no = :phone"; var sql = "select labour_id from user_labour where user_id = :userId";
return await this.customQuery(sql, {phone:phone_no}); var list = await this.customQuery(sql, {userId: userId});
}
async findUserInfoByid(user_id){ var result = [];
return this.model.findOne( if(list) {
{ for (var item of list) {
where:{id:user_id}, result.push(item.labour_id);
raw:true
} }
); }
return result;
} }
async findUserInfoByids(ids,attrs){ async findMapByUserIds(userIds) {
var result = {}; var result = {};
if (!ids || ids.length == 0){ if (!userIds || userIds.length == 0) {
return result; return result;
} }
attrs = attrs || "*"; var sql = "select user_id, labour_id from user_labour where id user_id (:userIds)";
var sql = "select " + attrs + "from user_info where id in (:ids)"; var list = await this.customQuery(sql, {userIds: userIds});
var list = await this.customQuery(sql,{ids:ids}); if (!list || list.length == 0) {
if (!list || list.length == 0){
return result; return result;
} }
for (var item of list){ for (var item of list) {
result[item.id] = item; var lst = result[item.id];
if(!lst) {
lst = [];
}
lst.push(item.labour_id);
result[item.id] = lst;
} }
return result; return result;
} }
} }
module.exports=UsersDao;
module.exports = UserlabourDao;
// var tesk = new UsersDao(); // var tesk = new UsersDao();
// var res = tesk.nameList(); // var res = tesk.nameList();
......
const system=require("../../../system"); const system = require("../../../system");
const settings=require("../../../../config/settings"); const settings = require("../../../../config/settings");
const uiconfig=system.getUiConfig2(settings.appKey); const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => { module.exports = (db, DataTypes) => {
return db.define("labour", { return db.define("userlabour", {
labour_type: DataTypes.STRING(50), user_id: DataTypes.STRING(50),
labour_count: DataTypes.INTEGER, labour_id: DataTypes.INTEGER,
age_range: DataTypes.STRING(50), }, {
sex_ratio: DataTypes.STRING(10),
labour_address: DataTypes.STRING(1000),
report_date: DataTypes.DATE,
work_address: DataTypes.STRING(1000),
situation_memo: DataTypes.STRING,
phone_no: DataTypes.STRING(20),
user_id: DataTypes.INTEGER,
cur_type: DataTypes.INTEGER,
cur_status: DataTypes.STRING(16),
publish_date: DataTypes.DATE,
},{
paranoid: true,//假的删除 paranoid: true,//假的删除
underscored: true, underscored: true,
version: false, version: false,
freezeTableName: true, freezeTableName: true,
//freezeTableName: true, //freezeTableName: true,
// define the table's name // define the table's name
tableName: 'labour_info', tableName: 'user_labour',
validate: { validate: {},
indexes: [
},
indexes:[
// Create a unique index on email // Create a unique index on email
// { // {
// unique: true, // unique: true,
......
const system = require("../../../system"); const system = require("../../../system");
const ServiceBase = require("../../sve.base"); const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings"); const settings = require("../../../../config/settings");
/** /**
* 供人信息 * 供人信息
*/ */
...@@ -8,12 +9,13 @@ class LabourService extends ServiceBase { ...@@ -8,12 +9,13 @@ class LabourService extends ServiceBase {
constructor() { constructor() {
super("operator", ServiceBase.getDaoName(LabourService)); super("operator", ServiceBase.getDaoName(LabourService));
this.usersDao = system.getObject("db.operator.usersDao"); this.usersDao = system.getObject("db.operator.usersDao");
this.userlabourDao = system.getObject("db.operator.userlabourDao");
} }
async SaveLabourInfo(params){//添加或更新招聘信息 async SaveLabourInfo(params) {//添加或更新招聘信息
var id = params.id; var id = params.id;
var labour; var labour;
if (id){ if (id) {
labour = await this.dao.findById(id); labour = await this.dao.findById(id);
labour.labour_type = params.labour_type; labour.labour_type = params.labour_type;
labour.labour_count = params.labour_count; labour.labour_count = params.labour_count;
...@@ -25,20 +27,19 @@ class LabourService extends ServiceBase { ...@@ -25,20 +27,19 @@ class LabourService extends ServiceBase {
labour.situation_memo = params.situation_memo; labour.situation_memo = params.situation_memo;
labour.phone_no = params.phone_no; labour.phone_no = params.phone_no;
labour.user_id = params.user_id; labour.user_id = params.user_id;
labour.publish_date= params.publish_date; labour.publish_date = params.publish_date;
labour = await labour.save(); labour = await labour.save();
labour = await this.dao.findById(id); labour = await this.dao.findById(id);
} } else {
else{
labour = await this.dao.create(params); labour = await this.dao.create(params);
} }
return system.getResultSuccess(labour); return system.getResultSuccess(labour);
} }
async findAllList(obj){//获取全部供人信息,返回符合条件的列表 async findAllList(obj) {//获取全部供人信息,返回符合条件的列表
var pageSize=obj.page_size || 10; var pageSize = obj.page_size || 10;
var currentPage=obj.current_page || 1; var currentPage = obj.current_page || 1;
try { try {
var sqlwhere = { var sqlwhere = {
order: [["publish_date", 'desc']], order: [["publish_date", 'desc']],
...@@ -48,22 +49,22 @@ class LabourService extends ServiceBase { ...@@ -48,22 +49,22 @@ class LabourService extends ServiceBase {
}; };
var list = await this.dao.model.findAndCountAll(sqlwhere) || []; var list = await this.dao.model.findAndCountAll(sqlwhere) || [];
return system.getResult(list); return system.getResult(list);
}catch (e) { } catch (e) {
console.log(e); console.log(e);
return system.getResult(null,"操作失败"); return system.getResult(null, "操作失败");
} }
} }
async findListByUserid(obj){//获取userid供人信息,返回符合条件的列表 async findListByUserid(obj) {//获取userid供人信息,返回符合条件的列表
if (!obj.user_id){ if (!obj.user_id) {
return system.getResult(null,"参数错误!"); return system.getResult(null, "参数错误!");
} }
var user_id = obj.user_id; var user_id = obj.user_id;
var pageSize=obj.page_size || 10; var pageSize = obj.page_size || 10;
var currentPage=obj.current_page || 1; var currentPage = obj.current_page || 1;
try { try {
var sqlwhere = { var sqlwhere = {
where: {user_id:user_id}, where: {user_id: user_id},
order: [["publish_date", 'desc']], order: [["publish_date", 'desc']],
limit: pageSize, limit: pageSize,
offset: (currentPage - 1) * pageSize, offset: (currentPage - 1) * pageSize,
...@@ -71,32 +72,33 @@ class LabourService extends ServiceBase { ...@@ -71,32 +72,33 @@ class LabourService extends ServiceBase {
}; };
var list = await this.dao.model.findAndCountAll(sqlwhere) || []; var list = await this.dao.model.findAndCountAll(sqlwhere) || [];
return system.getResult(list); return system.getResult(list);
}catch (e) { } catch (e) {
console.log(e); console.log(e);
return system.getResult(null,"操作失败"); return system.getResult(null, "操作失败");
} }
} }
async findlabourByWhere(obj){//根据条件获取招工信息 async findlabourByWhere(obj) {//根据条件获取招工信息
var pageSize=obj.page_size || 10; var pageSize = obj.page_size || 10;
var currentPage=obj.current_page || 1; var currentPage = obj.current_page || 1;
var user_id = Number(obj.userId);
var where = {}; var where = {};
if (obj.id){ if (obj.id) {
where.id = obj.id; where.id = obj.id;
} }
if (obj.user_id){ if (obj.user_id) {
where.user_id = obj.user_id; where.user_id = obj.user_id;
} }
if (obj.phone_no){ if (obj.phone_no) {
where.phone_no = obj.phone_no; where.phone_no = obj.phone_no;
} }
if (obj.labour_type && obj.labour_type != "全部"){ if (obj.labour_type && obj.labour_type != "全部") {
where.labour_type = obj.labour_type; where.labour_type = obj.labour_type;
} }
if (obj.work_address && obj.work_address != "全部"){ if (obj.work_address && obj.work_address != "全部") {
where.work_address = obj.work_address; where.work_address = obj.work_address;
} }
if (obj.cur_status && obj.cur_status != "全部"){ if (obj.cur_status && obj.cur_status != "全部") {
where.cur_status = obj.cur_status; where.cur_status = obj.cur_status;
} }
...@@ -109,58 +111,66 @@ class LabourService extends ServiceBase { ...@@ -109,58 +111,66 @@ class LabourService extends ServiceBase {
raw: true raw: true
}; };
var list = await this.dao.model.findAndCountAll(sqlwhere) || []; var list = await this.dao.model.findAndCountAll(sqlwhere) || [];
if(list) { if (list) {
await this.setUserInfo(list.rows); await this.setUserInfo(list.rows);
let labourIds = await this.userlabourDao.findLabourIdsByUserId(user_id) || [];
for (var item of list.rows) {
item.showNotify = labourIds.indexOf(item.id) == -1;
}
} }
return system.getResult(list); return system.getResult(list);
}catch (e) { } catch (e) {
console.log(e); console.log(e);
return system.getResult(null,"操作失败"); return system.getResult(null, "操作失败");
} }
}
async notifyInterview(obj) {
var id = Number(obj.id);
var user_id = Number(obj.userId);
let labour = await this.userlabourDao.create({user_id: user_id, labour_id: id});
return labour;
} }
async updatestatus(obj){//更新状态信息 async updatestatus(obj) {//更新状态信息
try{ try {
var whereobj = {where:{id: obj.id}}; var whereobj = {where: {id: obj.id}};
var setobj = {}; var setobj = {};
setobj.cur_status = obj.cur_status; setobj.cur_status = obj.cur_status;
if (obj.cur_status == "展示中"){ if (obj.cur_status == "展示中") {
setobj.cur_type = 1; setobj.cur_type = 1;
} } else if (obj.cur_status == "已下架") {
else if (obj.cur_status == "已下架"){
setobj.cur_type = 2; setobj.cur_type = 2;
} } else if (obj.cur_status == "已过期") {
else if (obj.cur_status == "已过期"){
setobj.cur_type = 3; setobj.cur_type = 3;
} } else if (obj.cur_status == "审核未通过") {
else if (obj.cur_status == "审核未通过"){
setobj.cur_type = 4; setobj.cur_type = 4;
} }
var self = this; var self = this;
var v = await this.db.transaction(async function (t) { var v = await this.db.transaction(async function (t) {
await self.dao.updateByWhere(setobj,whereobj,t); await self.dao.updateByWhere(setobj, whereobj, t);
}); });
return 1; return 1;
} catch (e) {
}
catch (e){
console.log(e); console.log(e);
return 0; return 0;
} }
} }
/** /**
* 删除用户下制定 招聘或这是供招信息记录 * 删除用户下制定 招聘或这是供招信息记录
* @param {*} params * @param {*} params
*/ */
async RemRecOrLob(params){ async RemRecOrLob(params) {
try { try {
let res =await this.dao.model.destroy({ let res = await this.dao.model.destroy({
where:{ where: {
id:params.id, id: params.id,
user_id:params.userId user_id: params.userId
} }
}); });
return system.getResult(res); return system.getResult(res);
...@@ -183,6 +193,7 @@ class LabourService extends ServiceBase { ...@@ -183,6 +193,7 @@ class LabourService extends ServiceBase {
} }
} }
} }
module.exports = LabourService; module.exports = LabourService;
// var tesk = new LabourService(); // var tesk = new LabourService();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment