B074-详情富文本 服务上下架 高级查询 分页 查看详情

目录

      • 服务详情修改优化
        • ProductServiceImpl
        • Product.vue
      • 详情数据-富文本-vue-quill-editor
        • 使用步骤
        • 测试
        • 图片的访问方式
        • 富文本集成fastDfs
      • 后台服务上下架(批量)
        • 前端开始
        • 后端完成
          • ProductController
          • ProductServiceImpl
          • ProductMapper
      • 前台展示上架
        • 前端开始
        • 后端完成
          • ProductQuery
          • ProductController
          • ProductMapper
          • 测试
        • 前端展示列表和图片
          • product.html
      • 服务高级查询
      • 分页
      • 查看详情
        • 跳转详情页
        • 数据展示后台接口
          • ProductController
          • ProductMapper
        • 前台展示
          • 导入vue和axios
          • 获取数据.js
          • 展示数据
            • 图片展示
            • 详情
            • 名称,售价,原价,销量
            • 切换图片js

服务详情修改优化

在这里插入图片描述

ProductServiceImpl

product后端保存操作修改

    @Overridepublic void update(Product product) {ProductDetail detail = product.getDetail();if(detail !=null){if(detail.getId() !=null){productDetailMapper.update(detail);}else{productDetailMapper.save(detail);}}productMapper.update(product);}

Product.vue

显示新增界面清除页面缓存

			//显示新增界面handleAdd: function () {this.fileList = [];//清楚页面缓存数据this.productFormVisible = true;//显示新增弹出框this.productForm = {id: null,name: '',resources: '',saleprice: 0,costprice: 0,detail:{id:null,intro:'',orderNotice:''}};},

详情数据-富文本-vue-quill-editor

使用步骤

见文档

测试

在这里插入图片描述
在这里插入图片描述

图片的访问方式

1.链接访问,
2.页面本地存储二进制字节码,base64加密,长度很长不好保存到数据库,

富文本集成fastDfs

修改页面本地存储为链接存储,步骤见文档
结果:
在这里插入图片描述

后台服务上下架(批量)

前端开始

页面加两个按钮,未选置灰,绑定事件,传id数组到后端,

<el-form-item><el-button type="success" @click="onsale" :disabled="this.sels.length===0">上架</el-button>
</el-form-item>
<el-form-item><el-button type="warning" @click="offsale" :disabled="this.sels.length===0">下架</el-button>
</el-form-item>
		sels: [],//列表选中行
		onsale(){var ids = this.sels.map(item => item.id);//获取选中的行if(!this.sels || this.sels.length  <1){this.$message({ message: '老铁,你不选中数据,臣妾上架不了啊....',type: 'error'});return;}this.$confirm('确认上架选中记录吗?', '温馨提示', {type: 'warning'}).then(() => {this.listLoading = true;this.$http.post('/product/onsale',ids).then((res) => {this.listLoading = false;if(res.data.success){this.$message({message: '上架成功',type: 'success'});}else{this.$message({message: res.data.message,type: 'error'});}this.getProducts();});}).catch(() => {});},offsale(){var ids = this.sels.map(item => item.id);//获取选中的行if(!this.sels || this.sels.length  <1){this.$message({ message: '老铁,你不选中数据,臣妾下架不了啊....',type: 'error'});return;}this.$confirm('确认下架选中记录吗?', '提示', {type: 'warning'}).then(() => {this.listLoading = true;this.$http.post('/product/offsale',ids).then((res) => {this.listLoading = false;if(res.data.success){this.$message({message: '下架成功',type: 'success'});}else{this.$message({message: res.data.message,type: 'error'});}this.getProducts();});}).catch(() => {});}

后端完成

ProductController
    /*** 批量上架*/@PostMapping("/onsale")public AjaxResult onsale(@RequestBody List<Long> ids){try {productService.onOrOffSale(ids,1);//flag:0下架 1上架return AjaxResult.me();} catch (Exception e) {e.printStackTrace();return AjaxResult.me().setMessage("上架失败!"+e.getMessage());}}/*** 批量下架*/@PostMapping("/offsale")public AjaxResult offsale(@RequestBody List<Long> ids){try {productService.onOrOffSale(ids,0);//flag:0下架 1上架return AjaxResult.me();} catch (Exception e) {e.printStackTrace();return AjaxResult.me().setMessage("下架失败!"+e.getMessage());}}
ProductServiceImpl
    @Overridepublic void onOrOffSale(List<Long> ids, int flag) {//1.判断是上架还是下架Map<String,Object> map = new HashMap<>();map.put("ids", ids);if(flag == 1){//1.1 调整状态//1.2时间map.put("onSaleTime",new Date());productMapper.onSale(map);}else{//1.1 调整状态//1.2时间map.put("offSaleTime",new Date());productMapper.offSale(map);}}
ProductMapper
    <!--void onSale(Map<String, Object> map);--><update id="onSale" >UPDATE t_product set state=1, onsaletime=#{onSaleTime} where id in<foreach collection="ids" item="id" open="(" close=")" separator=",">#{id}</foreach></update><!--void offSale(Map<String, Object> map);--><update id="offSale" >UPDATE t_product set state=0, offsaletime=#{offSaleTime} where id in<foreach collection="ids" item="id" open="(" close=")" separator=",">#{id}</foreach></update>

前台展示上架

前端开始

index修改栏目名称,拷贝search为product,修改引入路径,index支持跳转到product,product修改栏目名称并支持跳转到index,
拷贝success为adoutUs,修改引入路径,index支持跳转到adoutUs,adoutUs修改页面内容,

product引入vue和axios,用div包住body里的内容,写vue实例,

后端完成

ProductQuery
@Data
public class ProductQuery extends BaseQuery {//查询上下架的标识private Integer state;
}
ProductController
    /*** 前端主站使用的接口,只查询上架的*/@PostMapping("/list")public PageList<Product> queryWebPage(@RequestBody ProductQuery productQuery){productQuery.setState(1);return productService.queryPage(productQuery);}
ProductMapper
    <!--Integer queryCount(ProductQuery productQuery);--><select id="queryCount" parameterType="ProductQuery" resultType="integer">SELECT count(*) FROM t_product<include refid="whereSql"/></select><!--List<Product> queryData(ProductQuery productQuery)--><select id="queryData" resultType="Product" parameterType="ProductQuery">SELECT * FROM t_product<include refid="whereSql"/>limit #{start},#{pageSize}</select><!--Where条件--><sql id="whereSql"><where><if test="keyword != null and keyword != ''">AND name LIKE concat("%",#{keyword},"%")</if><if test="state != null">AND state = #{state}</if></where></sql>
测试

注释掉拦截器,然后可以免登录用swagger测试

前端展示列表和图片

调整入参获取数据,遍历,按照规格渲染到页面

fastDfs传800×800可以自定转430×430,350×350,60×60,

product.html
<ul class="am-avg-sm-2 am-avg-md-3 am-avg-lg-4 boxes"><li v-for="product in pageList.rows"><div class="i-pic limit"><img :src="baseFastUrl + product.resources.split(',')[0] + imgSuffix" /><p class="title fl">【官方旗舰店】{{product.name}}</p><p class="price fl"><b>¥</b><strong>{{product.saleprice}}</strong></p><p class="number fl">销量<span>{{product.salecount}}</span></p></div></li>
</ul>
<script type="text/javascript">new Vue({el: "#productDiv",data: {baseFastUrl: "http://115.159.217.249:8888/",imgSuffix: "_350x350.jpg",pageList: {total: 0,rows: []},queryParams: {pageSize: 12,currentPage: 1,keyword: '',}},methods: {getProducts() {this.$http.post("/product/list", this.queryParams).then(result => {result = result.data;//pageList  rows  totalconsole.log(result);if (result) {this.pageList = result;}}).catch(result => {console.log(result);alert("系统错误!");})}},mounted() {this.getProducts();}})
</script>

服务高级查询

元素绑定

<div class="search-bar pr"><a name="index_none_header_sysc" href="#"></a><form><input id="searchInput" name="index_none_header_sysc" v-model="queryParams.keyword" type="text" placeholder="搜索" autocomplete="off"><input id="ai-topsearch" class="submit am-btn" @click="search" value="搜索" index="1" type="button"></form>
</div>

方法绑定

search() {this.queryParams.currentPage = 1;//定为到第一页this.getProducts();},

分页

页数计算与展示,不同页查询,左右箭头分页查询并限制不超过第一页和最后页,

<!--分页 -->
<ul class="am-pagination am-pagination-right"><!--class="am-disabled"--><li><a href="javascript:;" @click="handCurrentPage(queryParams.currentPage -1)">&laquo;</a></li><li v-for="page in countPage"><a href="javascript:;" @click="handCurrentPage(page)">{{page}}</a></li><li><a href="javascript:;" @click="handCurrentPage(queryParams.currentPage +1)">&raquo;</a></li>
</ul>
	computed: {countPage() {//向上取整return Math.ceil(this.pageList.total / this.queryParams.pageSize);}},
		handCurrentPage(page) {//动态分页if (page == 0) {this.queryParams.currentPage = 1;//定位到第一页} else if (page >= this.countPage) {this.queryParams.currentPage = this.countPage;//定位到最后页} else {this.queryParams.currentPage = page;//定位到所选页}this.getProducts();},

查看详情

跳转详情页

<li v-for="product in pageList.rows" @click="goDetail(product.id)">
	goDetail(productId) {//跳转到详情页//当前窗体打开//location.href = "http://localhost/productDetail.html?productId=" + productId;window.open("http://localhost/productDetail.html?productId=" + productId);},

数据展示后台接口

ProductController
    @GetMapping("/{id}")@ApiOperation(value = "查询一条服务数据",notes = "需要传入id")public Product getById(@PathVariable("id") Long id){return productService.getById(id);}
ProductMapper
    <resultMap id="ProductMap" type="Product"><!--基础属性--><id column="id" property="id"/><result column="name" property="name"/><result column="resources" property="resources"/><result column="saleprice" property="saleprice"/><result column="costprice" property="costprice"/><result column="offsaletime" property="offsaletime"/><result column="onsaletime" property="onsaletime"/><result column="state" property="state"/><result column="createtime" property="createtime"/><result column="salecount" property="salecount"/><association property="detail" javaType="ProductDetail"><id column="did" property="id"/><result column="intro" property="intro"/><result column="orderNotice" property="orderNotice"/></association></resultMap><!--Product loadById(Long id);--><select id="loadById" resultMap="ProductMap">SELECTp.*, d.id did,d.intro,d.orderNoticeFROMt_product pLEFT JOIN t_product_detail d ON p.id = d.product_idWHEREp.id =  #{id}</select>

前台展示

导入vue和axios
获取数据.js
<script type="text/javascript">new Vue({el:"#productDetailDiv",data:{product:{},fastDfsUrl:"http://115.159.217.249:8888",midimgSuffix:"_350x350.jpg",smallimgSuffix:"_60x60.jpg",resources:[]},mounted(){let productId = parseUrlParams2Obj(location.href).productId;this.$http.get("/product/"+productId).then(result=>{this.product = result.data;if(this.product.resources){this.resources = this.product.resources.split(',');}}).catch(result=>{console.log(result);alert("系统错误");})}});
</script>
展示数据
图片展示
		<div class="tb-booth tb-pic tb-s310"><a :href="fastDfsUrl+resources[0]"><img :src="fastDfsUrl+resources[0]+midimgSuffix" alt="细节展示放大镜特效" :rel="fastDfsUrl+resources[0]" class="jqzoom" /></a></div><ul class="tb-thumb" id="thumblist"><li v-for="(resource,index) in resources"><div class="tb-pic tb-s40 tb-selected" v-if="index==0"><a href="#"><img :src="fastDfsUrl+resource+smallimgSuffix" :mid="fastDfsUrl+resource+midimgSuffix" :big="fastDfsUrl+resource"></a></div><div class="tb-pic tb-s40" v-else><a href="#"><img :src="fastDfsUrl+resource+smallimgSuffix" :mid="fastDfsUrl+resource+midimgSuffix" :big="fastDfsUrl+resource"></a></div></li></ul>
详情
		<div class="am-tab-panel am-fade am-in am-active"><div class="J_Brand"><div class="attr-list-hd tm-clear"><h4>服务简介:</h4></div><div class="clear"></div><div v-html="product.detail.intro" v-if="product.detail"></div><div class="clear"></div></div><div class="details"><div class="attr-list-hd after-market-hd"><h4>预定须知</h4></div><div class="twlistNews"><div v-html="product.detail.orderNotice" v-if="product.detail"></div></div></div><div class="clear"></div></div>
名称,售价,原价,销量

切换图片js
<script type="text/javascript">// 切换图片js$(document).ready(function() {$(".jqzoom").imagezoom();$("#thumblist").on("click","#thumblist li a", function() {$(this).parents("li").addClass("tb-selected").siblings().removeClass("tb-selected");$(".jqzoom").attr('src', $(this).find("img").attr("mid"));$(".jqzoom").attr('rel', $(this).find("img").attr("big"));});/*$("#thumblist li a").click(function() {$(this).parents("li").addClass("tb-selected").siblings().removeClass("tb-selected");$(".jqzoom").attr('src', $(this).find("img").attr("mid"));$(".jqzoom").attr('rel', $(this).find("img").attr("big"));});*/});
</script>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/9208.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

MySQL - 事务隔离级别

并发事务问题 脏读 概念&#xff1a; 一个事务读到另外一个事务还没提交的数据 举例&#xff1a; 事务A&#xff1a;第一步&#xff1a;select 第二步&#xff1a;update 第三步&#xff1a;… 事务B&#xff1a;第一步&#xff1a;select 第二步&#xff1a;… 假设原本在…

PostgreSQL 常用空间处理函数

1.OGC标准函数 管理函数&#xff1a; 添加几何字段 AddGeometryColumn(, , , , , ) 删除几何字段 DropGeometryColumn(, , ) 检查数据库几何字段并在geometry_columns中归档 Probe_Geometry_Columns() 给几何对象设置空间参考&#xff08;在通过一个范围做空间查询时常用&…

C#设计模式之---原型模式

原型模式&#xff08;Prototype Pattern&#xff09; 原型模式&#xff08;Prototype Pattern&#xff09; 是用原型实例指定创建对象的种类&#xff0c;并且通过拷贝这些原型创建新的对象。原型模式是一种创建型设计模式。也就是用一个已经创建的实例作为原型&#xff0c;通过…

使用docker 部署自己的chatgpt

直接docker部署 docker run --name chatgpt-web -d -p 3002:3002 --env OPENAI_API_KEYyour_api_key chenzhaoyu94/chatgpt-web:latestDocker compose部署 version: 3services:app:image: chenzhaoyu94/chatgpt-web # 总是使用 latest ,更新时重新 pull 该 tag 镜像即可ports…

NLP(六十一)使用Baichuan-13B-Chat模型构建智能文档问答助手

在文章NLP&#xff08;六十&#xff09;Baichuan-13B-Chat模型使用体验中&#xff0c;我们介绍了Baichuan-13B-Chat模型及其在向量嵌入和文档阅读上的初步尝试。   本文将详细介绍如何使用Baichuan-13B-Chat模型来构建智能文档问答助手。 文档问答流程 智能文档问答助手的流…

【*1900 图论】CF1328 E

Problem - E - Codeforces 题意&#xff1a; 思路&#xff1a; 注意到题目的性质&#xff1a;满足条件的路径个数是极少的&#xff0c;因为每个点离路径的距离<1 先考虑一条链&#xff0c;那么直接就选最深那个点作为端点即可 为什么&#xff0c;因为我们需要遍历所有点…

3.安装kubesphere

1.本地存储动态 PVC # 在所有节点安装 iSCSI 协议客户端&#xff08;OpenEBS 需要该协议提供存储支持&#xff09; yum install iscsi-initiator-utils -y # 设置开机启动 systemctl enable --now iscsid # 启动服务 systemctl start iscsid # 查看服务状态 systemctl status …

将数据转二进制流文件,用PostMan发送二进制流请求

一、将byte数组转二进制流文件&#xff0c;并保存到本地 byte [] oneshotBytesnew byte[]{78,-29,51,-125,86,-105,56,82,-94,-115,-22,-105,0,-45,-48,-114,27,13,38,45,-24,-15,-13,46,88,-90,-66,-29,52,-23,40,-2,116,2,-115,17,36,15,-84,88,-72,22,-86,41,-90,-19,-58,19…

Opencv-C++笔记 (13) : opencv-图像卷积一(均值、中值、高斯、双边滤波)与 边缘处理

文章目录 一、概述图像滤波1.1、均值滤波1.2中值滤波1.3、高斯滤波1.4、双边滤波1.5、方框滤波 二、自定义掩码三、边缘处理四、Sobel算子五、Scharr算子六、拉普拉斯算子十、Canny算法 一、概述图像滤波 头文件 quick_opencv.h&#xff1a;声明类与公共函数 #pragma once #i…

13.Netty源码之Netty中的类与API

highlight: arduino-light ServerBootstrap Bootstrap 意思是引导&#xff0c;一个 Netty 应用通常由一个 Bootstrap 开始&#xff0c;主要作用是配置整个 Netty 程序&#xff0c;串联各个组件&#xff0c;Netty 中ServerBootstrap 是服务端启动引导类。 java //泛型 AbstractB…

Vue2到3 全套学习内容(持续更新)

Vue 初次上手 1. Vue 概念 概念: Vue 是一个用于 构建用户界面 的 渐进式 框架 ①构建用户界面&#xff1a;基于数据动态渲染出用户看到的页面 ②渐进式&#xff1a;循序渐进 Vue的两种使用方式: ①Vue 核心包开发 场景: 局部 模块改造 ②Vue核心包&Vue插件工程化开发…

C++-----list

本期我们来讲解list&#xff0c;有了string和vector的基础&#xff0c;我们学习起来会快很多 目录 list介绍 ​编辑 list常用接口 insert erase reverse sort merge unique remove splice 模拟实现 基础框架 构造函数 push_back 迭代器 常见问题 const迭代器 …

MySQL存储过程

文章目录 MySQL存储过程一.MySQL存储过程1.概述2.简介3.存储过程中的控制结构及应用场景4.存储过程的优点5.存储过程语法6.不带参数创建&#xff08;示例&#xff09;6.1 创建存储过程6.2 调用存储过程6.3 查看存储过程6.4 存储过程的参数 7.实例8.修改存储过程9.删除存储过程 …

4 Linux基础篇-目录结构

4 Linux基础篇-目录结构 文章目录 4 Linux基础篇-目录结构4.1 Linux目录结构4.2 具体的目录结构 学习视频来自于B站【小白入门 通俗易懂】2021韩顺平 一周学会Linux。可能会用到的资料有如下所示&#xff0c;下载链接见文末&#xff1a; 《鸟哥的Linux私房菜 基础学习篇 第四版…

springboot 之以enable开头的注解

Spring​ 有很多 Enable 开头的注解&#xff0c;平时在使用的时候也没有注意过为什么会有这些注解 Enable 注解 首先我们先看一下有哪些常用的 Enable 开头的注解&#xff0c;以及都是干什么用的。 EnableRetry​&#xff1a;开启Spring 的重试功能&#xff1b; EnableSch…

web攻击面试|网络渗透面试(一)

Web攻击面试大纲 常见Web攻击类型 1.1 SQL注入攻击 1.2 XSS攻击 1.3 CSRF攻击 1.4 命令注入攻击SQL注入攻击 2.1 基本概念 2.2 攻击原理 2.3 防御措施XSS攻击 3.1 基本概念 3.2 攻击原理 3.3 防御措施CSRF攻击 4.1 基本概念 4.2 攻击原理 4.3 防御措施命令注入攻击 5.1 基本概…

手机python怎么用海龟画图,python怎么在手机上编程

大家好&#xff0c;给大家分享一下手机python怎么用海龟画图&#xff0c;很多人还不知道这一点。下面详细解释一下。现在让我们来看看&#xff01; 1、如何python手机版创造Al&#xff1f; 如果您想在手机上使用Python来创建AI&#xff08;人工智能&#xff09;程序&#xff0…

Golang并发控制

开发 go 程序的时候&#xff0c;时常需要使用 goroutine 并发处理任务&#xff0c;有时候这些 goroutine 是相互独立的&#xff0c;需要保证并发的数据安全性&#xff0c;也有的时候&#xff0c;goroutine 之间要进行同步与通信&#xff0c;主 goroutine 需要控制它所属的子gor…

nginx怎么做负载均衡

Nginx怎么做负载均衡 Nginx 是一个高性能的开源反向代理服务器&#xff0c;可以用于实现负载均衡。负载均衡指的是将用户请求平均分配给多个服务器&#xff0c;以提高整体系统性能和可靠性。下面是一个详细介绍如何使用 Nginx 实现负载均衡的步骤&#xff1a; 步骤 1&#xf…

Redis7.0版本集群

环境准备 centos 7.5redis-7.0.12.tar.gz 操作步骤 1、采用克隆模式创建三台虚拟机&#xff08;redis-cluster01、redis-cluster02、redis-cluster03&#xff09; 2、上传 redis-7.0.12.tar.gz 文件到 /home 目录下 3、解压文件 4、进入 /home/redis-7.0.12 目录下执行命令 m…