class TaskUpdateHandler(AccessHandler): def initialize(self): self.taskDao = TaskDao() self.taskTypeDao = TaskTypeDao() def post(self, *args, **kwargs): taskId = self.get_args("task_id") task = self.taskDao.get_task_details(taskId) user = self.get_current_user() task = model_object_to_json(task) task_id = self.taskDao.add_task(task["task_name"], task["task_key"], task["task_type"], task["task_num"], '', user.id, url=task["task_url"], parentId=task["id"]) taskType = self.taskTypeDao.get_task_type(taskId) taskType = type_list_to_json(taskType) types = [] for type in taskType: types.append(type["task_type"]) self.taskDao.update_task_id(task_id, task_id) self.taskTypeDao.add_type(task_id, types) result = {} result["status"] = 0 result["message"] = "更新成功" self.finish(result)
class TaskAddHandler(AccessHandler): def initialize(self): self.taskDao = TaskDao() self.taskTypeDao = TaskTypeDao() def post(self, *args, **kwargs): taskName = self.get_args("taskName") taskKey = self.get_args("key") taskType = self.get_args("type") taskNum = self.get_args("taskNum") startTime = self.get_args("startTime") taskComment = self.get_args("is_comment") if taskComment is None or taskComment == '': taskComment = 0 url = self.get_args("url") if startTime is None or startTime == '': startTime = datetime.datetime.now() if taskNum is None or taskNum == '' or taskNum == '0': taskNum = 100 types = self.get_args("shopType") user = self.get_current_user() taskId = self.taskDao.add_task(taskName, taskKey, taskType, taskNum, startTime, user.id, url, 0, taskComment) self.taskDao.update_task_id(taskId, taskId) self.taskTypeDao.add_type(taskId, types.split(",")) result = {} result["status"] = 0 result["message"] = "添加成功" self.finish(result)
class TaskIsOpenHandler(AccessHandler): def initialize(self): self.taskDao = TaskDao() def post(self, *args, **kwargs): taskId = self.get_args("task_id") is_open = self.get_args("is_open") self.taskDao.close_or_open_task(taskId, is_open) result = {} result["status"] = 0 result["message"] = "更新成功" self.finish(result)
class TaskPriceHandler(AccessHandler): def initialize(self): self.taskDao = TaskDao() def post(self, *args, **kwargs): taskId = self.get_args("task_id") prices = self.taskDao.get_price_range_by_task_id(taskId) prices = price_space_data(prices) plist = list(prices) price_list_sum = [] price_list = [] length = plist.__len__() if length > 0 and length <= 1: price_list.append(plist[0][0]) price_list.append(plist[0][0]) price_list_sum.append(plist[0][1]) price_list_sum.append(plist[0][1]) elif length > 10: min = plist[length - 1][0] max = plist[0][0] price_list = create_random_price(max, min) price_list_sum = sum_sales(price_list, plist) else: price_list_sum = sorted(plist, key=lambda tup: float(tup[1]), reverse=True) price_list = sorted(plist, key=lambda tup: float(tup[0]), reverse=True) result = {} result["status"] = 0 result["message"] = "更新成功" result["product_sales_count"] = price_list_sum result["price_value"] = price_list self.finish(result)
class TaskListHandler(AccessHandler): def initialize(self): self.taskDao = TaskDao() self.taskTypeDao = TaskTypeDao() def post(self, *args, **kwargs): page = self.get_args("page") pageSize = self.get_args("pageSize") search = self.get_args("key") status = self.get_args("status") if page is None or page == '': page = 1 else: page = int(page) if pageSize is None or pageSize == '': pageSize = 20 else: pageSize = int(pageSize) if search is None: search = '' result = {} tasks = self.taskDao.get_task_list(search, page, pageSize, status) count = self.taskDao.get_task_count(search, status) lastPage = count / pageSize + 1 pagination = {} pagination.setdefault("size", count) pagination.setdefault("current_page", page) pagination.setdefault("last_page", lastPage) pagination["pageSize"] = pageSize tasks = task_list_to_json(tasks) for task in tasks: id = task["id"] child_task = self.taskDao.get_child_task_list(id, 0) task["childs"] = task_list_to_json(child_task) taskTypes = self.taskTypeDao.get_task_type(task["task_id"]) task["task_types"] = type_list_to_json(taskTypes) result["status"] = 0 result["message"] = "获取数据成功" result["tasks"] = tasks result["pagination"] = pagination self.finish(result)
class TaskDetailsHandler(AccessHandler): def initialize(self): self.taskDao = TaskDao() self.taskTypeDao = TaskTypeDao() def post(self, *args, **kwargs): taskId = self.get_args("task_id") task = self.taskDao.get_task_details(taskId) task = model_object_to_json(task) taskType = self.taskTypeDao.get_task_type(taskId) taskType = type_list_to_json(taskType) task["task_types"] = taskType result = {} result["task"] = task result["status"] = 0 result["message"] = "获取成功" self.finish(result)
class IndexDataHandler(AccessHandler): def initialize(self): self.productDao = ProductDao() self.shopDao = ShopDao() self.taskDao = TaskDao() def post(self): productData = self.productDao.get_all_product() shopData = self.shopDao.select_all_shop_count() taskData = self.taskDao.get_all_task_count() result = {} result["status"] = 0 result["message"] = "获取数据成功" result["productData"] = productData result["shopData"] = shopData result["taskData"] = taskData self.finish(result)
def initialize(self): self.taskDao = TaskDao() self.taskTypeDao = TaskTypeDao()
def initialize(self): self.taskDao = TaskDao() self.shopDao = ShopDao() self.productDao = ProductDao()