提交 c8981712 authored 作者: zgy's avatar zgy

标签管理优化

上级 c412de24
......@@ -106,4 +106,16 @@ public class TbCfLabelController {
return R.ok().put("list", list);
}
/**
* 查询父标签的子类
*
* @return list
*/
@RequestMapping("/queryParentLabels")
@ResponseBody
public R queryParentLabels(@RequestParam(value = "parentId",defaultValue = "0") String parentId) {
List<TbCfLabelEntity> labelList = tbCfLabelService.queryParentLabels(parentId);
return R.ok().put("list", labelList);
}
}
......@@ -2,6 +2,8 @@ package com.platform.dao;
import com.platform.entity.TbCfLabelEntity;
import java.util.List;
/**
* 商品标签Dao
*
......@@ -10,4 +12,10 @@ import com.platform.entity.TbCfLabelEntity;
*/
public interface TbCfLabelDao extends BaseDao<TbCfLabelEntity> {
/**
* 查询所有父标签
*
* @return list
*/
List<TbCfLabelEntity> queryParentLabels(String parentId);
}
......@@ -8,7 +8,7 @@ import java.util.Date;
* 表名 tb_cf_label
*
* @author lipengjun
* @date 2020-03-12 16:20:26
* @date 2020-03-17 10:38:00
*/
public class TbCfLabelEntity implements Serializable {
private static final long serialVersionUID = 1L;
......@@ -17,6 +17,10 @@ public class TbCfLabelEntity implements Serializable {
* 标签ID
*/
private String id;
/**
* 父标签ID,如果没有父标签,则为:0
*/
private String parentId;
/**
* 标签名
*/
......@@ -47,6 +51,19 @@ public class TbCfLabelEntity implements Serializable {
public String getId() {
return id;
}
/**
* 设置:父标签ID,如果没有父标签,则为:0
*/
public void setParentId(String parentId) {
this.parentId = parentId;
}
/**
* 获取:父标签ID,如果没有父标签,则为:0
*/
public String getParentId() {
return parentId;
}
/**
* 设置:标签名
*/
......
......@@ -68,4 +68,11 @@ public interface TbCfLabelService {
* @return 删除条数
*/
int deleteBatch(String[] ids);
/**
* 查询父标签的子类
*
* @return list
*/
List<TbCfLabelEntity> queryParentLabels(String parentId);
}
......@@ -60,4 +60,15 @@ public class TbCfLabelServiceImpl implements TbCfLabelService {
public int deleteBatch(String[] ids) {
return tbCfLabelDao.deleteBatch(ids);
}
/**
* 查询父标签的子类
*
* @return list
*/
@Override
public List<TbCfLabelEntity> queryParentLabels(String parentId) {
return tbCfLabelDao.queryParentLabels(parentId);
}
}
......@@ -5,6 +5,7 @@
<resultMap type="com.platform.entity.TbCfLabelEntity" id="tbCfLabelMap">
<result property="id" column="id"/>
<result property="parentId" column="parent_id"/>
<result property="labelName" column="label_name"/>
<result property="enableFlag" column="enable_flag"/>
<result property="createTime" column="create_time"/>
......@@ -14,6 +15,7 @@
<select id="queryObject" resultType="com.platform.entity.TbCfLabelEntity">
select
`id`,
`parent_id`,
`label_name`,
`enable_flag`,
`create_time`,
......@@ -25,6 +27,7 @@
<select id="queryList" resultType="com.platform.entity.TbCfLabelEntity">
select
`id`,
`parent_id`,
`label_name`,
`enable_flag`,
`create_time`,
......@@ -46,6 +49,17 @@
limit #{offset}, #{limit}
</if>
</select>
<select id="queryParentLabels" resultType="com.platform.entity.TbCfLabelEntity">
select
`id`,
`parent_id`,
`label_name`,
`enable_flag`,
`create_time`,
`update_time`
from tb_cf_label
WHERE parent_id=#{parentId}
</select>
<select id="queryTotal" resultType="int">
select count(*) from tb_cf_label
......@@ -58,12 +72,14 @@
<insert id="save" parameterType="com.platform.entity.TbCfLabelEntity">
insert into tb_cf_label(
`id`,
`parent_id`,
`label_name`,
`enable_flag`,
`create_time`,
`update_time`)
values(
#{id},
#{parentId},
#{labelName},
#{enableFlag},
#{createTime},
......@@ -73,9 +89,10 @@
<update id="update" parameterType="com.platform.entity.TbCfLabelEntity">
update tb_cf_label
<set>
<if test="labelName != null">`label_name` = #{labelName}, </if>
<if test="enableFlag != null">`enable_flag` = #{enableFlag}, </if>
<if test="createTime != null">`create_time` = #{createTime}, </if>
<if test="parentId != null">`parent_id` = #{parentId},</if>
<if test="labelName != null">`label_name` = #{labelName},</if>
<if test="enableFlag != null">`enable_flag` = #{enableFlag},</if>
<if test="createTime != null">`create_time` = #{createTime},</if>
<if test="updateTime != null">`update_time` = #{updateTime}</if>
</set>
where id = #{id}
......
......@@ -33,16 +33,26 @@
<Card v-show="!showList">
<p slot="title">{{title}}</p>
<i-form ref="formValidate" :model="tbCfLabel" :rules="ruleValidate" :label-width="80">
<!-- <Form-item label="标签组名" prop="parentId">
<i-input v-model="tbCfLabel.parentId" placeholder="父标签ID,如果没有父标签,则为:0"/>
</Form-item>-->
<Form-item label="标签组名" prop="parentId">
<i-select placeholder="请选择" v-model="tbCfLabel.parentId">
<i-option v-for="(el,i) in labelList" :key='el.id'
:value="el.id">{{el.labelName}}
</i-option>
</i-select>
</Form-item>
<Form-item label="标签名" prop="labelName">
<i-input v-model="tbCfLabel.labelName" placeholder="标签名"/>
</Form-item>
<Form-item label="是否启用" prop="enableFlag">
<i-input v-model="tbCfLabel.enableFlag" placeholder="是否启用 0:不启用 1:启用"/>
</Form-item>
<Form-item>
<i-button type="primary" @click="handleSubmit('formValidate')">提交</i-button>
<i-button type="warning" @click="reload" style="margin-left: 8px"/>返回</i-button>
<i-button type="warning" @click="reload" style="margin-left: 8px"/>
返回</i-button>
<i-button type="ghost" @click="handleReset('formValidate')" style="margin-left: 8px">重置</i-button>
</Form-item>
</i-form>
......
......@@ -3,8 +3,9 @@ $(function () {
url: '../tbcflabel/list',
colModel: [
{label: 'id', name: 'id', index: 'id', key: true, hidden: true},
/*{label: '标签组名', name: 'parentId', index: 'parent_id', width: 80},*/
{label: '标签名', name: 'labelName', index: 'label_name', width: 80},
{label: '是否启用', name: 'enableFlag', index: 'enable_flag', width: 80, formatter: validFormat},
{label: '是否启用', name: 'enableFlag', index: 'enable_flag', width: 80,formatter: validFormat},
{label: '创建时间', name: 'createTime', index: 'create_time', width: 80}
]
});
......@@ -13,6 +14,7 @@ $(function () {
let vm = new Vue({
el: '#rrapp',
data: {
labelList:null,
showList: true,
title: null,
tbCfLabel: {},
......@@ -110,5 +112,14 @@ let vm = new Vue({
handleReset: function (name) {
handleResetForm(this, name);
}
},
created(){
$.get('../tbcflabel/queryParentLabels', res => {
this.labelList = JSON.parse(res).list;
this.labelList.unshift({
id: "0",
labelName: "标签组",
})
})
}
});
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论