1
This commit is contained in:
parent
02b918182c
commit
74ee7e5eb9
@ -54,34 +54,39 @@ public class BusiCategoryController extends BaseController {
|
||||
|
||||
|
||||
/**
|
||||
* 获取网站栏目详细信息
|
||||
*/
|
||||
* 获取网站栏目信息
|
||||
* @author PQZ
|
||||
* @date 11:54 2025/6/30
|
||||
* @param id id
|
||||
* @return com.ruoyi.common.core.domain.AjaxResult
|
||||
**/
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") String id) {
|
||||
return success(busiCategoryService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增网站栏目
|
||||
*/
|
||||
* 保存网站栏目
|
||||
* @author PQZ
|
||||
* @date 11:54 2025/6/30
|
||||
* @param busiCategory {@link BusiCategory}
|
||||
* @return com.ruoyi.common.core.domain.AjaxResult
|
||||
**/
|
||||
@Log(title = "网站栏目", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody BusiCategory busiCategory) {
|
||||
return toAjax(busiCategoryService.save(busiCategory));
|
||||
return toAjax(busiCategoryService.saveOrUpdate(busiCategory));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改网站栏目
|
||||
*/
|
||||
@Log(title = "网站栏目", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody BusiCategory busiCategory) {
|
||||
return toAjax(busiCategoryService.updateById(busiCategory));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除网站栏目
|
||||
*/
|
||||
* @author PQZ
|
||||
* @date 11:55 2025/6/30
|
||||
* @param ids 删除id
|
||||
* @return com.ruoyi.common.core.domain.AjaxResult
|
||||
**/
|
||||
@Log(title = "网站栏目", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable String[] ids) {
|
||||
|
@ -50,11 +50,11 @@ public class BusiCategory extends DlBaseEntity
|
||||
|
||||
/** 直接下级产品数 */
|
||||
@Excel(name = "直接下级产品数")
|
||||
private Long prodsJunior;
|
||||
private Integer prodsJunior;
|
||||
|
||||
/** 递归产品数 */
|
||||
@Excel(name = "递归产品数")
|
||||
private Long prodsAll;
|
||||
private Integer prodsAll;
|
||||
|
||||
/** 页面title */
|
||||
@Excel(name = "页面title")
|
||||
|
@ -21,4 +21,12 @@ public interface BusiProdNewMapper extends BaseMapper<BusiProdNew>
|
||||
IPage<ProdNewVO> queryListPage(@Param("entity") ProdNewVO entity, Page<BusiProdNew> page);
|
||||
|
||||
Long selectMaxSort(@Param("tenantId")String tenantId);
|
||||
|
||||
/**
|
||||
* 统计分类下产品数量
|
||||
* @author PQZ
|
||||
* @date 14:06 2025/6/30
|
||||
* @return java.util.List<com.ruoyi.busi.vo.ProdNewVO>
|
||||
**/
|
||||
List<ProdNewVO> getCatgAmount();
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.ruoyi.busi.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.busi.domain.BusiCategory;
|
||||
import com.ruoyi.busi.vo.BusiCategoryVO;
|
||||
import com.ruoyi.busi.vo.ProdNewVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -24,4 +25,13 @@ public interface IBusiCategoryService extends IService<BusiCategory> {
|
||||
**/
|
||||
List<BusiCategoryVO> treeCategory(BusiCategory category);
|
||||
|
||||
|
||||
/**
|
||||
* 设置直接产品数、递归产品数
|
||||
* @author PQZ
|
||||
* @date 14:12 2025/6/30
|
||||
**/
|
||||
void setCategoryAmount(List<ProdNewVO> list,String tenantId);
|
||||
|
||||
|
||||
}
|
||||
|
@ -25,4 +25,13 @@ public interface IBusiProdNewService extends IService<BusiProdNew>
|
||||
* @return java.lang.Long
|
||||
**/
|
||||
Long getMaxSort(String tenantId);
|
||||
|
||||
|
||||
/**
|
||||
* 为网站栏目中递归产品数和下级产品数赋值
|
||||
* @author PQZ
|
||||
* @date 14:03 2025/6/30
|
||||
* @return void
|
||||
**/
|
||||
void setAmount(String tenantId);
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.ruoyi.busi.domain.BusiCategory;
|
||||
import com.ruoyi.busi.mapper.BusiCategoryMapper;
|
||||
import com.ruoyi.busi.service.IBusiCategoryService;
|
||||
import com.ruoyi.busi.vo.BusiCategoryVO;
|
||||
import com.ruoyi.busi.vo.ProdNewVO;
|
||||
import com.ruoyi.common.core.domain.DlBaseEntity;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@ -51,6 +52,33 @@ public class BusiCategoryServiceImpl extends ServiceImpl<BusiCategoryMapper, Bus
|
||||
return buildCategoryTree(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置直接产品数、递归产品数
|
||||
*
|
||||
* @author PQZ
|
||||
* @date 14:12 2025/6/30
|
||||
**/
|
||||
@Override
|
||||
public void setCategoryAmount(List<ProdNewVO> list,String tenantId) {
|
||||
Map<String, Integer> idToProdsJunior = new HashMap<>();
|
||||
list.forEach(item -> {
|
||||
idToProdsJunior.put(item.getCatgId(),item.getAmount());
|
||||
});
|
||||
//查询全部栏目
|
||||
LambdaQueryWrapper<BusiCategory> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(DlBaseEntity::getDelFlag,0)
|
||||
.eq(BusiCategory::getTenantId,tenantId);
|
||||
List<BusiCategory> categoryList = list(lambdaQueryWrapper);
|
||||
//遍历赋值
|
||||
categoryList.forEach(item->{
|
||||
if (idToProdsJunior.containsKey(item.getId())) {
|
||||
item.setProdsJunior(idToProdsJunior.get(item.getId()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 生成树结构
|
||||
@ -66,6 +94,8 @@ public class BusiCategoryServiceImpl extends ServiceImpl<BusiCategoryMapper, Bus
|
||||
for (BusiCategory category : list) {
|
||||
BusiCategoryVO vo = new BusiCategoryVO();
|
||||
BeanUtils.copyProperties(category,vo);
|
||||
vo.setValue(category.getId());
|
||||
vo.setLabel(category.getCatgName());
|
||||
idToNodeMap.put(vo.getId(), vo);
|
||||
}
|
||||
List<BusiCategoryVO> roots = new ArrayList<>();
|
||||
|
@ -2,6 +2,7 @@ package com.ruoyi.busi.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.busi.service.IBusiCategoryService;
|
||||
import com.ruoyi.busi.vo.ProdNewVO;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@ -24,6 +25,8 @@ public class BusiProdNewServiceImpl extends ServiceImpl<BusiProdNewMapper,BusiPr
|
||||
{
|
||||
@Autowired
|
||||
private BusiProdNewMapper busiProdNewMapper;
|
||||
@Autowired
|
||||
private IBusiCategoryService categoryService;
|
||||
|
||||
@Override
|
||||
public IPage<ProdNewVO> queryListPage(ProdNewVO pageReqVO, Page<BusiProdNew> page) {
|
||||
@ -50,4 +53,19 @@ public class BusiProdNewServiceImpl extends ServiceImpl<BusiProdNewMapper,BusiPr
|
||||
Long sort = busiProdNewMapper.selectMaxSort(tenantId);
|
||||
return null==sort?1:sort+1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 为网站栏目中递归产品数和下级产品数赋值
|
||||
*
|
||||
* @author PQZ
|
||||
* @date 14:03 2025/6/30
|
||||
**/
|
||||
@Override
|
||||
public void setAmount(String tenantId) {
|
||||
//统计各分类产品数量
|
||||
List<ProdNewVO> list = busiProdNewMapper.getCatgAmount();
|
||||
if (!list.isEmpty()) {
|
||||
categoryService.setCategoryAmount(list,tenantId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,9 @@ import java.util.List;
|
||||
@Data
|
||||
public class BusiCategoryVO extends BusiCategory {
|
||||
|
||||
private String value;
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* 子集
|
||||
*/
|
||||
|
@ -33,6 +33,9 @@ public class ProdNewVO extends BusiProdNew {
|
||||
/** 随机产品数量 */
|
||||
private Integer randomNum;
|
||||
|
||||
/**同分类下产品数量*/
|
||||
private Integer amount;
|
||||
|
||||
/**
|
||||
* 批量传的图片
|
||||
**/
|
||||
|
@ -112,4 +112,15 @@
|
||||
del_flag = '0'
|
||||
AND tenant_id = #{tenantId}
|
||||
</select>
|
||||
<select id="getCatgAmount" resultType="com.ruoyi.busi.vo.ProdNewVO">
|
||||
SELECT
|
||||
catg_id as catgId,
|
||||
COUNT( id ) as amount
|
||||
FROM
|
||||
dl_busi_prod_new
|
||||
WHERE
|
||||
del_flag = 0
|
||||
GROUP BY
|
||||
catg_id
|
||||
</select>
|
||||
</mapper>
|
@ -11,7 +11,7 @@
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="栏目类型" prop="catgType">
|
||||
<el-select v-model="form.catgType" placeholder="请选择通告栏目类型" >
|
||||
<el-select :disabled="form.catgLevel > 1" v-model="form.catgType" placeholder="请选择通告栏目类型" >
|
||||
<el-option
|
||||
v-for="dict in dict.type.category_type"
|
||||
:key="dict.value"
|
||||
@ -28,18 +28,6 @@
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="产品上方内容html" prop="prodUp">
|
||||
<el-input type="textarea" v-model="form.prodUp" placeholder="请输入产品上方内容html" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="产品下方内容html" prop="prodDown">
|
||||
<el-input type="textarea" v-model="form.prodDown" placeholder="请输入产品下方内容html" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
@ -59,8 +47,21 @@
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row v-if="form.catgType == 'cp'" :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="产品上方内容html" prop="prodUp">
|
||||
<el-input type="textarea" v-model="form.prodUp" placeholder="请输入产品上方内容html" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="产品下方内容html" prop="prodDown">
|
||||
<el-input type="textarea" v-model="form.prodDown" placeholder="请输入产品下方内容html" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row>
|
||||
|
||||
<el-row v-if="form.catgType == 'dym' || form.catgType == 'xp'">
|
||||
<el-col>
|
||||
<el-form-item label="内容html" prop="content">
|
||||
<editor v-model="form.content" :min-height="192"/>
|
||||
@ -79,7 +80,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {addCategory} from "@/api/busi/category";
|
||||
import {addCategory,getCategory} from "@/api/busi/category";
|
||||
export default {
|
||||
name: "categoryForm",
|
||||
dicts: ['category_type'],
|
||||
@ -99,8 +100,9 @@ export default {
|
||||
prodDown:"",
|
||||
content:""
|
||||
},
|
||||
id:null,
|
||||
//列表页入参
|
||||
query:{},
|
||||
isChild:false,
|
||||
//表单校验规则
|
||||
rules:{
|
||||
code: [
|
||||
@ -116,19 +118,18 @@ export default {
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.query = this.$route.query
|
||||
if (this.$route.query.id){
|
||||
this.id = this.$route.query.id
|
||||
this.initCategory(this.$route.query.id)
|
||||
} else {
|
||||
this.form = this.$route.query
|
||||
}
|
||||
},
|
||||
|
||||
methods:{
|
||||
|
||||
/**确定按钮*/
|
||||
submitForm(){
|
||||
if (this.query.catgLevel){
|
||||
this.form.catgLevel = this.query.catgLevel
|
||||
}
|
||||
if (this.query.parentId){
|
||||
this.form.parentId = this.query.parentId
|
||||
}
|
||||
addCategory(this.form).then((res) => {
|
||||
if (res.code == 200){
|
||||
this.$modal.msgSuccess("保存成功");
|
||||
@ -137,6 +138,15 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
/**获取网站栏目分类*/
|
||||
initCategory(id){
|
||||
getCategory(id).then((res)=>{
|
||||
if (res.code == 200){
|
||||
this.form = res.data
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**取消按钮*/
|
||||
cancel(){
|
||||
this.reset();
|
||||
@ -148,7 +158,17 @@ export default {
|
||||
|
||||
/**表单重置*/
|
||||
reset(){
|
||||
|
||||
this.form = {
|
||||
catgName:"",
|
||||
catgType:"",
|
||||
sort:"",
|
||||
title:"",
|
||||
keyword:"",
|
||||
description:"",
|
||||
prodUp:"",
|
||||
prodDown:"",
|
||||
content:""
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -52,12 +52,21 @@
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
v-if="scope.row.catgType != 'dym' && scope.row.catgType != 'cp'"
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
icon="el-icon-document-copy"
|
||||
@click="handleChildAdd(scope.row)"
|
||||
v-hasPermi="['busi:category:edit']"
|
||||
>添加子栏目</el-button>
|
||||
<el-button
|
||||
v-if="scope.row.catgType == 'cp'"
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-document-copy"
|
||||
@click="handleChildAdd(scope.row)"
|
||||
v-hasPermi="['busi:category:edit']"
|
||||
>添加产品分类</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
@ -135,12 +144,18 @@ export default {
|
||||
|
||||
/**添加子栏目*/
|
||||
handleChildAdd(row){
|
||||
this.$router.push({path:'/category/categoryForm',query:{catgLevel:row.catgLevel+1,parentId:row.id}})
|
||||
this.$router.push({path:'/category/categoryForm',query:{
|
||||
catgLevel:row.catgLevel+1,
|
||||
parentId:row.id,
|
||||
catgType:row.catgType
|
||||
}})
|
||||
},
|
||||
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
|
||||
this.$router.push({path:'/category/categoryForm',query:{
|
||||
id:row.id,
|
||||
}})
|
||||
},
|
||||
|
||||
/** 删除按钮操作 */
|
||||
|
Loading…
Reference in New Issue
Block a user