1. 获取代码:


添加博主微信获取,备注来源:


2. 项目描述


基于SSM框架开发的企业物流(快递)配送管理平台。


3.功能简介

杨校老师项目之基于SSM企业物流快递配送管理系统_java

4. 技术栈:


Jsp + SSM + MySQL + LayUI + Bootstrap


5. 运行环境


IntelliJ IDEA/Eclipse + MySQL5.7+ JDK1.8 + Maven3.5.4 + Tomcat9.0


6.前台界面

杨校老师项目之基于SSM企业物流快递配送管理系统_毕设项目_02

杨校老师项目之基于SSM企业物流快递配送管理系统_spring boot_03

杨校老师项目之基于SSM企业物流快递配送管理系统_企业物流管理系统_04

杨校老师项目之基于SSM企业物流快递配送管理系统_SSM物流快递_05

杨校老师项目之基于SSM企业物流快递配送管理系统_java_06

7. 后台界面

杨校老师项目之基于SSM企业物流快递配送管理系统_毕设项目_07

杨校老师项目之基于SSM企业物流快递配送管理系统_java_08

杨校老师项目之基于SSM企业物流快递配送管理系统_java_09

杨校老师项目之基于SSM企业物流快递配送管理系统_java_10

杨校老师项目之基于SSM企业物流快递配送管理系统_java_11

杨校老师项目之基于SSM企业物流快递配送管理系统_java_12

杨校老师项目之基于SSM企业物流快递配送管理系统_spring boot_13

杨校老师项目之基于SSM企业物流快递配送管理系统_毕设项目_14

杨校老师项目之基于SSM企业物流快递配送管理系统_企业物流管理系统_15

杨校老师项目之基于SSM企业物流快递配送管理系统_spring boot_16

杨校老师项目之基于SSM企业物流快递配送管理系统_企业物流管理系统_17

8. 代码展示

  • 8.1 货物的实体类
package cn.javabs.logistics.entity.common;

import java.math.BigDecimal;

import org.springframework.stereotype.Component;

import cn.javabs.logistics.entity.admin.Enterprise;
import cn.javabs.logistics.entity.admin.GoodsType;

/**
* 货物实体类
*
* @author Mryang
*
*/
@Component
public class Goods {

public static final int NAME_MAX_LENGTH = 18;// 名称最大长度
public static final int AMOUNT_MAX_VALUE = 1000000;// 可出售数量最大值
public static final int ADDRESS_MAX_LENGTH = 50;// 地址最大长度
public static final int SYNOPSIS_MAX_LENGTH = 50;// 简介最大长度

public static final int NOT_SELLING = 0;// 暂停售卖
public static final int IS_SELLING = 1;// 正在售卖

private Long id;// id
private String name;// 名称
private String number;// 编号
private Long goodsTypeId;// 货物类型id
private int amount;// 可出售数量
private int waitingQuantity = 0;// 待发货数量
private BigDecimal price;// 售价
private Long enterpriseId;// 企业id
private int status;// 状态
private String photo;// 图片
private String address;// 发货地址
private String synopsis;// 简介
private GoodsType goodsType;// 分类
private Enterprise enterprise;// 企业
private String details;// 详情

public String getDetails() {
return details;
}

public void setDetails(String details) {
this.details = details;
}

public Enterprise getEnterprise() {
return enterprise;
}

public void setEnterprise(Enterprise enterprise) {
this.enterprise = enterprise;
}

public GoodsType getGoodsType() {
return goodsType;
}

public void setGoodsType(GoodsType goodsType) {
this.goodsType = goodsType;
}

public String getSynopsis() {
return synopsis;
}

public void setSynopsis(String synopsis) {
this.synopsis = synopsis;
}

public String getPhoto() {
return photo;
}

public void setPhoto(String photo) {
this.photo = photo;
}

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getNumber() {
return number;
}

public void setNumber(String number) {
this.number = number;
}

public Long getGoodsTypeId() {
return goodsTypeId;
}

public void setGoodsTypeId(Long goodsTypeId) {
this.goodsTypeId = goodsTypeId;
}

public int getAmount() {
return amount;
}

public void setAmount(int amount) {
this.amount = amount;
}

public int getWaitingQuantity() {
return waitingQuantity;
}

public void setWaitingQuantity(int waitingQuantity) {
this.waitingQuantity = waitingQuantity;
}

public BigDecimal getPrice() {
return price;
}

public void setPrice(BigDecimal price) {
this.price = price;
}

public Long getEnterpriseId() {
return enterpriseId;
}

public void setEnterpriseId(Long enterpriseId) {
this.enterpriseId = enterpriseId;
}

public int getStatus() {
return status;
}

public void setStatus(int status) {
this.status = status;
}

public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}

@Override
public String toString() {
return "Goods [id=" + id + ", name=" + name + ", number=" + number + ", goodsTypeId=" + goodsTypeId
+ ", amount=" + amount + ", waitingQuantity=" + waitingQuantity + ", price=" + price + ", enterpriseId="
+ enterpriseId + ", status=" + status + ", photo=" + photo + ", address=" + address + ", synopsis="
+ synopsis + ", goodsType=" + goodsType + ", enterprise=" + enterprise + "]";
}

}
  • 8.2 货物的controller控制器
package cn.javabs.logistics.controller.admin;

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import cn.javabs.logistics.bean.LoginTypeEnum;
import cn.javabs.logistics.bean.PrefixEnum;
import cn.javabs.logistics.entity.admin.Enterprise;
import cn.javabs.logistics.entity.common.Goods;
import cn.javabs.logistics.page.admin.Page;
import cn.javabs.logistics.service.admin.EnterpriseService;
import cn.javabs.logistics.service.admin.GoodsTypeService;
import cn.javabs.logistics.service.common.GoodsService;
import cn.javabs.logistics.util.StringUtil;

import net.sf.json.JSONObject;

@Controller
@RequestMapping("/admin/goods")
public class GoodsController {

@Autowired
private GoodsService goodsService;

@Autowired
private GoodsTypeService goodsTypeService;

@Autowired
private EnterpriseService enterpriseService;

/**
* 列表页面
*
* @param model
* @return
*/
@RequestMapping(value = "/list", method = RequestMethod.GET)
public ModelAndView list(ModelAndView model, HttpServletRequest request) {
Map<String, Object> queryMap = new HashMap<String, Object>();
model.addObject("goodsTypeList", goodsTypeService.findList(queryMap));
Object loginType = request.getSession().getAttribute("loginType");
if ((Integer) loginType == LoginTypeEnum.ENTERPRISE.getCode()) {
Enterprise loginEnterprise = (Enterprise) request.getSession().getAttribute("admin");
Enterprise enterprise = enterpriseService.findById(loginEnterprise.getId());
model.addObject("address", enterprise.getAddress());
} else {
model.addObject("address", "");
}
model.setViewName("goods/list");
return model;
}

/**
* 获取列表
*
* @param page
* @param name
* @return
*/
@RequestMapping(value = "/list", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> getList(Page page, HttpServletRequest request,
@RequestParam(name = "name", required = false, defaultValue = "") String name,
@RequestParam(name = "number", required = false, defaultValue = "") String number,
@RequestParam(name = "goodsTypeId", required = false) Long goodsTypeId) {
Map<String, Object> ret = new HashMap<>();
Map<String, Object> queryMap = new HashMap<String, Object>();
Object loginType = request.getSession().getAttribute("loginType");
if ((Integer) loginType == LoginTypeEnum.ENTERPRISE.getCode()) {
Enterprise enterprise = (Enterprise) request.getSession().getAttribute("admin");
queryMap.put("enterpriseId", enterprise.getId());
}
queryMap.put("name", name);
queryMap.put("number", number);
queryMap.put("goodsTypeId", goodsTypeId);
queryMap.put("offset", page.getOffset());
queryMap.put("pageSize", page.getRows());
ret.put("rows", goodsService.findList(queryMap));
ret.put("total", goodsService.getTotal(queryMap));
return ret;
}

/**
* 添加货物
*
* @param goods
* @param request
* @return
*/
@RequestMapping(value = "/add", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> add(Goods goods, HttpServletRequest request) {
Map<String, String> ret = new HashMap<String, String>();
Object loginType = request.getSession().getAttribute("loginType");
if ((Integer) loginType != LoginTypeEnum.ENTERPRISE.getCode()) {
ret.put("type", "error");
ret.put("msg", "请登录企业用户!");
return ret;
}
if (judge(goods, ret)) {
return ret;
}
if (goods.getAmount() < 1 || goods.getAmount() > Goods.AMOUNT_MAX_VALUE) {
ret.put("type", "error");
ret.put("msg", "数量需在1~" + Goods.AMOUNT_MAX_VALUE + "之间!");
return ret;
}
Enterprise enterprise = (Enterprise) request.getSession().getAttribute("admin");
goods.setEnterpriseId(enterprise.getId());
String number = StringUtil.generateSn(PrefixEnum.GOODS.getValue());
goods.setNumber(number);
if (goodsService.add(goods) <= 0) {
ret.put("type", "error");
ret.put("msg", "添加失败!");
return ret;
}
ret.put("type", "success");
ret.put("msg", "添加成功!");
return ret;
}

/**
* 编辑
*
* @param goods
* @return
*/
@RequestMapping(value = "/edit", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> edit(Goods goods, HttpServletRequest request) {
Map<String, String> ret = new HashMap<String, String>();
Object loginType = request.getSession().getAttribute("loginType");
if ((Integer) loginType != LoginTypeEnum.ENTERPRISE.getCode()) {
ret.put("type", "error");
ret.put("msg", "请登录企业用户!");
return ret;
}
if (judge(goods, ret)) {
return ret;
}
if (goodsService.edit(goods) <= 0) {
ret.put("type", "error");
ret.put("msg", "编辑失败!");
return ret;
}
ret.put("type", "success");
ret.put("msg", "编辑成功!");
return ret;
}

/**
* 批量删除
*
* @param ids
* @return
*/
@RequestMapping(value = "/delete", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> delete(String ids) {
Map<String, String> ret = new HashMap<String, String>();
if (StringUtils.isEmpty(ids)) {
ret.put("type", "error");
ret.put("msg", "选择要删除的数据!");
return ret;
}
if (ids.contains(",")) {
ids = ids.substring(0, ids.length() - 1);
}
try {
if (goodsService.delete(ids) <= 0) {
ret.put("type", "error");
ret.put("msg", "删除失败!");
return ret;
}
} catch (Exception e) {
ret.put("type", "error");
ret.put("msg", "所选择数据中有数据存在关联数据,无法删除!");
return ret;
}

ret.put("type", "success");
ret.put("msg", "删除成功!");
return ret;
}

// 判断
private boolean judge(Goods goods, Map<String, String> ret) {
if (goods == null) {
ret.put("type", "error");
ret.put("msg", "请填写正确的信息!");
return true;
}
if (goods.getGoodsTypeId() == null) {
ret.put("type", "error");
ret.put("msg", "请选择分类!");
return true;
}
if (StringUtils.isEmpty(goods.getPhoto())) {
ret.put("type", "error");
ret.put("msg", "请上传货物图片!");
return true;
}
if (StringUtils.isEmpty(goods.getName())) {
ret.put("type", "error");
ret.put("msg", "请填写名称!");
return true;
}
if (goods.getName().length() > Goods.NAME_MAX_LENGTH) {
ret.put("type", "error");
ret.put("msg", "名称最多为" + Goods.NAME_MAX_LENGTH + "位!");
return true;
}
if (StringUtils.isEmpty(goods.getAddress())) {
ret.put("type", "error");
ret.put("msg", "请填写发货地址!");
return true;
}
if (goods.getAddress().length() > Goods.ADDRESS_MAX_LENGTH) {
ret.put("type", "error");
ret.put("msg", "地址最多为" + Goods.ADDRESS_MAX_LENGTH + "位!");
return true;
}
return false;
}

@RequestMapping(value = "/addAmount", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> addAmount(Goods goods) {
Map<String, String> ret = new HashMap<String, String>();
if (goods == null) {
ret.put("type", "error");
ret.put("msg", "请填写正确的信息!");
return ret;
}
if (goods.getAmount() < 1 || goods.getAmount() > Goods.AMOUNT_MAX_VALUE) {
ret.put("type", "error");
ret.put("msg", "数量需在1~" + Goods.AMOUNT_MAX_VALUE + "之间!");
return ret;
}
Goods byId = goodsService.findById(goods.getId());
byId.setAmount(byId.getAmount() + goods.getAmount());
if (goodsService.addAmount(byId) <= 0) {
ret.put("type", "error");
ret.put("msg", "数量添加失败,请联系管理员!");
return ret;
}
ret.put("type", "success");
ret.put("msg", "添加成功!");
return ret;
}

@RequestMapping(value = "/editDetails", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> editDetails(Goods goods) {
Map<String, String> ret = new HashMap<String, String>();
if (goods == null) {
ret.put("type", "error");
ret.put("msg", "请填写正确的信息!");
return ret;
}
if (goodsService.editDetails(goods) <= 0) {
ret.put("type", "error");
ret.put("msg", "详情操作失败!");
return ret;
}
ret.put("type", "success");
ret.put("msg", "操作成功!");
return ret;
}

/**
* 富文本kindedit的图片上传
*
* @param request
* @param response
* @param imgFile
* @throws IOException
*/
@ResponseBody
@RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
public void uploadFile(HttpServletRequest request, HttpServletResponse response,
@RequestParam("imgFile") MultipartFile imgFile) throws IOException {
response.setContentType("application/json; charset=UTF-8");
JSONObject obj = new JSONObject();
/* Map obj = new HashMap<>(); */
obj.put("error", 0);
String massage = null;
PrintWriter out = response.getWriter();
// 判断文件类型是否是图片
String originalFilename = imgFile.getOriginalFilename();
// 获取文件后缀
String suffix = originalFilename.substring(originalFilename.lastIndexOf(".") + 1, originalFilename.length());
if (!"jpg,jpeg,gif,png".toUpperCase().contains(suffix.toUpperCase())) {
massage = "图片格式不正确,请选择jpg,jpeg,gif,png格式的图片!";
out.write("图片格式不正确,请选择jpg,jpeg,gif,png格式的图片!");
obj.put("error", 1);
}
if (imgFile.getSize() / 1024 > 1024 * 1024 * 1024) {
massage = "图片大小不能超过10M!";
out.write("图片大小不能超过10M");
obj.put("error", 1);
}
String savePath = request.getServletContext().getRealPath("/") + "/resources/upload/";
// 准备保存文件
File filePath = new File(savePath);
if (!filePath.exists()) {
// 若不存在文件夹,则创建一个文件夹
filePath.mkdir();
}

String filename = new Date().getTime() + "." + suffix;
try {
imgFile.transferTo(new File(savePath + filename));
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
int error = (Integer) obj.get("error");
if (error == 0) {
obj.put("url", request.getServletContext().getContextPath() + "/resources/upload/" + filename);
} else {
obj.put("message", massage);
}
out.println(obj.toString());
}

}
  • 8.3 货物的业务逻辑接口
package cn.javabs.logistics.service.common;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import cn.javabs.logistics.entity.common.Goods;
import cn.javabs.logistics.entity.common.Orders;
import cn.javabs.logistics.entity.common.Person;

/**
* 货物Service
*/
@Service
public interface GoodsService {

public Goods findById(Long id);// 根据id查找

public int add(Goods goods);// 添加

public int edit(Goods goods);// 编辑

public int delete(String ids);// 删除

public List<Goods> findList(Map<String, Object> queryMap);

public int getTotal(Map<String, Object> queryMap);

public int addAmount(Goods goods);// 添加货物数量

public List<Goods> findSendingList(Map<String, Object> queryMap);// 查询出售中的列表

public int findSendingTotal(Map<String, Object> queryMap);// 查询数量

public int editDetails(Goods goods);// 编辑详情

public int buyGoods(Goods goods, Person person, Orders orders);

}
  • 8.4 货物的业务逻辑接口的实现类
package cn.javabs.logistics.service.common.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.javabs.logistics.dao.admin.EnterpriseDao;
import cn.javabs.logistics.dao.common.GoodsDao;
import cn.javabs.logistics.dao.common.OrdersDao;
import cn.javabs.logistics.dao.common.PersonDao;
import cn.javabs.logistics.entity.admin.Enterprise;
import cn.javabs.logistics.entity.common.Goods;
import cn.javabs.logistics.entity.common.Orders;
import cn.javabs.logistics.entity.common.Person;
import cn.javabs.logistics.service.common.GoodsService;

/**
* 货物Service
*/
@Service
public class GoodsServiceImpl implements GoodsService {

@Autowired
private GoodsDao goodsDao;

@Autowired
private PersonDao personDao;

@Autowired
private EnterpriseDao enterpriseDao;

@Autowired
private OrdersDao ordersDao;

@Override
public Goods findById(Long id) {
return goodsDao.findById(id);
}

@Override
public int add(Goods goods) {
return goodsDao.add(goods);
}

@Override
public int edit(Goods goods) {
return goodsDao.edit(goods);
}

@Override
public int delete(String ids) {
return goodsDao.delete(ids);
}

@Override
public List<Goods> findList(Map<String, Object> queryMap) {
return goodsDao.findList(queryMap);
}

@Override
public int getTotal(Map<String, Object> queryMap) {
return goodsDao.getTotal(queryMap);
}

@Override
public int addAmount(Goods goods) {
return goodsDao.addAmount(goods);
}

@Override
public List<Goods> findSendingList(Map<String, Object> queryMap) {
// TODO Auto-generated method stub
return goodsDao.findSendingList(queryMap);
}

@Override
public int findSendingTotal(Map<String, Object> queryMap) {
return goodsDao.findSendingTotal(queryMap);
}

@Override
public int editDetails(Goods goods) {
// TODO Auto-generated method stub
return goodsDao.editDetails(goods);
}

/**
* 购买商品
*
* @param goods
* @param person
* @param order
* @return
*/
@Override
@Transactional
public int buyGoods(Goods goods, Person person, Orders orders) {
// 前台用户修改余额
person.setBalance(person.getBalance().subtract(orders.getPrice()));
personDao.editBalance(person);
// 货物对应的企业修改余额
Enterprise enterprise = enterpriseDao.findById(goods.getEnterpriseId());
enterprise.setBalance(enterprise.getBalance().add(orders.getPrice()));
enterpriseDao.editBalance(enterprise);
ordersDao.add(orders);
goods.setAmount(goods.getAmount() - orders.getQuantity());
goods.setWaitingQuantity(goods.getWaitingQuantity() + orders.getQuantity());
return goodsDao.editAmountAndWaitingQuantity(goods);
}

}
  • 8.5 货物的数据持久层的接口
package cn.javabs.logistics.dao.common;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import cn.javabs.logistics.entity.common.Goods;

@Repository
public interface GoodsDao {

public Goods findById(Long id);// 根据id查找

public int add(Goods goods);// 添加

public int edit(Goods goods);// 编辑

public int delete(String ids);// 删除

public List<Goods> findList(Map<String, Object> queryMap);

public int getTotal(Map<String, Object> queryMap);

public int addAmount(Goods goods);// 添加货物数量

public List<Goods> findSendingList(Map<String, Object> queryMap);// 查询出售中货物

public int findSendingTotal(Map<String, Object> queryMap);// 查询数量

public int editDetails(Goods goods);// 编辑详情

public int editAmountAndWaitingQuantity(Goods goods);// 购买后对数量进行修改

public int editWaitingQuantity(Goods goods);// 修改待发货数量
}
  • 8.6 货物的数据持久层的接口的映射文件
<?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="cn.javabs.logistics.dao.common.GoodsDao">
<!-- 根据id查找 -->
<select id="findById" parameterType="Long" resultType="Goods">
select * from goods where id = #{id}
</select>
<!-- 添加-->
<insert id="add" parameterType="Goods">
insert into goods(id,name,number,goodsTypeId,amount,waitingQuantity,price,enterpriseId,status,photo,address,synopsis)
values(null,#{name},#{number},#{goodsTypeId},#{amount},#{waitingQuantity},#{price},#{enterpriseId},#{status},#{photo},#{address},#{synopsis})
</insert>
<!-- 修改货物数量-->
<update id="addAmount" parameterType="Goods">
update goods set amount = #{amount} where id = #{id}
</update>
<!-- 修改货物待发货数量-->
<update id="editWaitingQuantity" parameterType="Goods">
update goods set waitingQuantity=#{waitingQuantity} where id = #{id}
</update>
<!-- 修改-->
<update id="edit" parameterType="Goods">
update goods set name = #{name},goodsTypeId=#{goodsTypeId},
price = #{price},status= #{status},photo=#{photo},address=#{address},synopsis=#{synopsis} where id = #{id}
</update>
<!-- 修改-->
<update id="editAmountAndWaitingQuantity" parameterType="Goods">
update goods set amount=#{amount},waitingQuantity=#{waitingQuantity} where id = #{id}
</update>
<!-- 修改-->
<update id="editDetails" parameterType="Goods">
update goods set details=#{details} where id = #{id}
</update>
<!-- 删除 -->
<delete id="delete" parameterType="String">
delete from goods where id in(${value})
</delete>
<!-- 分页获取列表 -->
<select id="findList" parameterType="Map" resultType="Goods">
select * from goods where 1 = 1
<if test="name != null">
and name like '%${name}%'
</if>
<if test="goodsTypeId != null">
and goodsTypeId = #{goodsTypeId}
</if>
<if test="number != null">
and number like '%${number}%'
</if>
<if test="enterpriseId != null">
and enterpriseId = #{enterpriseId}
</if>
<if test="offset != null and pageSize != null">
limit #{offset},#{pageSize}
</if>
</select>
<!-- 获取符合结果的总记录数 -->
<select id="getTotal" parameterType="Map" resultType="Integer">
select count(*) from goods where 1 = 1
<if test="name != null">
and name like '%${name}%'
</if>
<if test="enterpriseId != null">
and enterpriseId = ${enterpriseId}
</if>
</select>

<select id="findSendingTotal" parameterType="Map" resultType="Integer">
select count(*)
from goods where 1 = 1
<if test="status != null">
and status = #{status}
</if>
<if test="name != null">
and name like '%${name}%'
</if>
<if test="goodsTypeId != null">
and goodsTypeId = #{goodsTypeId}
</if>
</select>

<select id="findSendingList" parameterType="Map" resultMap="ResultMap">
select g.*,t.name tName,e.username eUsername
from (goods g left join goods_type t on g.goodsTypeId = t.id)
LEFT JOIN enterprise e on g.enterpriseId = e.id where 1 = 1
<if test="status != null">
and g.status = #{status}
</if>
<if test="name != null">
and g.name like '%${name}%'
</if>
<if test="goodsTypeId != null">
and g.goodsTypeId = #{goodsTypeId}
</if>
order by g.id desc
<if test="offset != null and pageSize != null">
limit #{offset},#{pageSize}
</if>
</select>

<resultMap type="Goods" id="ResultMap">
<id property="id" column="id"/>
<result column="name" property="name"/>
<result column="number" property="number"/>
<result column="goodsTypeId" property="goodsTypeId"/>
<result column="amount" property="amount"/>
<result column="price" property="price"/>
<result column="enterpriseId" property="enterpriseId"/>
<result column="photo" property="photo"/>
<result column="address" property="address"/>
<result column="synopsis" property="synopsis"/>
<association property="goodsType" column="goodsType"
javaType="GoodsType" resultMap="goodsTypeResult"/>
<association property="enterprise" column="enterprise"
javaType="Enterprise" resultMap="enterpriseResult"/>
</resultMap>

<resultMap type="GoodsType" id="goodsTypeResult">
<result column="tName" property="name"/>
</resultMap>

<resultMap type="Enterprise" id="enterpriseResult">
<result column="eUsername" property="username"/>
<result column="address" property="address"/>
</resultMap>
</mapper>

作者: 杨校

分享是快乐的,也见证了个人成长历程,文章大多都是工作经验总结以及平时学习积累,基于自身认知不足之处在所难免,也请大家指正,共同进步。