Commit 40899e05 authored by 方斌's avatar 方斌

official

parent 165e7b57
'use strict';
const Controller = require('egg').Controller;
const moment = require('moment');
class InvestmentController extends Controller {
//投资者关系列表
async list() {
const { ctx, service } = this;
const input_params = ctx.params;
const rule = {
page: { type: 'string', required: true }, //类型
type_id: { type: 'string', required: true }, //类型
language: { type: 'string', required: true }, //语言
}
ctx.validate(rule, input_params);
const ret = await service.official.investment.getList(input_params);
let rows = [];
ret.rows.forEach(ele => {
let file_url = '';
if (ele.file_url) {
file_url = this.app.config.CDN_BASE_URL + ele.file_url;
}
let item = { title: ele.title, file_url: file_url, type_id: ele.type_id, language: ele.language, created_time: moment(ele.created_time).format('YYYY-MM-DD') };
rows.push(item);
})
ctx.success({ page: ret.page, count: ret.count, rows: rows });
}
//投资者关系项列表
async typeList() {
const { ctx, service } = this;
const investment_types = await service.official.investment.getTypeList();
let ret = [];
investment_types.forEach(ele => {
ret.push({ id: ele.id, name: ele.name });
})
ctx.success(ret);
}
}
module.exports = InvestmentController;
'use strict';
const Controller = require('egg').Controller;
class JobController extends Controller {
async info() {
const { ctx, service } = this;
if (ctx.params.city_code === 'undefined') { return ctx.throw(422, 'city_code is missing!'); }
ctx.success({ results: blocks });
}
async list() {
const { ctx, service } = this;
if (ctx.params.jobtypeid === 'undefined') { return ctx.throw(422, 'job_style is missing!'); }
let job_type_id = ctx.params.jobtypeid;
const ret = await service.official.job.job.get_list( { job_type_id: job_type_id } );
ctx.success({ results: ret });
}
async all() {
const { ctx, service } = this;
if (ctx.params.jobtype === 'undefined') { return ctx.throw(422, 'job_style is missing!'); }
let job_type = ctx.params.jobtype;
const job_types = await service.official.job.type.get_list( { job_type: job_type } );
var jobs = [];
for(const item of job_types ) {
let job_type_id = item.id;
let ret = await service.official.job.job.get_list( { job_type_id: job_type_id } );
jobs.push({
id: item.id,
name: item.name,
icon: item.icon,
background: item.background,
jobs: ret,
});
}
ctx.success({ results : jobs });
}
async apply() {
const { service, ctx } = this;
const input_params = ctx.request.body;
console.log(input_params);
console.log(ctx.request);
// 招聘岗位de id号
if (typeof (input_params.job_id) === 'undefined' || !input_params.job_id) {
return ctx.throw(422, 'job_id is missing!');
}
//求职者姓名
if (typeof (input_params.name) === 'undefined' || !input_params.name) {
return ctx.throw(422, 'name is missing!');
}
//求职者手机号
if (typeof (input_params.telephone) === 'undefined' || !input_params.telephone) {
return ctx.throw(422, 'telephone is missing!');
}
//求职者邮箱
if (typeof (input_params.email) === 'undefined' || !input_params.email) {
return ctx.throw(422, 'email is missing!');
}
//求职者学校
if (typeof (input_params.school) === 'undefined' || !input_params.school) {
return ctx.throw(422, 'school is missing!');
}
//求职者专业
if (typeof (input_params.major) === 'undefined' || !input_params.major) {
return ctx.throw(422, 'major is missing!');
}
//求职者简历
if (typeof (input_params.resume) === 'undefined' || !input_params.resume) {
return ctx.throw(422, 'resume is missing!');
}
//邀请码
if (typeof (input_params.code) === 'undefined') {
return ctx.throw(422, 'code is missing!');
}
const ret = await service.official.job.apply.apply(input_params);
ctx.success({ results: ret });
}
async school_recruit() {
//默认是公积金管家的app_type_id
const school_recruitInfo = service.block.get_block_info({ app_type_id: '2150d0f1-ee07-4d17-a019-251be3699bd1', alias: 'official_school_recruit' });
const school_recruits = await this.formatBlock(school_recruitInfo);
//以下老版本的 取消
// const { ctx } = this;
// let filter = {
// where: {
// location: 'official_school_recruit',
// status: 1,
// valid: 1,
// },
// };
// const banner_type = await ctx.huodongModel.BannerType.findOne(filter);
// if (!banner_type) {
// ctx.failed('错误的location');
// }
// filter = {
// where: {
// banner_id: banner_type.sid,
// },
// };
// const banners = await ctx.huodongModel.Banner.findAll(filter);
const result = {};
let i = 0;
for (const v of school_recruits) {
if(i == 1) {
return false;
}
result.banner_id = v.id;
result.image = v.logo;
result.url = v.link;
result.title = v.title;
result.type = 'video';
i++;
}
ctx.success({ results: result });
}
async formatBlock(block) {
if (block.length === 0) {
return [];
}
const ret = [];
for (const v of block) {
const tmp = {
id: v.id,
title: v.title,
sub_title: v.subtitle,
description: v.description,
link: v.link,
logo: v.logo,
sort: v.sort,
};
ret.push(tmp);
}
return ret;
}
}
module.exports = JobController;
'use strict';
const Controller = require('egg').Controller;
class JobtypeController extends Controller {
async list() {
const { ctx, service } = this;
if (ctx.params.jobtype === 'undefined') { return ctx.throw(422, 'job_style is missing!'); }
let job_type = ctx.params.jobtype;
const ret = await service.official.job.type.get_list( { job_type: job_type } );
ctx.success({ results: ret });
}
async school() {
const { ctx, service } = this;
let job_type = 1;
const ret = await service.official.job.type.get_list( { job_type: job_type } );
ctx.success({ results: ret });
}
async social() {
const { ctx, service } = this;
let job_type = 2;
const ret = await service.official.job.type.get_list( { job_type: job_type } );
ctx.success({ results: ret });
}
}
module.exports = JobtypeController;
'use strict';
const moment = require('moment');
module.exports = app => {
const { STRING, INTEGER, DATE, ENUM, TEXT } = app.Sequelize;
const officialInvestment = app.blockModel.define('official_investment', {
id: { type: INTEGER, primaryKey: true, autoIncrement: true },
title: STRING,
description: STRING,
file_url: STRING,
type_id: INTEGER,
language: INTEGER,
status: INTEGER,
is_deleted: INTEGER,
created_time: {
type: DATE,
get() {
const date = this.getDataValue('created_time');
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
},
updated_time: {
type: DATE,
get() {
const date = this.getDataValue('updated_time');
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
},
}, {
timestamps: false,
tableName: 'official_investment',
});
officialInvestment.one = async (data) => {
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
return await officialInvestment.findOne({
attributes: attributes,
where: where,
});
}
officialInvestment.all = async (data) => {
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
return await officialInvestment.findAll({
attributes: attributes,
where: where,
});
}
officialInvestment.list = async (data = {}) => {
const limit = data.limit ? data.limit : 10;
const page = data.page ? data.page : 1;
const order = data.order ? data.order : [];
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
const condition = {
offset: (page - 1) * limit,
limit,
where: where,
order: order,
// attributes: attributes,
};
const { count, rows } = await officialInvestment.findAndCountAll(condition);
return { page, count, rows };
}
officialInvestment.add = async (data) => {
try {
//返回promise对象实力 instance
const res = await officialInvestment.create(data);
//从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
return res.id;
} catch (error) {
ctx.status = 500;
throw (error);
}
}
officialInvestment.edit = async (data) => {
const where = data.where;
const params = data.params;
officialInvestment.update(params, {
where: where
}).catch(e => res.json({ status: 500, error: e }));
}
return officialInvestment;
};
'use strict';
const moment = require('moment');
module.exports = app => {
const { STRING, INTEGER, DATE, ENUM, TEXT } = app.Sequelize;
const officialInvestmentType = app.blockModel.define('official_investment_type', {
id: { type: INTEGER, primaryKey: true, autoIncrement: true },
name: STRING,
status: INTEGER,
is_deleted: INTEGER,
created_time: {
type: DATE,
get() {
const date = this.getDataValue('created_at');
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
},
updated_time: {
type: DATE,
get() {
const date = this.getDataValue('updated_at');
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
},
}, {
timestamps: false,
tableName: 'official_investment_type',
});
officialInvestmentType.one = async (data) => {
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
return await officialInvestmentType.findOne({
attributes: attributes,
where: where,
});
}
officialInvestmentType.all = async (data) => {
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
const order = data.order ? data.order : [];
return await officialInvestmentType.findAll({
attributes: attributes,
where: where,
order: order,
});
}
officialInvestmentType.list = async (data = {}) => {
const limit = data.limit ? data.limit : 10;
const page = data.page ? data.page : 1;
const order = data.order ? data.order : [];
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
const condition = {
offset: (page - 1) * limit,
limit,
where: where,
order: order,
attributes: attributes,
};
console.log(condition);
const { count, rows } = await officialInvestmentType.findAndCountAll(condition);
return { page, count, rows };
}
officialInvestmentType.add = async (data) => {
try {
//返回promise对象实力 instance
const res = await officialInvestmentType.create(data);
//从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
return res.id;
} catch (error) {
ctx.status = 500;
throw (error);
}
}
officialInvestmentType.edit = async (data) => {
const where = data.where;
const params = data.params;
officialInvestmentType.update(params, {
where: where
}).catch(e => res.json({ status: 500, error: e }));
}
return officialInvestmentType;
};
......@@ -4,7 +4,7 @@ const moment = require('moment');
module.exports = app => {
const { STRING, INTEGER, DATE, ENUM} = app.Sequelize;
const OfficialJob = app.blockModel.define('zhiren_job', {
const OfficialJob = app.blockModel.define('official_job', {
id: { type: STRING, primaryKey: true, autoIncrement: true },
job_type: INTEGER,
job_type_id: INTEGER,
......@@ -32,7 +32,7 @@ module.exports = app => {
},
}, {
timestamps: false,
tableName: 'zhiren_job',
tableName: 'official_job',
});
OfficialJob.one = async (data) => {
......
......@@ -4,7 +4,7 @@ const moment = require('moment');
module.exports = app => {
const { STRING, INTEGER, DATE, ENUM} = app.Sequelize;
const OfficialJobApply = app.blockModel.define('zhiren_job_apply', {
const OfficialJobApply = app.blockModel.define('official_job_apply', {
id: { type: STRING, primaryKey: true, autoIncrement: true },
job_id: INTEGER,
name: STRING,
......@@ -31,7 +31,7 @@ module.exports = app => {
},
}, {
timestamps: false,
tableName: 'zhiren_job_apply',
tableName: 'official_job_apply',
});
OfficialJobApply.one = async (data) => {
......
......@@ -4,7 +4,7 @@ const moment = require('moment');
module.exports = app => {
const { STRING, INTEGER, DATE, ENUM} = app.Sequelize;
const OfficialJobType = app.blockModel.define('zhiren_job_type', {
const OfficialJobType = app.blockModel.define('official_job_type', {
id: { type: STRING, primaryKey: true, autoIncrement: true },
job_type: INTEGER,
name: STRING,
......@@ -28,7 +28,7 @@ module.exports = app => {
},
}, {
timestamps: false,
tableName: 'zhiren_job_type',
tableName: 'official_job_type',
});
OfficialJobType.one = async (data) => {
......
......@@ -9,4 +9,6 @@ module.exports = app => {
router.get('/', controller.home.index);
require('./router/gjj')(app);
require('./router/official')(app);// 官网招聘和投资者关系
};
'use strict';
module.exports = app => {
const router = app.router.namespace(app.config.projectRootPath + '/official');
router.get('/job/info/:id', 'official.job.info');//招聘岗位详情信息
router.get('/job/list/:jobtypeid', 'official.job.list');//招聘岗位列表
router.get('/jobtype/list/:jobtype', 'official.jobtype.list');//招聘类型列表
router.get('/jobtype/school', 'official.jobtype.school');//校园招聘类型列表
router.get('/jobtype/social', 'official.jobtype.social');//校园招聘类型列表
router.get('/job/all/:jobtype', 'official.job.all');//招聘类型+招聘岗位全部
router.post('/job/apply', 'official.job.apply');//简历提交,求职
router.get('/investment/:page/:type_id/:language', 'official.investment.list');//投资者关系
router.get('/investment_type', 'official.investment.typeList');//投资者项列表
};
'use strict';
const Service = require('egg').Service;
class InvestmentService extends Service {
async getList(input_params) {
const { ctx } = this;
const condition = {
page: input_params.page,
where: {
type_id: input_params.type_id,
language: input_params.language,
status: 1,
is_deleted: 0,
},
order: [['id', 'desc']]
};
const ret = await ctx.blockModel.OfficialInvestment.list(condition);
return ret;
}
async getTypeList() {
const { ctx } = this;
const ret = await ctx.blockModel.OfficialInvestmentType.all({ where: { status: 1, is_deleted: 0 }, order: [['sort_order', 'ASC']] });
return ret;
}
}
module.exports = InvestmentService;
\ No newline at end of file
'use strict';
const Service = require('egg').Service;
class ApplyService extends Service {
async apply(condition = {}) {
const { ctx } = this;
const moment = require('moment');
const now = moment().format('YYYY-MM-DD HH:mm:ss');
const data = {
job_id: condition.job_id,
name: condition.name,
telephone: condition.telephone,
email: condition.email,
school: condition.school,
major: condition.major,
resume: condition.resume,
code: condition.code,
created_time: now,
};
let ret = ctx.blockModel.OfficialJobApply.add(data);
return ret;
}
}
module.exports = ApplyService;
\ No newline at end of file
'use strict';
const Service = require('egg').Service;
class JobService extends Service {
async get_info(condition = {}) {
const { ctx } = this;
const job_id = condition.job_id ? condition.job_id : '';
//获得职位的信息
var job = job_id ? await ctx.blockModel.OfficialJob.one({
where: {
id : job_id, //
status: 1,//在线
is_deleted: 0,//未删除
},
attributes: ['id', 'name', 'duty', 'demand', 'salary', 'experience', 'grade'],
}) : {};
//当职位的信息不存在时,或者已经下线时,是空的
if(!job) {
return {};
}
return job;
}
async get_list(condition = {}) {
const { ctx } = this;
let { job_type_id } = {
job_type_id : condition.job_type_id ? condition.job_type_id : '',
// job_type : condition.job_type ? condition.job_type : '',
}
if(job_type_id == '') return {};
var where = {};
const attributes = ['id', 'name', 'duty', 'demand', 'salary', 'experience', 'grade'];
where.job_type_id = job_type_id;
//where.job_type = job_type;
where.status = 1;//在线
where.is_deleted = 0;//未删除
var data = {where , attributes};
var jobs = await ctx.blockModel.OfficialJob.all(data);
if(!jobs) return {};
return jobs;
}
}
module.exports = JobService;
\ No newline at end of file
'use strict';
const Service = require('egg').Service;
class TypeService extends Service {
async get_list(condition = {}) {
const { ctx } = this;
console.log(condition);
let job_type = condition.job_type ? condition.job_type : '';
var where = {};
const attributes = ['id', 'name', 'icon', 'background'];
where.job_type = job_type;
where.status = 1;//在线
where.is_deleted = 0;//未删除
var data = {where , attributes};
console.log(data);
var jobstyles = await ctx.blockModel.OfficialJobType.all(data);
if(!jobstyles) return {};
var ret = [];
for(const item of jobstyles) {
ret.push({
id: item.id,
name: item.name,
icon: this.config.CDN_BASE_URL + item.icon,
background: this.config.CDN_BASE_URL + item.background,
});
}
return ret;
}
}
module.exports = TypeService;
......@@ -80,5 +80,7 @@ module.exports = appInfo => {
config.NODE_URL = 'https://dev-nginx.jianbing.com';
config.HOUSE_SERVICE_API = 'https://dev-nginx.jianbing.com/house-service';
config.CDN_BASE_URL = 'https://r.51gjj.com/image/';
return config;
};
'use strict';
module.exports = appInfo => {
const config = exports = {};
config.debug = true;
// use for cookie sign key, should change to your own and keep security
config.keys = appInfo.name + '_1554705194320_9697';
config.projectRootPath = '/51business/api';
config.logger = {
dir: '/jianbing/logs/51business',
};
// add your config here
config.middleware = [ 'errorHandler', 'deviceLogin', 'deviceInit', 'responseSet' ];
// 是否启用csrf安全
config.security = {
csrf: {
enable: false,
},
domainWhiteList: [],
};
config.sequelize = {
datasources: [
{
// 东八时区
timezone: '+08:00',
delegate: 'blockModel',
baseDir: 'model/block',
// other sequelize configurations
dialect: 'mysql',
host: process.env.MYSQL_BLOCK_HOST,
database: process.env.MYSQL_BLOCK_DB_NAME,
username: process.env.MYSQL_BLOCK_USER,
password: process.env.MYSQL_BLOCK_PWD,
port: 3306,
}
],
};
config.redis = {
client: {
port: 6379,
host: process.env.REDIS_HOST,
password: process.env.REDIS_PWD,
db: 0,
},
};
config.CDN_BASE_URL = 'https://r.51gjj.com/image/';
config.NODE_URL = process.env.NODE_URL;
config.PHP_URL = process.env.PHP_URL;
config.HOUSE_SERVICE_API = process.env.HOUSE_SERVICE_API; // 房产
return config;
};
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