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 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 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 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 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 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 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 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 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): """ 项目列表 """ 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 write_error(self, status_code, **kwargs): """ 重写错误状态码信息 """ rsp = RspInfo() rsp.setObj(status_code) rsp.setInfo("错误的请求") self.write(respose_info)
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
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 queryListAll(self): """ 加载小组中不在当前项目中的成员 """ token = self.get_argument('token', None) proId = self.get_argument('proId', None) rsp = RspInfo() try: dao = ProjectUserDao() list = dao.getListAll(proId) 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
def reset(self): """ 重置用户密码 """ token = self.get_argument('token', None) userId = self.get_argument('userId', None) currentAuth = self.get_current_user()['userAuth'] or 9 rsp = RspInfo() try: dao = UserDao() res = dao.reset(userId, currentAuth) 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 post(self): """ 上传项目文件 """ rsp = RspInfo() try: upload_path = os.path.join(os.path.dirname(__file__), UPLOADPATH) fileName = self.get_argument('fileName', None) projectId = self.get_argument('projectId', None) projectName = self.get_argument('projectName', None) uploadBy = self.get_argument('uploadBy', None) file_metas = self.request.files['file'] for meta in file_metas: filename = meta['filename'] filepath = os.path.join(upload_path, filename) with open(filepath, 'wb') as up: up.write(meta['body']) # 入库 dao = ProjectFileDao() res = dao.inset(fileName, projectId, projectName, uploadBy) rsp.setSuccess() if res: rsp.setInfo("上传文件成功") else: rsp.setInfo("上传文件入库失败") except Exception as e: Utils.log('ERROR 上传文件失败 {}'.format(e)) rsp.setInfo("上传文件失败") 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 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 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 add(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) userCreator = self.get_current_user()['userId'] or None rsp = RspInfo() try: dao = UserDao() valid = dao.validInsert(userId) if valid: rsp.setInfo('该用户名已存在, 添加用户失败') raise Exception("该用户名已存在, 添加用户失败") res = dao.insert(userId, userName, userAuth, userLogin, 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 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 record(self): """ 查询文件列表 """ rsp = RspInfo() token = self.get_argument('token', None) page = self.get_argument('pageNum', 1) size = self.get_argument('pageSize', 10) currentUserr = self.get_current_user()['userId'] or '' try: dao = TaskDebugDao() list, total = dao.record(page, size, currentUserr) 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 status(self): """ 修改问题状态 """ rsp = RspInfo() token = self.get_argument('token', None) bugId = self.get_argument('bugId', None) status = self.get_argument('status', None) currentUser = self.get_current_user()['userId'] or '' try: dao = TaskDebugDao() res = dao.status(bugId, status, currentUser) 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 update(self): """ 更新任务进度 """ params = self.get_argument('data', []) currentUser = self.get_current_user()['userId'] or '' data = json.loads(params) Utils.log('data', data) rsp = RspInfo() try: dao = ProjectRateDao() for dat in data: dao.update(dat, currentUser) 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 list(self): rsp = RspInfo() token = self.get_argument('token', None) page = self.get_argument('pageNum', 1) size = self.get_argument('pageSize', 10) userId = self.get_argument('userId', None) userName = self.get_argument('userName', None) applyStart = self.get_argument('applyStart', None) applyEnd = self.get_argument('applyEnd', None) userCreator = self.get_current_user()['userId'] or None try: dao = ApplyDao() list, total = dao.list(page, size, userId, userName, applyStart, applyEnd, 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 update(self): """ 更新 project 记录 """ token = self.get_argument('token', None) proId = self.get_argument('proId', 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) rsp = RspInfo() try: dao = ProjectDao() res = dao.update(proId, proType, proUse, proDes) 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 commit(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) if userId and userPwd and userName: dao = ApplyDao() res = dao.apply(userId, userName, userPwd) if 0 == res: rsp.setInfo("账号正在使用或已提交申请") elif 1 == res: rsp.setSuccess() rsp.setInfo("账号申请提交成功") else: rsp.setInfo("账号申请提交失败") else: rsp.setInfo("参数校验失败") return rsp
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