文章目录
谷粒商城分布式基础篇十
商城概念
基本信息—分类
一般情况可以分为两级或者三级。咱们的项目一共分为三级,即一级分类、二级分类、三级分类。
比如:家用电器是一级分类,电视是二级分类,那么超薄电视就是三级分类。
数据库结构
基本信息—平台属性
平台属性和平台属性值
平台属性和平台属性值主要用于商品的检索,每个三级分类对应的属性都不同。
而每个商品对应的每种属性都有对应的属性值。
比如电脑整机的一级分类下,有笔记本、游戏本、台式机、一体机的二级分类。
笔记本这个二级分类又包含了处理器、屏幕尺寸、内存容量、硬盘容量、显卡类别这些属性。
那么针对联想某个型号的笔记本,它作为笔记本这种分类,每个分类属性都有对应的值,cpu(属性)是i7(属性值)的,内存(属性)是8G(属性值)的,屏幕尺寸(属性)是14寸(属性值)的。
基本信息—销售属性
销售属性,就是商品详情页右边,可以通过销售属性来定位一组spu下的哪款sku。可以让当前的商品详情页,跳转到自己的“兄弟”商品。
销售属性与平台属性
一般每种商品的销售属性不会太多,大约1-4种。整个电商的销售属性种类也不会太多,大概10种以内。比如:颜色、尺寸、版本、套装等等。不同销售属性的组合也就构成了一个spu下多个sku的结构。
销售属性与平台属性的关系
平台属性, 就是之前分类下面,辅助搜索的,类似于条件的属性。
销售属性,就是商品详情页右边,可以通过销售属性来定位一组spu下的哪款sku。可以让当前的商品详情页,跳转到自己的“兄弟”商品。
一般每种商品的销售属性不会太多,大约1-4种。整个平台的属性种类也不会太多,大概10种以内。比如:颜色、尺寸、版本、套装等等。
基本信息—spu与 sku
SPU(Standard Product Unit):标准化产品单元。是商品信息聚合的最小单位,是一组可复用、易检索的标准化信息的集合,该集合描述了一个产品的特性。
SKU=Stock Keeping Unit(库存量单位)。即库存进出计量的基本单元,可以是以件,盒,托盘等为单位。SKU这是对于大型连锁超市DC(配送中心)物流管理的一个必要的方法。现在已经被引申为产品统一编号的简称,每种产品均对应有唯一的SKU号。
比如,咱们购买一台iPhoneX手机,iPhoneX手机就是一个SPU,但是你购买的时候,不可能是以iPhoneX手机为单位买的,商家也不可能以iPhoneX为单位记录库存。必须要以什么颜色什么版本的iPhoneX为单位。比如,你购买的是一台银色、128G内存的、支持联通网络的iPhoneX ,商家也会以这个单位来记录库存数。那这个更细致的单位就叫库存单元(SKU)。
首先通过检索搜索出来的商品列表中,每个商品都是一个sku。每个sku都有自己独立的库存数。也就是说每一个商品详情展示都是一个sku。
那spu又是干什么的呢?
如上图,一般的电商系统你点击进去以后,都能看到这个商品关联了其他好几个类似的商品,而且这些商品很多的信息都是共用的,比如商品图片,海报、销售属性等。
那么系统是靠什么把这些sku识别为一组的呢,那是这些sku都有一个公用的spu信息。而它们公共的信息,都放在spu信息下。
所以,sku与spu的结构如下:
图中有两个图片信息表,其中spu_image表示整个spu相关下的所有图片信息,而sku_image表示这个spu下的某个sku使用的图片。sku_image中的图片是从spu_image中选取的。
但是由于一个spu下的所有sku的海报都是一样,所以只存一份spu_poster就可以了。
pms数据模型
根据以上的需求,以此将关联的数据库表结构设计为如下:
数据示例:
属性分组
前端组件抽取
src\views\modules\common\category.vue 将分类树形抽取成一个组件
<template>
<div>
<el-input placeholder="输入关键字进行过滤" v-model="filterText"></el-input>
<el-tree
:data="menus"
:props="defaultProps"
node-key="catId"
ref="menuTree"
@node-click="nodeclick"
:filter-node-method="filterNode"
:highlight-current = "true"
></el-tree>
</div>
</template>
<script>
//这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
//例如:import 《组件名称》 from ‘《组件路径》’;
export default {
//import引入的组件需要注入到对象中才能使用
components: {},
props: {},
data() {
//这里存放数据
return {
filterText: “”,
menus: [],
expandedKey: [],
defaultProps: {
children: “children”,
label: “name”
}
};
},
//计算属性 类似于data概念
computed: {},
//监控data中的数据变化
watch: {
filterText(val) {
this.KaTeX parse error: Expected 'EOF', got '}' at position 295: …n punctuation">}̲</span> <span…http({
url: this.KaTeX parse error: Expected 'EOF', got '}' at position 406: …n punctuation">}̲</span><span cl…emit(“tree-node-click”, data, node, component);
}
},
//生命周期 - 创建完成(可以访问当前this实例)
created() {
this.getMenus();
},
//生命周期 - 挂载完成(可以访问DOM元素)
mounted() {},
beforeCreate() {}, //生命周期 - 创建之前
beforeMount() {}, //生命周期 - 挂载之前
beforeUpdate() {}, //生命周期 - 更新之前
updated() {}, //生命周期 - 更新之后
beforeDestroy() {}, //生命周期 - 销毁之前
destroyed() {}, //生命周期 - 销毁完成
activated() {} //如果页面有keep-alive缓存功能,这个函数会触发
};
</script>
<style scoped>
</style>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
父子组件交互
父子组件传递数据:子组件给父组件传递数据,事件机制;子组件给父组件发送一个事件,携带上数据。
this.$emit(“事件名”,携带的数据…)
使用子组件
src\views\modules\product\attrgroup.vue
<template> <el-row :gutter="20"> <el-col :span="6"> <!-- 子组件分类树形节点被点击 回调treenodeclick--> <category @tree-node-click="treenodeclick"></category> </el-col> <el-col :span="18"> <div class="mod-config"> <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()"> <el-form-item> <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input> </el-form-item> <el-form-item> <el-button @click="getDataList()">查询</el-button> <el-button type="success" @click="getAllDataList()">查询全部</el-button> <el-button v-if="isAuth('product:attrgroup:save')" type="primary" @click="addOrUpdateHandle()" >新增</el-button> <el-button v-if="isAuth('product:attrgroup:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0" >批量删除</el-button> </el-form-item> </el-form> <el-table :data="dataList" border v-loading="dataListLoading" @selection-change="selectionChangeHandle" style="width: 100%;" > <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column> <el-table-column prop="attrGroupId" header-align="center" align="center" label="分组id"></el-table-column> <el-table-column prop="attrGroupName" header-align="center" align="center" label="组名"></el-table-column> <el-table-column prop="sort" header-align="center" align="center" label="排序"></el-table-column> <el-table-column prop="descript" header-align="center" align="center" label="描述"></el-table-column> <el-table-column prop="icon" header-align="center" align="center" label="组图标"></el-table-column> <el-table-column prop="catelogId" header-align="center" align="center" label="所属分类id"></el-table-column> <el-table-column fixed="right" header-align="center" align="center" width="150" label="操作" > <template slot-scope="scope"> <el-button type="text" size="small" @click="relationHandle(scope.row.attrGroupId)">关联</el-button> <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.attrGroupId)" >修改</el-button> <el-button type="text" size="small" @click="deleteHandle(scope.row.attrGroupId)">删除</el-button> </template> </el-table-column> </el-table> <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex" :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="totalPage" layout="total, sizes, prev, pager, next, jumper" ></el-pagination> <!-- 弹窗, 新增 / 修改 --> <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
<span class="token operator"><</span><span class="token operator">!</span><span class="token operator">--</span> 修改关联关系 <span class="token operator">--</span><span class="token operator">></span> <span class="token operator"><</span>relation<span class="token operator">-</span>update v<span class="token operator">-</span><span class="token keyword">if</span><span class="token operator">=</span><span class="token string">"relationVisible"</span> ref<span class="token operator">=</span><span class="token string">"relationUpdate"</span> @refreshData<span class="token operator">=</span><span class="token string">"getDataList"</span><span class="token operator">></span><span class="token operator"><</span><span class="token operator">/</span>relation<span class="token operator">-</span>update<span class="token operator">></span> <span class="token operator"><</span><span class="token operator">/</span>div<span class="token operator">></span> <span class="token operator"><</span><span class="token operator">/</span>el<span class="token operator">-</span>col<span class="token operator">></span>
</el-row>
</template>
<script>
/**
- 父子组件传递数据
- 1)、子组件给父组件传递数据,事件机制;
- 子组件给父组件发送一个事件,携带上数据。
- // this.KaTeX parse error: Expected '}', got 'EOF' at end of input: …oken function">nextTick(() => {
this.KaTeX parse error: Expected 'EOF', got '}' at position 302: …n punctuation">}̲</span><span cl…http({
url: this. h t t p < s p a n c l a s s = " t o k e n p u n c t u a t i o n " > . < / s p a n > < s p a n c l a s s = " t o k e n f u n c t i o n " > a d o r n U r l < / s p a n > < s p a n c l a s s = " t o k e n p u n c t u a t i o n " > ( < / s p a n > < s p a n c l a s s = " t o k e n t e m p l a t e − s t r i n g " > < s p a n c l a s s = " t o k e n s t r i n g " > ‘ / p r o d u c t / a t t r g r o u p / l i s t / < / s p a n > < s p a n c l a s s = " t o k e n i n t e r p o l a t i o n " > < s p a n c l a s s = " t o k e n i n t e r p o l a t i o n − p u n c t u a t i o n p u n c t u a t i o n " > http<span class="token punctuation">.</span><span class="token function">adornUrl</span><span class="token punctuation">(</span><span class="token template-string"><span class="token string">`/product/attrgroup/list/</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation"> http<spanclass="tokenpunctuation">.</span><spanclass="tokenfunction">adornUrl</span><spanclass="tokenpunctuation">(</span><spanclass="tokentemplate−string"><spanclass="tokenstring">‘/product/attrgroup/list/</span><spanclass="tokeninterpolation"><spanclass="tokeninterpolation−punctuationpunctuation">{this.catId}</span></span><span class="token punctuation">)</span><span class="token punctuation">,</span> method<span class="token punctuation">:</span> <span class="token string">"get"</span><span class="token punctuation">,</span> params<span class="token punctuation">:</span> <span class="token keyword">this</span><span class="token punctuation">.</span>$http<span class="token punctuation">.</span><span class="token function">adornParams</span><span class="token punctuation">(</span><span class="token punctuation">{</span> page<span class="token punctuation">:</span> <span class="token keyword">this</span><span class="token punctuation">.</span>pageIndex<span class="token punctuation">,</span> limit<span class="token punctuation">:</span> <span class="token keyword">this</span><span class="token punctuation">.</span>pageSize<span class="token punctuation">,</span> key<span class="token punctuation">:</span> <span class="token keyword">this</span><span class="token punctuation">.</span>dataForm<span class="token punctuation">.</span>key <span class="token punctuation">}</span><span class="token punctuation">)</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">{</span> data <span class="token punctuation">}</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>data <span class="token operator">&&</span> data<span class="token punctuation">.</span>code <span class="token operator">===</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">this</span><span class="token punctuation">.</span>dataList <span class="token operator">=</span> data<span class="token punctuation">.</span>page<span class="token punctuation">.</span>list<span class="token punctuation">;</span> <span class="token keyword">this</span><span class="token punctuation">.</span>totalPage <span class="token operator">=</span> data<span class="token punctuation">.</span>page<span class="token punctuation">.</span>totalCount<span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span> <span class="token keyword">this</span><span class="token punctuation">.</span>dataList <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">;</span> <span class="token keyword">this</span><span class="token punctuation">.</span>totalPage <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token keyword">this</span><span class="token punctuation">.</span>dataListLoading <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">;</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token comment">// 每页数</span> <span class="token function">sizeChangeHandle</span><span class="token punctuation">(</span>val<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">this</span><span class="token punctuation">.</span>pageSize <span class="token operator">=</span> val<span class="token punctuation">;</span> <span class="token keyword">this</span><span class="token punctuation">.</span>pageIndex <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">getDataList</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token comment">// 当前页</span> <span class="token function">currentChangeHandle</span><span class="token punctuation">(</span>val<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">this</span><span class="token punctuation">.</span>pageIndex <span class="token operator">=</span> val<span class="token punctuation">;</span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">getDataList</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token comment">// 多选</span> <span class="token function">selectionChangeHandle</span><span class="token punctuation">(</span>val<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">this</span><span class="token punctuation">.</span>dataListSelections <span class="token operator">=</span> val<span class="token punctuation">;</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token comment">// 新增 / 修改</span> <span class="token function">addOrUpdateHandle</span><span class="token punctuation">(</span>id<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">this</span><span class="token punctuation">.</span>addOrUpdateVisible <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">;</span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">$nextTick</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span> <span class="token keyword">this</span><span class="token punctuation">.</span>$refs<span class="token punctuation">.</span>addOrUpdate<span class="token punctuation">.</span><span class="token function">init</span><span class="token punctuation">(</span>id<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token comment">// 删除</span> <span class="token function">deleteHandle</span><span class="token punctuation">(</span>id<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">var</span> ids <span class="token operator">=</span> id <span class="token operator">?</span> <span class="token punctuation">[</span>id<span class="token punctuation">]</span> <span class="token punctuation">:</span> <span class="token keyword">this</span><span class="token punctuation">.</span>dataListSelections<span class="token punctuation">.</span><span class="token function">map</span><span class="token punctuation">(</span>item <span class="token operator">=></span> <span class="token punctuation">{</span> <span class="token keyword">return</span> item<span class="token punctuation">.</span>attrGroupId<span class="token punctuation">;</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">$confirm</span><span class="token punctuation">(</span> <span class="token template-string"><span class="token string">
确定对[id= < / s p a n > i d s < s p a n c l a s s = " t o k e n p u n c t u a t i o n " > . < / s p a n > < s p a n c l a s s = " t o k e n f u n c t i o n " > j o i n < / s p a n > < s p a n c l a s s = " t o k e n p u n c t u a t i o n " > ( < / s p a n > < s p a n c l a s s = " t o k e n s t r i n g " > " , " < / s p a n > < s p a n c l a s s = " t o k e n p u n c t u a t i o n " > ) < / s p a n > < s p a n c l a s s = " t o k e n i n t e r p o l a t i o n − p u n c t u a t i o n p u n c t u a t i o n " > < / s p a n > < / s p a n > < s p a n c l a s s = " t o k e n s t r i n g " > ] 进 行 [ < / s p a n > < s p a n c l a s s = " t o k e n i n t e r p o l a t i o n " > < s p a n c l a s s = " t o k e n i n t e r p o l a t i o n − p u n c t u a t i o n p u n c t u a t i o n " > {</span>ids<span class="token punctuation">.</span><span class="token function">join</span><span class="token punctuation">(</span><span class="token string">","</span><span class="token punctuation">)</span><span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">]进行[</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation"> </span>ids<spanclass="tokenpunctuation">.</span><spanclass="tokenfunction">join</span><spanclass="tokenpunctuation">(</span><spanclass="tokenstring">","</span><spanclass="tokenpunctuation">)</span><spanclass="tokeninterpolation−punctuationpunctuation"></span></span><spanclass="tokenstring">]进行[</span><spanclass="tokeninterpolation"><spanclass="tokeninterpolation−punctuationpunctuation">{id ? “删除” : “批量删除”}]操作?`,
“提示”,
{
confirmButtonText: “确定”,
cancelButtonText: “取消”,
type: “warning”
}
).then(() => {
this.KaTeX parse error: Expected '}', got 'EOF' at end of input: …ation">.</span>http.adornUrl("/product/attrgroup/delete"),
method: “post”,
data: this.KaTeX parse error: Expected 'EOF', got '}' at position 292: …n punctuation">}̲</span><span cl…message({
message: “操作成功”,
type: “success”,
duration: 1500,
onClose: () => {
this.getDataList();
}
});
} else {
this.$message.error(data.msg);
}
});
});
}
}
};
</script>
<style scoped>
</style>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
- 163
- 164
- 165
- 166
- 167
- 168
- 169
- 170
- 171
- 172
- 173
- 174
- 175
- 176
- 177
- 178
- 179
- 180
- 181
- 182
- 183
- 184
- 185
- 186
- 187
- 188
- 189
- 190
- 191
- 192
- 193
- 194
- 195
- 196
- 197
- 198
- 199
- 200
- 201
- 202
- 203
- 204
- 205
- 206
- 207
- 208
- 209
- 210
- 211
- 212
- 213
- 214
- 215
- 216
- 217
- 218
获取分类属性分组
请求
GET /product/attrgroup/list/{catelogId}
- 1
请求参数
{
page: 1,//当前页码
limit: 10,//每页记录数
sidx: 'id',//排序字段
order: 'asc/desc',//排序方式
key: '华为'//检索关键字
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
分页数据
响应数据
{
"msg": "success",
"code": 0,
"page": {
"totalCount": 0,
"pageSize": 10,
"totalPage": 0,
"currPage": 1,
"list": [{
"attrGroupId": 0, //分组id
"attrGroupName": "string", //分组名
"catelogId": 0, //所属分类
"descript": "string", //描述
"icon": "string", //图标
"sort": 0 //排序
"catelogPath": [2,45,225] //分类完整路径
}]
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
controller
/** * 列表 */ @RequestMapping("/list/{catelogId}") public R list(@RequestParam Map<String,Object> params,@PathVariable("catelogId") Long catelogId) {
PageUtils page <span class="token operator">=</span> attrGroupService<span class="token punctuation">.</span><span class="token function">queryPage</span><span class="token punctuation">(</span>params<span class="token punctuation">,</span>catelogId<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">return</span> <span class="token constant">R</span><span class="token punctuation">.</span><span class="token function">ok</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"page"</span><span class="token punctuation">,</span> page<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
serviceImpl
@Override public PageUtils queryPage(Map<String, Object> params, Long catelogId) { String key = (String) params.get("key"); //select * from pms_attr_group where catelog_id=? and (attr_group_id=key or attr_group_name like %key%) QueryWrapper<AttrGroupEntity> wrapper = new QueryWrapper<AttrGroupEntity>(); if(!StringUtils.isEmpty(key)){ wrapper.and((obj)->{ obj.eq("attr_group_id",key).or().like("attr_group_name",key); }); }
<span class="token keyword">if</span><span class="token punctuation">(</span> catelogId <span class="token operator">==</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">{</span> IPage<span class="token operator"><</span>AttrGroupEntity<span class="token operator">></span> page <span class="token operator">=</span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">page</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Query</span><span class="token operator"><</span>AttrGroupEntity<span class="token operator">></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">getPage</span><span class="token punctuation">(</span>params<span class="token punctuation">)</span><span class="token punctuation">,</span> wrapper<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">PageUtils</span><span class="token punctuation">(</span>page<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span><span class="token keyword">else</span> <span class="token punctuation">{</span> wrapper<span class="token punctuation">.</span><span class="token function">eq</span><span class="token punctuation">(</span><span class="token string">"catelog_id"</span><span class="token punctuation">,</span>catelogId<span class="token punctuation">)</span><span class="token punctuation">;</span> IPage<span class="token operator"><</span>AttrGroupEntity<span class="token operator">></span> page <span class="token operator">=</span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">page</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Query</span><span class="token operator"><</span>AttrGroupEntity<span class="token operator">></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">getPage</span><span class="token punctuation">(</span>params<span class="token punctuation">)</span><span class="token punctuation">,</span> wrapper<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">PageUtils</span><span class="token punctuation">(</span>page<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
新增分组
前端组件
src\views\modules\product\attrgroup-add-or-update.vue 组件
<template>
<el-dialog
:title="!dataForm.id ? '新增' : '修改'"
:close-on-click-modal="false"
:visible.sync="visible"
@closed="dialogClose"
>
<el-form
:model="dataForm"
:rules="dataRule"
ref="dataForm"
@keyup.enter.native="dataFormSubmit()"
label-width="120px"
>
<el-form-item label="组名" prop="attrGroupName">
<el-input v-model="dataForm.attrGroupName" placeholder="组名"></el-input>
</el-form-item>
<el-form-item label="排序" prop="sort">
<el-input v-model="dataForm.sort" placeholder="排序"></el-input>
</el-form-item>
<el-form-item label="描述" prop="descript">
<el-input v-model="dataForm.descript" placeholder="描述"></el-input>
</el-form-item>
<el-form-item label="组图标" prop="icon">
<el-input v-model="dataForm.icon" placeholder="组图标"></el-input>
</el-form-item>
<el-form-item label="所属分类" prop="catelogId">
<!-- <el-input v-model="dataForm.catelogId" placeholder="所属分类id"></el-input> @change="handleChange" -->
<!-- <el-cascader filterable placeholder="试试搜索:手机" v-model="catelogPath" :options="categorys" :props="props"></el-cascader> -->
<!-- :catelogPath="catelogPath"自定义绑定的属性,可以给子组件传值 -->
<category-cascader :catelogPath.sync="catelogPath"></category-cascader>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false">取消</el-button>
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
</span>
</el-dialog>
</template>
<script>
import CategoryCascader from ‘…/common/category-cascader’
export default {
data() {
return {
props:{
value:“catId”,
label:“name”,
children:“children”
},
visible: false,
categorys: [],
catelogPath: [],
dataForm: {
attrGroupId: 0,
attrGroupName: “”,
sort: “”,
descript: “”,
icon: “”,
catelogId: 0
},
dataRule: {
attrGroupName: [
{ required: true, message: “组名不能为空”, trigger: “blur” }
],
sort: [{ required: true, message: “排序不能为空”, trigger: “blur” }],
descript: [
{ required: true, message: “描述不能为空”, trigger: “blur” }
],
icon: [{ required: true, message: “组图标不能为空”, trigger: “blur” }],
catelogId: [
{ required: true, message: “所属分类id不能为空”, trigger: “blur” }
]
}
};
},
components:{CategoryCascader},
methods: {
dialogClose(){
this.catelogPath = [];
},
getCategorys(){
this.KaTeX parse error: Expected '}', got 'EOF' at end of input: …ation">.</span>http.adornUrl("/product/category/list/tree"),
method: “get”
}).then(({ data }) => {
this.categorys = data.data;
});
},
init(id) {
this.dataForm.attrGroupId = id || 0;
this.visible = true;
this.KaTeX parse error: Expected 'EOF', got '&' at position 167: …ken operator">=&̲gt;</span> <spa…refs[“dataForm”].resetFields();
if (this.dataForm.attrGroupId) {
this.KaTeX parse error: Expected '}', got 'EOF' at end of input: …ation">.</span>http.adornUrl(
/product/attrgroup/info/</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span><span class="token keyword">this</span><span class="token punctuation">.</span>dataForm<span class="token punctuation">.</span>attrGroupId<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">
),
method: “get”,
params: this.KaTeX parse error: Expected 'EOF', got '}' at position 215: …n punctuation">}̲</span><span cl…refs[“dataForm”].validate(valid => {
if (valid) {
this.KaTeX parse error: Expected '}', got 'EOF' at end of input: …ation">.</span>http.adornUrl(
/product/attrgroup/</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span> <span class="token operator">!</span><span class="token keyword">this</span><span class="token punctuation">.</span>dataForm<span class="token punctuation">.</span>attrGroupId <span class="token operator">?</span> <span class="token string">"save"</span> <span class="token punctuation">:</span> <span class="token string">"update"</span> <span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">
),
method: “post”,
data: this.KaTeX parse error: Expected 'EOF', got '}' at position 1993: …n punctuation">}̲</span><span cl…message({
message: “操作成功”,
type: “success”,
duration: 1500,
onClose: () => {
this.visible = false;
this.KaTeX parse error: Expected 'EOF', got '}' at position 232: …n punctuation">}̲</span> …message.error(data.msg);
}
});
}
});
}
},
created(){
this.getCategorys();
}
};
</script>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
src\views\modules\common\category-cascader.vue
<template>
<!--
使用说明:
1)、引入category-cascader.vue
2)、语法:<category-cascader :catelogPath.sync="catelogPath"></category-cascader>
解释:
catelogPath:指定的值是cascader初始化需要显示的值,应该和父组件的catelogPath绑定;
由于有sync修饰符,所以cascader路径变化以后自动会修改父的catelogPath,这是结合子组件this.$emit("update:catelogPath",v);做的
-->
<div>
<el-cascader
filterable
clearable
placeholder="试试搜索:手机"
v-model="paths"
:options="categorys"
:props="setting"
></el-cascader>
</div>
</template>
<script>
//这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
//例如:import 《组件名称》 from ‘《组件路径》’;
export default {
//import引入的组件需要注入到对象中才能使用
components: {},
//接受父组件传来的值
props: {
catelogPath: {
type: Array,
default(){
return [];
}
}
},
data() {
//这里存放数据
return {
setting: {
value: “catId”,
label: “name”,
children: “children”
},
categorys: [],
paths: this.catelogPath
};
},
watch:{
catelogPath(v){
this.paths = this.catelogPath;
},
paths(v){
this.KaTeX parse error: Expected 'EOF', got '}' at position 705: …n punctuation">}̲</span> <span…http({
url: this.$http.adornUrl("/product/category/list/tree"),
method: “get”
}).then(({ data }) => {
this.categorys = data.data;
});
}
},
//生命周期 - 创建完成(可以访问当前this实例)
created() {
this.getCategorys();
}
};
</script>
<style scoped>
</style>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
使用子组件
修改分组
回显无法选择三级分类
因为开始返回数据虽然children为空还是返回了,vue还是会渲染
解决:在实体体类加注解JsonInclude 表示为空则不返回
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@TableField(exist = false)
private List<CategoryEntity> children;
- 1
- 2
- 3
效果:
新增和修改自动生成的controller无需修改…
Mybatis-Plus分页插件
创建建Mybatis-Plus配置类,引入分页插件,设置参数。
/**
* @program: MyMall
* @description: Mybatis-plus分页插件配置
* @author: DAIHAO
* @created: 2020/05/10 20:54
*/
@EnableTransactionManagement
@Configuration
@MapperScan("com.daihao.mall.product.dao")
public class MybatisPlusConfig {
@Bean
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
// 设置请求的页面大于最大页后操作, true调回到首页,false 继续请求 默认false
paginationInterceptor.setOverflow(true);
// 设置最大单页限制数量,默认 500 条,-1 不受限制
paginationInterceptor.setLimit(1000);
// 开启 count 的 join 优化,只针对部分 left join
paginationInterceptor.setCountSqlParser(new JsqlParserCountOptimize(true));
return paginationInterceptor;
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
品牌分类管理
效果
表结构
设计冗余字段-品牌字段、分类字段:尽量避免联表操作
CREATE TABLE `pms_category_brand_relation` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`brand_id` bigint(20) DEFAULT NULL COMMENT '品牌id',
`catelog_id` bigint(20) DEFAULT NULL COMMENT '分类id',
`brand_name` varchar(255) DEFAULT NULL,
`catelog_name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COMMENT='品牌分类关联';
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
查询
/**
* 获取当前品牌关联的所有分类列表
*/
@GetMapping(value = "/catelog/list")
public R list(@RequestParam("brandId") Long brandId) {
List<CategoryBrandRelationEntity> data = categoryBrandRelationService.list(
new QueryWrapper<CategoryBrandRelationEntity>().eq("brand_id", brandId)
);
return R.ok().put("data", data);
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
保存
/** * 保存 */ @RequestMapping("/save") public R save(@RequestBody CategoryBrandRelationEntity categoryBrandRelation) { categoryBrandRelationService.saveDetail(categoryBrandRelation);
<span class="token keyword">return</span> R<span class="token punctuation">.</span><span class="token function">ok</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
saveDetail()
保存应该通过关联关系去品牌和分类表中查询数据保存到品牌关联表中
/** * 保存关联关系 * * @param categoryBrandRelation */ @Override public void saveDetail(CategoryBrandRelationEntity categoryBrandRelation) { Long brandId = categoryBrandRelation.getBrandId(); Long catelogId = categoryBrandRelation.getCatelogId(); //1、查询详细名字 BrandEntity brandEntity = brandDao.selectById(brandId); CategoryEntity categoryEntity = categoryDao.selectById(catelogId);
<span class="token comment">//设置关联关系 品牌名字 分类名字</span> categoryBrandRelation<span class="token punctuation">.</span><span class="token function">setBrandName</span><span class="token punctuation">(</span>brandEntity<span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> categoryBrandRelation<span class="token punctuation">.</span><span class="token function">setCatelogName</span><span class="token punctuation">(</span>categoryEntity<span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">save</span><span class="token punctuation">(</span>categoryBrandRelation<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
级联更新
因为品牌关联表中设计了冗余字段,所以当品牌和分类修改时也应该修改品牌关联表中品牌和分类数据
品牌修改
/** * 修改 */ @RequestMapping("/update") public R updateDetail(@RequestBody BrandEntity brand) { brandService.updateDetail(brand);
<span class="token keyword">return</span> R<span class="token punctuation">.</span><span class="token function">ok</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
updateDetail()
@Override
public void updateDetail(BrandEntity brand) {
//修改品牌数据保证冗余字段的数据一致
this.updateById(brand);
if (StringUtils.isNotEmpty(brand.getName())) {
//同步更新其他光联表中的数据
categoryBrandRelationService.updateBrand(brand.getBrandId(), brand.getName());
//TODO 更新其他关联
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
updateBrand()
/**
* 品牌名修改改时更新关联关系表中品牌数据
*
* @param brandId
* @param name
*/
@Override
public void updateBrand(Long brandId, String name) {
CategoryBrandRelationEntity relationEntity = new CategoryBrandRelationEntity();
relationEntity.setBrandId(brandId);
relationEntity.setBrandName(name);
this.update(relationEntity, new UpdateWrapper<CategoryBrandRelationEntity>().eq("brand_id", brandId));
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
分类修改
/** * 修改 */ @RequestMapping("/update") public R update(@RequestBody CategoryEntity category) { categoryService.updateCascade(category);
<span class="token keyword">return</span> R<span class="token punctuation">.</span><span class="token function">ok</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
updateCascade()
/**
* 级联更新所有关联的数据
*
* @param category
*/
@Transactional
@Override
public void updateCascade(CategoryEntity category) {
this.updateById(category);
//
categoryBrandRelationService.updateCategory(category.getCatId(), category.getName());
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
updateCategory()
@Override
public void updateCategory(Long catId, String name) {
this.baseMapper.updateCategory(catId, name);
}
- 1
- 2
- 3
- 4
CategoryBrandRelationDao.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace=“com.daihao.mall.product.dao.CategoryBrandRelationDao”>
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type=“com.daihao.mall.product.entity.CategoryBrandRelationEntity” id=“categoryBrandRelationMap”>
<result property=“id” column=“id”/>
<result property=“brandId” column=“brand_id”/>
<result property=“catelogId” column=“catelog_id”/>
<result property=“brandName” column=“brand_name”/>
<result property=“catelogName” column=“catelog_name”/>
</resultMap>
<update id=“updateCategory”>
update pms_category_brand_relation SET catelog_name = #{name} WHERE catelog_id = #{catId}
</update>
</mapper>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
平台属性-规格参数新增与VO
Object划分
1.PO(persistant object)持久对象
PO就是对应数据库中某个表中的一条记录,多个记录可以用PO的集合。PO中应该不包含任何对数据库的操作。
2.Do (Domain Object)领域对象
就是从现实世界中抽象出来的有形或无形的业务实体。
3.To(Transfer Object) ,数据传输对象
不同的应用程序之间传输的对象
4.DTO (Data Transfer Object)数据传输对象
这个概念来源于12EE的设计模式,原来的目的是为了EIB的分布式应用提供粗粒度的数据实体,以减少分布式调用的次数,从而提高分布式调用的性能和降低网络负载,但在这里,泛指用于展示层与服务层之间的数据传输对象。
5.Vo(value object)值对象
通常用于业务层之间的数据传递,和P0一样也是仅仅包含数据而已。但应是抽象出的业务对象,可以和表对应,也可以不,这根据业务的需要。用new关键字创建,由GC回收的。
View object:视图对象:
接受页面传递来的数据,封装对象
将业务处理完成的对象,封装成页面要用的数据
6.BO(business object)业务对象
从业务模型的角度看,见UML元件领域模型中的领域对象。封装业务逻辑的java对象,通过调用DAO方法,结合PO,VO进行业务操作。business object:业务对象主要作用是把业务逻辑封装为一个对象。这个对象可以包括一个或多个其它的对象。比如一个简历,有教育经历、工作经历、社会关系等等。我们可以把教育经历对应一个Po ,工作经历对应一个PO ,社会关系对应一个PO。建立一个对应简历的BO对象处理简历,每个BO包含这些PO。这样处理业务逻辑时,我们就可以针对B0去处理
7.POJO(plain ordinary java object)简单无规则java对象
传统意义的java对象。就是说在一些Object/Relation Mapping工具中,能够做到维护数据库表记录的persisent object完全是一个符合Java Bean规范的纯Java对象,没有增加别的属性和方法。我的理解就是最基本的java Bean ,只有属性字段及setter和getter方法。POJO是DO/DTO/BO/VO的统称。
8.DAO(data access object)数据访问对象
是一个sun的一个标准j2ee设计模式, 这个模式中有个接口就是DAO ,它负持久层的操作。为业务层提供接口。此对象用于访问数据库。通常和PO结合使用, DAO中包含了各种数据库的操作方法。通过它的方法,结合PO对数据库进行相关的操作。夹在业务逻辑与数据库资源中间。配合vo,提供数据库的CRUD操作
表结构
CREATE TABLE `pms_attr` (
`attr_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '属性id',
`attr_name` char(30) DEFAULT NULL COMMENT '属性名',
`search_type` tinyint(4) DEFAULT NULL COMMENT '是否需要检索[0-不需要,1-需要]',
`icon` varchar(255) DEFAULT NULL COMMENT '属性图标',
`value_select` char(255) DEFAULT NULL COMMENT '可选值列表[用逗号分隔]',
`attr_type` tinyint(4) DEFAULT NULL COMMENT '属性类型[0-销售属性,1-基本属性,2-既是销售属性又是基本属性]',
`enable` bigint(20) DEFAULT NULL COMMENT '启用状态[0 - 禁用,1 - 启用]',
`catelog_id` bigint(20) DEFAULT NULL COMMENT '所属分类',
`show_desc` tinyint(4) DEFAULT NULL COMMENT '快速展示【是否展示在介绍上;0-否 1-是】,在sku中仍然可以调整',
PRIMARY KEY (`attr_id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COMMENT='商品属性';
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
CREATE TABLE `pms_attr_group` (
`attr_group_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '分组id',
`attr_group_name` char(20) DEFAULT NULL COMMENT '组名',
`sort` int(11) DEFAULT NULL COMMENT '排序',
`descript` varchar(255) DEFAULT NULL COMMENT '描述',
`icon` varchar(255) DEFAULT NULL COMMENT '组图标',
`catelog_id` bigint(20) DEFAULT NULL COMMENT '所属分类id',
PRIMARY KEY (`attr_group_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COMMENT='属性分组';
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
CREATE TABLE `pms_attr_attrgroup_relation` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`attr_id` bigint(20) DEFAULT NULL COMMENT '属性id',
`attr_group_id` bigint(20) DEFAULT NULL COMMENT '属性分组id',
`attr_sort` int(11) DEFAULT NULL COMMENT '属性组内排序',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COMMENT='属性&属性分组关联';
- 1
- 2
- 3
- 4
- 5
- 6
- 7
效果
crud代码自行查找源码
销售属性-规格参数新增与VO
效果
平台属性和销售属性的查询可通用一个查询方法:通过请求url不同来分别查询不同
QueryWrapper<AttrEntity> queryWrapper = new QueryWrapper<AttrEntity>().eq("attr_type", "base".equalsIgnoreCase(type) ? ProductConstant.AttrEnum.ATTR_TYPE_BASE.getCode() : ProductConstant.AttrEnum.ATTR_TYPE_SALE.getCode());
- 1
</div>
<link href="https://csdnimg.cn/release/phoenix/mdeditor/markdown_views-60ecaf1f42.css" rel="stylesheet">
</div>