#-*-coding:utf-8-*- import json import uuid from django.contrib import auth from django.core.cache import cache from django.conf import settings from common import core_views as cv import common.common_functions as ccf import common.error_info as ce import control_user as cu import control_role as crol import control_organization as co import common.common_control as ccc import control_permission as cp import control_department as cd import control_bankcard as cb class InfoView(cv.AdminView): def get(self, request): ''' #获取全局账号信息(权限控制) ''' try: users = cu.get_account_info(request) return cv.to_suc(users) except Exception as e: return cv.to_fail(e) class UserInfoView(cv.BaseView): def get(self, request): """ #获取用户个人信息 @id:1,用户id """ try: data = cu.get_user_personal_info(request) return cv.to_suc(data) except Exception as e: cv.tracefail() return cv.to_fail(e) return cv.to_suc() class UserView(cv.BaseView): def get(self, request): """ #获取用户详情 @id:1,用户id """ try: data = cu.get_user_info(request) return cv.to_suc(data) except Exception as e: cv.tracefail() return cv.to_fail(e) return cv.to_suc() def post(self, request): ''' #新增员工 @realname:"肖小肖",员工名称 @phone:"129823" @email:"129823@qq.com" @department_id:1,部门id @utype:1/2/3,员工类型 @is_active:1/0,是否启用 @remark:"好员工",备注 ''' qdata = request.json try: rst = cu.add_user(request) return cv.to_suc() except Exception as e: cv.tracefail() return cv.to_fail(e) def put(self, request): """ #修改员工 @id:1,员工id @realname:"肖小肖",员工名称 @phone:"129823" @email:"129823@qq.com" @department_id:1,部门id @utype:1/2/3,员工类型 @is_active:1/0,是否启用 @remark:"好员工",备注 """ qdata = request.json try: data = cu.update_user(request) except Exception as e: return cv.to_fail(e) return cv.to_suc(data) def delete(self, request): """ #删除员工 @id:1,多个id用逗号分隔 """ qdata = request.json try: cu.delete_user(request) except Exception as e: return cv.to_fail(e) return cv.to_suc() class UserListView(cv.AuthView): def get(self, request): """ #员工列表 @name:"用户名" @department_id:1 @utype:1 @is_active:1 """ try: total,res = cu.get_user_list(request) return cv.to_suc({"total":total,"list":res}) except Exception as e: return cv.to_fail(e) class UnauditUserListView(cv.AuthView): def get(self, request): """ #待审核员工列表 @name:"用户名" @utype:1 """ try: total,res = cu.get_unaudit_user_list(request) return cv.to_suc({"total":total,"list":res}) except Exception as e: return cv.to_fail(e) class PermissionListView(cv.AuthView): def get(self, request): """#权限列表 @role_id:1 角色id 可选参数 传了就只返回对应角色的权限 @platform:"operation" 权限归属 可选参数 传了就对权限进行平台过滤 """ qdata = request.json role_id = qdata.get("role_id",None) platform = qdata.get("platform",None) roles = cp.get_permission_list(role_id,platform) return cv.to_suc(roles) class ResetPwdView(cv.BaseView): def put(self, request): """ #重置密码(忘记密码) @phone:"15982456282",手机号 @password:"",新密码 @repassword:"",确认密码 @phcode:"123",验证码 """ try: cu.reset_password(request) return cv.to_suc() except Exception as e: return cv.to_fail(e) class ResetUserPwdView(cv.AuthView): def put(self, request): """ #修改用户密码 @uid:10,用户id不传则默认当前用户 @code:"",验证码 @password:"",新密码 """ try: cu.reset_user_password(request) return cv.to_suc() except Exception as e: return cv.to_fail(e) class DepartmentView(cv.AuthView): def post(self,request): """ #新增部门 @name:"综管部",部门名称 @pid:1,上级部门 @permissions:["CusManage.*.*","CusManage.MyCus.*"] """ try: cd.add_department(request) return cv.to_suc() except Exception as e: return cv.to_fail(e) def put(self,request): """ #修改部门 @id:1,部门id @name:"综管部",部门名称 @pid:1,上级部门 @permissions:["CusManage.*.*","CusManage.MyCus.*"] """ try: cd.update_department(request) return cv.to_suc() except Exception as e: return cv.to_fail(e) def delete(self,request): """ #删除部门 @id:1,部门id """ try: cd.delete_department(request) return cv.to_suc() except Exception as e: return cv.to_fail(e) class DepartmentListView(cv.AuthView): def get(self,request): """#部门列表 @name:"研发",部门名称 """ try: total,rst = cd.get_department_list(request) except Exception as e: cv.tracefail() return cv.to_fail(e) return cv.to_suc({"total":total,"list":rst}) class UserBankCardView(cv.AuthView): def post(self,request): """#新增银行卡 @name:"建设银行",银行名称 @cardno:"6229000",银行卡卡号 """ try: rst = cb.add_bankcard(request) except Exception as e: cv.tracefail() return cv.to_fail(e) return cv.to_suc() def delete(self,request): """#删除银行卡 @id:1,银行卡id """ try: rst = cb.delete_bankcard(request) except Exception as e: cv.tracefail() return cv.to_fail(e) return cv.to_suc() class UserBankCardListView(cv.AuthView): def get(self,request): """#银行卡列表 """ try: rst = cb.get_bankcard_list(request) except Exception as e: cv.tracefail() return cv.to_fail(e) return cv.to_suc(rst) class UserIncomeView(cv.AuthView): def get(self,request): """#我的收益 """ try: rst = cb.get_user_income(request) except Exception as e: cv.tracefail() return cv.to_fail(e) return cv.to_suc(rst) class UserApplyCashView(cv.AuthView): def post(self,request): """#申请提现 @bankcard_id:1,银行卡id @cashtype:"bank/alipay",提现方式 @cashamount:1000,提现金额 """ try: rst = cb.apply_cash(request) except Exception as e: cv.tracefail() return cv.to_fail(e) return cv.to_suc(rst)