运用Spring+SpringMVC+Mybatis+Mybatis plus等开源框架技术开发基于WEB的物流管理系统代码
时间: 2023-08-12 07:05:09 浏览: 91
由于物流管理系统是一个比较复杂的系统,涉及到很多模块和功能,这里我提供一个简单的示例代码,仅供参考。
1. 配置文件
application.properties
```
# 数据库配置
spring.datasource.url=jdbc:mysql://localhost:3306/logistics?useSSL=false&serverTimezone=UTC&useUnicode=true&characterEncoding=utf8
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
# Mybatis-plus配置
mybatis-plus.mapper-locations=classpath:mapper/*.xml
mybatis-plus.global-config.db-config.logic-delete-field=deleted
mybatis-plus.global-config.db-config.logic-delete-value=1
mybatis-plus.global-config.db-config.logic-not-delete-value=0
```
2. 货物管理模块
GoodsController.java
```java
@RestController
@RequestMapping("/goods")
public class GoodsController {
@Autowired
private GoodsService goodsService;
/**
* 获取所有货物
*/
@GetMapping("/")
public ResponseResult<List<Goods>> getAllGoods() {
List<Goods> goodsList = goodsService.list();
return new ResponseResult<>(ResponseStatus.SUCCESS, goodsList);
}
/**
* 添加货物
*/
@PostMapping("/")
public ResponseResult<Void> addGoods(@RequestBody Goods goods) {
boolean result = goodsService.save(goods);
if (result) {
return new ResponseResult<>(ResponseStatus.SUCCESS);
} else {
return new ResponseResult<>(ResponseStatus.FAILED);
}
}
/**
* 修改货物
*/
@PutMapping("/")
public ResponseResult<Void> updateGoods(@RequestBody Goods goods) {
boolean result = goodsService.updateById(goods);
if (result) {
return new ResponseResult<>(ResponseStatus.SUCCESS);
} else {
return new ResponseResult<>(ResponseStatus.FAILED);
}
}
/**
* 删除货物
*/
@DeleteMapping("/{id}")
public ResponseResult<Void> deleteGoods(@PathVariable Long id) {
boolean result = goodsService.removeById(id);
if (result) {
return new ResponseResult<>(ResponseStatus.SUCCESS);
} else {
return new ResponseResult<>(ResponseStatus.FAILED);
}
}
}
```
GoodsService.java
```java
public interface GoodsService extends IService<Goods> {
}
```
GoodsServiceImpl.java
```java
@Service
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements GoodsService {
}
```
GoodsMapper.java
```java
public interface GoodsMapper extends BaseMapper<Goods> {
}
```
Goods.java
```java
@Data
public class Goods implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 货物ID
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* 货物名称
*/
private String name;
/**
* 货物类型
*/
private String type;
/**
* 货物数量
*/
private Integer quantity;
/**
* 货物描述
*/
private String description;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
private Date createTime;
/**
* 更新时间
*/
@TableField(fill = FieldFill.UPDATE)
private Date updateTime;
/**
* 是否删除
*/
@TableLogic
private Integer deleted;
}
```
3. 订单管理模块、配送管理模块、仓库管理模块和用户管理模块的代码类似,这里不再赘述。
以上代码仅供参考,具体实现可以根据实际需求进行调整和修改。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![gz](https://img-home.csdnimg.cn/images/20210720083447.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)