GoodsImgs
This commit is contained in:
parent
f585ac2ed9
commit
418c0de76d
|
|
@ -1,12 +1,46 @@
|
|||
package com.ghy.goods.mapper;
|
||||
|
||||
import com.ghy.goods.domain.GoodsImgs;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author clunt
|
||||
* 商品图片mapper层
|
||||
*/
|
||||
public interface GoodsImgsMapper {
|
||||
|
||||
/**
|
||||
* 批量插入商品图片
|
||||
*
|
||||
* @param goodsImgs 商品图片信息
|
||||
* @return 成功条数
|
||||
*/
|
||||
int batchInsert(Collection<GoodsImgs> goodsImgs);
|
||||
|
||||
/**
|
||||
* 批量修改商品图片
|
||||
*
|
||||
* @param goodsImgs 商品图片信息
|
||||
* @return 成功条数
|
||||
*/
|
||||
int batchUpdate(Collection<GoodsImgs> goodsImgs);
|
||||
|
||||
/**
|
||||
* 批量删除商品图片
|
||||
*
|
||||
* @param ids 商品图片ID
|
||||
* @return 成功条数
|
||||
*/
|
||||
int delete(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 通过商品ID查询图片
|
||||
*
|
||||
* @param goodsId 商品ID
|
||||
* @return 商品的所有图片信息
|
||||
*/
|
||||
List<GoodsImgs> selectByGoodsId(@Param("goodsId") Long goodsId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,21 @@
|
|||
package com.ghy.goods.service;
|
||||
|
||||
import com.ghy.goods.domain.GoodsImgs;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品图片接口
|
||||
*/
|
||||
public interface GoodsImgsService {
|
||||
|
||||
int batchInsert(Collection<GoodsImgs> goodsImgs);
|
||||
int batchUpdate(Collection<GoodsImgs> goodsImgs);
|
||||
|
||||
int delete(Collection<Long> ids);
|
||||
|
||||
List<GoodsImgs> selectByGoodsId(@NotNull Long goodsId);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,16 @@
|
|||
package com.ghy.goods.service.impl;
|
||||
|
||||
import com.ghy.goods.domain.GoodsImgs;
|
||||
import com.ghy.goods.mapper.GoodsImgsMapper;
|
||||
import com.ghy.goods.service.GoodsImgsService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author clunt
|
||||
|
|
@ -9,4 +18,30 @@ import org.springframework.stereotype.Service;
|
|||
*/
|
||||
@Service
|
||||
public class GoodsImgsServiceImpl implements GoodsImgsService {
|
||||
|
||||
@Resource
|
||||
GoodsImgsMapper goodsImgsMapper;
|
||||
|
||||
@Override
|
||||
public int batchInsert(Collection<GoodsImgs> goodsImgs) {
|
||||
if (CollectionUtils.isEmpty(goodsImgs)) return 0;
|
||||
return goodsImgsMapper.batchInsert(goodsImgs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchUpdate(Collection<GoodsImgs> goodsImgs) {
|
||||
if (CollectionUtils.isEmpty(goodsImgs)) return 0;
|
||||
return goodsImgsMapper.batchUpdate(goodsImgs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Collection<Long> ids) {
|
||||
if (CollectionUtils.isEmpty(ids)) return 0;
|
||||
return goodsImgsMapper.delete(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GoodsImgs> selectByGoodsId(@NotNull Long goodsId) {
|
||||
return goodsImgsMapper.selectByGoodsId(goodsId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
<?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">
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ghy.goods.mapper.GoodsImgsMapper">
|
||||
|
||||
<resultMap id="GoodsImgsResult" type="com.ghy.goods.domain.GoodsImgs">
|
||||
<result property="goodsImgsId" column="goods_imgs_id" />
|
||||
<result property="goodsId" column="goods_id" />
|
||||
<result property="imgUrl" column="img_url" />
|
||||
<result property="goodsImgsId" column="goods_imgs_id" />
|
||||
<result property="goodsId" column="goods_id" />
|
||||
<result property="imgUrl" column="img_url" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
|
|
@ -19,5 +18,51 @@
|
|||
FROM goods_imgs
|
||||
</sql>
|
||||
|
||||
<delete id="delete">
|
||||
DELETE FROM goods_imgs WHERE goods_imgs_id IN
|
||||
<foreach collection="array" item="goodsImgsId" open="(" separator="," close=")">
|
||||
#{goodsImgsId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="selectByGoodsId" resultType="com.ghy.goods.domain.GoodsImgs">
|
||||
<include refid="selectGoodsImgs"/>
|
||||
<where>
|
||||
<if test="goodsId != null and goodsId != 0">
|
||||
AND goods_id = #{goodsId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<insert id="batchInsert" parameterType="com.ghy.goods.domain.GoodsImgs" useGeneratedKeys="true" keyProperty="goodsImgsId">
|
||||
<foreach collection="array" item="goodsImgs">
|
||||
INSERT INTO goods_imgs(
|
||||
<if test="goodsImgsId != null and goodsImgsId != 0">goods_imgs_id,</if>
|
||||
<if test="goodsId != null and goodsId != 0">goods_id,</if>
|
||||
<if test="imgUrl != null and imgUrl != ''">img_url,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
create_time)
|
||||
VALUES(
|
||||
<if test="goodsImgsId != null and goodsImgsId != 0">#{goodsImgsId},</if>
|
||||
<if test="goodsId != null and goodsId != 0">#{goodsId},</if>
|
||||
<if test="imgUrl != null and imgUrl != ''">#{imgUrl},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
sysdate());
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<update id="batchUpdate" parameterType="com.ghy.goods.domain.GoodsImgs">
|
||||
<foreach collection="array" item="goodsImgs">
|
||||
UPDATE goods_imgs
|
||||
<set>
|
||||
<if test="goodsId != null and goodsId != ''">goods_id = #{goodsId},</if>
|
||||
<if test="imgUrl != null and imgUrl != ''">img_url = #{imgUrl},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
WHERE goods_imgs_id = #{goodsImgsId};
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue