This commit is contained in:
dzc committed 2025-04-02 20:20:36 +08:00
1 parent 7e0a1f96f3
commit 529c7cda9d
6 files changed
+74 -8

No files matched your search

@@ -3,7 +3,11 @@ package com.bsd.pjcloud.hard.api.dto.spu;
import com.bsd.pjcloud.hard.api.entity.spu.HardSpuEntity;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public class HardSpuDto extends HardSpuEntity {
private LocalDateTime[] createTimeList;
}
@@ -6,4 +6,9 @@ import lombok.Data;
@Data
public class HardSpuVo extends HardSpuEntity {
/**
* 分类相关
*/
private String categoryName;
}
@@ -1,11 +1,17 @@
package com.bsd.pjcloud.hard.mapper.spu;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.hard.api.dto.spu.HardSpuDto;
import com.bsd.pjcloud.hard.api.entity.spu.HardSpuEntity;
import com.bsd.pjcloud.hard.api.vo.spu.HardSpuVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface HardSpuMapper extends PjcloudBaseMapper<HardSpuEntity> {
Page<HardSpuVo> scopPageJoin(Page page, @Param("dto") HardSpuDto dto, @Param("dataScope") DataScope dataScope);
}
@@ -39,8 +39,9 @@ public class HardSpuCategoryServiceImpl extends ServiceImpl<HardSpuCategoryMappe
*/
@Override
public Long create(HardSpuCategoryEntity entity) {
if (existName(entity)) {
throw new RuntimeException("分类名不能重复");
}
baseMapper.insert(entity);
return entity.getId();
}
@@ -50,7 +51,9 @@ public class HardSpuCategoryServiceImpl extends ServiceImpl<HardSpuCategoryMappe
*/
@Override
public Long edit(HardSpuCategoryEntity entity) {
if (existName(entity)) {
throw new RuntimeException("分类名不能重复");
}
baseMapper.updateById(entity);
return entity.getId();
}
@@ -60,7 +63,7 @@ public class HardSpuCategoryServiceImpl extends ServiceImpl<HardSpuCategoryMappe
*/
@Override
public void delByIds(ArrayList<Long> list) {
if (ObjectUtil.isEmpty(list)) return;
baseMapper.deleteByIds(list);
}
@@ -31,26 +31,39 @@ public class HardSpuServiceImpl extends ServiceImpl<HardSpuMapper, HardSpuEntity
*/
@Override
public Page<HardSpuVo> scopPageJoin(Page page, HardSpuDto dto, DataScope dataScope) {
return null;
return baseMapper.scopPageJoin(page, dto, dataScope);
}
/**
* 新增
*/
@Override
public Long create(HardSpuEntity entity) {
if (existName(entity)) {
throw new RuntimeException("商品名不能重复");
}
baseMapper.insert(entity);
return entity.getId();
}
/**
* 编辑
*/
@Override
public Long edit(HardSpuEntity entity) {
if (existName(entity)) {
throw new RuntimeException("商品名不能重复");
}
baseMapper.updateById(entity);
return entity.getId();
}
/**
* 删除
*/
@Override
public void delByIds(ArrayList<Long> list) {
if (ObjectUtil.isEmpty(list)) return;
baseMapper.deleteByIds(list);
}
@@ -19,4 +19,39 @@
<result property="delFlag" column="del_flag"/>
<result property="tenantId" column="tenant_id"/>
</resultMap>
<sql id="selectA">
select a.id,
a.spu_category_id,
a.name,
a.pic,
a.price,
a.sales_count,
a.repertory_count,
a.sort,
a.status,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
a.del_flag,
a.tenant_id,
</sql>
<sql id="whereA">
a.del_flag = '0'
<if test="dto.createTimeList != null and dto.createTimeList.length == 2">
and a.create_time between #{dto.createTimeList[0]} and #{dto.createTimeList[1]}
</if>
</sql>
<select id="scopPageJoin" resultType="com.bsd.pjcloud.hard.api.vo.spu.HardSpuVo">
<include refid="selectA"/>
c.name as categoryName
from hard_spu a
left join hard_spu_category c on c.id = a.spu_category_id
<where>
<include refid="whereA"/>
</where>
</select>
</mapper>