#coding = utf-8
importpymysqlimporttime#展示页面
defprintinfo(info1,info2):print('''==========欢迎来到管理系统v2.1.1==========
1.%s
2.%s
3.退出'''%(info1, info2))
a= input("请以数字形式输入您的操作:")returna#链接数据库
defconnectsql():
conn=pymysql.connect(
host= '192.168.1.110',
port= 3306,
user= 'root',
passwd= 'root',
db= 'recruitdb',
charset='utf8')
cor=conn.cursor()#返回游标
returnconn, cor#登录操作
deflogin(a, acor, aconn):
a1=int(a)
lcor=acor
lconn=aconn
req= input('请输入账号:')
passwd= input('请输入用户密码:')
id=0
user_reg= ''user_pwd= ''user_name= ''user_parent=0
user_roleId=0#定义一个旗帜,判断是否登录成功
flag =False#查询管理员(专员)数据 a1 = 1为管理员 2 为专员
sql = lcor.execute('select * from user_t where user_roleId = %d'%a1 )
info=lcor.fetchmany(sql)for f,g,h,j,k,l ininfo:if req == g and passwd ==h :
flag=True
id=f
user_reg=g
user_pwd=h
user_name=j
user_parent=k
user_roleId=l
aconn.commit()return[flag, id, user_reg, user_pwd, user_name, user_parent, user_roleId]classPeople(object):def __init__(self,cor,aconn, id, name):
self.cor=cor
self.conn=aconn
self.id=id
self.name=namedefadd_resume(self):
self.r_name= input('姓名:')
self.r_sex= input('性别:')
self.r_phone= input('联系方式:')
self.r_email= input('邮箱:')
self.r_skill= input('技能方向:')#毕业时间
self.time1 = input('毕业时间(yyyy-mm-dd):')
self.timeStruct1= time.strptime(self.time1, "%Y-%m-%d")
self.timeStamp1=int(time.mktime(self.timeStruct1))
self.r_graduationTime= time.strftime('%Y-%m-%d',time.localtime(self.timeStamp1))
self.r_graduationSchool= input('毕业院校:')#面试时间
self.time2 = input('面试时间(yyyy-mm-dd hh:mm:ss):')
self.timeStruct2= time.strptime(self.time2, "%Y-%m-%d %H:%M:%S")
self.timeStamp2=int(time.mktime(self.timeStruct2))
self.r_interviewTime= time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(self.timeStamp2))print('创建人:%s'%self.name)print('操作人:%s'%self.name)#操作时间,获取当前时间
self.r_operationTime = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
self.cor.execute('insert into resume_t(resume_user_name,resume_user_sex,\
resume_user_phone,resume_user_email,resume_user_skill,\
resume_user_graduationTime,resume_user_graduationSchool,\
resume_user_interviewTime,resume_user_remarks,resume_operation_userId,resume_operationTime)\
values ("%s","%s","%s","%s","%s","%s","%s","%s","%s",%d,"%s")'\%(self.r_name,self.r_sex,self.r_phone,self.r_email,self.r_skill,self.r_graduationTime,\
self.r_graduationSchool,self.r_interviewTime,self.name,self.id,self.r_operationTime))
self.conn.commit()#数据提交给数据库
self.conn.close()print('插入成功!')defsearch_resume(self):
self.k= input("请选择1.电话,邮箱查询 2.模糊查询:")if self.k == '1':
self.sel= input('请选择你需要进行查询的方式(1-电话号码,2-邮箱):')if self.sel == '1':
self.sql= self.cor.execute('select resume_user_phone from resume_t')
self.all_phone=self.cor.fetchmany(self.sql)
self.l=[]for self.i inself.all_phone:
self.l.append(self.i[0])
self.phone= input('请输入电话号码:')if self.phone inself.l:
self.sql_phone= self.cor.execute('select * from resume_t where resume_user_phone\
= "%s"'%self.phone)
self.info=self.cor.fetchmany(self.sql_phone)for self.res inself.info:print('姓名:%s'%self.res[1])print('性别:%s'%self.res[2])print('联系方式:%s'%self.res[3])print('邮箱:%s'%self.res[4])print('技能方向:%s'%self.res[5])print('毕业时间:%s'%self.res[6])print('毕业院校:%s'%(self.res[7]))print('面试时间:%s'%(self.res[8]))print('创建人:%s'%(self.res[9]))print('操作员:%s'%(self.name))print('操作时间:%s'%(self.res[11]))else:print('没有该电话号码的简历')elif self.sel == '2':
self.sql= self.cor.execute('select resume_user_phone from resume_t')
self.all_email=self.cor.fetchmany(self.sql)
self.l=[]for self.i inself.all_email:
self.l.append(self.i[0])
self.email= input('请输入邮箱:')if self.email inself.l:
self.sql_email= self.cor.execute('select * from resume_t where \
resume_user_email = "%s"'%self.email)
self.info=self.cor.fetchmany(self.sql_email)for self.res inself.info:print('姓名:%s'%self.res[1])print('性别:%s'%self.res[2])print('联系方式:%s'%self.res[3])print('邮箱:%s'%self.res[4])print('技能方向:%s'%self.res[5])print('毕业时间:%s'%self.res[6])print('毕业院校:%s'%(self.res[7]))print('面试时间:%s'%(self.res[8]))print('创建人:%s'%(self.res[9]))print('操作员:%s'%(self.name))print('操作时间:%s'%(self.res[11]))else:print('没有该邮箱的简历')if self.k == '2':
choose= input('选择要进行模糊查询的字段(1-姓名,2-技能方向,3-毕业院校):')if choose == '1':
self.key= input('输入姓名关键字:')
self.arg= '%'+self.key+'%'self.sql= self.cor.execute('select * from resume_t where resume_user_name like "%s"'%self.arg)
self.info=self.cor.fetchmany(self.sql)if self.info is notNone:for self.res inself.info:print('姓名:%s'%self.res[1])print('性别:%s'%self.res[2])print('联系方式:%s'%self.res[3])print('邮箱:%s'%self.res[4])print('技能方向:%s'%self.res[5])print('毕业时间:%s'%self.res[6])print('毕业院校:%s'%self.res[7])print('面试时间:%s'%self.res[8])print('创建人:%s'%self.res[9])print('操作员:%s'%(self.name))print('操作时间:%s'%self.res[11])else:print('没有该姓名的简历')elif choose == '2':
self.key= input('输入技能方向关键字:')
self.arg= '%'+self.key+'%'self.sql= self.cor.execute('select * from resume_t where resume_user_skill like "%s"'%self.arg)
self.info=self.cor.fetchmany(self.sql)if self.info is notNone:for self.res inself.info:print('姓名:%s'%self.res[1])print('性别:%s'%self.res[2])print('联系方式:%s'%self.res[3])print('邮箱:%s'%self.res[4])print('技能方向:%s'%self.res[5])print('毕业时间:%s'%self.res[6])print('毕业院校:%s'%self.res[7])print('面试时间:%s'%self.res[8])print('创建人:%s'%self.res[9])print('操作员:%s'%(self.name))print('操作时间:%s'%self.res[11])else:print('没有该姓名的简历')elif choose == '3':
self.key= input('输入毕业院校关键字:')
self.arg= '%'+self.key+'%'self.sql= self.cor.execute('select * from resume_t where resume_user_graduationSchool like "%s"'%self.arg)
self.info=self.cor.fetchmany(self.sql)if self.info is notNone:for self.res inself.info:print('姓名:%s'%self.res[1])print('性别:%s'%self.res[2])print('联系方式:%s'%self.res[3])print('邮箱:%s'%self.res[4])print('技能方向:%s'%self.res[5])print('毕业时间:%s'%self.res[6])print('毕业院校:%s'%self.res[7])print('面试时间:%s'%self.res[8])print('创建人:%s'%self.res[9])print('操作员:%s'%(self.name))print('操作时间:%s'%self.res[11])else:print('没有该毕业院校的简历')classAdmin(object):def __init__(self, cor, aconn, id, name ):
self.cor=cor
self.conn=aconn
self.id=id
self.name=namedefadduser(self):
self.user_reg= input('请输入账号:')
self.user_reg= input('请输入密码:')
self.user_reg= input('请输入姓名:')
self.cor.execute('insert into user_t(id_, user_reg, user_pwd, user_name, user_parent, user_roleId) values(NULL, "%s", "%s", "%s",NULL ,2)'%(self.user_reg,self.user_reg,self.user_reg))
self.conn.commit()defsearch(self):
sql= self.cor.execute('select id_, user_name from user_t where user_roleId = 2')
info=self.cor.fetchmany(sql)for i ininfo:print('id:%d 名字:%s' %i)
self.a= input('请输入想要查看员工所操作简历的员工名字:')
self.sql= self.cor.execute('select * from resume_t where resume_user_remarks = "%s"'%self.a)
self.info=self.cor.fetchmany(sql)for self.i inself.info:print('ID: %d, 姓名:%s,性别:%s,联系方式:%s,邮箱:%s,技能方向:%s,毕业时间:%s,毕业院校:%s,面试时间:%s,创建人:%s,操作员:%d,操作时间:%s'%self.i)defaction(a, cor, conn):
acor=cor
aconn=connif a == '1':#登录
infoList =login(a, acor, conn)ifinfoList[0]:
b= printinfo('查看专员信息','添加专员')
admin= Admin(acor,aconn, infoList[1],infoList[4])if b == '1':
admin.search()elif b == '2':
admin.adduser()else:print('已成功退到登录页面!')else:print('登录失败!')if a == '2':#登录
infoList =login(a, acor,aconn)ifinfoList[0]:#登录后的展示页面
b = printinfo('查看简历','新建简历')
user= People(acor,aconn, infoList[1],infoList[4])if b == '1':
user.search_resume()elif b == '2':
user.add_resume()else:print('已成功退到登录页面!')else:print('登录失败!')whileTrue:#链接数据库
conn,cor =connectsql()#页面展示
a = printinfo('管理员登录', '专员登录')#用户操作
action(a, cor, conn)if a == '3':breakcor.close()
conn.close()