Commit 74314a32 by 王昆

gsb

parent 7f931ff4
......@@ -432,7 +432,6 @@ class LaoActionApi extends APIBase {
} catch {
return system.getResult(null, "获取数据失败");
}
}
async FindUserInfoByWhere(obj) { //根据条件获取用户或者企业信息
......@@ -475,6 +474,25 @@ class LaoActionApi extends APIBase {
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) { //根据条件获取招聘信息
var parm = obj;
if (obj.page_size) {
......
const system=require("../../../system");
const Dao=require("../../dao.base");
class UsersDao extends Dao{
constructor(){
super(Dao.getModelName(UsersDao));
}
const system = require("../../../system");
const Dao = require("../../dao.base");
async nameList() {
var sql = "SELECT * FROM user_info";
return await this.customQuery(sql);
class UserlabourDao extends Dao {
constructor() {
super(Dao.getModelName(UserlabourDao));
}
async findUserInfoByPhone(phone_no){
var sql = "select * from user_info where phone_no = :phone";
return await this.customQuery(sql, {phone:phone_no});
}
async findLabourIdsByUserId(userId) {
var sql = "select labour_id from user_labour where user_id = :userId";
var list = await this.customQuery(sql, {userId: userId});
async findUserInfoByid(user_id){
return this.model.findOne(
{
where:{id:user_id},
raw:true
var result = [];
if(list) {
for (var item of list) {
result.push(item.labour_id);
}
);
}
return result;
}
async findUserInfoByids(ids,attrs){
async findMapByUserIds(userIds) {
var result = {};
if (!ids || ids.length == 0){
if (!userIds || userIds.length == 0) {
return result;
}
attrs = attrs || "*";
var sql = "select " + attrs + "from user_info where id in (:ids)";
var list = await this.customQuery(sql,{ids:ids});
if (!list || list.length == 0){
var sql = "select user_id, labour_id from user_labour where id user_id (:userIds)";
var list = await this.customQuery(sql, {userIds: userIds});
if (!list || list.length == 0) {
return result;
}
for (var item of list){
result[item.id] = item;
for (var item of list) {
var lst = result[item.id];
if(!lst) {
lst = [];
}
lst.push(item.labour_id);
result[item.id] = lst;
}
return result;
}
}
module.exports=UsersDao;
module.exports = UserlabourDao;
// var tesk = new UsersDao();
// var res = tesk.nameList();
......
const system=require("../../../system");
const settings=require("../../../../config/settings");
const uiconfig=system.getUiConfig2(settings.appKey);
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("labour", {
labour_type: DataTypes.STRING(50),
labour_count: 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,
},{
return db.define("userlabour", {
user_id: DataTypes.STRING(50),
labour_id: DataTypes.INTEGER,
}, {
paranoid: true,//假的删除
underscored: true,
version: false,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'labour_info',
validate: {
},
indexes:[
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
// define the table's name
tableName: 'user_labour',
validate: {},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
/**
* 供人信息
*/
......@@ -8,12 +9,13 @@ class LabourService extends ServiceBase {
constructor() {
super("operator", ServiceBase.getDaoName(LabourService));
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 labour;
if (id){
if (id) {
labour = await this.dao.findById(id);
labour.labour_type = params.labour_type;
labour.labour_count = params.labour_count;
......@@ -25,142 +27,150 @@ class LabourService extends ServiceBase {
labour.situation_memo = params.situation_memo;
labour.phone_no = params.phone_no;
labour.user_id = params.user_id;
labour.publish_date= params.publish_date;
labour.publish_date = params.publish_date;
labour = await labour.save();
labour = await this.dao.findById(id);
}
else{
} else {
labour = await this.dao.create(params);
}
return system.getResultSuccess(labour);
}
async findAllList(obj){//获取全部供人信息,返回符合条件的列表
var pageSize=obj.page_size || 10;
var currentPage=obj.current_page || 1;
async findAllList(obj) {//获取全部供人信息,返回符合条件的列表
var pageSize = obj.page_size || 10;
var currentPage = obj.current_page || 1;
try {
var sqlwhere = {
order: [["publish_date", 'desc']],
limit: pageSize,
offset: (currentPage - 1) * pageSize,
raw: true
order: [["publish_date", 'desc']],
limit: pageSize,
offset: (currentPage - 1) * pageSize,
raw: true
};
var list = await this.dao.model.findAndCountAll(sqlwhere) || [];
return system.getResult(list);
}catch (e) {
} catch (e) {
console.log(e);
return system.getResult(null,"操作失败");
return system.getResult(null, "操作失败");
}
}
async findListByUserid(obj){//获取userid供人信息,返回符合条件的列表
if (!obj.user_id){
return system.getResult(null,"参数错误!");
async findListByUserid(obj) {//获取userid供人信息,返回符合条件的列表
if (!obj.user_id) {
return system.getResult(null, "参数错误!");
}
var user_id = obj.user_id;
var pageSize=obj.page_size || 10;
var currentPage=obj.current_page || 1;
var pageSize = obj.page_size || 10;
var currentPage = obj.current_page || 1;
try {
var sqlwhere = {
where: {user_id:user_id},
order: [["publish_date", 'desc']],
limit: pageSize,
offset: (currentPage - 1) * pageSize,
raw: true
where: {user_id: user_id},
order: [["publish_date", 'desc']],
limit: pageSize,
offset: (currentPage - 1) * pageSize,
raw: true
};
var list = await this.dao.model.findAndCountAll(sqlwhere) || [];
return system.getResult(list);
}catch (e) {
} catch (e) {
console.log(e);
return system.getResult(null,"操作失败");
return system.getResult(null, "操作失败");
}
}
async findlabourByWhere(obj){//根据条件获取招工信息
var pageSize=obj.page_size || 10;
var currentPage=obj.current_page || 1;
async findlabourByWhere(obj) {//根据条件获取招工信息
var pageSize = obj.page_size || 10;
var currentPage = obj.current_page || 1;
var user_id = Number(obj.userId);
var where = {};
if (obj.id){
if (obj.id) {
where.id = obj.id;
}
if (obj.user_id){
if (obj.user_id) {
where.user_id = obj.user_id;
}
if (obj.phone_no){
if (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;
}
if (obj.work_address && obj.work_address != "全部"){
if (obj.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;
}
try {
var sqlwhere = {
where: where,
order: [["publish_date", 'desc']],
limit: pageSize,
offset: (currentPage - 1) * pageSize,
raw: true
where: where,
order: [["publish_date", 'desc']],
limit: pageSize,
offset: (currentPage - 1) * pageSize,
raw: true
};
var list = await this.dao.model.findAndCountAll(sqlwhere) || [];
if(list) {
if (list) {
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);
}catch (e) {
} catch (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){//更新状态信息
try{
var whereobj = {where:{id: obj.id}};
async updatestatus(obj) {//更新状态信息
try {
var whereobj = {where: {id: obj.id}};
var setobj = {};
setobj.cur_status = obj.cur_status;
if (obj.cur_status == "展示中"){
if (obj.cur_status == "展示中") {
setobj.cur_type = 1;
}
else if (obj.cur_status == "已下架"){
} else if (obj.cur_status == "已下架") {
setobj.cur_type = 2;
}
else if (obj.cur_status == "已过期"){
} else if (obj.cur_status == "已过期") {
setobj.cur_type = 3;
}
else if (obj.cur_status == "审核未通过"){
} else if (obj.cur_status == "审核未通过") {
setobj.cur_type = 4;
}
var self = this;
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;
}
catch (e){
} catch (e) {
console.log(e);
return 0;
}
}
/**
* 删除用户下制定 招聘或这是供招信息记录
* @param {*} params
* @param {*} params
*/
async RemRecOrLob(params){
async RemRecOrLob(params) {
try {
let res =await this.dao.model.destroy({
where:{
id:params.id,
user_id:params.userId
let res = await this.dao.model.destroy({
where: {
id: params.id,
user_id: params.userId
}
});
return system.getResult(res);
......@@ -183,6 +193,7 @@ class LabourService extends ServiceBase {
}
}
}
module.exports = 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