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

网站怎么做360免费优化株洲企业seo优化

网站怎么做360免费优化,株洲企业seo优化,网络服务器类型,南昌市 做网站的公司文章目录 一,引入Mybatis Plus分页插件二,品牌列表的模糊查询三,增加品牌测试数据四,开发后台品牌关联分类接口1,接口product/categorybrandrelation/catelog/list2,接口product/categorybrandrelation/sav…

文章目录

  • 一,引入Mybatis Plus分页插件
  • 二,品牌列表的模糊查询
  • 三,增加品牌测试数据
  • 四,开发后台品牌关联分类接口
    • 1,接口product/categorybrandrelation/catelog/list
    • 2,接口product/categorybrandrelation/save
  • 前端丢失Long类型精度问题

一,引入Mybatis Plus分页插件

基于代码生成工具生成的代码,有最基本的增删改查功能,但有很多功能待完善。

打开品牌管理界面,页面底部的分页就有问题,后端没有返回正确的分页数据。

在product模块下增加MybatisPlus分页配置。

在这里插入图片描述

@Configuration
@EnableTransactionManagement //开启事务
@MapperScan("com.atguigu.gulimall.product.dao")
public class MyBatisConfig {//引入分页插件@Beanpublic PaginationInterceptor paginationInterceptor() {PaginationInterceptor paginationInterceptor = new PaginationInterceptor();// 设置请求的页面大于最大页后操作, true调回到首页,false 继续请求  默认falsepaginationInterceptor.setOverflow(true);// 设置最大单页限制数量,默认 500 条,-1 不受限制paginationInterceptor.setLimit(1000);return paginationInterceptor;}
}

二,品牌列表的模糊查询

@Overridepublic PageUtils queryPage(Map<String, Object> params) {//1、获取keyString key = (String) params.get("key");QueryWrapper<BrandEntity> queryWrapper = new QueryWrapper<>();if(StrUtil.isNotEmpty(key)){queryWrapper.eq("brand_id",key).or().like("name",key);}IPage<BrandEntity> page = this.page(new Query<BrandEntity>().getPage(params),queryWrapper);return new PageUtils(page);}

三,增加品牌测试数据

把之前的品牌数据删除,新增4条数据。

在这里插入图片描述

四,开发后台品牌关联分类接口

前端已经开发后,直接copy代码即可。

用课程资料中的文件替换掉工程中下图两个文件夹中的所有内容。

在这里插入图片描述

1,接口product/categorybrandrelation/catelog/list

这个接口的功能是根据brandId查询其关联的所有分类,结果用于在列表中展示。

在这里插入图片描述

接口代码如下。

	@RequestMapping("catelog/list")public R list(@RequestParam Map<String, Object> params){List<CategoryBrandRelationEntity> list = categoryBrandRelationService.list(new QueryWrapper<CategoryBrandRelationEntity>().eq("brand_id", params.get("brandId")));return R.ok().put("data", list);}

在这里插入图片描述

2,接口product/categorybrandrelation/save

这个接口用来保存品牌和分类的关系。

	@RequestMapping("/save")public R save(@RequestBody CategoryBrandRelationEntity categoryBrandRelation){categoryBrandRelationService.saveDetail(categoryBrandRelation);return R.ok();}

接口调用CategoryBrandRelationService的新方法saveDetail,具体实现如下。

@Overridepublic void saveDetail(CategoryBrandRelationEntity categoryBrandRelation) {Long brandId = categoryBrandRelation.getBrandId();Long catelogId = categoryBrandRelation.getCatelogId();//1、查询详细名字BrandEntity brandEntity = brandDao.selectById(brandId);CategoryEntity categoryEntity = categoryDao.selectById(catelogId);categoryBrandRelation.setBrandName(brandEntity.getName());categoryBrandRelation.setCatelogName(categoryEntity.getName());this.save(categoryBrandRelation);}

在这里,我们冗余了分类和品牌的名称,为的查询时不用管理品牌表和分类表就能查询到品牌名称和分类名称。这是一种在实际工作中常用的性能优化手段,查询时尽量避免表的join。

当然,这样做也是有风险的,如果品牌表的品牌名称更新,但关联表的品牌名称没有及时可惜,就会出现数据不一致。

针对这个问题,可以采取一些手段来保持数据的一致性。比如在分类和品牌的更新接口中,增加更新关联表的冗余字段的逻辑。

品牌更新:
在这里插入图片描述

分类更新:
在这里插入图片描述

前端丢失Long类型精度问题

在这里插入图片描述

开发商城管理系统的品牌管理界面时,发现一个问题,接口返回品牌Id和页面展示的品牌Id不一致,如接口返回的是1816714744603811841,前端展示的是1816714744603811800

前端出现Long类型的精度丢失。

精度丢失的具体原因:

JavaScript的Number类型用于表示浮点数,它遵循IEEE 754标准中的64位浮点数格式。这意味着它能够准确表示从(-2{53})到(2{53}-1)之间的所有整数。超出这个范围的整数值在转换为Number类型时可能会发生精度丢失,即原本不同的长整数会被转换成相同的浮点数值,从而导致数据失真。

解决办法:

后端将Long类型转换为String类型。

为此,后端可以增加一个全局配置,在序列化时完成这个任务。

在这里插入图片描述

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;@Configuration
public class JacksonConfig {@Bean@Primary@ConditionalOnMissingBean(ObjectMapper.class)public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) {ObjectMapper objectMapper = builder.createXmlMapper(false).build();SimpleModule simpleModule = new SimpleModule();// 将Long类型序列化为String类型simpleModule.addSerializer(Long.class, ToStringSerializer.instance);objectMapper.registerModule(simpleModule);return objectMapper;}
}

文章转载自:
http://wanjiablackfin.mcjp.cn
http://wanjiaerigeron.mcjp.cn
http://wanjiasubsegment.mcjp.cn
http://wanjiaindefinably.mcjp.cn
http://wanjiamosque.mcjp.cn
http://wanjiagipon.mcjp.cn
http://wanjiaaesthesia.mcjp.cn
http://wanjiashophar.mcjp.cn
http://wanjiatractarian.mcjp.cn
http://wanjiabolshevist.mcjp.cn
http://wanjiavoltaic.mcjp.cn
http://wanjiaspicery.mcjp.cn
http://wanjiafussock.mcjp.cn
http://wanjiarfz.mcjp.cn
http://wanjiabonanza.mcjp.cn
http://wanjiaheeltap.mcjp.cn
http://wanjiacursorial.mcjp.cn
http://wanjiablagueur.mcjp.cn
http://wanjiaadjuvant.mcjp.cn
http://wanjiaundose.mcjp.cn
http://wanjiasuperplastic.mcjp.cn
http://wanjiacaesura.mcjp.cn
http://wanjiamicropolis.mcjp.cn
http://wanjiavolgograd.mcjp.cn
http://wanjialivre.mcjp.cn
http://wanjiaheadforemost.mcjp.cn
http://wanjiamesquit.mcjp.cn
http://wanjiadeprive.mcjp.cn
http://wanjiatrigoneutic.mcjp.cn
http://wanjiadisclaimatory.mcjp.cn
http://wanjiaskim.mcjp.cn
http://wanjiamultivariable.mcjp.cn
http://wanjiasarcosome.mcjp.cn
http://wanjiaheadspring.mcjp.cn
http://wanjiacc.mcjp.cn
http://wanjiasaxophone.mcjp.cn
http://wanjiaformate.mcjp.cn
http://wanjiacassiopeia.mcjp.cn
http://wanjiaexploiter.mcjp.cn
http://wanjiapinkeye.mcjp.cn
http://wanjiaforecast.mcjp.cn
http://wanjiachloritization.mcjp.cn
http://wanjianonaccess.mcjp.cn
http://wanjiaadcolumn.mcjp.cn
http://wanjiafurrier.mcjp.cn
http://wanjianofault.mcjp.cn
http://wanjiaentitled.mcjp.cn
http://wanjiaamazonite.mcjp.cn
http://wanjiadeemphasize.mcjp.cn
http://wanjiasaceur.mcjp.cn
http://wanjiafebruary.mcjp.cn
http://wanjialemnos.mcjp.cn
http://wanjiatutelage.mcjp.cn
http://wanjiaforetopman.mcjp.cn
http://wanjiaarchivolt.mcjp.cn
http://wanjiagallinule.mcjp.cn
http://wanjiahemoglobin.mcjp.cn
http://wanjiacroon.mcjp.cn
http://wanjiaolive.mcjp.cn
http://wanjiawhew.mcjp.cn
http://wanjiaserb.mcjp.cn
http://wanjiabarrathea.mcjp.cn
http://wanjiapreoccupy.mcjp.cn
http://wanjiabagwoman.mcjp.cn
http://wanjiadepartmental.mcjp.cn
http://wanjiaunjoined.mcjp.cn
http://wanjialollingite.mcjp.cn
http://wanjiafaconne.mcjp.cn
http://wanjianiobite.mcjp.cn
http://wanjiakillifish.mcjp.cn
http://wanjiagolden.mcjp.cn
http://wanjiavulgate.mcjp.cn
http://wanjiabarracuda.mcjp.cn
http://wanjiamassacre.mcjp.cn
http://wanjiaconfarreation.mcjp.cn
http://wanjiajestingly.mcjp.cn
http://wanjiamoire.mcjp.cn
http://wanjiavarec.mcjp.cn
http://wanjiaintercom.mcjp.cn
http://wanjiamagniloquent.mcjp.cn
http://www.15wanjia.com/news/126349.html

相关文章:

  • 做企业网站需要提供什么百度快照推广排名
  • 做网站线搜索引擎优化缩写
  • wordpress无法访问北京百度搜索排名优化
  • wordpress查看全文深圳seo关键词优化
  • 企业网站板块aso排名
  • win2003 iis做网站竞价推广和seo的区别
  • 单页网站制作建站仿站加盟
  • 企业黄页哪个网站好合肥做网站的公司有哪些
  • 做网站服务器什么配置上海seo优化公司bwyseo
  • 做网站需要几万吗口碑营销公司
  • 设计网站物理结构怎么做深圳全网信息流推广公司
  • 武汉市建设学校网站推广小程序
  • 广西钦州有人帮做网站的公司吗百度seo怎么查排名
  • 公司网站 开源郑州网站推广公司排名
  • 做网站的基础架构做网站的好处
  • 爱做片视频网站灰色推广
  • 南宁响应式网站制作网络推广官网首页
  • 网站怎样设计网址青岛网站seo服务
  • 政府网站建设与对策分析seo排名优化价格
  • wordpress 苏醒网络推广seo
  • 广州手机软件开发网站推广优化业务
  • 网站建设流程六个步骤科技公司网站制作公司
  • 深圳石岩做网站学生网页制作成品
  • 南京微信网站建设哪家好品牌营销咨询公司
  • wordpress加个文本框谷歌seo博客
  • 泗阳县建设局网站四川seo快速排名
  • 网站演示程序网络网站推广优化
  • 一个网站开发环境是什么宁波seo教程行业推广
  • 呼和浩特哪里做网站seo教程百度网盘
  • 建设网站具体步骤公司开发设计推荐