增加mybatisplus sql日志监控
This commit is contained in:
1 parent
1296549d1d
commit
2bbbb35eac
20 files changed
+637
-4
No files matched your search
@@ -146,6 +146,11 @@
|
|||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>p6spy</groupId>
|
||||||
|
<artifactId>p6spy</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
package com.ruoyi.app.common.persistence.dao;
|
||||||
|
|
||||||
|
import com.ruoyi.app.common.persistence.model.StoreGoodsCate;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 商城商品分类 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author hupeng
|
||||||
|
* @since 2019-09-08
|
||||||
|
*/
|
||||||
|
public interface StoreGoodsCateMapper extends BaseMapper<StoreGoodsCate> {
|
||||||
|
|
||||||
|
}
|
||||||
+8
@@ -1,8 +1,15 @@
|
|||||||
package com.ruoyi.app.common.persistence.dao;
|
package com.ruoyi.app.common.persistence.dao;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.ruoyi.app.common.persistence.model.StoreGoods;
|
||||||
import com.ruoyi.app.common.persistence.model.StoreGoodsCollect;
|
import com.ruoyi.app.common.persistence.model.StoreGoodsCollect;
|
||||||
|
import com.ruoyi.app.modular.shop.service.dto.GoodsDTO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -16,4 +23,5 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface StoreGoodsCollectMapper extends BaseMapper<StoreGoodsCollect> {
|
public interface StoreGoodsCollectMapper extends BaseMapper<StoreGoodsCollect> {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,11 @@
|
|||||||
package com.ruoyi.app.common.persistence.dao;
|
package com.ruoyi.app.common.persistence.dao;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.ruoyi.app.common.persistence.model.StoreGoods;
|
import com.ruoyi.app.common.persistence.model.StoreGoods;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -16,4 +19,15 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface StoreGoodsMapper extends BaseMapper<StoreGoods> {
|
public interface StoreGoodsMapper extends BaseMapper<StoreGoods> {
|
||||||
|
|
||||||
|
@Results({
|
||||||
|
@Result(property = "goodsId",column = "goods_id"),
|
||||||
|
@Result(property = "goodsName",column = "goods_name"),
|
||||||
|
@Result(property = "goodsSn",column = "goods_sn"),
|
||||||
|
@Result(property = "goodsLogo",column = "goods_logo"),
|
||||||
|
@Result(property = "shopPrice",column = "shop_price"),
|
||||||
|
@Result(property = "marketPrice",column = "market_price")
|
||||||
|
})
|
||||||
|
@Select("select g.* from store_goods_collect c left join store_goods g " +
|
||||||
|
"on c.goods_id=g.goods_id where c.user_id=#{userId}")
|
||||||
|
List<StoreGoods> collectGoods(Page page, @Param("userId") int userId);
|
||||||
}
|
}
|
||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
<?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.ruoyi.app.common.persistence.dao.StoreGoodsCateMapper">
|
||||||
|
|
||||||
|
<!-- 通用查询映射结果 -->
|
||||||
|
<resultMap id="BaseResultMap" type="com.ruoyi.app.common.persistence.model.StoreGoodsCate">
|
||||||
|
<id column="id" property="id" />
|
||||||
|
<result column="pid" property="pid" />
|
||||||
|
<result column="brand_id" property="brandId" />
|
||||||
|
<result column="cate_title" property="cateTitle" />
|
||||||
|
<result column="cate_desc" property="cateDesc" />
|
||||||
|
<result column="img_url" property="imgUrl" />
|
||||||
|
<result column="sort" property="sort" />
|
||||||
|
<result column="status" property="status" />
|
||||||
|
<result column="is_deleted" property="isDeleted" />
|
||||||
|
<result column="create_at" property="createAt" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,171 @@
|
|||||||
|
package com.ruoyi.app.common.persistence.model;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 商城商品分类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author hupeng
|
||||||
|
* @since 2019-09-08
|
||||||
|
*/
|
||||||
|
@TableName("store_goods_cate")
|
||||||
|
public class StoreGoodsCate extends Model<StoreGoodsCate> {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 上级分类编号
|
||||||
|
*/
|
||||||
|
private Long pid;
|
||||||
|
/**
|
||||||
|
* 品牌ID
|
||||||
|
*/
|
||||||
|
@TableField("brand_id")
|
||||||
|
private Long brandId;
|
||||||
|
/**
|
||||||
|
* 商品分类名称
|
||||||
|
*/
|
||||||
|
@TableField("cate_title")
|
||||||
|
private String cateTitle;
|
||||||
|
/**
|
||||||
|
* 商品分类
|
||||||
|
*/
|
||||||
|
@TableField("cate_desc")
|
||||||
|
private String cateDesc;
|
||||||
|
/**
|
||||||
|
* 缩略图url
|
||||||
|
*/
|
||||||
|
@TableField("img_url")
|
||||||
|
private String imgUrl;
|
||||||
|
/**
|
||||||
|
* 商品分类排序
|
||||||
|
*/
|
||||||
|
private Long sort;
|
||||||
|
/**
|
||||||
|
* 商品状态(1有效,0无效)
|
||||||
|
*/
|
||||||
|
private Long status;
|
||||||
|
/**
|
||||||
|
* 删除状态(1删除,0未删除)
|
||||||
|
*/
|
||||||
|
@TableField("is_deleted")
|
||||||
|
private Long isDeleted;
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@TableField("create_at")
|
||||||
|
private Date createAt;
|
||||||
|
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getPid() {
|
||||||
|
return pid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPid(Long pid) {
|
||||||
|
this.pid = pid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getBrandId() {
|
||||||
|
return brandId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBrandId(Long brandId) {
|
||||||
|
this.brandId = brandId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCateTitle() {
|
||||||
|
return cateTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCateTitle(String cateTitle) {
|
||||||
|
this.cateTitle = cateTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCateDesc() {
|
||||||
|
return cateDesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCateDesc(String cateDesc) {
|
||||||
|
this.cateDesc = cateDesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getImgUrl() {
|
||||||
|
return imgUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImgUrl(String imgUrl) {
|
||||||
|
this.imgUrl = imgUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getSort() {
|
||||||
|
return sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSort(Long sort) {
|
||||||
|
this.sort = sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(Long status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getIsDeleted() {
|
||||||
|
return isDeleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsDeleted(Long isDeleted) {
|
||||||
|
this.isDeleted = isDeleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreateAt() {
|
||||||
|
return createAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateAt(Date createAt) {
|
||||||
|
this.createAt = createAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Serializable pkVal() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "StoreGoodsCate{" +
|
||||||
|
", id=" + id +
|
||||||
|
", pid=" + pid +
|
||||||
|
", brandId=" + brandId +
|
||||||
|
", cateTitle=" + cateTitle +
|
||||||
|
", cateDesc=" + cateDesc +
|
||||||
|
", imgUrl=" + imgUrl +
|
||||||
|
", sort=" + sort +
|
||||||
|
", status=" + status +
|
||||||
|
", isDeleted=" + isDeleted +
|
||||||
|
", createAt=" + createAt +
|
||||||
|
"}";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
package com.ruoyi.app.common.utils;
|
||||||
|
|
||||||
|
|
||||||
|
import com.ruoyi.app.modular.shop.service.dto.CateDTO;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName TreeUtil
|
||||||
|
* @Author hupeng <610796224@qq.com>
|
||||||
|
* @Date 2019/9/8
|
||||||
|
**/
|
||||||
|
public class TreeUtil {
|
||||||
|
/**
|
||||||
|
* 获得指定节点下所有归档
|
||||||
|
* @param list
|
||||||
|
* @param parentId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static List<CateDTO> list2TreeConverter(List<CateDTO> list, int parentId) {
|
||||||
|
List<CateDTO> returnList = new ArrayList<>();
|
||||||
|
|
||||||
|
for (CateDTO res : list) {
|
||||||
|
//判断对象是否为根节点
|
||||||
|
|
||||||
|
if (res.getPid() == parentId) {
|
||||||
|
//该节点为根节点,开始递归
|
||||||
|
|
||||||
|
recursionFn(list, res); //通过递归为节点设置childList
|
||||||
|
|
||||||
|
returnList.add(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归列表
|
||||||
|
* 通过递归,给指定t节点设置childList
|
||||||
|
* @param list
|
||||||
|
* @param t
|
||||||
|
*/
|
||||||
|
public static void recursionFn(List<CateDTO> list, CateDTO t) {
|
||||||
|
//只能获取当前t节点的子节点集,并不是所有子节点集
|
||||||
|
List<CateDTO> childsList = getChildList(list, t);
|
||||||
|
//设置他的子集对象集
|
||||||
|
t.setChildsList(childsList);
|
||||||
|
|
||||||
|
//迭代子集对象集
|
||||||
|
for (CateDTO nextChild : childsList) { //遍历完,则退出递归
|
||||||
|
|
||||||
|
//判断子集对象是否还有子节点
|
||||||
|
if (!CollectionUtils.isEmpty(childsList)) {
|
||||||
|
//有下一个子节点,继续递归
|
||||||
|
recursionFn(list, nextChild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得指定节点下的所有子节点
|
||||||
|
* @param list
|
||||||
|
* @param t
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static List<CateDTO> getChildList(List<CateDTO> list, CateDTO t) {
|
||||||
|
List<CateDTO> childsList = new ArrayList<CateDTO>();
|
||||||
|
//遍历集合元素,如果元素的Parentid==指定元素的id,则说明是该元素的子节点
|
||||||
|
for (CateDTO t1 : list) {
|
||||||
|
if (t1.getPid() == t.getId() ) {
|
||||||
|
childsList.add(t1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return childsList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否还有下一个子节点
|
||||||
|
* @param list
|
||||||
|
* @param t
|
||||||
|
*/
|
||||||
|
public static boolean hasChild(List<CateDTO> list, CateDTO t) {
|
||||||
|
return getChildList(list, t).size() > 0 ? true : false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ package com.ruoyi.app.modular.shop.controller;
|
|||||||
|
|
||||||
import com.itmuch.lightsecurity.jwt.UserOperator;
|
import com.itmuch.lightsecurity.jwt.UserOperator;
|
||||||
import com.ruoyi.app.common.R;
|
import com.ruoyi.app.common.R;
|
||||||
|
import com.ruoyi.app.common.persistence.model.WechatNewsArticle;
|
||||||
import com.ruoyi.app.modular.member.service.IMemberService;
|
import com.ruoyi.app.modular.member.service.IMemberService;
|
||||||
import com.ruoyi.app.modular.shop.service.dto.AdsDTO;
|
import com.ruoyi.app.modular.shop.service.dto.AdsDTO;
|
||||||
import com.ruoyi.app.modular.shop.service.dto.GoodsDTO;
|
import com.ruoyi.app.modular.shop.service.dto.GoodsDTO;
|
||||||
@@ -17,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -61,10 +63,20 @@ public class IndexController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/shop/news-lists")
|
@GetMapping("/shop/news-lists")
|
||||||
|
@ApiOperation(value = "新闻列表",notes = "新闻列表")
|
||||||
public R news(@Validated @RequestBody PageVO pageVO){
|
public R news(@Validated @RequestBody PageVO pageVO){
|
||||||
|
|
||||||
List<NewsDTO> newsList = newsService.getList(pageVO.getPage(),pageVO.getLimit());
|
List<NewsDTO> newsList = newsService.getList(pageVO.getPage(),pageVO.getLimit());
|
||||||
|
|
||||||
return R.success(newsList);
|
return R.success(newsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/shop/news-detail")
|
||||||
|
@ApiOperation(value = "新闻详情",notes = "新闻详情")
|
||||||
|
public R newsDetail(@RequestParam(value = "id",defaultValue = "0") int id){
|
||||||
|
WechatNewsArticle newsArticle = newsService.getById(id);
|
||||||
|
return R.success(newsArticle);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package com.ruoyi.app.modular.shop.controller;
|
||||||
|
|
||||||
|
import com.itmuch.lightsecurity.jwt.UserOperator;
|
||||||
|
import com.ruoyi.app.common.R;
|
||||||
|
import com.ruoyi.app.modular.shop.service.dto.CateDTO;
|
||||||
|
import com.ruoyi.app.modular.shop.service.dto.GoodsDTO;
|
||||||
|
import com.ruoyi.app.modular.shop.service.impl.CateServiceImpl;
|
||||||
|
import com.ruoyi.app.modular.shop.service.impl.GoodsServiceImpl;
|
||||||
|
import com.ruoyi.app.modular.shop.service.vo.PageVO;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName MallController
|
||||||
|
* @Author hupeng <610796224@qq.com>
|
||||||
|
* @Date 2019/9/8
|
||||||
|
**/
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||||
|
@Api(value = "商城模块", tags = "商城模块", description = "商城模块")
|
||||||
|
public class MallController {
|
||||||
|
private final CateServiceImpl cateService;
|
||||||
|
private final GoodsServiceImpl goodsService;
|
||||||
|
private final UserOperator userOperator;
|
||||||
|
|
||||||
|
@GetMapping("/shop/mall-lists")
|
||||||
|
public R lists(@Validated @RequestBody PageVO pageVO){
|
||||||
|
int userId = userOperator.getUser().getId();
|
||||||
|
List<CateDTO> goodsCates = cateService.getList();
|
||||||
|
List<GoodsDTO> recommedGoods = goodsService.getList(0,
|
||||||
|
pageVO.getPage(),pageVO.getLimit(),userId,"",1);
|
||||||
|
List<GoodsDTO> newGoods = goodsService.getList(0,pageVO.getPage(),
|
||||||
|
pageVO.getLimit(),userId,"",2);
|
||||||
|
|
||||||
|
goodsService.collectGoods(pageVO.getPage(),pageVO.getLimit(),userId);
|
||||||
|
|
||||||
|
Map<String,Object> map = new HashMap<>();
|
||||||
|
map.put("goodsCates",goodsCates);
|
||||||
|
map.put("recommedGoods",recommedGoods);
|
||||||
|
map.put("newGoods",newGoods);
|
||||||
|
return R.success(map);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.ruoyi.app.modular.shop.service;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.ruoyi.app.common.persistence.model.StoreGoodsCate;
|
||||||
|
import com.ruoyi.app.modular.shop.service.dto.CateDTO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
public interface ICateService extends IService<StoreGoodsCate> {
|
||||||
|
public List<CateDTO> getList();
|
||||||
|
}
|
||||||
@@ -15,4 +15,6 @@ public interface IGoodsService extends IService<StoreGoods> {
|
|||||||
int userId,String keywords,int order);
|
int userId,String keywords,int order);
|
||||||
|
|
||||||
public boolean isCollect(int goodsId,int userId);
|
public boolean isCollect(int goodsId,int userId);
|
||||||
|
|
||||||
|
public List<StoreGoods> collectGoods(int page,int limit,int userId);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package com.ruoyi.app.modular.shop.service.dto;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 商城商品分类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author hupeng
|
||||||
|
* @since 2019-09-08
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CateDTO implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 上级分类编号
|
||||||
|
*/
|
||||||
|
private Long pid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品分类名称
|
||||||
|
*/
|
||||||
|
private String cateTitle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缩略图url
|
||||||
|
*/
|
||||||
|
private String imgUrl;
|
||||||
|
|
||||||
|
private List<CateDTO> childsList = new ArrayList<>();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.ruoyi.app.modular.shop.service.impl;
|
||||||
|
|
||||||
|
|
||||||
|
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.ruoyi.app.common.persistence.dao.StoreGoodsCateMapper;
|
||||||
|
import com.ruoyi.app.common.persistence.model.StoreGoodsCate;
|
||||||
|
import com.ruoyi.app.common.utils.TreeUtil;
|
||||||
|
import com.ruoyi.app.modular.shop.service.ICateService;
|
||||||
|
import com.ruoyi.app.modular.shop.service.dto.CateDTO;
|
||||||
|
import com.ruoyi.app.modular.shop.service.mapper.CateMapper;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||||
|
public class CateServiceImpl extends ServiceImpl<StoreGoodsCateMapper, StoreGoodsCate> implements ICateService {
|
||||||
|
|
||||||
|
private final CateMapper cateMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CateDTO> getList() {
|
||||||
|
QueryWrapper<StoreGoodsCate> wrapper = new QueryWrapper<>();
|
||||||
|
wrapper.eq("is_deleted",0);
|
||||||
|
List<CateDTO> list = cateMapper.toDto(baseMapper.selectList(wrapper));
|
||||||
|
return TreeUtil.list2TreeConverter(list,0);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -32,6 +32,7 @@ public class GoodsServiceImpl extends ServiceImpl<StoreGoodsMapper, StoreGoods>
|
|||||||
private final StoreGoodsMapper storeGoodsMapper;
|
private final StoreGoodsMapper storeGoodsMapper;
|
||||||
private final StoreGoodsCollectMapper storeGoodsCollectMapper;
|
private final StoreGoodsCollectMapper storeGoodsCollectMapper;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品列表
|
* 商品列表
|
||||||
* @param cateId
|
* @param cateId
|
||||||
@@ -92,4 +93,14 @@ public class GoodsServiceImpl extends ServiceImpl<StoreGoodsMapper, StoreGoods>
|
|||||||
if(ObjectUtil.isNotNull(goodsCollect)) return true;
|
if(ObjectUtil.isNotNull(goodsCollect)) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<StoreGoods> collectGoods(int page,int limit,int userId) {
|
||||||
|
System.out.println("userId"+userId);
|
||||||
|
Page<StoreGoods> pageModel = new Page<>(page, limit);
|
||||||
|
List<StoreGoods> list = baseMapper.collectGoods(pageModel,userId);
|
||||||
|
//System.out.println(list);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.ruoyi.app.modular.shop.service.mapper;
|
||||||
|
|
||||||
|
|
||||||
|
import com.ruoyi.app.common.persistence.model.StoreGoodsCate;
|
||||||
|
import com.ruoyi.app.modular.mapper.EntityMapper;
|
||||||
|
import com.ruoyi.app.modular.shop.service.dto.CateDTO;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.ReportingPolicy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hupeng
|
||||||
|
* @date 2019-09-07
|
||||||
|
*/
|
||||||
|
@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||||
|
public interface CateMapper extends EntityMapper<CateDTO, StoreGoodsCate> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -50,10 +50,12 @@ mybatis-plus:
|
|||||||
spring:
|
spring:
|
||||||
#DATABASE CONFIG
|
#DATABASE CONFIG
|
||||||
datasource:
|
datasource:
|
||||||
driver-class-name: com.mysql.jdbc.Driver
|
#driver-class-name: com.mysql.jdbc.Driver
|
||||||
|
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
|
||||||
username: root
|
username: root
|
||||||
password: root
|
password: root
|
||||||
url: jdbc:mysql://localhost:3306/ruoyi?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=UTC
|
url: jdbc:p6spy:mysql://localhost:3306/ruoyi?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=UTC
|
||||||
|
#url: jdbc:mysql://localhost:3306/ruoyi?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=UTC
|
||||||
type: com.alibaba.druid.pool.DruidDataSource #这里是配置druid连接池,以下都是druid的配置信息
|
type: com.alibaba.druid.pool.DruidDataSource #这里是配置druid连接池,以下都是druid的配置信息
|
||||||
filters: stat,wall,log4j
|
filters: stat,wall,log4j
|
||||||
maxActive: 20
|
maxActive: 20
|
||||||
@@ -102,3 +104,7 @@ spring:
|
|||||||
base-package: com.battcn.controller.basic
|
base-package: com.battcn.controller.basic
|
||||||
system-group:
|
system-group:
|
||||||
base-package: com.battcn.controller.system
|
base-package: com.battcn.controller.system
|
||||||
|
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
com.ruoyi.app.modular: debug
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration>
|
||||||
|
<!-- 日志存放路径 -->
|
||||||
|
<property name="log.path" value="/home/ruoyi/logs" />
|
||||||
|
<!-- 日志输出格式 -->
|
||||||
|
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
|
||||||
|
|
||||||
|
<!-- 控制台输出 -->
|
||||||
|
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 系统日志输出 -->
|
||||||
|
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/sys-info.log</file>
|
||||||
|
<!-- 循环政策:基于时间创建日志文件 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 日志文件名格式 -->
|
||||||
|
<fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<!-- 日志最大的历史 60天 -->
|
||||||
|
<maxHistory>60</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<!-- 过滤的级别 -->
|
||||||
|
<level>INFO</level>
|
||||||
|
<!-- 匹配时的操作:接收(记录) -->
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/sys-error.log</file>
|
||||||
|
<!-- 循环政策:基于时间创建日志文件 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 日志文件名格式 -->
|
||||||
|
<fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<!-- 日志最大的历史 60天 -->
|
||||||
|
<maxHistory>60</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<!-- 过滤的级别 -->
|
||||||
|
<level>ERROR</level>
|
||||||
|
<!-- 匹配时的操作:接收(记录) -->
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 用户访问日志输出 -->
|
||||||
|
<appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/sys-user.log</file>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 按天回滚 daily -->
|
||||||
|
<fileNamePattern>${log.path}/sys-user.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<!-- 日志最大的历史 60天 -->
|
||||||
|
<maxHistory>60</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 系统模块日志级别控制 -->
|
||||||
|
<logger name="com.ruoyi" level="info" />
|
||||||
|
<!-- Spring日志级别控制 -->
|
||||||
|
<logger name="org.springframework" level="warn" />
|
||||||
|
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="console" />
|
||||||
|
</root>
|
||||||
|
|
||||||
|
<!--系统操作日志-->
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="file_info" />
|
||||||
|
<appender-ref ref="file_error" />
|
||||||
|
</root>
|
||||||
|
|
||||||
|
<!--系统用户操作日志-->
|
||||||
|
<logger name="sys-user" level="info">
|
||||||
|
<appender-ref ref="sys-user"/>
|
||||||
|
</logger>
|
||||||
|
</configuration>
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
module.log=com.p6spy.engine.logging.P6LogFactory,com.p6spy.engine.outage.P6OutageFactory
|
||||||
|
# 自定义日志打印
|
||||||
|
logMessageFormat=com.baomidou.mybatisplus.extension.p6spy.P6SpyLogger
|
||||||
|
#日志输出到控制台
|
||||||
|
appender=com.baomidou.mybatisplus.extension.p6spy.StdoutLogger
|
||||||
|
# 使用日志系统记录 sql
|
||||||
|
#appender=com.p6spy.engine.spy.appender.Slf4JLogger
|
||||||
|
# 设置 p6spy driver 代理
|
||||||
|
deregisterdrivers=true
|
||||||
|
# 取消JDBC URL前缀
|
||||||
|
useprefix=true
|
||||||
|
# 配置记录 Log 例外,可去掉的结果集有error,info,batch,debug,statement,commit,rollback,result,resultset.
|
||||||
|
excludecategories=info,debug,result,batch,resultset
|
||||||
|
# 日期格式
|
||||||
|
dateformat=yyyy-MM-dd HH:mm:ss
|
||||||
|
# 实际驱动可多个
|
||||||
|
#driverlist=org.h2.Driver
|
||||||
|
# 是否开启慢SQL记录
|
||||||
|
outagedetection=true
|
||||||
|
# 慢SQL记录标准 2 秒
|
||||||
|
outagedetectioninterval=2
|
||||||
@@ -58,7 +58,7 @@ public class EntityGenerator {
|
|||||||
StrategyConfig strategy = new StrategyConfig();
|
StrategyConfig strategy = new StrategyConfig();
|
||||||
//strategy.setTablePrefix(new String[]{"_"});// 此处可以修改为您的表前缀
|
//strategy.setTablePrefix(new String[]{"_"});// 此处可以修改为您的表前缀
|
||||||
strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
|
strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
|
||||||
strategy.setInclude(new String[]{"store_goods_collect","store_spec","store_spec_goods_price","store_spec_item"});
|
strategy.setInclude(new String[]{"store_goods_cate"});
|
||||||
mpg.setStrategy(strategy);
|
mpg.setStrategy(strategy);
|
||||||
|
|
||||||
// 包配置
|
// 包配置
|
||||||
|
|||||||
@@ -438,4 +438,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user