分类管理增删改查完成
This commit is contained in:
parent
7dcf15fd79
commit
bad6ecb111
7
TODOs.md
7
TODOs.md
@ -4,6 +4,13 @@
|
|||||||
小程序扫门禁码之后门禁开门
|
小程序扫门禁码之后门禁开门
|
||||||
小程序修改密码
|
小程序修改密码
|
||||||
|
|
||||||
|
# IP 配置
|
||||||
|
|
||||||
|
内网穿透:124.220.172.110
|
||||||
|
nacos:106.75.217.14
|
||||||
|
数据库:本地
|
||||||
|
|
||||||
|
|
||||||
# QCloud
|
# QCloud
|
||||||
|
|
||||||
主账号ID 100014397291
|
主账号ID 100014397291
|
||||||
|
@ -43,7 +43,7 @@ public class FieldBuilder {
|
|||||||
FieldType fieldType, SearchType searchType, AddType addType, EditType editType,
|
FieldType fieldType, SearchType searchType, AddType addType, EditType editType,
|
||||||
String searchPlaceholder, String addPlaceholder, String editPlaceholder,
|
String searchPlaceholder, String addPlaceholder, String editPlaceholder,
|
||||||
FieldRuleListBuilder fieldRuleListBuilder, String mockDataPattern) {
|
FieldRuleListBuilder fieldRuleListBuilder, String mockDataPattern) {
|
||||||
JSONObject jsonObject = new JSONObject(2);
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
|
||||||
/* 实际字段 */
|
/* 实际字段 */
|
||||||
// 用于筛选、增删改
|
// 用于筛选、增删改
|
||||||
|
@ -19,7 +19,7 @@ public class FieldMapperBuilder {
|
|||||||
// if (mapper == null || mapper.size() == 0) {
|
// if (mapper == null || mapper.size() == 0) {
|
||||||
// return this;
|
// return this;
|
||||||
// }
|
// }
|
||||||
// JSONObject jsonObject = new JSONObject(2);
|
// JSONObject jsonObject = new JSONObject(3);
|
||||||
// jsonObject.put("key", prop);
|
// jsonObject.put("key", prop);
|
||||||
// jsonObject.put("value", label);
|
// jsonObject.put("value", label);
|
||||||
// jsonObject.put("mapper", mapper);
|
// jsonObject.put("mapper", mapper);
|
||||||
@ -28,7 +28,7 @@ public class FieldMapperBuilder {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
public FieldMapperBuilder add(String prop, String label, HashMap mapper) {
|
public FieldMapperBuilder add(String prop, String label, HashMap mapper) {
|
||||||
JSONObject jsonObject = new JSONObject(2);
|
JSONObject jsonObject = new JSONObject(3);
|
||||||
jsonObject.put("key", prop);
|
jsonObject.put("key", prop);
|
||||||
jsonObject.put("value", label);
|
jsonObject.put("value", label);
|
||||||
jsonObject.put("mapper", mapper);
|
jsonObject.put("mapper", mapper);
|
||||||
|
@ -8,6 +8,7 @@ import org.springframework.beans.BeanUtils;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
// 数据库关系映射
|
// 数据库关系映射
|
||||||
@ -38,4 +39,23 @@ public class GoodCategoryVO implements Serializable {
|
|||||||
List<GoodCategoryVO> goodCategoryVOList = goodCategoryList.stream().map(GoodCategoryVO::convertFrom).collect(Collectors.toList());
|
List<GoodCategoryVO> goodCategoryVOList = goodCategoryList.stream().map(GoodCategoryVO::convertFrom).collect(Collectors.toList());
|
||||||
return goodCategoryVOList;
|
return goodCategoryVOList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static GoodCategory convertTo(GoodCategoryVO goodCategoryVO) {
|
||||||
|
if (goodCategoryVO == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
GoodCategory goodCategory = new GoodCategory();
|
||||||
|
BeanUtils.copyProperties(goodCategoryVO, goodCategory);
|
||||||
|
try {
|
||||||
|
if (!Objects.isNull(goodCategoryVO.getId())) {
|
||||||
|
Long goodCategoryId = Long.valueOf(goodCategoryVO.getId());
|
||||||
|
goodCategory.setId(goodCategoryId);
|
||||||
|
} else {
|
||||||
|
goodCategory.setId(null);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
goodCategory.setId(null);
|
||||||
|
}
|
||||||
|
return goodCategory;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,7 @@ public class GoodController {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
// 拼装返回结果
|
// 拼装返回结果
|
||||||
JSONObject map = new JSONObject(2);
|
JSONObject map = new JSONObject(6);
|
||||||
map.put("total", goodPageInfo.getTotal());
|
map.put("total", goodPageInfo.getTotal());
|
||||||
map.put("list", voList);
|
map.put("list", voList);
|
||||||
map.put("columns", columns);
|
map.put("columns", columns);
|
||||||
@ -244,12 +244,12 @@ public class GoodController {
|
|||||||
if (good.getId() == null || good.getId() < 1) {
|
if (good.getId() == null || good.getId() < 1) {
|
||||||
// 新增商品
|
// 新增商品
|
||||||
if (existGood != null) {
|
if (existGood != null) {
|
||||||
return Res.error("商品名已存在,操作失败");
|
return Res.error("商品已存在,操作失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (password == null || "".equals(password)) {
|
if (good.getGoodsName() == null || "".equals(good.getGoodsName())) {
|
||||||
// return Res.error("密码不能为空");
|
return Res.error("商品名称不能为空");
|
||||||
// }
|
}
|
||||||
good.setId(null);
|
good.setId(null);
|
||||||
goodService.addGood(good);
|
goodService.addGood(good);
|
||||||
} else {
|
} else {
|
||||||
@ -275,7 +275,7 @@ public class GoodController {
|
|||||||
if (id == null || id <= 0) {
|
if (id == null || id <= 0) {
|
||||||
return Res.error("商品不存在,删除失败");
|
return Res.error("商品不存在,删除失败");
|
||||||
}
|
}
|
||||||
// 先查询商品名是否存在
|
// 先查询商品是否存在
|
||||||
Good existGood = goodService.getGoodById(id);
|
Good existGood = goodService.getGoodById(id);
|
||||||
if (existGood == null) {
|
if (existGood == null) {
|
||||||
return Res.error("商品不存在,删除失败");
|
return Res.error("商品不存在,删除失败");
|
||||||
@ -308,6 +308,13 @@ public class GoodController {
|
|||||||
return Res.success(map);
|
return Res.success(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传商品图片到腾讯云COS桶
|
||||||
|
* —— 获取上传临时密钥及生成文件名
|
||||||
|
*
|
||||||
|
* @param ext
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@GetMapping("/manage/imageUpload/getTmpCosCredential")
|
@GetMapping("/manage/imageUpload/getTmpCosCredential")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Res getTmpCosCredential(@RequestParam(required = true) String ext) {
|
public Res getTmpCosCredential(@RequestParam(required = true) String ext) {
|
||||||
@ -319,4 +326,144 @@ public class GoodController {
|
|||||||
// 返回结果
|
// 返回结果
|
||||||
return Res.success(credential);
|
return Res.success(credential);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取商品分类
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/manage/getCategoryList")
|
||||||
|
@ResponseBody
|
||||||
|
public Res getCategoryList(PageQuery pageQuery, GoodCategoryVO goodCategoryVO) {
|
||||||
|
// 查询分页数据
|
||||||
|
PageHelper.startPage(pageQuery.getPageIndex(), pageQuery.getPageSize());
|
||||||
|
List<GoodCategory> goodCategoryList = goodService.getCateListWithQuery(goodCategoryVO);
|
||||||
|
PageInfo<GoodCategory> goodCategoryPageInfo = new PageInfo<>(goodCategoryList);
|
||||||
|
List<GoodCategory> list = goodCategoryPageInfo.getList();
|
||||||
|
List<GoodCategoryVO> voList = GoodCategoryVO.convertFrom(list);
|
||||||
|
|
||||||
|
// id列 字段名(区分大小写;以VO中的变量名为准)
|
||||||
|
// 新增、修改弹窗时,使用该列作为主键列进行操作
|
||||||
|
String idFieldName = "id";
|
||||||
|
|
||||||
|
// 当前管理页面
|
||||||
|
String pageName = "分类管理";
|
||||||
|
|
||||||
|
// 指定前端表格显示列
|
||||||
|
JSONArray columns = FieldBuilder.create()
|
||||||
|
.add("categoryName", "categoryName", "商品分类", "",
|
||||||
|
FieldType.TEXT, SearchType.INPUT, AddType.INPUT, EditType.INPUT,
|
||||||
|
FieldBuilder.SEARCH_PLACEHOLDER_SAME_AS_FIELDNAME,
|
||||||
|
"商品分类", FieldBuilder.EDIT_PLACEHOLDER_SAME_AS_ADD_PLACEHOLDER,
|
||||||
|
FieldRuleListBuilder.create()
|
||||||
|
.add(FieldRuleBuilder.create("商品分类").required())
|
||||||
|
.add(FieldRuleBuilder.create("商品分类").minMax(2, 4)),
|
||||||
|
"DPD @cword(2, 4)"
|
||||||
|
)
|
||||||
|
.add("order", "order", "排序", "",
|
||||||
|
FieldType.TEXT, SearchType.CAN_NOT_SEARCH, AddType.INPUT, EditType.INPUT,
|
||||||
|
FieldBuilder.SEARCH_PLACEHOLDER_SAME_AS_FIELDNAME,
|
||||||
|
"排序", FieldBuilder.EDIT_PLACEHOLDER_SAME_AS_ADD_PLACEHOLDER,
|
||||||
|
FieldRuleListBuilder.create(),
|
||||||
|
"DTD /^\\d+?$/"
|
||||||
|
)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// 指定需要翻译的字段
|
||||||
|
JSONArray fieldMapper = FieldMapperBuilder.create()
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// 拼装返回结果
|
||||||
|
JSONObject map = new JSONObject(6);
|
||||||
|
map.put("total", goodCategoryPageInfo.getTotal());
|
||||||
|
map.put("list", voList);
|
||||||
|
map.put("columns", columns);
|
||||||
|
map.put("fieldMapper", fieldMapper);
|
||||||
|
map.put("idFieldName", idFieldName);
|
||||||
|
map.put("pageName", pageName);
|
||||||
|
|
||||||
|
// 返回结果
|
||||||
|
return Res.success(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增 / 编辑分类
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/manage/editCategory")
|
||||||
|
@ResponseBody
|
||||||
|
public Res editCategory(@ModelAttribute GoodCategoryVO goodCategoryVO) {
|
||||||
|
GoodCategory goodCategory = GoodCategoryVO.convertTo(goodCategoryVO);
|
||||||
|
|
||||||
|
// 先查询分类是否存在
|
||||||
|
GoodCategory existGoodCategory = goodService.getGoodCategoryById(goodCategory.getId());
|
||||||
|
|
||||||
|
if (goodCategory.getId() == null || goodCategory.getId() < 1) {
|
||||||
|
// 新增分类
|
||||||
|
if (existGoodCategory != null) {
|
||||||
|
return Res.error("分类已存在,操作失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (goodCategory.getCategoryName() == null || "".equals(goodCategory.getCategoryName())) {
|
||||||
|
return Res.error("分类名称不能为空");
|
||||||
|
}
|
||||||
|
goodCategory.setId(null);
|
||||||
|
goodService.addGoodCategory(goodCategory);
|
||||||
|
} else {
|
||||||
|
// 修改分类
|
||||||
|
if (existGoodCategory == null) {
|
||||||
|
return Res.error("分类不存在,操作失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
goodService.updateGoodCategory(goodCategory);
|
||||||
|
}
|
||||||
|
return Res.success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除分类
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/manage/deleteCategory")
|
||||||
|
@ResponseBody
|
||||||
|
public Res deleteCategory(Long id) {
|
||||||
|
if (id == null || id <= 0) {
|
||||||
|
return Res.error("分类不存在,删除失败");
|
||||||
|
}
|
||||||
|
// 先查询分类是否存在
|
||||||
|
GoodCategory existGoodCategory = goodService.getGoodCategoryById(id);
|
||||||
|
if (existGoodCategory == null) {
|
||||||
|
return Res.error("分类不存在,删除失败");
|
||||||
|
}
|
||||||
|
boolean b = goodService.deleteGoodCategory(existGoodCategory.getId());
|
||||||
|
return Res.success(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出分类列表
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/manage/exportCategoryList")
|
||||||
|
@ResponseBody
|
||||||
|
public Res exportCategoryList(GoodCategoryVO goodCategoryVO) {
|
||||||
|
List<GoodCategory> categoryList = goodService.getCateListWithQuery(goodCategoryVO);
|
||||||
|
List<GoodCategoryVO> goodCategoryVOList = GoodCategoryVO.convertFrom(categoryList);
|
||||||
|
|
||||||
|
// 当前时间
|
||||||
|
Date now = Calendar.getInstance().getTime();
|
||||||
|
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd_HHmmss");
|
||||||
|
String dateTime = format.format(now);
|
||||||
|
|
||||||
|
HashMap<String, Object> map = new HashMap<>();
|
||||||
|
map.put("list", goodCategoryVOList);
|
||||||
|
map.put("sheetName", "商品分类表-" + System.currentTimeMillis());
|
||||||
|
map.put("fileName", "商品分类表_导出时间_" + dateTime);
|
||||||
|
|
||||||
|
return Res.success(map);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.cxyxiaomo.epp.shop.dao;
|
package com.cxyxiaomo.epp.shop.dao;
|
||||||
|
|
||||||
import com.cxyxiaomo.epp.common.pojo.GoodCategory;
|
import com.cxyxiaomo.epp.common.pojo.GoodCategory;
|
||||||
|
import com.cxyxiaomo.epp.common.vo.GoodCategoryVO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@ -12,5 +13,14 @@ public interface GoodCategoryDao {
|
|||||||
|
|
||||||
List<GoodCategory> list();
|
List<GoodCategory> list();
|
||||||
|
|
||||||
GoodCategory getById(Integer id);
|
GoodCategory getById(Long id);
|
||||||
|
|
||||||
|
|
||||||
|
public boolean addCategory(GoodCategory goodCategory);
|
||||||
|
|
||||||
|
public boolean updateCategory(GoodCategory goodCategory);
|
||||||
|
|
||||||
|
public List<GoodCategory> getCategoryList(GoodCategoryVO goodCategoryVO);
|
||||||
|
|
||||||
|
public boolean deleteCategoryById(Long goodCategoryId);
|
||||||
}
|
}
|
||||||
|
@ -49,11 +49,27 @@ public class GoodService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取分类列表(不带查询参数)
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public List<GoodCategory> getCateList() {
|
public List<GoodCategory> getCateList() {
|
||||||
List<GoodCategory> list = goodCategoryDao.list();
|
List<GoodCategory> list = goodCategoryDao.list();
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取分类列表(带查询参数)
|
||||||
|
*
|
||||||
|
* @param goodCategoryVO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<GoodCategory> getCateListWithQuery(GoodCategoryVO goodCategoryVO) {
|
||||||
|
List<GoodCategory> list = goodCategoryDao.getCategoryList(goodCategoryVO);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public Good getGoodById(Long id) {
|
public Good getGoodById(Long id) {
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
@ -79,4 +95,25 @@ public class GoodService {
|
|||||||
public boolean deleteGood(Long goodId) {
|
public boolean deleteGood(Long goodId) {
|
||||||
return goodDao.deleteGoodById(goodId);
|
return goodDao.deleteGoodById(goodId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean addGoodCategory(GoodCategory goodCategory) {
|
||||||
|
goodCategory.setId(null);
|
||||||
|
return goodCategoryDao.addCategory(goodCategory);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean updateGoodCategory(GoodCategory goodCategory) {
|
||||||
|
return goodCategoryDao.updateCategory(goodCategory);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean deleteGoodCategory(Long goodCategoryId) {
|
||||||
|
return goodCategoryDao.deleteCategoryById(goodCategoryId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public GoodCategory getGoodCategoryById(Long id) {
|
||||||
|
if (id == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return goodCategoryDao.getById(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!DOCTYPE mapper
|
|
||||||
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.cxyxiaomo.epp.shop.dao.GoodCategoryDao">
|
|
||||||
<select id="list" resultType="com.cxyxiaomo.epp.common.pojo.GoodCategory">
|
|
||||||
SELECT * FROM goods_category
|
|
||||||
WHERE 1 = 1
|
|
||||||
order by `order` asc
|
|
||||||
</select>
|
|
||||||
<select id="getById" parameterType="java.lang.Integer" resultType="com.cxyxiaomo.epp.common.pojo.GoodCategory">
|
|
||||||
SELECT * FROM goods_category
|
|
||||||
WHERE id = #{id}
|
|
||||||
order by `order` asc
|
|
||||||
</select>
|
|
||||||
</mapper>
|
|
@ -0,0 +1,46 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.cxyxiaomo.epp.shop.dao.GoodCategoryDao">
|
||||||
|
<select id="list" resultType="com.cxyxiaomo.epp.common.pojo.GoodCategory">
|
||||||
|
SELECT * FROM goods_category
|
||||||
|
WHERE 1 = 1
|
||||||
|
order by `order` asc
|
||||||
|
</select>
|
||||||
|
<select id="getById" parameterType="java.lang.Long" resultType="com.cxyxiaomo.epp.common.pojo.GoodCategory">
|
||||||
|
SELECT * FROM goods_category
|
||||||
|
WHERE id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="addCategory" parameterType="com.cxyxiaomo.epp.common.pojo.GoodCategory">
|
||||||
|
INSERT INTO goods_category ( category_name, `order`)
|
||||||
|
VALUES (#{categoryName}, #{order})
|
||||||
|
</insert>
|
||||||
|
<update id="updateCategory" parameterType="com.cxyxiaomo.epp.common.pojo.GoodCategory">
|
||||||
|
UPDATE goods_category
|
||||||
|
<set>
|
||||||
|
<if test="categoryName != null and categoryName != ''">category_name = #{categoryName,jdbcType=VARCHAR},</if>
|
||||||
|
<if test="order != null">`order` = #{order},</if>
|
||||||
|
</set>
|
||||||
|
WHERE id = #{id}
|
||||||
|
</update>
|
||||||
|
<select id="getCategoryList" resultType="com.cxyxiaomo.epp.common.pojo.GoodCategory">
|
||||||
|
select *
|
||||||
|
from goods_category
|
||||||
|
where 1 = 1
|
||||||
|
<if test="id != null">
|
||||||
|
AND id = #{id}
|
||||||
|
</if>
|
||||||
|
<if test="categoryName != null && categoryName != ''">
|
||||||
|
AND category_name LIKE concat('%',#{categoryName,jdbcType=VARCHAR},'%')
|
||||||
|
</if>
|
||||||
|
order by `order` asc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<delete id="deleteCategoryById">
|
||||||
|
DELETE
|
||||||
|
FROM goods_category
|
||||||
|
WHERE id = #{goodCategoryId}
|
||||||
|
</delete>
|
||||||
|
</mapper>
|
@ -186,7 +186,7 @@ public class UserController {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
// 拼装返回结果
|
// 拼装返回结果
|
||||||
JSONObject map = new JSONObject(2);
|
JSONObject map = new JSONObject(6);
|
||||||
map.put("total", userPageInfo.getTotal());
|
map.put("total", userPageInfo.getTotal());
|
||||||
map.put("list", voList);
|
map.put("list", voList);
|
||||||
map.put("columns", columns);
|
map.put("columns", columns);
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-gateway</artifactId>
|
<artifactId>spring-cloud-starter-gateway</artifactId>
|
||||||
<version>3.1.4</version>
|
<version>3.1.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Spring Cloud Starter Load Balancer -->
|
<!-- Spring Cloud Starter Load Balancer -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
7
frontend/components.d.ts
vendored
7
frontend/components.d.ts
vendored
@ -12,6 +12,9 @@ declare module '@vue/runtime-core' {
|
|||||||
ElAlert: typeof import('element-plus/es')['ElAlert']
|
ElAlert: typeof import('element-plus/es')['ElAlert']
|
||||||
ElAvatar: typeof import('element-plus/es')['ElAvatar']
|
ElAvatar: typeof import('element-plus/es')['ElAvatar']
|
||||||
ElButton: typeof import('element-plus/es')['ElButton']
|
ElButton: typeof import('element-plus/es')['ElButton']
|
||||||
|
ElCard: typeof import('element-plus/es')['ElCard']
|
||||||
|
ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
|
||||||
|
ElCol: typeof import('element-plus/es')['ElCol']
|
||||||
ElDialog: typeof import('element-plus/es')['ElDialog']
|
ElDialog: typeof import('element-plus/es')['ElDialog']
|
||||||
ElDropdown: typeof import('element-plus/es')['ElDropdown']
|
ElDropdown: typeof import('element-plus/es')['ElDropdown']
|
||||||
ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
|
ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
|
||||||
@ -26,14 +29,18 @@ declare module '@vue/runtime-core' {
|
|||||||
ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
|
ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
|
||||||
ElOption: typeof import('element-plus/es')['ElOption']
|
ElOption: typeof import('element-plus/es')['ElOption']
|
||||||
ElPagination: typeof import('element-plus/es')['ElPagination']
|
ElPagination: typeof import('element-plus/es')['ElPagination']
|
||||||
|
ElProgress: typeof import('element-plus/es')['ElProgress']
|
||||||
ElRadio: typeof import('element-plus/es')['ElRadio']
|
ElRadio: typeof import('element-plus/es')['ElRadio']
|
||||||
ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
|
ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
|
||||||
|
ElRow: typeof import('element-plus/es')['ElRow']
|
||||||
ElSelect: typeof import('element-plus/es')['ElSelect']
|
ElSelect: typeof import('element-plus/es')['ElSelect']
|
||||||
ElSubMenu: typeof import('element-plus/es')['ElSubMenu']
|
ElSubMenu: typeof import('element-plus/es')['ElSubMenu']
|
||||||
ElTable: typeof import('element-plus/es')['ElTable']
|
ElTable: typeof import('element-plus/es')['ElTable']
|
||||||
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
|
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
|
||||||
ElTooltip: typeof import('element-plus/es')['ElTooltip']
|
ElTooltip: typeof import('element-plus/es')['ElTooltip']
|
||||||
|
ElUpload: typeof import('element-plus/es')['ElUpload']
|
||||||
Header: typeof import('./src/components/header.vue')['default']
|
Header: typeof import('./src/components/header.vue')['default']
|
||||||
|
ImageUpload: typeof import('./src/components/image-upload.vue')['default']
|
||||||
ManageList: typeof import('./src/components/manage-list.vue')['default']
|
ManageList: typeof import('./src/components/manage-list.vue')['default']
|
||||||
RouterLink: typeof import('vue-router')['RouterLink']
|
RouterLink: typeof import('vue-router')['RouterLink']
|
||||||
RouterView: typeof import('vue-router')['RouterView']
|
RouterView: typeof import('vue-router')['RouterView']
|
||||||
|
51
frontend/src/api/shop-cate.js
Normal file
51
frontend/src/api/shop-cate.js
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
import send_request from '../utils/send_request';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取商品列表
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function getCateList(params) {
|
||||||
|
return send_request({
|
||||||
|
url: '/shop/good/manage/getCategoryList',
|
||||||
|
method: 'GET',
|
||||||
|
params: params,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加/修改商品信息
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function editCate(params) {
|
||||||
|
return send_request({
|
||||||
|
url: '/shop/good/manage/editCategory',
|
||||||
|
method: 'POST',
|
||||||
|
useQS: true,
|
||||||
|
params: params,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除商品
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function deleteCate(params) {
|
||||||
|
return send_request({
|
||||||
|
url: '/shop/good/manage/deleteCategory',
|
||||||
|
method: 'POST',
|
||||||
|
useQS: true,
|
||||||
|
params: params,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出商品列表
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function exportCateList(params) {
|
||||||
|
return send_request({
|
||||||
|
url: '/shop/good/manage/exportCategoryList',
|
||||||
|
method: 'GET',
|
||||||
|
params: params,
|
||||||
|
});
|
||||||
|
};
|
@ -31,9 +31,6 @@
|
|||||||
</span>
|
</span>
|
||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<el-dropdown-menu>
|
<el-dropdown-menu>
|
||||||
<a href="https://github.com/lin-xin/vue-manage-system" target="_blank">
|
|
||||||
<el-dropdown-item>项目仓库</el-dropdown-item>
|
|
||||||
</a>
|
|
||||||
<el-dropdown-item command="user">个人中心</el-dropdown-item>
|
<el-dropdown-item command="user">个人中心</el-dropdown-item>
|
||||||
<el-dropdown-item divided command="loginout">退出登录</el-dropdown-item>
|
<el-dropdown-item divided command="loginout">退出登录</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
|
@ -28,14 +28,18 @@ const emit = defineEmits(['change'])
|
|||||||
|
|
||||||
const handleHttpRequest = async (data: UploadRequestOptions) => {
|
const handleHttpRequest = async (data: UploadRequestOptions) => {
|
||||||
console.log('httpRequest', data)
|
console.log('httpRequest', data)
|
||||||
await cos.upload(data.file)
|
let result = await cos.upload(data.file)
|
||||||
|
console.log("result", result)
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleSuccess: UploadProps['onSuccess'] = (
|
const handleSuccess: UploadProps['onSuccess'] = (
|
||||||
response,
|
response, // 这里的 response 就是 handleHttpRequest 返回的结果
|
||||||
uploadFile
|
uploadFile
|
||||||
) => {
|
) => {
|
||||||
let url = URL.createObjectURL(uploadFile.raw!)
|
console.log("response", response)
|
||||||
|
// let url = URL.createObjectURL(uploadFile.raw!)
|
||||||
|
let url = "//" + response.Location
|
||||||
emit('change', url)
|
emit('change', url)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,9 +73,14 @@ const items = [
|
|||||||
{
|
{
|
||||||
icon: 'OfficeBuilding',
|
icon: 'OfficeBuilding',
|
||||||
index: '/shop',
|
index: '/shop',
|
||||||
title: '商品管理',
|
title: '生活物资',
|
||||||
permiss: 'shop',
|
permiss: 'shop',
|
||||||
subs: [
|
subs: [
|
||||||
|
{
|
||||||
|
index: '/shop-cate-setting',
|
||||||
|
title: '分类管理',
|
||||||
|
permiss: 'shop-cate-setting',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
index: '/shop-good-setting',
|
index: '/shop-good-setting',
|
||||||
title: '商品管理',
|
title: '商品管理',
|
||||||
@ -86,7 +91,7 @@ const items = [
|
|||||||
{
|
{
|
||||||
icon: 'Avatar',
|
icon: 'Avatar',
|
||||||
index: '/privilege',
|
index: '/privilege',
|
||||||
title: '用户管理',
|
title: '系统管理',
|
||||||
permiss: 'privilege',
|
permiss: 'privilege',
|
||||||
subs: [
|
subs: [
|
||||||
{
|
{
|
||||||
|
@ -31,6 +31,15 @@ const routes: RouteRecordRaw[] = [
|
|||||||
},
|
},
|
||||||
component: () => import('../views/shop-good-setting.vue'),
|
component: () => import('../views/shop-good-setting.vue'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/shop-cate-setting',
|
||||||
|
name: 'shop-cate-setting',
|
||||||
|
meta: {
|
||||||
|
title: '分类管理',
|
||||||
|
permiss: 'shop-good-setting',
|
||||||
|
},
|
||||||
|
component: () => import('../views/shop-cate-setting.vue'),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/privilege-user-setting',
|
path: '/privilege-user-setting',
|
||||||
name: 'privilege-user-setting',
|
name: 'privilege-user-setting',
|
||||||
|
@ -9,6 +9,7 @@ interface ObjectList {
|
|||||||
export const usePermissStore = defineStore('permiss', {
|
export const usePermissStore = defineStore('permiss', {
|
||||||
state: () => {
|
state: () => {
|
||||||
return {
|
return {
|
||||||
|
// 系统管理员
|
||||||
"1": [
|
"1": [
|
||||||
"default",
|
"default",
|
||||||
|
|
||||||
@ -16,10 +17,13 @@ export const usePermissStore = defineStore('permiss', {
|
|||||||
|
|
||||||
"shop",
|
"shop",
|
||||||
"shop-good-setting",
|
"shop-good-setting",
|
||||||
|
"shop-cate-setting",
|
||||||
|
|
||||||
"privilege",
|
"privilege",
|
||||||
"privilege-user-setting",
|
"privilege-user-setting",
|
||||||
],
|
],
|
||||||
|
|
||||||
|
// 社区管理员
|
||||||
"2": [
|
"2": [
|
||||||
"default",
|
"default",
|
||||||
|
|
||||||
@ -27,6 +31,7 @@ export const usePermissStore = defineStore('permiss', {
|
|||||||
|
|
||||||
"shop",
|
"shop",
|
||||||
"shop-good-setting",
|
"shop-good-setting",
|
||||||
|
"shop-cate-setting",
|
||||||
|
|
||||||
"privilege",
|
"privilege",
|
||||||
"privilege-user-setting",
|
"privilege-user-setting",
|
||||||
|
11
frontend/src/views/shop-cate-setting.vue
Normal file
11
frontend/src/views/shop-cate-setting.vue
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<template>
|
||||||
|
<div class="container">
|
||||||
|
<manageList :list-func="shopCateApi.getCateList" :add-func="shopCateApi.editCate" :edit-func="shopCateApi.editCate"
|
||||||
|
:delete-func="shopCateApi.deleteCate" :export-func="shopCateApi.exportCateList" edit-permiss="shop-cate-setting" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import manageList from '../components/manage-list.vue';
|
||||||
|
import * as shopCateApi from '../api/shop-cate';
|
||||||
|
</script>
|
Loading…
Reference in New Issue
Block a user