def post(self, opt): """ 用户列表 """ rsp = RspInfo() for case in switch(opt): if case('all'): rsp = self.queryListAll() break if case('list'): rsp = self.queryList() break if case('info'): rsp = self.queryInfo() break if case('append'): rsp = self.append() break if case('remove'): rsp = self.remove() break if case(): # Default self.write_error(404) return self.write(rsp.toDict()) return
def remove(self): """ 移除项目成员,已分配任务的不可移除 """ token = self.get_argument('token', None) proId = self.get_argument('proId', None) userId = self.get_argument('userId', None) rsp = RspInfo() try: dao = ProjectUserDao() if dao.valid(proId, userId): Utils.log('INFO', '已分配任务的不可移除') rsp.setInfo('已分配任务的成员不可移除') else: res = dao.remove(proId, userId) rsp.setSuccess() rsp.setInfo("移除项目成员成功") except Exception as e: print('ERROR {}'.format(e)) Utils.log('ERROR {}'.format(e)) rsp.setInfo("移除项目成员失败") finally: del (dao) return rsp
def update(self): """ 更新用户记录 """ token = self.get_argument('token', None) userId = self.get_argument('userId', None) userName = self.get_argument('userName', None) userAuth = self.get_argument('userAuth', None) userLogin = self.get_argument('userLogin', None) currentAuth = self.get_current_user()['userAuth'] or 9 rsp = RspInfo() try: dao = UserDao() res = dao.update(userId, userName, userAuth, userLogin, currentAuth) if res: rsp.setSuccess() rsp.setInfo("更新用户成功") else: rsp.setInfo("更新用户失败") except Exception as e: print('ERROR {}'.format(e)) Utils.log('ERROR {}'.format(e)) rsp.setInfo("更新用户失败") finally: del (dao) return rsp
def queryInfo(self): """ 加载小组项目中的成员及负责模块 """ token = self.get_argument('token', None) page = self.get_argument('pageNum', 1) size = self.get_argument('pageSize', 10) proId = self.get_argument('proId', None) userId = self.get_argument('userId', None) userName = self.get_argument('userName', None) rsp = RspInfo() try: dao = ProjectUserDao() list, total = dao.getInfo(page, size, proId, userId, userName) rsp.setSuccess() rsp.setInfo("加载成员成功") rsp.setData(list, total) except Exception as e: print('ERROR {}'.format(e)) Utils.log('ERROR {}'.format(e)) rsp.setInfo("加载成员失败") finally: del (dao) return rsp
def delete(self): """ 删除任务模块 """ token = self.get_argument('token', None) modId = self.get_argument('modId', '') currentAuth = self.get_current_user()['userAuth'] or '' rsp = RspInfo() try: dao = ProjectTaskDao() res = dao.delete(modId, currentAuth) if res: # 删除任务模块时, 删除任务进度信息 rate = ProjectRateDao() rate.delete(modId) rsp.setSuccess() rsp.setInfo("删除任务模块成功") else: rsp.setInfo("删除任务模块失败") except Exception as e: print('ERROR {}'.format(e)) Utils.log('ERROR {}'.format(e)) rsp.setInfo("删除任务模块失败") finally: del (dao) del (rate) return rsp
def add(self): """ 添加 project 记录 """ token = self.get_argument('token', None) proName = self.get_argument('proName', None) proType = self.get_argument('proType', None) proUse = self.get_argument('proUse', None) proDes = self.get_argument('proDes', None) userCreator = self.get_current_user()['userId'] or None rsp = RspInfo() try: dao = ProjectDao() res = dao.insert(proName, proType, proUse, proDes, userCreator) if res: rsp.setSuccess() rsp.setInfo("添加项目成功") rsp.setObj(token) except Exception as e: print('ERROR {}'.format(e)) Utils.log('ERROR {}'.format(e)) rsp.setInfo("添加项目失败") finally: del (dao) return rsp
def handle(self): rsp = RspInfo() token = self.get_argument('token', None) userId = self.get_argument('userId', None) userName = self.get_argument('userName', None) userPwd = self.get_argument('userPwd', None) userCreator = self.get_current_user()['userId'] or None try: dao = ApplyDao() user = UserDao() if not userId: rsp.setInfo("参数校验失败") return rsp res_1 = dao.remove(userId) res_2 = user.insert(userId, userName, '1', '1', userCreator) if res_1 and res_2: rsp.setSuccess() rsp.setInfo("审核用户通过") except Exception as e: print('ERROR {}'.format(e)) Utils.log('ERROR {}'.format(e)) rsp.setInfo("审核用户失败") finally: del(dao) del(user) return rsp
def get(self, opt): """ project type list """ rsp = RspInfo() rsp = self.queryList() self.write(rsp.toDict()) return
def post(self, opt): """ 项目类型列表 """ rsp = RspInfo() rsp = self.queryList() self.write(rsp.toDict()) return
def post(self): """ 项目列表 """ rsp = RspInfo() token = self.get_argument('token', None) page = self.get_argument('pageNum', 1) size = self.get_argument('pageSize', 10) proId = self.get_argument('proId', None) proName = self.get_argument('proName', None) proType = self.get_argument('proType', None) proUse = self.get_argument('proUse', None) userCreator = self.get_current_user()['userId'] or None try: dao = ProjectDao() list, total = dao.getList(page, size, proId, proName, proType, proUse, userCreator) rsp.setSuccess() rsp.setData(list, total) except Exception as e: print('ERROR {}'.format(e)) Utils.log('ERROR {}'.format(e)) rsp.setInfo("查询项目列表失败") finally: del (dao) self.write(rsp.toDict()) return
def post(self): rsp = RspInfo() userId = self.get_argument('userId', None) userPwd = self.get_argument('userPwd', None) if userId and userPwd: log = LoginDao() list, total = log.checkLogin(userId, userPwd) if 1 == total: info = { 'userId': list[0].get('USER_ID'), 'userName': list[0].get('USER_NAME'), 'userAuth': list[0].get('USER_AUTH') } token = Utils.makeToken(info) info['token'] = token # 登录信息 token 保存 Redis MyRedis().set(info['userId'], token) rsp.setSuccess() rsp.setObj(info) else: rsp.setInfo("登录失败, 请检查用户名或密码是否正确") else: pass self.write(rsp.toDict()) return
def list(self): """ 查询任务列表 """ token = self.get_argument('token', None) page = self.get_argument('pageNum', 1) size = self.get_argument('pageSize', 10) proName = self.get_argument('proName', None) userName = self.get_argument('userName', None) modName = self.get_argument('modName', None) limitTime = self.get_argument('limitTime', None) currentUser = self.get_current_user()['userId'] or '' rsp = RspInfo() try: dao = ProjectTaskDao() list, total = dao.list(page, size, proName, userName, modName, limitTime, currentUser) rsp.setSuccess() rsp.setData(list, total) except Exception as e: print('ERROR {}'.format(e)) Utils.log('ERROR {}'.format(e)) rsp.setInfo("查询项目列表失败") finally: del (dao) return rsp
def append(self): """ 创建任务问题 bug """ token = self.get_argument('token', None) proId = self.get_argument('proId', None) proName = self.get_argument('proName', None) modId = self.get_argument('modId', None) modName = self.get_argument('modName', None) bugTitle = self.get_argument('bugTitle', None) bugLevel = self.get_argument('bugLevel', None) bugDes = self.get_argument('bugDes', None) userId = self.get_argument('userId', None) currentUser = self.get_current_user()['userId'] or '' rsp = RspInfo() try: dao = TaskDebugDao() res = dao.insert(proId, proName, modId, modName, bugTitle, bugLevel, bugDes, userId, currentUser) if res: rsp.setSuccess() rsp.setInfo("提交BUG成功") except Exception as e: print('ERROR {}'.format(e)) Utils.log('ERROR {}'.format(e)) rsp.setInfo("提交BUG失败") finally: del (dao) return rsp
def list(self): """ 查询文件列表 """ rsp = RspInfo() token = self.get_argument('token', None) page = self.get_argument('pageNum', 1) size = self.get_argument('pageSize', 10) proName = self.get_argument('proName', None) modName = self.get_argument('modName', None) bugTitle = self.get_argument('bugTitle', None) bugLevel = self.get_argument('bugLevel', None) bugStatus = self.get_argument('bugStatus', None) createBy = self.get_argument('createBy', None) handleBy = self.get_argument('handleBy', None) createStart = self.get_argument('createStart', None) createEnd = self.get_argument('createEnd', None) userCreator = self.get_current_user()['userId'] or '' try: dao = TaskDebugDao() list, total = dao.list(page, size, proName, modName, bugTitle, bugLevel, bugStatus, createBy, handleBy, createStart, createEnd, userCreator) rsp.setSuccess() rsp.setData(list, total) except Exception as e: print('ERROR {}'.format(e)) Utils.log('ERROR {}'.format(e)) rsp.setInfo("获取文件下载列表失败") finally: del (dao) return rsp
def list(self): """ 查询文件列表 """ rsp = RspInfo() token = self.get_argument('token', None) page = self.get_argument('pageNum', 1) size = self.get_argument('pageSize', 10) proName = self.get_argument('proName', None) fileName = self.get_argument('fileName', None) uploadStart = self.get_argument('uploadStart', None) uploadEnd = self.get_argument('uploadEnd', None) userCreator = self.get_current_user()['userId'] or None try: dao = SettingDownloadDao() list, total = dao.list(page, size, proName, fileName, uploadStart, uploadEnd, userCreator) rsp.setSuccess() rsp.setData(list, total) except Exception as e: print('ERROR {}'.format(e)) Utils.log('ERROR {}'.format(e)) rsp.setInfo("获取文件下载列表失败") finally: del (dao) return rsp
def remove(self): """ 删除文件 """ rsp = RspInfo() token = self.get_argument('token', None) fileId = self.get_argument('fileId', None) fileName = self.get_argument('fileName', None) userCreator = self.get_current_user()['userId'] or None try: dao = SettingDownloadDao() if dao.delete(fileId, userCreator): rsp.setSuccess() rsp.setInfo("删除文件成功") else: rsp.setInfo("删除文件失败") os.remove( os.path.join(os.path.dirname(__file__), UPLOADPATH, fileName)) # 删除服务器文件资源 except Exception as e: print('ERROR {}'.format(e)) Utils.log('ERROR {}'.format(e)) finally: del (dao) return rsp
def post(self, opt): """ 项目模块信息 """ rsp = RspInfo() for case in switch(opt): if case('query'): rsp = self.query() break if case(): # Default self.write_error(404) return self.write(rsp.toDict()) return
def append(self): """ 将项目成员添加的当前的项目中,以待分配模块任务 """ token = self.get_argument('token', None) proId = self.get_argument('proId', None) proName = self.get_argument('proName', None) userCreator = self.get_current_user()['userId'] or None users = self.get_argument('users', None) Utils.log(users) allUsers = json.loads(users) rsp = RspInfo() try: dao = ProjectUserDao() res = dao.append(proId, proName, userCreator, allUsers) if res: rsp.setSuccess() rsp.setInfo("添加成员成功") except Exception as e: print('ERROR {}'.format(e)) Utils.log('ERROR {}'.format(e)) rsp.setInfo("添加成员失败") finally: del (dao) return rsp
def add(self): """ 执行分配任务 """ token = self.get_argument('token', None) proId = self.get_argument('proId', None) userId = self.get_argument('userId', None) modName = self.get_argument('modName', None) modDes = self.get_argument('modDes', None) modStart = self.get_argument('modStart', None) modEnd = self.get_argument('modEnd', None) currentUser = self.get_current_user()['userId'] or '' rsp = RspInfo() try: dao = ProjectTaskDao() modId = Utils.makeId() res = dao.insert(proId, userId, modId, modName, modDes, modStart, modEnd) if res: # 添加任务模块时, 添加任务进度信息 rate = ProjectRateDao() rate.insert(userId, modId, currentUser) rsp.setSuccess() rsp.setInfo("添加任务模块成功") except Exception as e: print('ERROR {}'.format(e)) Utils.log('ERROR {}'.format(e)) rsp.setInfo("添加任务模块失败") finally: del (dao) del (rate) return rsp
def post(self, opt): rsp = RspInfo() for case in switch(opt): if case('commit'): rsp = self.commit() break if case('list'): rsp = self.list() break if case('handle'): rsp = self.handle() break if case(): # Default self.write_error(404) return self.write(rsp.toDict()) return
def post(self, opt): """ 文件列表 """ rsp = RspInfo() for case in switch(opt): if case('files'): rsp = self.list() break if case('remove'): rsp = self.remove() break if case(): # Default self.write_error(404) return self.write(rsp.toDict()) return
def post(self): """ 修改密码 """ rsp = RspInfo() token = self.get_argument('token', None) oldPwd = self.get_argument('oldPwd', None) newPwd = self.get_argument('newPwd', None) if oldPwd and newPwd: userId = self.current_user.get('userId', None) dao = LoginDao() result = dao.updatePwd(userId, oldPwd, newPwd) if result: rsp.setSuccess() self.write(rsp.toDict()) return self.write({'oldPwd': oldPwd, 'newPwd': newPwd, 'token': token}) return
def post(self): rsp = RspInfo() token = self.get_argument('token', None) userInfo = Utils.verifyToken(token) rsp.setSuccess() rsp.setObj(userInfo) self.write(rsp.toDict()) return
def queryList(self): """ 加载项目类型 """ token = self.get_argument('token', None) rsp = RspInfo() try: dao = ProjectTypeDao() list = dao.getList() rsp.setSuccess() rsp.setInfo("加载项目类型成功") rsp.setData(list) except Exception as e: print('ERROR {}'.format(e)) Utils.log('ERROR {}'.format(e)) rsp.setInfo("加载项目类型失败") finally: del(dao) return rsp
def post(self, opt): """ 项目列表 """ rsp = RspInfo() for case in switch(opt): if case('add'): rsp = self.add() break if case('update'): rsp = self.update() break if case('delete'): rsp = self.delete() break if case(): # Default self.write_error(404) return self.write(rsp.toDict()) return
def delete(self): """ 删除 project 记录 """ token = self.get_argument('token', None) proId = self.get_argument('proId', None) rsp = RspInfo() try: dao = ProjectDao() if dao.valid(proId): Utils.log('WARNING', '校验项目已分配成员或者模块') rsp.setInfo('校验项目已分配成员或者模块, 无法删除') elif dao.delete(proId): rsp.setSuccess() rsp.setInfo("删除用户成功") except Exception as e: print('ERROR {}'.format(e)) Utils.log('ERROR {}'.format(e)) rsp.setInfo("删除用户失败") finally: del (dao) return rsp
def write_error(self, status_code, **kwargs): """ 重写错误状态码信息 """ rsp = RspInfo() rsp.setObj(status_code) rsp.setInfo("错误的请求") self.write(respose_info)
def post(self, opt): """ 文件列表 """ rsp = RspInfo() for case in switch(opt): if case('append'): rsp = self.append() break if case('list'): rsp = self.list() break if case('record'): rsp = self.record() break if case('status'): rsp = self.status() break if case(): # Default self.write_error(404) return self.write(rsp.toDict()) return
def query(self): """ 查询任务进度 """ userId = self.get_current_user()['userId'] or '' rsp = RspInfo() try: dao = ProjectRateDao() res = dao.query(userId) rsp.setSuccess() rsp.setObj(res) except Exception as e: print('ERROR {}'.format(e)) Utils.log('ERROR 查询任务进度失败 {}'.format(e)) rsp.setInfo("查询任务进度失败") finally: del (dao) return rsp
def query(self): """ 查询项目模块信息 """ proId = self.get_argument('proId', None) userId = self.get_current_user()['userId'] or '' rsp = RspInfo() try: dao = ProjectModuleDao() list = dao.query(proId, userId) rsp.setSuccess() rsp.setData(list) except Exception as e: print('ERROR {}'.format(e)) Utils.log('ERROR 查询项目模块信息失败 {}'.format(e)) rsp.setInfo("查询项目模块信息失败") finally: del (dao) return rsp