| | |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.doumee.dao.business.model.Brand; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author æ±è¹è¹ |
| | | * @date 2023/05/12 13:58 |
| | | */ |
| | | public interface BrandMapper extends BaseMapper<Brand> { |
| | | |
| | | List<Brand> selectListByConditon(Brand paramBrand); |
| | | } |
| | |
| | | package com.doumee.dao.business; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Constants; |
| | | import com.doumee.dao.business.model.Goods; |
| | | import com.doumee.dao.business.model.dto.GoodsRequest; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.apache.ibatis.annotations.Select; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author æ±è¹è¹ |
| | | * @date 2023/05/12 13:58 |
| | | */ |
| | | public interface GoodsMapper extends BaseMapper<Goods> { |
| | | |
| | | |
| | | List<Goods> selectListByCollection(Goods paramGoods); |
| | | } |
| | |
| | | queryWrapper.leftJoin(Category.class, Category::getId, Goods::getCategoryId); |
| | | queryWrapper.leftJoin(Brand.class, Brand::getId, Goods::getBrandId); |
| | | queryWrapper.eq(Goods::getStatus,Constants.ZERO); |
| | | queryWrapper.eq(Goods::getCompanyId, goods.getCompanyId()); |
| | | queryWrapper.eq(Goods::getIsdeleted,Constants.ZERO); |
| | | queryWrapper.like(StringUtils.isNotBlank(goods.getAttrFirstIds()),Goods::getAttrFirstIds,goods.getAttrFirstIds()); |
| | | queryWrapper.like(StringUtils.isNotBlank(goods.getAttrFirstNames()),Goods::getAttrFirstNames,goods.getAttrFirstNames()); |
| | |
| | | queryWrapper.between(!Objects.isNull(goods.getSPrice())&&!Objects.isNull(goods.getEPrice()), |
| | | Goods::getPrice,goods.getSPrice(),goods.getEPrice()); |
| | | queryWrapper.orderByDesc(Goods::getId); |
| | | List<Goods> goodsList = goodsJoinMapper.selectJoinList(Goods.class,queryWrapper); |
| | | List<Goods> goodsList = this.goodsMapper.selectListByCollection(goods); |
| | | // List<Goods> goodsList = goodsJoinMapper.selectJoinList(Goods.class,queryWrapper); |
| | | if(!Objects.isNull(goodsList)&&goodsList.size()>Constants.ZERO){ |
| | | this.dealGoodsMsg(goodsList); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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.doumee.dao.business.BrandMapper"> |
| | | |
| | | |
| | | <select id="selectListByConditon" parameterType="com.doumee.dao.business.model.Brand" resultType="com.doumee.dao.business.model.Brand"> |
| | | |
| | | select aal.id, aal.NAME,aal.type,aal.sortnum |
| | | FROM ( |
| | | SELECT id, NAME,type,sortnum |
| | | FROM `brand` |
| | | <where> |
| | | <if test="isdeleted!=null and isdeleted!=''">and isdeleted = #{isdeleted} |
| | | </if> |
| | | <choose> |
| | | <when test="type!=null and type =='0'.toString()"> |
| | | and type=1 |
| | | </when> |
| | | <otherwise> |
| | | <if test="categoryId!=null and categoryId!=''"> |
| | | AND EXISTS( |
| | | SELECT g.id |
| | | FROM goods g |
| | | WHERE g.brand_id = brand.id |
| | | AND g.category_id = #{categoryId} |
| | | AND g.COMPANY_ID = #{companyId} |
| | | AND g.STATUS = 0 |
| | | AND g.ISDELETED = 0 |
| | | ) |
| | | AND company_id = #{companyId} |
| | | </if> |
| | | </otherwise> |
| | | </choose> |
| | | </where> |
| | | UNION all |
| | | |
| | | SELECT id,NAME,type,sortnum |
| | | FROM `brand` |
| | | <where> |
| | | <if test="isdeleted!=null and isdeleted!=''"> |
| | | and isdeleted = #{isdeleted} |
| | | </if> |
| | | <choose> |
| | | <when test="type!=null and type =='0'.toString()"> |
| | | and type=1 |
| | | </when> |
| | | <otherwise> |
| | | <if test="categoryId!=null and categoryId!=''"> |
| | | AND EXISTS( |
| | | SELECT g.id |
| | | FROM goods g |
| | | WHERE g.brand_id = brand.id |
| | | AND g.category_id = #{categoryId} |
| | | AND g.COMPANY_ID = #{companyId} |
| | | AND g.STATUS = 0 |
| | | AND g.ISDELETED = 0 |
| | | ) |
| | | AND type = 1 AND company_id is NULL |
| | | </if> |
| | | </otherwise> |
| | | </choose> |
| | | </where> |
| | | ) aal |
| | | ORDER BY |
| | | aal.type ASC, |
| | | aal.sortnum ASC |
| | | </select> |
| | | </mapper> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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.doumee.dao.business.GoodsMapper"> |
| | | |
| | | |
| | | <resultMap id="BaseResultMap" type="com.doumee.dao.business.model.Goods"> |
| | | <id property="id" column="id"/> |
| | | <collection property="goodsParamList" ofType="com.doumee.dao.business.model.GoodsParam" |
| | | select="selectParamByGoodsId" column="{goodsId=id}" |
| | | > |
| | | |
| | | </collection> |
| | | |
| | | </resultMap> |
| | | <select id="selectParamByGoodsId" resultType="com.doumee.dao.business.model.GoodsParam"> |
| | | SELECT gp.GOODS_ID FROM cate_param_select cps , goods_param gp |
| | | where gp.PRAMA_ID = cps.PARAM_ID and gp.VAL = cps.`NAME` |
| | | and gp.GOODS_ID =#{goodsId} |
| | | </select> |
| | | |
| | | <select id="selectListByCollection1" parameterType="com.doumee.dao.business.model.Goods" resultType="com.doumee.dao.business.model.Goods"> |
| | | SELECT |
| | | t.id, |
| | | t.creator, |
| | | t.create_date, |
| | | t.editor, |
| | | t.edit_date, |
| | | t.isdeleted, |
| | | t.remark, |
| | | t.company_id, |
| | | t.NAME, |
| | | t.STATUS, |
| | | t.sortnum, |
| | | t.imgurl, |
| | | t.category_id, |
| | | t.brand_id, |
| | | t.zd_price, |
| | | t.price, |
| | | t.content, |
| | | |
| | | t.attr_secod_ids, |
| | | t.attr_first_names, |
| | | t.attr_secod_names, |
| | | t.pinyin, |
| | | t.short_pinyin, |
| | | t.goods_id, |
| | | t.type, |
| | | t.categoryName, |
| | | t.brandName, |
| | | t.attrFirst, |
| | | t.attrSecond, |
| | | t.categoryImgurl, |
| | | t.attr_first_ids |
| | | FROM |
| | | `zhuboshoplist` t |
| | | WHERE |
| | | t.STATUS = 0 |
| | | <if test="companyId!=null and companyId!=''"> |
| | | AND t.company_id =#{companyId} |
| | | </if> |
| | | <if test="brandId!=null and brandId!=''"> |
| | | AND t.brand_id =#{brandId} |
| | | </if> |
| | | <if test="categoryId!=null and categoryId!=''"> |
| | | AND t.CATEGORY_ID =#{categoryId} |
| | | </if> |
| | | AND t.isdeleted = 0 |
| | | ORDER BY |
| | | t.id DESC |
| | | </select> |
| | | |
| | | |
| | | <select id="selectListByCollection" parameterType="com.doumee.dao.business.model.Goods" resultType="com.doumee.dao.business.model.Goods"> |
| | | SELECT |
| | | t.id, |
| | | t.creator, |
| | | t.create_date, |
| | | t.editor, |
| | | t.edit_date, |
| | | t.isdeleted, |
| | | t.remark, |
| | | t.company_id, |
| | | t.NAME, |
| | | t.STATUS, |
| | | t.sortnum, |
| | | t.imgurl, |
| | | t.category_id, |
| | | t.brand_id, |
| | | t.zd_price, |
| | | t.price, |
| | | t.content, |
| | | |
| | | t.attr_secod_ids, |
| | | t.attr_first_names, |
| | | t.attr_secod_names, |
| | | t.pinyin, |
| | | t.short_pinyin, |
| | | t.goods_id, |
| | | t.type, |
| | | t1.NAME AS categoryName, |
| | | t2.NAME AS brandName, |
| | | t1.attr_first AS attrFirst, |
| | | t1.attr_second AS attrSecond, |
| | | t1.imgurl AS categoryImgurl, |
| | | ( |
| | | SELECT IFNULL(GROUP_CONCAT(cps.id),"" ) FROM cate_param_select cps , goods_param gp |
| | | where gp.PRAMA_ID = cps.PARAM_ID and gp.VAL = cps.`NAME` |
| | | and gp.GOODS_ID =t.id |
| | | ) as attr_first_ids |
| | | FROM |
| | | `goods` t |
| | | LEFT JOIN `category` t1 ON ( t1.id = t.category_id ) |
| | | LEFT JOIN `brand` t2 ON ( t2.id = t.brand_id ) |
| | | WHERE |
| | | t.STATUS = 0 |
| | | <if test="companyId!=null and companyId!=''"> |
| | | AND t.company_id =#{companyId} |
| | | </if> |
| | | <if test="brandId!=null and brandId!=''"> |
| | | AND t.brand_id =#{brandId} |
| | | </if> |
| | | <if test="categoryId!=null and categoryId!=''"> |
| | | AND t.CATEGORY_ID =#{categoryId} |
| | | </if> |
| | | AND t.isdeleted = 0 |
| | | ORDER BY |
| | | t.id DESC |
| | | </select> |
| | | |
| | | |
| | | </mapper> |