def get(self): """编辑简历页 根据ID获取用户信息""" parser = reqparse.RequestParser() parser.add_argument('id', type=int, location='values') args = parser.parse_args() stu = Student.query.filter_by(uId=args['id']).first() if stu: return make_result(stu), 200 if stu is None: return make_result(), 200
def get(self): """搜索工作""" parser = reqparse.RequestParser() parser.add_argument('key', type=str, location='values') parser.add_argument('type', type=int, location='values') args = parser.parse_args() if args['key'] is None: args['key'] = "" jobs = Job.query.filter( and_(Job.isDel == 0, Job.tittle.like('%' + args['key'] + '%'))).all() if jobs is None: jobs = Job.query.filter( and_(Job.isDel == 0, Job.recruitNum > Job.signNum)).all() if args.type == 1: newjobs = queryToDict(jobs) res = [[], [], [], []] for job in newjobs: job['creatTime'] = get_from_timestamp(job['creatTime']) res[0] = newjobs for i in range(3): if job['status'] == i + 1: res[i + 1].append(job) return res, 200 return make_result(jobs), 200
def get(self): """根据ID获取其他项简历""" parser = reqparse.RequestParser() parser.add_argument('id', type=int, location='values') parser.add_argument('type', type=int, location='values') args = parser.parse_args() print(args['id']) info = {} if args['type'] == 1: info = EduResume.query.filter_by(id=args['id']). \ with_entities(EduResume.school, EduResume.major, EduResume.degree, EduResume.startTime, EduResume.endTime, EduResume.experience).first_or_404() if args['type'] == 2: info = WorkResume.query.filter_by(id=args['id']). \ with_entities(WorkResume.company, WorkResume.startTime, WorkResume.endTime, WorkResume.experience). \ first_or_404() if args['type'] == 3: info = OtherResume.query.filter_by(userId=args['id']).first() if info is None: return {"code": 10001} if args['type'] == 4: info = OtherResume.query.filter_by(userId=args['id']).first() if info is None: return {"code": 10001} return make_result(info), 200
def get(self): """获取教育经历""" parser = reqparse.RequestParser() parser.add_argument('id', type=int, location='values') args = parser.parse_args() edus = EduResume.query.filter( and_(EduResume.isDel == 0, EduResume.userId == args['id'])).all() return make_result(edus), 200
def get(self): """根据ID获取工作""" parser = reqparse.RequestParser() parser.add_argument('id', type=int, location='values') args = parser.parse_args() print(args['id']) job = Job.query.filter_by(id=args['id']).first_or_404() return make_result(job), 200
def get(self): """获取所有可报名工作""" # id = JobParse().get_result().id jobs = Job.query.filter( and_(Job.isDel == 0, Job.recruitNum > Job.signNum, Job.status == 2)).all() # jobs = Job.query.filter(Job.isDel == 0).all() return make_result(jobs), 200
def get(self): """查看我的申请数字""" parser = reqparse.RequestParser() parser.add_argument('useId', type=int, location='values') args = parser.parse_args() res = Job_Signup.query.filter( and_(Job_Signup.isDel == 0, Job_Signup.userId == args['useId'])).all() return make_result(res), 200
def delete(self): """删除该表的某项或多项纪录""" # 获取要操作的数据 data = self._get_data() # 筛选model total_count, fail_count, msg, models = self._make_data_to_model(data) # 数据库操作,获取结果信息 total_msg = self._chose_to_do('delete', models, total_count, fail_count, msg) return make_result(total_msg)
def post(self): """审核工作""" parser = reqparse.RequestParser() parser.add_argument('id', type=int) parser.add_argument('status', type=int) args = parser.parse_args() print(args) job = Job.query.filter_by(id=args['id']).first_or_404() job.status = args.status job.update() return make_result(job), 200
def get(self): """学生查看我的申请列表""" parser = reqparse.RequestParser() parser.add_argument('useId', type=int, location='values') args = parser.parse_args() res = db.session.query(Job.id, Job.tittle, Job.place, Job.reward, Job_Signup.status). \ filter(Job.isDel == 0). \ filter(Job_Signup.jobId == Job.id). \ filter(and_(Job_Signup.isDel == 0, Job_Signup.userId == args['useId'])). \ all() return make_result(res), 200
def post(self): """公司提交资料审核""" parser = reqparse.RequestParser() parser.add_argument('id', type=int) args = parser.parse_args() com = Company.query.filter( and_(Company.isDel == 0, Company.uId == args['id'])).first_or_404() form = ComSign() form.uId = args['id'] form.cId = com.id form.add() return make_result(com), 200
def post(self): """修改公司的信息""" parser = reqparse.RequestParser() parser.add_argument('id', type=int) parser.add_argument('data', type=dict) args = parser.parse_args() com = Company.query.filter( and_(Company.isDel == 0, Company.uId == args['id'])).first_or_404() for key in args.data: setattr(com, key, args.data[key]) com.update() return make_result(com), 200
def get(self): """根据ID获取公司信息""" parser = reqparse.RequestParser() parser.add_argument('id', type=int, location='values') parser.add_argument('type', type=int, location='values') args = parser.parse_args() if args.type == 1: com = Company.query.filter(and_(Company.isDel == 0, Company.uId == args['id'])). \ with_entities(Company.cname, Company.cplace, Company.cphone, Company.cemail, Company.ctype, Company.cinfo,Company.pname, Company.pphone, Company.isVerify).first() return make_result(com, 20002), 200 com = Company.query.filter(and_(Company.isDel == 0, Company.uId == args['id'])). \ with_entities(Company.cname, Company.cplace, Company.cphone, Company.cemail, Company.ctype, Company.cinfo, Company.pname, Company.pphone).first() if com: return make_result(com, 20002), 200 if com is None: newCom = Company() newCom.uId = args['id'] newCom.isVerify = 0 newCom.add() return {"code": 2001}, 200
def post(self): """修改公司的信息""" parser = reqparse.RequestParser() parser.add_argument('id', type=int) parser.add_argument('data', type=dict) args = parser.parse_args() print(args.data) stu = Student.query.filter( and_(Student.isDel == 0, Student.uId == args['id'])).first_or_404() for key in args.data: setattr(stu, key, args.data[key]) stu.update() return make_result(stu), 200
def get(self): """获取该表单项或者全部记录""" # 判断是否分页,默认分页 is_page = request.args.to_dict( )['is_page'] if 'is_page' in request.args.to_dict() else False # 如果填写了id字段 则优先返回根据id查询的结果 if IdParse().get_result().id: model = self._find_by_id(IdParse().get_result().id) return make_result(model) # 按条件分页查询 elif not is_page: # 获取 查询条件 和 排序条件 query, by = self._parse_query_field() # 获取分页 默认显示页面(默认为1) 和 页面默认条数(默认为10) page, size = self._parse_page_size() # 获取分页结果paginate对象 res = self._find_by_page(page=page, size=size, query=query, by=by) return make_result(res) # 按条件查询不分页 else: # 获取 查询条件 和 排序条件 query, by = self._parse_query_field() res = self._find_all(query, by) return make_result(res)
def post(self): """修改学生的信息""" parser = reqparse.RequestParser() parser.add_argument('id', type=int) parser.add_argument('data', type=dict) parser.add_argument('type', type=int) parser.add_argument('self', type=str) args = parser.parse_args() print(args) if args.type == 1: edu = EduResume.query.filter_by(id=args['id']).first_or_404() modifyData(edu, args) if args.type == 2: work = WorkResume().query.filter_by(id=args['id']).first_or_404() modifyData(work, args) if args.type == 3: other = OtherResume.query.filter_by( userId=args['id']).first_or_404() if other: other.selfIntroduction = args.self modifyData(other, args) if other is None: newOther = OtherResume() setData(newOther, args) if args.type == 4: other = OtherResume.query.filter_by(userId=args['id']).first() if other: other.selfIntroduction = args.self other.update() make_result(other), 200 if other is None: newOther = OtherResume() newOther.selfIntroduction = args.self newOther.userId = args.id newOther.add() make_result(newOther), 200
def post(self): """审核公司信息""" parser = reqparse.RequestParser() parser.add_argument('uid', type=int) parser.add_argument('isVerify', type=int) args = parser.parse_args() print(args) com = Company.query.filter( and_(Company.isDel == 0, Company.uId == args['uid'])).first_or_404() form = ComSign.query.filter( and_(ComSign.isDel == 0, ComSign.uId == args['uid'])).first_or_404() com.isVerify = args['isVerify'] form.isVerify = args['isVerify'] form.update() com.update() return make_result(com), 200
def get(self): """获取热门搜索""" hot = Search.query.filter(Search.isDel == 0).all() return make_result(hot), 200
def modifyData(new, args): for key in args.data: setattr(new, key, args.data[key]) new.update() return make_result(new), 200
def setData(new, args): for key in args.data: setattr(new, key, args.data[key]) new.add() return make_result(), 200