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

rest_framework_mongoengine实现后端的增删改查

rest_framework_mongoengine实现后端增删改查

一、增删改查

1. 继承ModelViewSet实现增删改查
  • 父urls.py
path("api/testapp/", include("apps.testapp.urls")), # 测试
  • 子urls.py
# -*- coding: utf-8 -*-
from django.urls import path
from rest_framework_mongoengine.routers import SimpleRouterfrom apps.testapp.views import TestView, ProductViewSeturlpatterns = [# 测试接口...
]model_mango_url = SimpleRouter()
model_mango_url.register(r'product', ProductViewSet)
urlpatterns += model_mango_url.urls
print("urlpatterns============", urlpatterns)
  • models.py
from django.db import models# Create your models here.
from mongoengine import Document, fieldsclass Product(Document):name = fields.StringField(required=True)description = fields.StringField()price = fields.StringField()
  • serializer.py
from rest_framework import serializers
from rest_framework_mongoengine.serializers import DocumentSerializerfrom apps.testapp.models import Productclass ProductSerializer(DocumentSerializer):# 序列化的是后更改了name字段 required=Falsename = serializers.CharField(required=False)class Meta:model = Productfields = '__all__'
  • views.py
from django.http import JsonResponse
from django.shortcuts import render# Create your views here.
from rest_framework.response import Response
from rest_framework.decorators import api_view
from rest_framework.views import APIView
from rest_framework_mongoengine.viewsets import ModelViewSetfrom apps.testapp.models import Product
from apps.testapp.serializers import ProductSerializerclass ProductViewSet(ModelViewSet):queryset = Product.objects.all()serializer_class = ProductSerializer
1.1 创建(create)
1.新增单个
POST {{ipaddr}}api/testapp/product/{"name":"iphone14","description":"十分骄傲了就是佛爱事件的发生","price":"12"
}
2.批量插入
  • urls.py
urlpatterns = [# 批量插入path(r'product/create', ProductViewSet.as_view({'post': 'create_many'})),
]
  • views.py
class ProductViewSet(ModelViewSet):queryset = Product.objects.all()serializer_class = ProductSerializer# 如果重写的是create方法,那么之前的创建单个资源,也会走这个方法,所以为了区分,保留之前的单个字典插入,这里命名craete_manydef create_many(self, request, *args, **kwargs):serializer = self.serializer_class(data=request.data, many=True)if serializer.is_valid():products = [Product(**item) for item in serializer.validated_data]Product.objects.insert(products)return Response(serializer.validated_data, status=201)return Response(serializer.errors, status=400)
  • 测试
POST   {{ipaddr}}api/testapp/product/create[{"name": "iphone16","description": "十分骄傲了就是佛爱事件的发生","price": "12"},{"name": "iphone17","description": "十分骄傲了就是佛爱事件的发生","price": "12"},{"name": "iphone18","description": "十分骄傲了就是佛爱事件的发生","price": "12"}
]
1.2 读取(read)
1.获取所有列表 list
GET {{ipaddr}}api/testapp/product/

说明:底层使用的list方法

2.获取单个详情 retrieve
GET {{ipaddr}}api/testapp/product/660cbeb432362db8ac968ee9/

说明:底层使用的是retrieve

3.分页查询
GET {{ipaddr}}api/testapp/product?page=2&limit=2
  • settings.py
REST_FRAMEWORK = {..."DEFAULT_PAGINATION_CLASS": "dvadmin.utils.pagination.CustomPagination",  # 自定义分页...
}
  • pagination.py
# -*- coding: utf-8 -*-from collections import OrderedDictfrom django.core import paginator
from django.core.paginator import Paginator as DjangoPaginator, InvalidPage
from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Responseclass CustomPagination(PageNumberPagination):page_size = 10page_size_query_param = "limit"max_page_size = 999django_paginator_class = DjangoPaginatordef paginate_queryset(self, queryset, request, view=None):"""Paginate a queryset if required, either returning apage object, or `None` if pagination is not configured for this view."""empty = Truepage_size = self.get_page_size(request)if not page_size:return Nonepaginator = self.django_paginator_class(queryset, page_size)page_number = request.query_params.get(self.page_query_param, 1)if page_number in self.last_page_strings:page_number = paginator.num_pagestry:self.page = paginator.page(page_number)except InvalidPage as exc:# msg = self.invalid_page_message.format(#     page_number=page_number, message=str(exc)# )# raise NotFound(msg)empty = Falseif paginator.num_pages > 1 and self.template is not None:# The browsable API should display pagination controls.self.display_page_controls = Trueself.request = requestif not empty:self.page = []return list(self.page)def get_paginated_response(self, data):code = 2000msg = 'success'page = int(self.get_page_number(self.request, paginator)) or 1total = self.page.paginator.count if self.page else 0limit = int(self.get_page_size(self.request)) or 10is_next = self.page.has_next() if self.page else Falseis_previous = self.page.has_previous() if self.page else Falseif not data:code = 2000msg = "暂无数据"data = []return Response(OrderedDict([('code', code),('msg', msg),('page', page),('limit', limit),('total', total),('is_next', is_next),('is_previous', is_previous),('data', data)]))
4.根据name模糊查询 list

重写list方法,最好不要重写retrieve方法,二者区别如下:

获取所有列表 底层使用list方法:api/product/
获取单个资源 底层使用retrieve:api/product/123456789/ # 数字是id

因此,如果重写retrieve方法,那么传递参数的时候如果再拼接api/product/name/ 底层识别路径参数的时候不容易区分是name还是id;

  • views.py
class ProductViewSet(ModelViewSet):queryset = Product.objects.all()serializer_class = ProductSerializerdef list(self, request, *args, **kwargs):"""重写list方法,根据name字段模糊查询,获取所有列表也是走这个方法"""# request.query_params.get('name') 这种方式接受参数 url格式为:/product/?name=apple;# kwargs.get("name")  # 这种方式接受参数 url格式:/product/<str:name>/name = request.query_params.get('name')if name:product = Product.objects.filter(name__icontains=name)serializer = self.get_serializer(product, many=True)return Response(serializer.data)else:print("list方法 获取所有列表============")return super().list(request, *args, **kwargs)
  • 测试
# 根据name模糊查询
GET  {{ipaddr}}api/testapp/product/?name=iphone18
# 查询所有
GET  {{ipaddr}}api/testapp/product/
5.多条件查询 list

重写list方法

  • views.py
from rest_framework.response import Response
from rest_framework.decorators import api_view
from rest_framework.views import APIView
from rest_framework_mongoengine.viewsets import ModelViewSetfrom apps.testapp.models import Product
from apps.testapp.serializers import ProductSerializerclass ProductViewSet(ModelViewSet):queryset = Product.objects.all()serializer_class = ProductSerializerdef list(self, request, *args, **kwargs):"""重写list方法,根据name字段模糊查询,获取所有列表也是走这个方法"""# request.query_params.get('name') 这种方式接受参数 url格式为:/product/?name=apple;# kwargs.get("name")  # 这种方式接受参数 url格式:/product/<str:name>/params = request.query_paramsname = params.get('name')price = params.get('price')# 根据查询参数过滤 querysetqueryset = Product.objects.all()if name:queryset = queryset.filter(name__icontains=name)if price:queryset = queryset.filter(price=price)# 序列化查询结果,并返回响应serializer = self.get_serializer(queryset, many=True)return Response(serializer.data)
  • 测试
GET   {{ipaddr}}api/testapp/product/?name=iphone18&price=136
6.返回部分字段
  • views.py
from rest_framework.response import Response
from rest_framework.decorators import api_view
from rest_framework.views import APIView
from rest_framework_mongoengine.viewsets import ModelViewSetfrom apps.testapp.models import Product
from apps.testapp.serializers import ProductSerializerclass TestView(APIView):class ProductViewSet(ModelViewSet):queryset = Product.objects.all()serializer_class = ProductSerializerdef list(self, request, *args, **kwargs):"""重写list方法,根据name字段模糊查询,获取所有列表也是走这个方法"""# request.query_params.get('name') 这种方式接受参数 url格式为:/product/?name=apple;# kwargs.get("name")  # 这种方式接受参数 url格式:/product/<str:name>/params = request.query_paramsname = params.get('name')price = params.get('price')queryset = Product.objects.all()if name:queryset = queryset.filter(name__icontains=name)if price:queryset = queryset.filter(price=price)# 定义一个包含部分字段的新序列化器class PartialProductSerializer(ProductSerializer):class Meta(ProductSerializer.Meta):fields = ('name', 'price')# 序列化查询结果,并返回响应serializer = PartialProductSerializer(queryset, many=True)return Response(serializer.data)
  • 测试
GET  {{ipaddr}}api/testapp/product/?name=iphone18&price=136[{"name": "iphone18","price": "136"}
]
7.排序查询
  • views.py
from rest_framework.response import Response
from rest_framework.decorators import api_view
from rest_framework.views import APIView
from rest_framework_mongoengine.viewsets import ModelViewSetfrom apps.testapp.models import Product
from apps.testapp.serializers import ProductSerializerclass TestView(APIView):class ProductViewSet(ModelViewSet):queryset = Product.objects.all()serializer_class = ProductSerializerdef list(self, request, *args, **kwargs):"""重写list方法,根据name字段模糊查询,获取所有列表也是走这个方法"""# request.query_params.get('name') 这种方式接受参数 url格式为:/product/?name=apple;# kwargs.get("name")  # 这种方式接受参数 url格式:/product/<str:name>/params = request.query_paramsname = params.get('name')price = params.get('price')queryset = Product.objects.all()if name:queryset = queryset.filter(name__icontains=name)if price:queryset = queryset.filter(price=price)# 定义一个包含部分字段的新序列化器class PartialProductSerializer(ProductSerializer):class Meta(ProductSerializer.Meta):fields = ('name', 'price')# queryset = queryset.order_by('price')  # 按照price字段升序排序queryset = queryset.order_by('-price')  # 按照price字段降序排序# 序列化查询结果,并返回响应serializer = PartialProductSerializer(queryset, many=True)return Response(serializer.data)
  • 测试
GET   {{ipaddr}}api/testapp/product/?name=iphone18[{"name": "iphone18","price": "436"},{"name": "iphone18","price": "166"},{"name": "iphone18","price": "136"},{"name": "iphone18","price": "12"}
]
1.3 更新(update)
1.修改单个
PUT {{ipaddr}}api/testapp/product/660cc1ce799f2e1df6778875/
{"price":"15999"
}
2.批量修改

举例:批量修改name="iphone14"的数据,price更新为1300

  • views.py
# Create your views here.
from rest_framework.response import Response
from rest_framework.decorators import api_view, action
from rest_framework.views import APIView
from rest_framework_mongoengine.viewsets import ModelViewSetfrom apps.testapp.models import Product
from apps.testapp.serializers import ProductSerializerclass ProductViewSet(ModelViewSet):queryset = Product.objects.all()serializer_class = ProductSerializer"""@action说明:methods:一个列表,包含允许的 HTTP 方法。例如,['get', 'post'] 表示这个动作既允许 GET 请求也允许 POST 请求。detail:一个布尔值,指示这个动作是否适用于单个实例。如果设置为 True,则动作的 URL 将包含一个实例的主键,例如 /products/1/batch_update/。如果设置为 False,则动作的 URL 不包含实例的主键,例如 /products/batch_update/。"""@action(methods=['post'], detail=False)def batch_update(self, request):# 获取请求的数据data = request.data# 确保请求的数据中包含了需要更新的名称和价格if 'name' in data and 'price' in data:# 获取要更新的名称和价格name_to_update = data['name']new_price = data['price']# 执行批量更新操作updated_count = Product.objects.filter(name=name_to_update).update(price=new_price)# 返回更新结果return Response({'message': f'Updated {updated_count} products.', 'name': name_to_update, 'new_price': new_price})else:# 如果请求的数据不完整,返回错误信息return Response({'error': 'Name and price fields are required.'}, status=400)
  • 测试
POST  {{ipaddr}}api/testapp/product/batch_update/{"name":"iphone14","price":"1300"
}
1.4 删除(Delete)
1.删除单个资源
DELETE  {{ipaddr}}api/testapp/product/660cbeb432362db8ac968ee9/
2.批量删除
  • views.py
from django.http import JsonResponse
from django.shortcuts import render# Create your views here.
from rest_framework.response import Response
from rest_framework.decorators import api_view, action
from rest_framework.views import APIView
from rest_framework_mongoengine.viewsets import ModelViewSetfrom apps.testapp.models import Product
from apps.testapp.serializers import ProductSerializerclass ProductViewSet(ModelViewSet):queryset = Product.objects.all()serializer_class = ProductSerializer@action(methods=['post'], detail=False)def batch_delete(self, request):# 获取请求的数据data = request.data# 确保请求的数据中包含了需要删除的名称if 'name' in data:# 获取要删除的名称name_to_delete = data['name']# 执行批量删除操作deleted_count = Product.objects.filter(name=name_to_delete).delete()# 返回删除结果return Response({'message': f'Deleted {deleted_count} products.', 'name': name_to_delete})else:# 如果请求的数据不完整,返回错误信息return Response({'error': 'Name field is required.'}, status=400)
  • 测试
POST   {{ipaddr}}api/testapp/product/batch_delete/{"name":"iphone19"
}

相关文章:

rest_framework_mongoengine实现后端的增删改查

rest_framework_mongoengine实现后端增删改查 ‍ 一、增删改查 1. 继承ModelViewSet实现增删改查 父urls.py path("api/testapp/", include("apps.testapp.urls")), # 测试子urls.py # -*- coding: utf-8 -*- from django.urls import path from res…...

【精读文献】Scientific data|2017-2021年中国10米玉米农田变化制图

论文名称&#xff1a;Mapping annual 10-m maize cropland changes in China during 2017–2021 第一作者及通讯作者&#xff1a;Xingang Li, Ying Qu 第一作者单位及通讯作者单位&#xff1a;北京师范大学地理学部 文章发表期刊&#xff1a;《Scientific data》&#xff08…...

高光谱图像修复笔记

目录 RetinexFormer 也有MST-plus-plus代码&#xff0c;分辨率可以调 MST-plus-plus github地址&#xff1a; WACV2023 DSTrans RetinexFormer GitHub - caiyuanhao1998/Retinexformer: "Retinexformer: One-stage Retinex-based Transformer for Low-light Image E…...

GPS定位原理及应用分析

一&#xff0e;定位原理 1.卫星定位&#xff08;GPS&#xff0c;北斗导航&#xff09; ①&#xff0e;硬件构成&#xff08;24颗卫星&#xff0c;可构建一套导航系统&#xff09; 为何是24颗卫星&#xff1f; 可以做到全球覆盖&#xff0c;同一地点地球上空可观测到4颗卫星。 …...

Java面试篇9——并发编程

并发编程知识梳理 提示&#xff0c;此仅为面试&#xff0c;若想对线程有跟完整了解&#xff0c;请点击这里 提示&#xff1a;直接翻到最后面看面试真题&#xff0c;上面的为详解 面试考点 文档说明 在文档中对所有的面试题都进行了难易程度和出现频率的等级说明 星数越多代表…...

[RK3399 Linux] 使用busybox 1.36.1制作rootfs

一、 编译、安装、配置 busybox 1.1 下载源码 根文件系统是根据busybox来制作的。 下载地址:https://busybox.net/downloads/。 这里就以1.36.1版本为例进行编译安装介绍: 注意:编译linux内核与文件系统中的所有程序要使用相同的交叉编译器。 下载完成后解压: mkdir …...

JavaScript入门--循环

JavaScript入门--循环 一、for循环二、for in语句三、break语句四、continue语句五、while循环六、do-while语句一、for循环 先来看一个循环案例: for (i = 0; i < 5; i++) {...

【Delphi 爬虫库 1】GET和POST方法

文章目录 1.最简单的Get方法实现2.可自定义请求头、自定义Cookie的Get方法实现3.提取响应协议头4.Post方法实现单词翻译 爬虫的基本原理是根据需求获取信息并返回。就像当我们感到饥饿时&#xff0c;可以选择自己烹饪食物、外出就餐&#xff0c;或者订外卖一样。在编程中&#…...

[leetcode] 快乐数 E

:::details 编写一个算法来判断一个数 n 是不是快乐数。 「快乐数」 定义为&#xff1a; 对于一个正整数&#xff0c;每一次将该数替换为它每个位置上的数字的平方和。 然后重复这个过程直到这个数变为 1&#xff0c;也可能是 无限循环 但始终变不到 1。 如果这个过程 结果为 1…...

Lobe UI - 基于 AntDesign 开发的 AIGC Web 应用的开源 UI 组件库

今天推荐一个可以快速开发 ChatGPT UI 界面的组件库&#xff0c;质量很高&#xff0c;拿来就能用。 Lobe UI 是由 lobehub 团队开发的一套 web UI 组件库&#xff0c;和我之前推荐的很多通用型的 UI 组件库不同&#xff0c;Lobe UI 是专门为目前火热的 AIGC 应用开发而打造&am…...

Java常用类 -- Random类

该类实例用于生成伪随机数的流 伪随机数&#xff1a;通过算法算出来的数&#xff0c;是假的随机数 &#xff08;一&#xff09;具体使用 public static void main(String[] args) { ​Random r new Random(); ​System.out.println("随机出int类型的数据" r.nextIn…...

Docker安装Kong网关

文章目录 一、kong是什么?二、搭建步骤1.搭建PostgreSQL2.搭建Kong网关2.1、制作镜像2.2、数据库初始化2.3、启动Kong网关一、kong是什么? Github地址:https://github.com/Kong/kong Kong是一个可扩展、开源的云原生API网关,可以在分布式环境中管理、监控和安全地发布API…...

spispispi

SPI C.. & C.. logic是SPI的控制逻辑&#xff0c;芯片内部进行地址锁存、数据读写等操作&#xff0c;都是由控制逻辑自动完成。控制逻辑的左边是SPI的通信引脚&#xff0c;这些引脚和主控芯片相连&#xff0c;主控芯片通过SPI协议&#xff0c;把指令和数据发送给控制逻辑&a…...

MySQL——创建和插入

一、插入数据 INSERT 使用建议; 在任何情况下建议列出列名&#xff0c;在 VALUES 中插入值时&#xff0c;注意值和列的意义对应关系 values 指定的值顺序非常重要&#xff0c;决定了值是否被保存到正确的列中 在指定了列名的情况下&#xff0c;你可以仅对需要插入的列给到…...

【BUG】element-ui表格中使用video标签,数据翻页,video中的视频仍然显示第一页的视频,没有重新加载

BUG描述 遇到一个问题&#xff0c;使用element-ui构建的管理端后台&#xff0c;表格里面每一行都有一个video标签&#xff0c;里面有视频&#xff0c;当我翻页了以后&#xff0c;视频不会重新加载&#xff0c;仍然显示的是第一页的视频&#xff0c;代码如下&#xff1a; <e…...

【JavaSE】你真的了解内部类吗?

前言 本篇会详细讲解内部类的四种形式&#xff0c;让你掌握内部类~ 欢迎关注个人主页&#xff1a;逸狼 创造不易&#xff0c;可以点点赞吗~ 如有错误&#xff0c;欢迎指出~ 目录 前言 内部类介绍 实例内部类 定义 调用 静态内部类 定义 调用 匿名内部类 定义和调用1 调用方法2 …...

Vue3(二):报错调试,vue3响应式原理、computed和watch,ref,props,接口

一、准备工作调试 跟着张天禹老师看前几集的时候可能会遇到如下问题&#xff1a; 1.下载插件&#xff1a;Vue Language Features (Volar)或者直接下载vue-offical 2.npm run serve时运行时出现错误&#xff1a;Error: vitejs/plugin-vue requires vue (&#xff1e;3.2.13) …...

前端console用法分享

console对于前端人员来讲肯定都不陌生&#xff0c;相信大部分开发者都会使用console来进行调试&#xff0c;但它能做的绝不仅限于调试。 最常见的控制台方法 作为开发者&#xff0c;最常用的 console 方法如下&#xff1a; 控制台打印结果&#xff1a; 今天我分享的是一些 co…...

Matlab|电价型负荷需求响应(考虑电价变化)

程序复现来源于《计及需求响应消纳风电的电-热综合能源系统经济调度 》第四章内容。 一、原理 需求响应的基本原理是需求侧根据电力市场价格和电网要求改变其负荷需求以 获取一定的利益回报。其中 PDR 可通过直观的电价变化信号引导用户调节用电方式&#xff0c; 从而达到优…...

PySide QWebChannel实现Python与JS双向通信的前后端分离桌面应用

文章目录 一、前言二、实现方法1.前端部分2.后端部分3.依赖文件三、运行结果一、前言 以往开发桌面应用通常都是页面接口一起写,这样开发周期比较长,且页面样式不灵活,如果能把页面交给前端写的话,就可前后端并行开发桌面应用了,并且css语言灵活好用样式丰富。下面介绍一…...

清明三天,用Python赚了4万?

每年4月&#xff0c;是Python圈子里接私活的旺季&#xff0c;特别是在节假日这种数据暴增的时间段&#xff0c;爬虫采集、逆向破解类的私活订单会集中爆发&#xff0c;量大价高。几乎所有的圈内人都在趁着旺季接私活。 正好&#xff0c;我昨天就做了一单爬虫逆向私活&#xff…...

【C/C++笔试练习】read函数、虚拟存储、用户态、线程特点、缺页处理、调度算法、进程优先级、锁的使用、创建进程、不用加减乘除做加法、三角形

文章目录 C/C笔试练习选择部分&#xff08;1&#xff09;read函数&#xff08;2&#xff09;虚拟存储&#xff08;3&#xff09;用户态&#xff08;4&#xff09;线程特点&#xff08;5&#xff09;缺页处理&#xff08;6&#xff09;调度算法&#xff08;7&#xff09;进程优先…...

设计模式(021)行为型之访问者模式

访问者模式是一种行为型设计模式&#xff0c;它可以在不修改现有代码结构的情况下&#xff0c;为复杂的对象结构添加新的操作。该模式将数据结构和数据操作进行分离&#xff0c;使得数据结构可以独立于操作进行变化&#xff0c;同时也可以在不改变操作的前提下增加新的操作。 在…...

Linux中磁盘的分区,格式化,挂载和文件系统的修复

一.分区工具 1.分区工具介绍 fdisk 2t及以下分区 推荐 (分完区不保存不生效&#xff0c;有反悔的可能) gdisk 全支持 推荐 parted 全支持 不推荐 ( 即时生效&#xff0c;分完立即生效) 2.fdisk 分区,查看磁盘 格式:fdisk -l [磁盘设备] fdisk -l 查看…...

Android retrofit

目录 一.简介 二.基本使用 三.注解 四.转换器 五.适配器 六.文件上传与下载 一.简介 A type-safe HTTP client for Android and Java。封装了OkHttp&#xff0c;也是由Square公司贡献的一个处理网络请求的开源项目。 square/retrofit: A type-safe HTTP client for Andr…...

【C++风云录】五款 C++ 库的探索与应用:物联网、嵌入式与数据处理

提升你的C技能&#xff1a;五个关键库的使用与指南 前言 在今天的数字化世界里&#xff0c;C 作为一种强大且快速的编程语言&#xff0c;在各类复杂系统和应用的开发中扮演着重要角色。然而&#xff0c;单凭语言本身的能力&#xff0c;我们往往无法实现所有的功能需求&#x…...

Qt_30道常见面试题及答案

1. 简述 Qt 是什么&#xff1f; 答&#xff1a;Qt 是一个跨平台的应用程序开发框架&#xff0c;它提供了一系列的工具和库&#xff0c;用于开发图形用户界面&#xff08;GUI&#xff09;应用程序。 2. Qt 有哪些主要模块&#xff1f; 答&#xff1a;Qt 的主要模块包括 Qt Co…...

【vue】v-model 双向数据绑定

:value&#xff1a;单向数据绑定v-model&#xff1a;双向数据绑定 <!DOCTYPE html> <html lang"en"><head><meta charset"UTF-8"><meta name"viewport" content"widthdevice-width, initial-scale1.0">…...

C#创建磁性窗体的方法:创建特殊窗体

目录 一、磁性窗体 二、磁性窗体的实现方法 (1)无标题窗体的移动 (2)Left属性 (3)Top属性 二、设计一个磁性窗体的实例 &#xff08;1&#xff09;资源管理器Resources.Designer.cs设计 &#xff08;2&#xff09;公共类Frm_Play.cs &#xff08;3&#xff09;主窗体 …...

Gateway 基本配置指南:构建高效的网络接入网关

简介&#xff1a; Gateway 是一个常用的网络接入网关&#xff0c;它可以帮助组织实现安全、可靠和高性能的网络连接。本文将介绍 Gateway 的基本配置&#xff0c;帮助读者了解如何正确配置和部署一个高效的 Gateway 网关。 1.网络拓扑规划&#xff1a; 在配置 Gateway 前&#…...

嵩县网站建设/宁波网络营销推广咨询报价

本文假设读者已经有一定Dagger2使用经验 使用疑惑 之前工作中一直在使用dagger2进行开发&#xff0c;用起来确实很爽&#xff0c;但是我从我第一次使用我就一直有一个问题或者说疑问&#xff08;本人才疏学浅脑子不够使&#xff09;&#xff0c;通常情况下我们有如下清单 MyApp…...

福州 网站建设/常见的网站推广方法有哪些

知道自己不能做什么远比知道自己能做什么重要。单例模式介绍&#xff1a;单例模式(Singleton)&#xff0c;也叫单子模式&#xff0c;是一种常用的软件设计模式。在应用这个模式时&#xff0c;单例对象的类必须保证只有一个实例存在。许多时候整个系统只需要拥有一个全局对象&am…...

张家港网站建设/网络营销师资格证

不同数据库模糊查询特殊字符处理 (2010-10-21 19:04:47) 转载▼标签&#xff1a; 杂谈 分类&#xff1a; MSN搬家一、Sqlserver 特殊字符 [ 、 % 、_ [ 用于转义&#xff08;事实上只有左方括号用于转义&#xff0c;右方括号使用最近优先原则匹配最近的左方括号&#xff09;&a…...

电子商务网站建设与管理课设/关键词代发排名推广

当初说要在博客上有技术讨论在其中,但是不知什么原因迟迟没有添加,今天就开先例吧,谈谈DSP芯片的cmd文件的考虑吧.因为本人觉得在DSP变成中,cmd文件是很重要的,它是工程链接命令文件,是联系软件和硬件的文件,主要是在存储器映像中分配块.TI公司的汇编器和链接器所创建的目标文件…...

门业网站源码/seo网站快速排名

求助java静态代码块内变量的使用public class Practice{static String string "static filed";static {String strings "static block";static void show(){ //这是什么错误&#xff0c;求解System.out.println("a method in static block"…...

公司网站在国外打开很慢使用cdn好还是国外租用服务器好/百度站长之家工具

1 关键是&#xff0c;你是要实现什么功能&#xff1a;是四个条件都有内容时查询&#xff0c;还是哪个内容有查哪个&#xff1f;2 如果四个组合框都有内容&#xff0c;相对简单些&#xff1a;3 string s "select * from 表名 where 身份" comboBox1.SelectedItem.To…...