parent
3858e21e39
commit
b5eb19d4ee
|
|
@ -0,0 +1,45 @@
|
|||
import request from '@/utils/request'
|
||||
|
||||
// 获取品牌分组分页数据
|
||||
export function getAttrGroupList(data) {
|
||||
return request({
|
||||
url: '/mall-product/product/attrgroup/list/'+data.catelogId,
|
||||
method: 'get',
|
||||
params:data
|
||||
})
|
||||
}
|
||||
|
||||
//获取具体品牌分组数据
|
||||
export function getAttrGroup(data) {
|
||||
return request({
|
||||
url: `/mall-product/product/attrgroup/info/${data}`,
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
// 保存品牌分组数据
|
||||
export function addAttrGroup(data) {
|
||||
return request({
|
||||
url: `/mall-product/product/attrgroup/save`,
|
||||
method: 'post',
|
||||
data:data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改品牌分组数据
|
||||
export function editAttrGroup(data) {
|
||||
return request({
|
||||
url: `/mall-product/product/attrgroup/update`,
|
||||
method: 'put',
|
||||
data:data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除品牌分组数据
|
||||
export function delAttrGroup(ids) {
|
||||
return request({
|
||||
url: '/mall-product/product/attrgroup/delete',
|
||||
method: 'delete',
|
||||
data:ids
|
||||
})
|
||||
}
|
||||
|
|
@ -45,7 +45,6 @@ export default class SocketService {
|
|||
|
||||
// 连接成功的事件
|
||||
this.ws.onopen = () => {
|
||||
console.log("连接服务端成功了");
|
||||
this.connected = true;
|
||||
// 重置重新连接的次数
|
||||
this.connectRetryCount = 0;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,73 @@
|
|||
<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>
|
||||
|
||||
import {getMenus} from "@/api/mall/product/category";
|
||||
|
||||
export default {
|
||||
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.$emit("update:catelogPath",v);
|
||||
//还可以使用pubsub-js进行传值
|
||||
// this.PubSub.publish("catPath",v);
|
||||
}
|
||||
},
|
||||
//方法集合
|
||||
methods: {
|
||||
getCategorys() {
|
||||
getMenus().then(res =>{
|
||||
this.categorys =res.page
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
created() {
|
||||
this.getCategorys();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
</style>
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
<template>
|
||||
<el-tree
|
||||
:data="menus"
|
||||
:props="defaultProps"
|
||||
@node-click="nodeClick"
|
||||
node-key="catId"
|
||||
ref="menuTree">
|
||||
</el-tree>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {getMenus} from "@/api/mall/product/category";
|
||||
|
||||
export default {
|
||||
name: "category",
|
||||
|
||||
data() {
|
||||
return {
|
||||
menus: [],
|
||||
expandedKey: [],
|
||||
defaultProps: {
|
||||
children: "children",
|
||||
label: "name"
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
created() {
|
||||
this.getMenus()
|
||||
},
|
||||
|
||||
methods:{
|
||||
getMenus() {
|
||||
this.$modal.loading("请稍候...");
|
||||
getMenus().then(res => {
|
||||
this.$modal.closeLoading()
|
||||
this.menus = res.page;
|
||||
})
|
||||
},
|
||||
|
||||
nodeClick(data,node,component) {
|
||||
//向父组件发送事件
|
||||
this.$emit("tree-node-click",data,node,component)
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
|
|
@ -0,0 +1,191 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="6">
|
||||
<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-group>
|
||||
<el-button @click="getDataList()">查询</el-button>
|
||||
<el-button type="success" @click="getAllDataList()">查询全部</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="addOrUpdateHandle()"
|
||||
>新增
|
||||
</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
@click="deleteHandle()"
|
||||
:disabled="dataListSelections.length <= 0"
|
||||
>批量删除
|
||||
</el-button>
|
||||
</el-button-group>
|
||||
|
||||
</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="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>
|
||||
|
||||
<pagination
|
||||
v-show="totalPage>0"
|
||||
:total="totalPage"
|
||||
:page.sync="pageIndex"
|
||||
:limit.sync="pageSize"
|
||||
@pagination="getDataList"
|
||||
/>
|
||||
<!-- 弹窗, 新增 / 修改 -->
|
||||
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
|
||||
|
||||
<!-- 修改关联关系 -->
|
||||
<!-- <relation-update v-if="relationVisible" ref="relationUpdate" @refreshData="getDataList"></relation-update>-->
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
/**
|
||||
* 父子组件传递数据
|
||||
* 1)、子组件给父组件传递数据,事件机制;
|
||||
* 子组件给父组件发送一个事件,携带上数据。
|
||||
* // this.$emit("事件名",携带的数据...)
|
||||
*/
|
||||
import Category from '../../../components/mall/category'
|
||||
|
||||
import {getAttrGroupList, delAttrGroup} from "@/api/mall/product/attr-group";
|
||||
|
||||
import AddOrUpdate from "./attrgroup-add-or-update";
|
||||
// import RelationUpdate from "./attr-group-relation";
|
||||
|
||||
export default {
|
||||
components: {Category, AddOrUpdate, /*RelationUpdate*/},
|
||||
props: {},
|
||||
data() {
|
||||
return {
|
||||
catId: 0,
|
||||
dataForm: {
|
||||
key: ""
|
||||
},
|
||||
dataList: [],
|
||||
pageIndex: 1,
|
||||
pageSize: 10,
|
||||
totalPage: 0,
|
||||
dataListLoading: false,
|
||||
dataListSelections: [],
|
||||
addOrUpdateVisible: false,
|
||||
relationVisible: false
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getDataList();
|
||||
},
|
||||
methods: {
|
||||
//处理分组与属性的关联
|
||||
relationHandle(groupId) {
|
||||
this.relationVisible = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.relationUpdate.init(groupId);
|
||||
});
|
||||
},
|
||||
|
||||
//感知树节点被点击
|
||||
treenodeclick(data, node, component) {
|
||||
if (node.level === 3) {
|
||||
this.catId = data.catId;
|
||||
this.getDataList(); //重新查询
|
||||
}
|
||||
},
|
||||
getAllDataList() {
|
||||
this.catId = 0;
|
||||
this.getDataList();
|
||||
},
|
||||
// 获取数据列表
|
||||
getDataList() {
|
||||
this.dataListLoading = true;
|
||||
|
||||
let params = {
|
||||
page: this.pageIndex,
|
||||
limit: this.pageSize,
|
||||
key: this.dataForm.key,
|
||||
catelogId: this.catId,
|
||||
}
|
||||
getAttrGroupList(params).then(res => {
|
||||
this.dataListLoading = false;
|
||||
this.dataList = res.page.list
|
||||
})
|
||||
},
|
||||
|
||||
// 多选
|
||||
selectionChangeHandle(val) {
|
||||
this.dataListSelections = val;
|
||||
},
|
||||
// 新增 / 修改
|
||||
addOrUpdateHandle(id) {
|
||||
this.addOrUpdateVisible = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.addOrUpdate.init(id);
|
||||
});
|
||||
},
|
||||
// 删除
|
||||
deleteHandle(id) {
|
||||
var ids = id ? [id] : this.dataListSelections.map(item => {
|
||||
return item.attrGroupId;
|
||||
});
|
||||
this.$confirm(
|
||||
`确定对[id=${ids.join(",")}]进行[${id ? "删除" : "批量删除"}]操作?`,
|
||||
"提示",
|
||||
{
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}
|
||||
).then(() => {
|
||||
delAttrGroup(ids).then(res => {
|
||||
this.$modal.notifySuccess("删除成功");
|
||||
this.getDataList();
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
</style>
|
||||
|
|
@ -0,0 +1,134 @@
|
|||
<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">
|
||||
<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 '../../../components/mall/category-cascader'
|
||||
import {getMenus} from "@/api/mall/product/category";
|
||||
|
||||
import {addAttrGroup, getAttrGroup} from "@/api/mall/product/attr-group";
|
||||
|
||||
export default {
|
||||
name: "attrgroup-add-or-update",
|
||||
|
||||
components: {CategoryCascader},
|
||||
|
||||
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"}
|
||||
]
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
dialogClose() {
|
||||
this.catelogPath = [];
|
||||
},
|
||||
|
||||
|
||||
init(id) {
|
||||
this.dataForm.attrGroupId = id;
|
||||
this.visible = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs["dataForm"].resetFields();
|
||||
if (this.dataForm.attrGroupId) {
|
||||
getAttrGroup(this.dataForm.attrGroupId).then(res => {
|
||||
this.dataForm = res.attrGroup
|
||||
//查出catelogId的完整路径
|
||||
this.catelogPath = res.attrGroup.catelogPath;
|
||||
})
|
||||
}
|
||||
});
|
||||
},
|
||||
// 表单提交
|
||||
dataFormSubmit() {
|
||||
this.$refs["dataForm"].validate(valid => {
|
||||
if (valid) {
|
||||
let data = {
|
||||
attrGroupId: this.dataForm.attrGroupId || undefined,
|
||||
attrGroupName: this.dataForm.attrGroupName,
|
||||
sort: this.dataForm.sort,
|
||||
descript: this.dataForm.descript,
|
||||
icon: this.dataForm.icon,
|
||||
catelogId: this.catelogPath[this.catelogPath.length - 1]
|
||||
}
|
||||
if (!this.dataForm.attrGroupId) {
|
||||
addAttrGroup(data).then(res => {
|
||||
this.$modal.notifySuccess("添加成功");
|
||||
this.visible = false;
|
||||
this.$emit("refreshDataList");
|
||||
})
|
||||
} else {
|
||||
editAttrGroup(data).then(res => {
|
||||
this.$modal.notifySuccess("修改成功");
|
||||
this.visible = false;
|
||||
this.$emit("refreshDataList");
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
};
|
||||
</script>
|
||||
|
|
@ -31,13 +31,13 @@
|
|||
style="width: 100%;"
|
||||
>
|
||||
<el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
|
||||
<el-table-column prop="name" header-align="center" align="center" label="品牌名"></el-table-column>
|
||||
<el-table-column prop="logo" header-align="center" align="center" label="品牌logo">
|
||||
<el-table-column prop="name" header-align="center" align="center" label="品牌名" :show-overflow-tooltip="true"></el-table-column>
|
||||
<el-table-column prop="logo" header-align="center" align="center" label="品牌logo" :show-overflow-tooltip="true">
|
||||
<template slot-scope="scope">
|
||||
<img :src="scope.row.logo" style="width: 100px; height: 80px" alt=""/>
|
||||
<img :src="scope.row.logo" style="width: 40px; height: 30px" alt=""/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="descript" header-align="center" align="center" label="介绍"></el-table-column>
|
||||
<el-table-column prop="descript" header-align="center" align="center" label="介绍" :show-overflow-tooltip="true"></el-table-column>
|
||||
<el-table-column prop="showStatus" header-align="center" align="center" label="显示状态">
|
||||
<template slot-scope="scope">
|
||||
<el-switch
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
<el-button type="text" icon="el-icon-edit" size="mini" @click="edit(data)">修改</el-button>
|
||||
<el-divider direction="vertical"></el-divider>
|
||||
<el-button
|
||||
v-if="node.childNodes.length==0"
|
||||
v-if="node.childNodes.length===0"
|
||||
type="text"
|
||||
size="mini"
|
||||
icon="el-icon-delete"
|
||||
|
|
@ -50,9 +50,9 @@
|
|||
:visible.sync="dialogVisible"
|
||||
width="30%"
|
||||
:close-on-click-modal="false">
|
||||
<el-form :model="category">
|
||||
<el-form-item label="分类名称">
|
||||
<el-input v-model="category.name" autocomplete="off"></el-input>
|
||||
<el-form :model="category" :rules="dataRule" ref="category">
|
||||
<el-form-item label="分类名称" prop="name">
|
||||
<el-input v-model="category.name" autocomplete="off" maxlength="50"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="菜单图标" prop="icon">
|
||||
<el-popover
|
||||
|
|
@ -74,8 +74,8 @@
|
|||
</el-input>
|
||||
</el-popover>
|
||||
</el-form-item>
|
||||
<el-form-item label="计量单位">
|
||||
<el-input v-model="category.productUnit" autocomplete="off"></el-input>
|
||||
<el-form-item label="计量单位" prop="productUnit">
|
||||
<el-input v-model="category.productUnit" autocomplete="off" maxlength="50"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
|
|
@ -120,6 +120,16 @@ export default {
|
|||
defaultProps: {
|
||||
children: "children",
|
||||
label: "name"
|
||||
},
|
||||
|
||||
dataRule: {
|
||||
name: [
|
||||
{ required: true, message: "分类名称不能为空", trigger: "blur" },
|
||||
{ min: 1, max: 50, message: '长度在 1 到 50 个字符', trigger: 'blur' }
|
||||
],
|
||||
productUnit: [
|
||||
{ min: 1, max: 50, message: '长度在 1 到 50 个字符', trigger: 'blur' }
|
||||
],
|
||||
}
|
||||
};
|
||||
},
|
||||
|
|
@ -284,12 +294,16 @@ export default {
|
|||
},
|
||||
|
||||
submitData() {
|
||||
if (this.dialogType === "add") {
|
||||
this.addCategory();
|
||||
}
|
||||
if (this.dialogType === "edit") {
|
||||
this.editCategory();
|
||||
}
|
||||
this.$refs["category"].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.dialogType === "add") {
|
||||
this.addCategory();
|
||||
}
|
||||
if (this.dialogType === "edit") {
|
||||
this.editCategory();
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
//修改三级分类数据
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
package com.xjs.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 该注解加在属性上,如果属性的值为空,则该属性不进行序列化返回
|
||||
* @author xiejs
|
||||
* @since 2022-03-16
|
||||
*/
|
||||
@Target({ElementType.FIELD,ElementType.PARAMETER})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface CustomizeJsonExclude {
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.xjs.config;
|
||||
|
||||
import com.alibaba.fastjson.serializer.PropertyFilter;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.alibaba.fastjson.serializer.ValueFilter;
|
||||
import com.alibaba.fastjson.support.config.FastJsonConfig;
|
||||
|
|
@ -11,7 +12,6 @@ import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilde
|
|||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
|
@ -42,24 +42,40 @@ public class JsonConfig {
|
|||
list.add(SerializerFeature.WriteEnumUsingToString);
|
||||
|
||||
fastJsonConfig.setSerializerFeatures(list.toArray(new SerializerFeature[list.size()]));
|
||||
fastConverter.setFastJsonConfig(fastJsonConfig);
|
||||
HttpMessageConverter<?> converter = fastConverter;
|
||||
|
||||
|
||||
//解决远程调用 ---(Content-Type cannot contain wildcard type '*')报错
|
||||
fastConverter.setSupportedMediaTypes(Arrays.asList(MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON_UTF8));
|
||||
|
||||
|
||||
//解决mp雪花算法前端精度丢失
|
||||
fastJsonConfig.setSerializeFilters(new ValueFilter() {
|
||||
ValueFilter valueFilter = new ValueFilter() {
|
||||
@Override
|
||||
public Object process(Object object, String name, Object value) {
|
||||
if ((StringUtils.endsWith(name, "Id") || StringUtils.equals(name,"id")) && value != null
|
||||
if ((StringUtils.endsWith(name, "Id") || StringUtils.equals(name, "id")) && value != null
|
||||
&& value.getClass() == Long.class) {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
});
|
||||
return new HttpMessageConverters(converter);
|
||||
};
|
||||
|
||||
//忽略某些空值
|
||||
PropertyFilter filter = (source, key, value) -> {
|
||||
if (value == null) {
|
||||
return false;
|
||||
}
|
||||
if(value instanceof List && ((List) value).size() == 0){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
fastJsonConfig.setSerializeFilters(valueFilter,filter);
|
||||
|
||||
fastConverter.setFastJsonConfig(fastJsonConfig);
|
||||
|
||||
return new HttpMessageConverters(fastConverter);
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
|
|||
|
|
@ -1,19 +1,15 @@
|
|||
package com.xjs.mall.product.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.xjs.mall.product.entity.AttrGroupEntity;
|
||||
import com.xjs.mall.product.service.AttrGroupService;
|
||||
import com.xjs.mall.product.service.CategoryService;
|
||||
import com.xjs.utils.PageUtils;
|
||||
import com.xjs.utils.R;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
|
||||
|
|
@ -22,20 +18,23 @@ import com.xjs.utils.R;
|
|||
*
|
||||
* @author xiejs
|
||||
* @email 1294405880@qq.com
|
||||
* @date 2022-03-15 10:16:53
|
||||
* @since 2022-03-15 10:16:53
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("product/attrgroup")
|
||||
public class AttrGroupController {
|
||||
@Autowired
|
||||
private AttrGroupService attrGroupService;
|
||||
@Autowired
|
||||
private CategoryService categoryService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = attrGroupService.queryPage(params);
|
||||
@RequestMapping("/list/{catelogId}")
|
||||
public R list(@RequestParam Map<String, Object> params,Long catelogId){
|
||||
|
||||
PageUtils page =attrGroupService.queryPage(params,catelogId);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
|
@ -48,6 +47,9 @@ public class AttrGroupController {
|
|||
public R info(@PathVariable("attrGroupId") Long attrGroupId){
|
||||
AttrGroupEntity attrGroup = attrGroupService.getById(attrGroupId);
|
||||
|
||||
Long[] path=categoryService.finCatelogPath(attrGroup.getCatelogId());
|
||||
attrGroup.setCatelogPath(path);
|
||||
|
||||
return R.ok().put("attrGroup", attrGroup);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,17 @@
|
|||
package com.xjs.mall.product.controller;
|
||||
|
||||
import com.ruoyi.common.log.annotation.Log;
|
||||
import com.ruoyi.common.log.enums.BusinessType;
|
||||
import com.xjs.mall.product.entity.BrandEntity;
|
||||
import com.xjs.mall.product.service.BrandService;
|
||||
import com.xjs.utils.PageUtils;
|
||||
import com.xjs.utils.R;
|
||||
import com.xjs.validation.group.AddGroup;
|
||||
import com.xjs.validation.group.SelectGroup;
|
||||
import com.xjs.validation.group.UpdateGroup;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
|
@ -17,10 +24,11 @@ import java.util.Map;
|
|||
*
|
||||
* @author xiejs
|
||||
* @email 1294405880@qq.com
|
||||
* @date 2022-03-15 10:16:53
|
||||
* @since 2022-03-15 10:16:53
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("product/brand")
|
||||
@Api(tags = "商城-商品-品牌")
|
||||
public class BrandController {
|
||||
@Autowired
|
||||
private BrandService brandService;
|
||||
|
|
@ -29,7 +37,7 @@ public class BrandController {
|
|||
* 列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
public R list(@Validated(SelectGroup.class) @RequestParam Map<String, Object> params){
|
||||
PageUtils page = brandService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
|
|
@ -50,7 +58,8 @@ public class BrandController {
|
|||
* 保存
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
public R save(@RequestBody BrandEntity brand){
|
||||
@Log(title = "品牌管理", businessType = BusinessType.INSERT)
|
||||
public R save(@Validated(AddGroup.class) @RequestBody BrandEntity brand){
|
||||
brandService.save(brand);
|
||||
|
||||
return R.ok();
|
||||
|
|
@ -60,7 +69,8 @@ public class BrandController {
|
|||
* 修改
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
public R update(@RequestBody BrandEntity brand){
|
||||
@Log(title = "品牌管理", businessType = BusinessType.UPDATE)
|
||||
public R update(@Validated(UpdateGroup.class) @RequestBody BrandEntity brand){
|
||||
brandService.updateById(brand);
|
||||
|
||||
return R.ok();
|
||||
|
|
@ -70,6 +80,7 @@ public class BrandController {
|
|||
* 删除
|
||||
*/
|
||||
@DeleteMapping("/delete")
|
||||
@Log(title = "品牌管理", businessType = BusinessType.DELETE)
|
||||
public R delete(@RequestBody Long[] brandIds){
|
||||
brandService.removeByIds(Arrays.asList(brandIds));
|
||||
|
||||
|
|
|
|||
|
|
@ -5,9 +5,12 @@ import com.ruoyi.common.log.enums.BusinessType;
|
|||
import com.xjs.mall.product.entity.CategoryEntity;
|
||||
import com.xjs.mall.product.service.CategoryService;
|
||||
import com.xjs.utils.R;
|
||||
import com.xjs.validation.group.AddGroup;
|
||||
import com.xjs.validation.group.UpdateGroup;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
|
@ -58,7 +61,7 @@ public class CategoryController {
|
|||
@PostMapping("/save")
|
||||
@ApiOperation("保存")
|
||||
@Log(title = "商品分类", businessType = BusinessType.INSERT)
|
||||
public R save(@RequestBody CategoryEntity category) {
|
||||
public R save(@Validated(AddGroup.class) @RequestBody CategoryEntity category) {
|
||||
categoryService.save(category);
|
||||
|
||||
return R.ok();
|
||||
|
|
@ -70,7 +73,7 @@ public class CategoryController {
|
|||
@PutMapping("/update")
|
||||
@ApiOperation("修改")
|
||||
@Log(title = "商品分类", businessType = BusinessType.UPDATE)
|
||||
public R update(@RequestBody CategoryEntity category) {
|
||||
public R update(@Validated(UpdateGroup.class) @RequestBody CategoryEntity category) {
|
||||
categoryService.updateById(category);
|
||||
|
||||
return R.ok();
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
package com.xjs.mall.product.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 属性分组
|
||||
|
|
@ -45,4 +45,10 @@ public class AttrGroupEntity implements Serializable {
|
|||
*/
|
||||
private Long catelogId;
|
||||
|
||||
/**
|
||||
* 分类id完整路径
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private Long[] catelogPath;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,12 @@ package com.xjs.mall.product.entity;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.xjs.validation.group.AddGroup;
|
||||
import com.xjs.validation.group.SelectGroup;
|
||||
import com.xjs.validation.group.UpdateGroup;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
|
|
@ -27,14 +31,19 @@ public class BrandEntity implements Serializable {
|
|||
/**
|
||||
* 品牌名
|
||||
*/
|
||||
@NotBlank(message = "品牌名不能为空", groups = {UpdateGroup.class, AddGroup.class})
|
||||
@Size(max = 50, message = "请控制品牌名长度在50字符", groups = {UpdateGroup.class, SelectGroup.class,AddGroup.class})
|
||||
private String name;
|
||||
/**
|
||||
* 品牌logo地址
|
||||
*/
|
||||
@NotBlank(message = "品牌logo地址不能为空", groups = {UpdateGroup.class, AddGroup.class})
|
||||
private String logo;
|
||||
/**
|
||||
* 介绍
|
||||
*/
|
||||
@NotBlank(message = "介绍不能为空", groups = {UpdateGroup.class, AddGroup.class})
|
||||
@Size(max = 500, message = "请控制介绍长度在500字符", groups = {UpdateGroup.class, SelectGroup.class,AddGroup.class})
|
||||
private String descript;
|
||||
/**
|
||||
* 显示状态[0-不显示;1-显示]
|
||||
|
|
@ -43,10 +52,15 @@ public class BrandEntity implements Serializable {
|
|||
/**
|
||||
* 检索首字母
|
||||
*/
|
||||
@NotBlank(message = "检索首字母不能为空", groups = {UpdateGroup.class, AddGroup.class})
|
||||
@Size(max = 1, message = "请控制检索首字母在1字符", groups = {UpdateGroup.class, SelectGroup.class,AddGroup.class})
|
||||
@Pattern(regexp = "^[a-zA-Z]$",message = "检索首字母必须是一个字母",groups = {UpdateGroup.class, AddGroup.class})
|
||||
private String firstLetter;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@NotNull(message = "排序不能为空",groups = {UpdateGroup.class, AddGroup.class})
|
||||
@Min(value = 0,message = "排序必须大于等于0",groups = {UpdateGroup.class, AddGroup.class})
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,16 @@
|
|||
package com.xjs.mall.product.entity;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.xjs.validation.group.AddGroup;
|
||||
import com.xjs.validation.group.UpdateGroup;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -29,6 +34,8 @@ public class CategoryEntity implements Serializable {
|
|||
/**
|
||||
* 分类名称
|
||||
*/
|
||||
@NotBlank(message = "分类名称不能为空", groups = {UpdateGroup.class, AddGroup.class})
|
||||
@Size(max = 50, message = "请控制分类名称长度在50字符", groups = {UpdateGroup.class,AddGroup.class})
|
||||
private String name;
|
||||
/**
|
||||
* 父分类id
|
||||
|
|
@ -50,10 +57,12 @@ public class CategoryEntity implements Serializable {
|
|||
/**
|
||||
* 图标地址
|
||||
*/
|
||||
@Size(max = 50, message = "请控制图标地址长度在50字符", groups = {UpdateGroup.class,AddGroup.class})
|
||||
private String icon;
|
||||
/**
|
||||
* 计量单位
|
||||
*/
|
||||
@Size(max = 50, message = "请控制计量单位长度在50字符", groups = {UpdateGroup.class,AddGroup.class})
|
||||
private String productUnit;
|
||||
/**
|
||||
* 商品数量
|
||||
|
|
@ -63,6 +72,7 @@ public class CategoryEntity implements Serializable {
|
|||
/**
|
||||
* 子分类
|
||||
*/
|
||||
@JSONField
|
||||
@TableField(exist = false)
|
||||
private List<CategoryEntity> children;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package com.xjs.mall.product.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xjs.utils.PageUtils;
|
||||
import com.xjs.mall.product.entity.AttrGroupEntity;
|
||||
import com.xjs.utils.PageUtils;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -16,5 +16,20 @@ import java.util.Map;
|
|||
public interface AttrGroupService extends IService<AttrGroupEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 分页
|
||||
* @param params 条件
|
||||
* @param categoryId 类别id
|
||||
* @return pageUtils
|
||||
*/
|
||||
PageUtils queryPage(Map<String, Object> params, Long categoryId);
|
||||
|
||||
/**
|
||||
* 根据分类id查出所有的分组以及这些组里面的属性
|
||||
* @param categoryId 分类id
|
||||
* @return list
|
||||
*/
|
||||
//List<AttrGroupWithAttrsVo> getAttrGroupWithAttrsByCatelogId(Long categoryId);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,5 +29,12 @@ public interface CategoryService extends IService<CategoryEntity> {
|
|||
* @param asList ids
|
||||
*/
|
||||
void removeMenuByIds(List<Long> asList);
|
||||
|
||||
/**
|
||||
* 找到catelogI的完整路径
|
||||
* @param catelogId 分类id
|
||||
* @return long s
|
||||
*/
|
||||
Long[] finCatelogPath(Long catelogId);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,18 @@
|
|||
package com.xjs.mall.product.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.xjs.utils.PageUtils;
|
||||
import com.xjs.utils.Query;
|
||||
|
||||
import com.xjs.mall.product.dao.AttrGroupDao;
|
||||
import com.xjs.mall.product.entity.AttrGroupEntity;
|
||||
import com.xjs.mall.product.service.AttrGroupService;
|
||||
import com.xjs.utils.PageUtils;
|
||||
import com.xjs.utils.Query;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Service("attrGroupService")
|
||||
|
|
@ -20,10 +22,35 @@ public class AttrGroupServiceImpl extends ServiceImpl<AttrGroupDao, AttrGroupEnt
|
|||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<AttrGroupEntity> page = this.page(
|
||||
new Query<AttrGroupEntity>().getPage(params),
|
||||
new QueryWrapper<AttrGroupEntity>()
|
||||
new QueryWrapper<>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params, Long categoryId) {
|
||||
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%)
|
||||
LambdaQueryWrapper<AttrGroupEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
if(!StringUtils.isEmpty(key)){
|
||||
wrapper.and((obj)->{
|
||||
obj.eq(AttrGroupEntity::getAttrGroupId,key).or().like(AttrGroupEntity::getAttrGroupName,key);
|
||||
});
|
||||
}
|
||||
|
||||
if( categoryId == 0){
|
||||
IPage<AttrGroupEntity> page = this.page(new Query<AttrGroupEntity>().getPage(params),
|
||||
wrapper);
|
||||
return new PageUtils(page);
|
||||
}else {
|
||||
wrapper.eq(AttrGroupEntity::getCatelogId,categoryId);
|
||||
IPage<AttrGroupEntity> page = this.page(new Query<AttrGroupEntity>().getPage(params),
|
||||
wrapper);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -11,10 +11,7 @@ import com.xjs.utils.Query;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
|
|
@ -55,6 +52,29 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryDao, CategoryEntity
|
|||
categoryDao.deleteBatchIds(asList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long[] finCatelogPath(Long catelogId) {
|
||||
List<Long> paths = new ArrayList<>();
|
||||
|
||||
List<Long> parentPath = findParentPath(catelogId, paths);
|
||||
|
||||
Collections.reverse(parentPath);
|
||||
|
||||
return parentPath.toArray(new Long[parentPath.size()]);
|
||||
}
|
||||
|
||||
//225,25,2
|
||||
private List<Long> findParentPath(Long catelogId, List<Long> paths) {
|
||||
//1、收集当前节点id
|
||||
paths.add(catelogId);
|
||||
CategoryEntity byId = this.getById(catelogId);
|
||||
if (byId.getParentCid() != 0) {
|
||||
findParentPath(byId.getParentCid(), paths);
|
||||
}
|
||||
return paths;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 递归获取子菜单
|
||||
|
|
|
|||
Loading…
Reference in New Issue