فهرست منبع

农品交易模块

zmj 9 ماه پیش
والد
کامیت
ccf2f70da6

+ 105 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/controller/ProductInfoController.java

@@ -0,0 +1,105 @@
+package com.ruoyi.base.controller;
+
+import java.util.List;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.ruoyi.common.log.annotation.Log;
+import com.ruoyi.common.log.enums.BusinessType;
+import com.ruoyi.common.security.annotation.RequiresPermissions;
+import com.ruoyi.base.domain.ProductInfo;
+import com.ruoyi.base.service.IProductInfoService;
+import com.ruoyi.common.core.web.controller.BaseController;
+import com.ruoyi.common.core.web.domain.AjaxResult;
+import com.ruoyi.common.core.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.web.page.TableDataInfo;
+
+/**
+ * 交易信息Controller
+ *
+ * @author zmj
+ * @date 2025-08-21
+ */
+@RestController
+@RequestMapping("/productInfo")
+public class ProductInfoController extends BaseController
+{
+    @Autowired
+    private IProductInfoService productInfoService;
+
+    /**
+     * 查询交易信息列表
+     */
+    @RequiresPermissions("base:productInfo:list")
+    @GetMapping("/list")
+    public TableDataInfo list(ProductInfo productInfo)
+    {
+        startPage();
+        List<ProductInfo> list = productInfoService.selectProductInfoList(productInfo);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出交易信息列表
+     */
+    @RequiresPermissions("base:productInfo:export")
+    @Log(title = "交易信息", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, ProductInfo productInfo)
+    {
+        List<ProductInfo> list = productInfoService.selectProductInfoList(productInfo);
+        ExcelUtil<ProductInfo> util = new ExcelUtil<ProductInfo>(ProductInfo.class);
+        util.exportExcel(response, list, "交易信息数据");
+    }
+
+    /**
+     * 获取交易信息详细信息
+     */
+    @RequiresPermissions("base:productInfo:query")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") String id)
+    {
+        return success(productInfoService.selectProductInfoById(id));
+    }
+
+    /**
+     * 新增交易信息
+     */
+    @RequiresPermissions("base:productInfo:add")
+    @Log(title = "交易信息", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody ProductInfo productInfo)
+    {
+        return toAjax(productInfoService.insertProductInfo(productInfo));
+    }
+
+    /**
+     * 修改交易信息
+     */
+    @RequiresPermissions("base:productInfo:edit")
+    @Log(title = "交易信息", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody ProductInfo productInfo)
+    {
+        return toAjax(productInfoService.updateProductInfo(productInfo));
+    }
+
+    /**
+     * 删除交易信息
+     */
+    @RequiresPermissions("base:productInfo:remove")
+    @Log(title = "交易信息", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable String[] ids)
+    {
+        return toAjax(productInfoService.deleteProductInfoByIds(ids));
+    }
+}

+ 285 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/domain/ProductInfo.java

@@ -0,0 +1,285 @@
+package com.ruoyi.base.domain;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.ruoyi.common.core.annotation.Excel;
+import com.ruoyi.common.core.web.domain.BaseEntity;
+
+/**
+ * 交易信息对象 product_info
+ *
+ * @author zmj
+ * @date 2025-08-21
+ */
+public class ProductInfo extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /**  */
+    private String id;
+
+    /** 发布者ID */
+    @Excel(name = "发布者ID")
+    private String userId;
+
+    /** 农品分类:0-未知,1-水果,2-蔬菜,3-粮食,4-畜产品,5-水产品,6-中药材 */
+    @Excel(name = "农品分类:0-未知,1-水果,2-蔬菜,3-粮食,4-畜产品,5-水产品,6-中药材")
+    private String categoryId;
+
+    /** 类型:0-销售, 1-收购 */
+    @Excel(name = "类型:0-销售, 1-收购")
+    private Long type;
+
+    /** 标题 */
+    @Excel(name = "标题")
+    private String title;
+
+    /** 产品详细描述/补充说明 */
+    @Excel(name = "产品详细描述/补充说明")
+    private String description;
+
+    /** 价格/预算 */
+    @Excel(name = "价格/预算")
+    private String price;
+
+    /** 数量 */
+    @Excel(name = "数量")
+    private BigDecimal quantity;
+
+    /** 单位:0-斤,1-公斤,2-吨,3-只,4-头,5-尾 */
+    @Excel(name = "单位:0-斤,1-公斤,2-吨,3-只,4-头,5-尾")
+    private Long unit;
+
+    /** 所在地 */
+    @Excel(name = "所在地")
+    private String location;
+
+    /** 图片URL */
+    @Excel(name = "图片URL")
+    private String imageUrl;
+
+    /** 状态:0-未知,1-审核中,2-已上架,3-已下架 */
+    @Excel(name = "状态:0-未知,1-审核中,2-已上架,3-已下架")
+    private Long status;
+
+    /** 联系人ID */
+    @Excel(name = "联系人ID")
+    private String contactId;
+
+    /** 联系人 */
+    @Excel(name = "联系人")
+    private String contactName;
+
+    /** 联系电话 */
+    @Excel(name = "联系电话")
+    private String contactPhone;
+
+    /** 省市区信息 */
+    @Excel(name = "省市区信息")
+    private String cityInfo;
+
+    /** 发布时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "发布时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date publishTime;
+
+    public void setId(String id)
+    {
+        this.id = id;
+    }
+
+    public String getId()
+    {
+        return id;
+    }
+
+    public void setUserId(String userId)
+    {
+        this.userId = userId;
+    }
+
+    public String getUserId()
+    {
+        return userId;
+    }
+
+    public void setCategoryId(String categoryId)
+    {
+        this.categoryId = categoryId;
+    }
+
+    public String getCategoryId()
+    {
+        return categoryId;
+    }
+
+    public void setType(Long type)
+    {
+        this.type = type;
+    }
+
+    public Long getType()
+    {
+        return type;
+    }
+
+    public void setTitle(String title)
+    {
+        this.title = title;
+    }
+
+    public String getTitle()
+    {
+        return title;
+    }
+
+    public void setDescription(String description)
+    {
+        this.description = description;
+    }
+
+    public String getDescription()
+    {
+        return description;
+    }
+
+    public void setPrice(String price)
+    {
+        this.price = price;
+    }
+
+    public String getPrice()
+    {
+        return price;
+    }
+
+    public void setQuantity(BigDecimal quantity)
+    {
+        this.quantity = quantity;
+    }
+
+    public BigDecimal getQuantity()
+    {
+        return quantity;
+    }
+
+    public void setUnit(Long unit)
+    {
+        this.unit = unit;
+    }
+
+    public Long getUnit()
+    {
+        return unit;
+    }
+
+    public void setLocation(String location)
+    {
+        this.location = location;
+    }
+
+    public String getLocation()
+    {
+        return location;
+    }
+
+    public void setImageUrl(String imageUrl)
+    {
+        this.imageUrl = imageUrl;
+    }
+
+    public String getImageUrl()
+    {
+        return imageUrl;
+    }
+
+    public void setStatus(Long status)
+    {
+        this.status = status;
+    }
+
+    public Long getStatus()
+    {
+        return status;
+    }
+
+    public void setContactId(String contactId)
+    {
+        this.contactId = contactId;
+    }
+
+    public String getContactId()
+    {
+        return contactId;
+    }
+
+    public void setContactName(String contactName)
+    {
+        this.contactName = contactName;
+    }
+
+    public String getContactName()
+    {
+        return contactName;
+    }
+
+    public void setContactPhone(String contactPhone)
+    {
+        this.contactPhone = contactPhone;
+    }
+
+    public String getContactPhone()
+    {
+        return contactPhone;
+    }
+
+    public void setCityInfo(String cityInfo)
+    {
+        this.cityInfo = cityInfo;
+    }
+
+    public String getCityInfo()
+    {
+        return cityInfo;
+    }
+
+    public void setPublishTime(Date publishTime)
+    {
+        this.publishTime = publishTime;
+    }
+
+    public Date getPublishTime()
+    {
+        return publishTime;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("id", getId())
+            .append("userId", getUserId())
+            .append("categoryId", getCategoryId())
+            .append("type", getType())
+            .append("title", getTitle())
+            .append("description", getDescription())
+            .append("price", getPrice())
+            .append("quantity", getQuantity())
+            .append("unit", getUnit())
+            .append("location", getLocation())
+            .append("imageUrl", getImageUrl())
+            .append("status", getStatus())
+            .append("contactId", getContactId())
+            .append("contactName", getContactName())
+            .append("contactPhone", getContactPhone())
+            .append("cityInfo", getCityInfo())
+            .append("publishTime", getPublishTime())
+            .append("createBy", getCreateBy())
+            .append("createTime", getCreateTime())
+            .append("updateBy", getUpdateBy())
+            .append("updateTime", getUpdateTime())
+            .toString();
+    }
+}

+ 61 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/mapper/ProductInfoMapper.java

@@ -0,0 +1,61 @@
+package com.ruoyi.base.mapper;
+
+import java.util.List;
+import com.ruoyi.base.domain.ProductInfo;
+
+/**
+ * 交易信息Mapper接口
+ *
+ * @author zmj
+ * @date 2025-08-21
+ */
+public interface ProductInfoMapper
+{
+    /**
+     * 查询交易信息
+     *
+     * @param id 交易信息主键
+     * @return 交易信息
+     */
+    public ProductInfo selectProductInfoById(String id);
+
+    /**
+     * 查询交易信息列表
+     *
+     * @param productInfo 交易信息
+     * @return 交易信息集合
+     */
+    public List<ProductInfo> selectProductInfoList(ProductInfo productInfo);
+
+    /**
+     * 新增交易信息
+     *
+     * @param productInfo 交易信息
+     * @return 结果
+     */
+    public int insertProductInfo(ProductInfo productInfo);
+
+    /**
+     * 修改交易信息
+     *
+     * @param productInfo 交易信息
+     * @return 结果
+     */
+    public int updateProductInfo(ProductInfo productInfo);
+
+    /**
+     * 删除交易信息
+     *
+     * @param id 交易信息主键
+     * @return 结果
+     */
+    public int deleteProductInfoById(String id);
+
+    /**
+     * 批量删除交易信息
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteProductInfoByIds(String[] ids);
+}

+ 96 - 0
ruoyi-modules/ruoyi-base/src/main/java/com/ruoyi/base/service/impl/ProductInfoServiceImpl.java

@@ -0,0 +1,96 @@
+package com.ruoyi.base.service.impl;
+
+import java.util.List;
+import com.ruoyi.common.core.utils.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.ruoyi.base.mapper.ProductInfoMapper;
+import com.ruoyi.base.domain.ProductInfo;
+import com.ruoyi.base.service.IProductInfoService;
+
+/**
+ * 交易信息Service业务层处理
+ *
+ * @author zmj
+ * @date 2025-08-21
+ */
+@Service
+public class ProductInfoServiceImpl implements IProductInfoService
+{
+    @Autowired
+    private ProductInfoMapper productInfoMapper;
+
+    /**
+     * 查询交易信息
+     *
+     * @param id 交易信息主键
+     * @return 交易信息
+     */
+    @Override
+    public ProductInfo selectProductInfoById(String id)
+    {
+        return productInfoMapper.selectProductInfoById(id);
+    }
+
+    /**
+     * 查询交易信息列表
+     *
+     * @param productInfo 交易信息
+     * @return 交易信息
+     */
+    @Override
+    public List<ProductInfo> selectProductInfoList(ProductInfo productInfo)
+    {
+        return productInfoMapper.selectProductInfoList(productInfo);
+    }
+
+    /**
+     * 新增交易信息
+     *
+     * @param productInfo 交易信息
+     * @return 结果
+     */
+    @Override
+    public int insertProductInfo(ProductInfo productInfo)
+    {
+        productInfo.setCreateTime(DateUtils.getNowDate());
+        return productInfoMapper.insertProductInfo(productInfo);
+    }
+
+    /**
+     * 修改交易信息
+     *
+     * @param productInfo 交易信息
+     * @return 结果
+     */
+    @Override
+    public int updateProductInfo(ProductInfo productInfo)
+    {
+        productInfo.setUpdateTime(DateUtils.getNowDate());
+        return productInfoMapper.updateProductInfo(productInfo);
+    }
+
+    /**
+     * 批量删除交易信息
+     *
+     * @param ids 需要删除的交易信息主键
+     * @return 结果
+     */
+    @Override
+    public int deleteProductInfoByIds(String[] ids)
+    {
+        return productInfoMapper.deleteProductInfoByIds(ids);
+    }
+
+    /**
+     * 删除交易信息信息
+     *
+     * @param id 交易信息主键
+     * @return 结果
+     */
+    @Override
+    public int deleteProductInfoById(String id)
+    {
+        return productInfoMapper.deleteProductInfoById(id);
+    }
+}

+ 151 - 0
ruoyi-modules/ruoyi-base/src/main/resources/mapper/base/ProductInfoMapper.xml

@@ -0,0 +1,151 @@
+<?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.base.mapper.ProductInfoMapper">
+
+    <resultMap type="ProductInfo" id="ProductInfoResult">
+        <result property="id"    column="id"    />
+        <result property="userId"    column="user_id"    />
+        <result property="categoryId"    column="category_id"    />
+        <result property="type"    column="type"    />
+        <result property="title"    column="title"    />
+        <result property="description"    column="description"    />
+        <result property="price"    column="price"    />
+        <result property="quantity"    column="quantity"    />
+        <result property="unit"    column="unit"    />
+        <result property="location"    column="location"    />
+        <result property="imageUrl"    column="image_url"    />
+        <result property="status"    column="status"    />
+        <result property="contactId"    column="contact_id"    />
+        <result property="contactName"    column="contact_name"    />
+        <result property="contactPhone"    column="contact_phone"    />
+        <result property="cityInfo"    column="city_info"    />
+        <result property="publishTime"    column="publish_time"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="remark"    column="remark"    />
+    </resultMap>
+
+    <sql id="selectProductInfoVo">
+        select id, user_id, category_id, type, title, description, price, quantity, unit, location, image_url, status, contact_id, contact_name, contact_phone, city_info, publish_time, create_by, create_time, update_by, update_time,remark from product_info
+    </sql>
+
+    <select id="selectProductInfoList" parameterType="ProductInfo" resultMap="ProductInfoResult">
+        <include refid="selectProductInfoVo"/>
+        <where>
+            <if test="userId != null  and userId != ''"> and user_id = #{userId}</if>
+            <if test="categoryId != null  and categoryId != ''"> and category_id = #{categoryId}</if>
+            <if test="type != null "> and type = #{type}</if>
+            <if test="title != null  and title != ''"> and title = #{title}</if>
+            <if test="description != null  and description != ''"> and description = #{description}</if>
+            <if test="price != null  and price != ''"> and price = #{price}</if>
+            <if test="quantity != null "> and quantity = #{quantity}</if>
+            <if test="unit != null "> and unit = #{unit}</if>
+            <if test="location != null  and location != ''"> and location = #{location}</if>
+            <if test="imageUrl != null  and imageUrl != ''"> and image_url = #{imageUrl}</if>
+            <if test="status != null "> and status = #{status}</if>
+            <if test="contactId != null  and contactId != ''"> and contact_id = #{contactId}</if>
+            <if test="contactName != null  and contactName != ''"> and contact_name like concat('%', #{contactName}, '%')</if>
+            <if test="contactPhone != null  and contactPhone != ''"> and contact_phone = #{contactPhone}</if>
+            <if test="cityInfo != null  and cityInfo != ''"> and city_info = #{cityInfo}</if>
+            <if test="publishTime != null "> and publish_time = #{publishTime}</if>
+        </where>
+    </select>
+
+    <select id="selectProductInfoById" parameterType="String" resultMap="ProductInfoResult">
+        <include refid="selectProductInfoVo"/>
+        where id = #{id}
+    </select>
+
+    <insert id="insertProductInfo" parameterType="ProductInfo" useGeneratedKeys="true" keyProperty="id">
+        insert into product_info
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="userId != null and userId != ''">user_id,</if>
+            <if test="categoryId != null and categoryId != ''">category_id,</if>
+            <if test="type != null">type,</if>
+            <if test="title != null and title != ''">title,</if>
+            <if test="description != null">description,</if>
+            <if test="price != null and price != ''">price,</if>
+            <if test="quantity != null">quantity,</if>
+            <if test="unit != null">unit,</if>
+            <if test="location != null">location,</if>
+            <if test="imageUrl != null and imageUrl != ''">image_url,</if>
+            <if test="status != null">status,</if>
+            <if test="contactId != null and contactId != ''">contact_id,</if>
+            <if test="contactName != null and contactName != ''">contact_name,</if>
+            <if test="contactPhone != null and contactPhone != ''">contact_phone,</if>
+            <if test="cityInfo != null">city_info,</if>
+            <if test="publishTime != null">publish_time,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateBy != null">update_by,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="remark != null">remark,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="userId != null and userId != ''">#{userId},</if>
+            <if test="categoryId != null and categoryId != ''">#{categoryId},</if>
+            <if test="type != null">#{type},</if>
+            <if test="title != null and title != ''">#{title},</if>
+            <if test="description != null">#{description},</if>
+            <if test="price != null and price != ''">#{price},</if>
+            <if test="quantity != null">#{quantity},</if>
+            <if test="unit != null">#{unit},</if>
+            <if test="location != null">#{location},</if>
+            <if test="imageUrl != null and imageUrl != ''">#{imageUrl},</if>
+            <if test="status != null">#{status},</if>
+            <if test="contactId != null and contactId != ''">#{contactId},</if>
+            <if test="contactName != null and contactName != ''">#{contactName},</if>
+            <if test="contactPhone != null and contactPhone != ''">#{contactPhone},</if>
+            <if test="cityInfo != null">#{cityInfo},</if>
+            <if test="publishTime != null">#{publishTime},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="remark != null">#{remark},</if>
+         </trim>
+    </insert>
+
+    <update id="updateProductInfo" parameterType="ProductInfo">
+        update product_info
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="userId != null and userId != ''">user_id = #{userId},</if>
+            <if test="categoryId != null and categoryId != ''">category_id = #{categoryId},</if>
+            <if test="type != null">type = #{type},</if>
+            <if test="title != null and title != ''">title = #{title},</if>
+            <if test="description != null">description = #{description},</if>
+            <if test="price != null and price != ''">price = #{price},</if>
+            <if test="quantity != null">quantity = #{quantity},</if>
+            <if test="unit != null">unit = #{unit},</if>
+            <if test="location != null">location = #{location},</if>
+            <if test="imageUrl != null and imageUrl != ''">image_url = #{imageUrl},</if>
+            <if test="status != null">status = #{status},</if>
+            <if test="contactId != null and contactId != ''">contact_id = #{contactId},</if>
+            <if test="contactName != null and contactName != ''">contact_name = #{contactName},</if>
+            <if test="contactPhone != null and contactPhone != ''">contact_phone = #{contactPhone},</if>
+            <if test="cityInfo != null">city_info = #{cityInfo},</if>
+            <if test="publishTime != null">publish_time = #{publishTime},</if>
+            <if test="createBy != null">create_by = #{createBy},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="remark != null">remark = #{remark},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteProductInfoById" parameterType="String">
+        delete from product_info where id = #{id}
+    </delete>
+
+    <delete id="deleteProductInfoByIds" parameterType="String">
+        delete from product_info where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>