当前位置: 首页 > wzjs >正文

制作网站怎么用图片做背景电子商务的就业方向是什么

制作网站怎么用图片做背景,电子商务的就业方向是什么,移动电商网站开发需求文档,南通网站关键词优化目录 前言 用户的查询 controller层 添加路由 service层 用户的添加 controller层 添加路由 service层-添加用户 service层-添加用户和租户关系 验证结果 结果 前言 完成租户添加功能后,下一步需要实现租户下的用户管理。基础功能包括:查询租…

目录

前言

用户的查询

controller层

添加路由

service层

用户的添加

controller层

添加路由

service层-添加用户

service层-添加用户和租户关系

验证结果

结果


前言


完成租户添加功能后,下一步需要实现租户下的用户管理。基础功能包括:查询租户用户列表接口,添加用户接口

用户的查询

controller层
class AccountListApi(Resource):"""Resource for getting account list."""@validate_tokendef get(self):"""Get account list."""parser = reqparse.RequestParser()parser.add_argument("tenant_id", type=str, required=True, location="json")parser.add_argument("page", type=int, required=False, default=1, location="args")parser.add_argument("limit", type=int, required=False, default=20, location="args")parser.add_argument("search", type=str, required=False, location="args")args = parser.parse_args()accounts = AccountService.get_accounts_by_tenant(tenant_id=args["tenant_id"],page=args["page"],limit=args["limit"],search=args["search"])return {"result": "success","data": accounts}
添加路由
api.add_resource(AccountListApi, "/accounts")
service层
@staticmethoddef get_accounts_by_tenant(tenant_id: str, page: int = 1, limit: int = 20, search: str = None, status: str = None) -> dict:query = (db.session.query(Account, TenantAccountJoin.role).select_from(Account).join(TenantAccountJoin, Account.id == TenantAccountJoin.account_id).filter(TenantAccountJoin.tenant_id == tenant_id))if search:search = f"%{search}%"query = query.filter(db.or_(Account.name.ilike(search),Account.email.ilike(search)))if status:query = query.filter(Account.status == status)query = query.order_by(Account.name, Account.email)total = query.count()query = query.offset((page - 1) * limit).limit(limit)results = query.all()account_list = [{"id": str(account[0].id),"name": account[0].name,"email": account[0].email,"created_at": account[0].created_at.isoformat(),"role": account[1]} for account in results]return {'items': account_list,'total': total,'page': page,'limit': limit}

用户的添加

controller层
class AccountCreateApi(Resource):"""Resource for creating a new account."""@validate_tokendef post(self):"""Create a new account."""parser = reqparse.RequestParser()parser.add_argument("name", type=str, required=True, location="json")parser.add_argument("email", type=str, required=True, location="json")parser.add_argument("password", type=str, required=True, location="json")parser.add_argument("tenant_id", type=str, required=True, location="json")args = parser.parse_args()account = current_usertenant = TenantService.get_tenant_by_id(args["tenant_id"])if not tenant:return {"result": "fail", "message": "Tenant not found"}, 404try:new_account = AccountService.create_account(email=args["email"],name=args["name"],interface_language="zh-Hans",password=args["password"])TenantService.create_tenant_member(tenant, new_account, role="owner")return {"result": "success","data": {"id": str(new_account.id),"name": new_account.name,"email": new_account.email,"created_at": new_account.created_at.isoformat()}}except Exception as e:return {"result": "error", "message": str(e)}, 400

传入租户id和用户信息,我这里就直接默认语言是中文。

添加路由
api.add_resource(AccountCreateApi, "/accounts/create")
service层-添加用户
@staticmethoddef create_account(email: str,name: str,interface_language: str,password: Optional[str] = None,interface_theme: str = "light",is_setup: Optional[bool] = False,) -> Account:"""create account"""# if not FeatureService.get_system_features().is_allow_register and not is_setup:#     from controllers.console.error import AccountNotFound##     raise AccountNotFound()if dify_config.BILLING_ENABLED and BillingService.is_email_in_freeze(email):raise AccountRegisterError(description=("This email account has been deleted within the past ""30 days and is temporarily unavailable for new account registration"))account = Account()account.email = emailaccount.name = nameif password:# generate password saltsalt = secrets.token_bytes(16)base64_salt = base64.b64encode(salt).decode()# encrypt password with saltpassword_hashed = hash_password(password, salt)base64_password_hashed = base64.b64encode(password_hashed).decode()account.password = base64_password_hashedaccount.password_salt = base64_saltaccount.interface_language = interface_languageaccount.interface_theme = interface_theme# Set timezone based on languageaccount.timezone = language_timezone_mapping.get(interface_language, "UTC")db.session.add(account)db.session.commit()return account
service层-添加用户和租户关系
@staticmethoddef create_tenant_member(tenant: Tenant, account: Account, role: str = "normal") -> TenantAccountJoin:"""Create tenant member"""if role == TenantAccountRole.OWNER.value:if TenantService.has_roles(tenant, [TenantAccountRole.OWNER]):logging.error(f"Tenant {tenant.id} has already an owner.")raise Exception("Tenant already has an owner.")ta = db.session.query(TenantAccountJoin).filter_by(tenant_id=tenant.id, account_id=account.id).first()if ta:ta.role = roleelse:ta = TenantAccountJoin(tenant_id=tenant.id, account_id=account.id, role=role)db.session.add(ta)db.session.commit()return ta

这里直接调用已有方法

TenantAccountJoin
验证结果

用户表

用户租户关联表

结果

用创建的用户和密码从前端登录进去后,智能体、知识库、插件、模型等都完全隔离了。


文章转载自:

http://HoFyGqpu.nbgfz.cn
http://gvTTynuy.nbgfz.cn
http://9eWC7Fv7.nbgfz.cn
http://lyfj7uWe.nbgfz.cn
http://tcOtgmpa.nbgfz.cn
http://829XP9UO.nbgfz.cn
http://bpF7jQY9.nbgfz.cn
http://2QK9DLnt.nbgfz.cn
http://SsWZzaRs.nbgfz.cn
http://dKyqdEsP.nbgfz.cn
http://lNSgL9Ib.nbgfz.cn
http://ACLSJw2N.nbgfz.cn
http://dDjMacXd.nbgfz.cn
http://CZjljOBz.nbgfz.cn
http://Yxj43H8h.nbgfz.cn
http://yyaMIcJO.nbgfz.cn
http://hZmuFXp4.nbgfz.cn
http://aKPxOmJ5.nbgfz.cn
http://y3PpO3Qb.nbgfz.cn
http://9Y3wDFH4.nbgfz.cn
http://bjDF9EOh.nbgfz.cn
http://FGK1uySt.nbgfz.cn
http://1Ao7OLx4.nbgfz.cn
http://TuoYVwBm.nbgfz.cn
http://1B0zYbI3.nbgfz.cn
http://RLOB1iRF.nbgfz.cn
http://mcXajNz1.nbgfz.cn
http://B7VecshT.nbgfz.cn
http://CNvep2wD.nbgfz.cn
http://Wc24ytB3.nbgfz.cn
http://www.dtcms.com/wzjs/719060.html

相关文章:

  • 厦门网站建设培训机构响应式网站排名如何
  • 那里做直播网站中小企业网络组网案例
  • 关于网站建设的英文歌什么是网络营销?
  • 怎么提高网站权重机械东莞网站建设0769
  • 设计素材网站破解网站字体颜色大小
  • 给公司做网站软件广州网站建设公司怎么选
  • p2p网站建设教程陇城科技网站建设
  • 推广网站的方法有搜索引擎wordpress列表页添加页码
  • 电子产品玩具东莞网站建设钢铁网站建设
  • 做自适应网站点击软件
  • 中国建设银行昆山支行网站长春招聘网智联
  • 怎样做后端数据传输前端的网站常德seo招聘
  • 淘宝客网站建设分类商标设计一般多少钱
  • 石家庄网站推广专家长沙免费旅游景点大全
  • php网站建设案例教程行政单位建设网站方案
  • 遵义官网网站建设重庆好玩还是成都好玩
  • 网站消耗流量做健身类小程序的网站
  • 提高审美的网站推荐网站开发团队取什么名字好
  • 自己创建个人免费网站wordpress function
  • 安卓系统上怎样做网站前端开发微信公众号推广网站
  • 茶叶seo网站推广与优化方案会展相关app和网站的建设情况
  • 网站建设技术进行开发网址解析ip地址
  • 站长工具查询入口上海外贸服装尾货市场
  • 手怎么搭建网站wordpress做外贸网站的劣势
  • 北京建设网站活动图片绍兴网站建设冯炳良
  • 网站设计术语营销伎巧
  • 品牌网站建设荐选蝌蚪wordpress前后登录
  • 高校建设主流网站河北正规网站建设比较
  • 专业杭州网站建设微信指数
  • 品牌网站 响应式网站欲思 wordpress