商品管理幻灯图片更换实现

<?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.java1234.mapper.ProductMapper">

    <resultMap id="productResult" type="com.java1234.entity.Product">
        <association property="type" column="typeId" select="com.java1234.mapper.SmallTypeMapper.findById"></association>
    </resultMap>

    <select id="list" parameterType="Map" resultMap="productResult">
        select * from t_product
        <where>
            <if test="name!=null and name!='' ">
                and name like concat('%',#{name},'%')
            </if>
        </where>
        <if test="start!=null and pageSize!=null ">
            limit #{start},#{pageSize}
        </if>
    </select>

    <select id="getTotal" parameterType="Map" resultType="Long">
        select count(*) from t_product
        <where>
            <if test="name!=null and name!='' ">
                and name like concat('%',#{name},'%')
            </if>
        </where>
    </select>

    <insert id="add" parameterType="com.java1234.entity.Product">
        insert into t_product values(null,#{name},#{price},#{stock},#{proPic},#{hot},#{swiper},#{swiperPic},#{swiperSort},#{type.id},null,#{productIntroImgs},#{productParaImgs},#{description});
    </insert>

    <update id="update" parameterType="com.java1234.entity.Product">
        update t_product
        <set>
            <if test="name!=null and name!=''">
                name=#{name},
            </if>
            <if test="price!=null">
                price=#{price},
            </if>
            <if test="stock!=null">
                stock=#{stock},
            </if>
            <if test="type!=null and type.id!=null">
                typeId=#{type.id},
            </if>
            <if test="proPic!=null and proPic!=''">
                proPic=#{proPic},
            </if>
            <if test="description!=null and description!=''">
                description=#{description},
            </if>
            <if test="productIntroImgs!=null and productIntroImgs!=''">
                productIntroImgs=#{productIntroImgs},
            </if>
            <if test="productParaImgs!=null and productParaImgs!=''">
                productParaImgs=#{productParaImgs},
            </if>
            <if test="swiperPic!=null and swiperPic!=''">
                swiperPic=#{swiperPic},
            </if>
            <if test="swiperSort!=null">
                swiperSort=#{swiperSort},
            </if>
        </set>
        where id=#{id}
    </update>

    <select id="findById" parameterType="Integer" resultMap="productResult">
        select * from t_product where id=#{id}
    </select>

</mapper>
package com.java1234.controller.admin;

import com.java1234.entity.*;
import com.java1234.service.IProductService;
import com.java1234.util.DateUtil;
import org.apache.commons.io.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 管理端-商品Controller控制器
 * @author java1234_小锋
 * @site www.java1234.com
 * @company 南通小锋网络科技有限公司
 * @create 2022-02-14 6:54
 */
@RestController
@RequestMapping("/admin/product")
public class AdminProductController {
   


    @Autowired
    private IProductService productService;

    @Value("${productImagesFilePath}")
    private String productImagesFilePath;


    @Value("${swiperImagesFilePath}")
    private String swiperImagesFilePath;
    /**
     * 根据条件分页查询
     * @param pageBean
     * @return
     */
    @RequestMapping("/list")
    public R list(@RequestBody PageBean pageBean){
   
        System.out.println(pageBean);
        Map<String,Object> map=new HashMap<>();
        map.put("name",pageBean.getQuery().trim());
        map.put("start",pageBean.getStart());
        map.put("pageSize",pageBean.getPageSize());
        List<Product> productList = productService.list(map);
        Long total = productService.getTotal(map);

        Map<<

你可能感兴趣的:(分布式小程序电商,java)