开发平台为idea,maven管理工具,Mybatis操作数据库,根据市场数字化需要为农户打造小程序可远程查看农场的种植情况。项目是调试,讲解服务均可有偿获取,需要可在最下方QQ二维码处联系我。
Springboot+Vue+小程序,基于微信小程序的农场信息管理系统。数据库Mysql,17张表。
前台可以查阅接受保护的农产品。
后台对请求进行管理。
后台管理功能有。
1.农户管理
2.农产品展示
3.产品类型
4.农产品订单管理
5.预采摘登记管理
6.远程看护管理
7.蔬果类型管理
8.播种管理
9.施肥信息管理
10.浇水管理
11.轮播图管理,农业活动及活动分类管理。
12.个人信息管理。
部分数据库设计:
表名:nongchanpindingdan
功能:农产品订单
|------------------|-----------|------------|------|----|-------------------|
| 字段名称 | 类型 | 长度 | 字段说明 | 主键 | 默认值 |
| id | bigint | | 主键 | 主键 | |
| addtime | timestamp | | 创建时间 | | CURRENT_TIMESTAMP |
| dingdanbianhao | varchar | 200 | 订单编号 | | |
| chanpinmingcheng | varchar | 200 | 产品名称 | | |
| chanpinleixing | varchar | 200 | 产品类型 | | |
| chanpintupian | longtext | 4294967295 | 产品图片 | | |
| chandi | varchar | 200 | 产地 | | |
| guige | varchar | 200 | 规格 | | |
| shuliang | int | | 数量 | | |
| jiage | int | | 价格 | | |
| zonge | double | | 总额 | | |
| goumaishijian | datetime | | 购买时间 | | |
| dingdanbeizhu | varchar | 200 | 订单备注 | | |
| shouhuodizhi | varchar | 200 | 收货地址 | | |
| youkexingming | varchar | 200 | 游客姓名 | | |
| nonghuzhanghao | varchar | 200 | 农户账号 | | |
| nonghuxingming | varchar | 200 | 农户姓名 | | |
表名:newstype
功能:农业活动分类
|----------|-----------|-----|------|----|-------------------|
| 字段名称 | 类型 | 长度 | 字段说明 | 主键 | 默认值 |
| id | bigint | | 主键 | 主键 | |
| addtime | timestamp | | 创建时间 | | CURRENT_TIMESTAMP |
| typename | varchar | 200 | 分类名称 | | |
表名:yucaizhaidengji
功能:预采摘登记
|----------------|-----------|------------|------|----|-------------------|
| 字段名称 | 类型 | 长度 | 字段说明 | 主键 | 默认值 |
| id | bigint | | 主键 | 主键 | |
| addtime | timestamp | | 创建时间 | | CURRENT_TIMESTAMP |
| caizhaichanpin | varchar | 200 | 采摘产品 | | |
| caizhaishijian | datetime | | 采摘时间 | | |
| caizhaididian | varchar | 200 | 采摘地点 | | |
| caizhairenshu | int | | 采摘人数 | | |
| caizhaigongju | varchar | 200 | 采摘工具 | | |
| caizhaitupian | longtext | 4294967295 | 采摘图片 | | |
| nonghuzhanghao | varchar | 200 | 农户账号 | | |
| nonghuxingming | varchar | 200 | 农户姓名 | | |
表名:news
功能:农业活动
|--------------|-----------|------------|--------|----|-------------------|
| 字段名称 | 类型 | 长度 | 字段说明 | 主键 | 默认值 |
| id | bigint | | 主键 | 主键 | |
| addtime | timestamp | | 创建时间 | | CURRENT_TIMESTAMP |
| title | varchar | 200 | 标题 | | |
| introduction | longtext | 4294967295 | 简介 | | |
| typename | varchar | 200 | 分类名称 | | |
| name | varchar | 200 | 发布人 | | |
| headportrait | longtext | 4294967295 | 头像 | | |
| clicknum | int | | 点击次数 | | 0 |
| clicktime | datetime | | 最近点击时间 | | |
| thumbsupnum | int | | 赞 | | 0 |
| crazilynum | int | | 踩 | | 0 |
| storeupnum | int | | 收藏数 | | 0 |
| picture | longtext | 4294967295 | 图片 | | |
| content | longtext | 4294967295 | 内容 | | |
代码示例:
1.农产品增删改查模块
java
package com.controller;
import java.util.Arrays;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import com.entity.NonghuEntity;
import com.service.NonghuService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.annotation.IgnoreAuth;
import com.entity.NongchanpinzhanshiEntity;
import com.entity.view.NongchanpinzhanshiView;
import com.service.NongchanpinzhanshiService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MPUtil;
/**
* 农产品展示
* 后端接口
*/
@RestController
@RequestMapping("/nongchanpinzhanshi")
public class NongchanpinzhanshiController {
@Autowired
private NonghuService nonghuService;
@Autowired
private NongchanpinzhanshiService nongchanpinzhanshiService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, NongchanpinzhanshiEntity nongchanpinzhanshi,
HttpServletRequest request) {
String tableName = request.getSession().getAttribute("tableName").toString();
if (tableName.equals("nonghu")) {
nongchanpinzhanshi.setNonghuzhanghao((String) request.getSession().getAttribute("username"));
}
EntityWrapper<NongchanpinzhanshiEntity> ew = new EntityWrapper<>();
PageUtils page = nongchanpinzhanshiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, nongchanpinzhanshi), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params, NongchanpinzhanshiEntity nongchanpinzhanshi,
HttpServletRequest request) {
String tableName = request.getSession().getAttribute("tableName").toString();
if (tableName.equals("nonghu")) {
nongchanpinzhanshi.setNonghuzhanghao((String) request.getSession().getAttribute("username"));
}
EntityWrapper<NongchanpinzhanshiEntity> ew = new EntityWrapper<>();
PageUtils page = nongchanpinzhanshiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, nongchanpinzhanshi), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list(NongchanpinzhanshiEntity nongchanpinzhanshi) {
EntityWrapper<NongchanpinzhanshiEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(nongchanpinzhanshi, "nongchanpinzhanshi"));
return R.ok().put("data", nongchanpinzhanshiService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(NongchanpinzhanshiEntity nongchanpinzhanshi) {
EntityWrapper<NongchanpinzhanshiEntity> ew = new EntityWrapper<>();
ew.allEq(MPUtil.allEQMapPre(nongchanpinzhanshi, "nongchanpinzhanshi"));
NongchanpinzhanshiView nongchanpinzhanshiView = nongchanpinzhanshiService.selectView(ew);
return R.ok("查询农产品展示成功").put("data", nongchanpinzhanshiView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id) {
NongchanpinzhanshiEntity nongchanpinzhanshi = nongchanpinzhanshiService.selectById(id);
nongchanpinzhanshi.setClicknum(nongchanpinzhanshi.getClicknum() + 1);
nongchanpinzhanshi.setClicktime(new Date());
nongchanpinzhanshiService.updateById(nongchanpinzhanshi);
nongchanpinzhanshi = nongchanpinzhanshiService.selectView(new EntityWrapper<NongchanpinzhanshiEntity>().eq("id", id));
return R.ok().put("data", nongchanpinzhanshi);
}
/**
* 前端详情
*/
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id) {
NongchanpinzhanshiEntity nongchanpinzhanshi = nongchanpinzhanshiService.selectById(id);
nongchanpinzhanshi.setClicknum(nongchanpinzhanshi.getClicknum() + 1);
nongchanpinzhanshi.setClicktime(new Date());
nongchanpinzhanshiService.updateById(nongchanpinzhanshi);
nongchanpinzhanshi = nongchanpinzhanshiService.selectView(new EntityWrapper<NongchanpinzhanshiEntity>().eq("id", id));
return R.ok().put("data", nongchanpinzhanshi);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody NongchanpinzhanshiEntity nongchanpinzhanshi, HttpServletRequest request) {
NonghuEntity nonghu = nonghuService.selectOne(new EntityWrapper<NonghuEntity>()
.eq("nonghuzhanghao", nongchanpinzhanshi.getNonghuzhanghao())
.eq("nonghuxingming", nongchanpinzhanshi.getNonghuxingming()));
if (ObjectUtils.isEmpty(nonghu)) {
return R.error(404, "该账户不存在,请确认农户账号姓名");
}
nongchanpinzhanshiService.insert(nongchanpinzhanshi);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody NongchanpinzhanshiEntity nongchanpinzhanshi, HttpServletRequest request) {
nongchanpinzhanshi.setUserid((Long) request.getSession().getAttribute("userId"));
nongchanpinzhanshiService.insert(nongchanpinzhanshi);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody NongchanpinzhanshiEntity nongchanpinzhanshi, HttpServletRequest request) {
nongchanpinzhanshiService.updateById(nongchanpinzhanshi);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids) {
nongchanpinzhanshiService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 前端智能排序
*/
@IgnoreAuth
@RequestMapping("/autoSort")
public R autoSort(@RequestParam Map<String, Object> params, NongchanpinzhanshiEntity nongchanpinzhanshi, HttpServletRequest request, String pre) {
EntityWrapper<NongchanpinzhanshiEntity> ew = new EntityWrapper<NongchanpinzhanshiEntity>();
Map<String, Object> newMap = new HashMap<String, Object>();
Map<String, Object> param = new HashMap<String, Object>();
Iterator<Map.Entry<String, Object>> it = param.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, Object> entry = it.next();
String key = entry.getKey();
String newKey = entry.getKey();
if (pre.endsWith(".")) {
newMap.put(pre + newKey, entry.getValue());
} else if (StringUtils.isEmpty(pre)) {
newMap.put(newKey, entry.getValue());
} else {
newMap.put(pre + "." + newKey, entry.getValue());
}
}
params.put("sort", "clicknum");
params.put("order", "desc");
PageUtils page = nongchanpinzhanshiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, nongchanpinzhanshi), params), params));
return R.ok().put("data", page);
}
}
2.农产品展示实体:
java
package com.entity.vo;
import java.util.Date;
import org.springframework.format.annotation.DateTimeFormat;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.io.Serializable;
/**
* 农产品展示
*/
public class NongchanpinzhanshiVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 产品类型
*/
private String chanpinleixing;
/**
* 产地
*/
private String chandi;
/**
* 规格
*/
private String guige;
/**
* 数量
*/
private Integer shuliang;
/**
* 价格
*/
private Integer jiage;
/**
* 采摘日期
*/
@JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat
private Date caizhairiqi;
/**
* 保质期
*/
private String baozhiqi;
/**
* 产品描述
*/
private String chanpinmiaoshu;
/**
* 产品图片
*/
private String chanpintupian;
/**
* 农户账号
*/
private String nonghuzhanghao;
/**
* 农户姓名
*/
private String nonghuxingming;
/**
* 最近点击时间
*/
@JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat
private Date clicktime;
/**
* 点击次数
*/
private Integer clicknum;
/**
* 用户id
*/
private Long userid;
/**
* 设置:产品类型
*/
public void setChanpinleixing(String chanpinleixing) {
this.chanpinleixing = chanpinleixing;
}
/**
* 获取:产品类型
*/
public String getChanpinleixing() {
return chanpinleixing;
}
/**
* 设置:产地
*/
public void setChandi(String chandi) {
this.chandi = chandi;
}
/**
* 获取:产地
*/
public String getChandi() {
return chandi;
}
/**
* 设置:规格
*/
public void setGuige(String guige) {
this.guige = guige;
}
/**
* 获取:规格
*/
public String getGuige() {
return guige;
}
/**
* 设置:数量
*/
public void setShuliang(Integer shuliang) {
this.shuliang = shuliang;
}
/**
* 获取:数量
*/
public Integer getShuliang() {
return shuliang;
}
/**
* 设置:价格
*/
public void setJiage(Integer jiage) {
this.jiage = jiage;
}
/**
* 获取:价格
*/
public Integer getJiage() {
return jiage;
}
/**
* 设置:采摘日期
*/
public void setCaizhairiqi(Date caizhairiqi) {
this.caizhairiqi = caizhairiqi;
}
/**
* 获取:采摘日期
*/
public Date getCaizhairiqi() {
return caizhairiqi;
}
/**
* 设置:保质期
*/
public void setBaozhiqi(String baozhiqi) {
this.baozhiqi = baozhiqi;
}
/**
* 获取:保质期
*/
public String getBaozhiqi() {
return baozhiqi;
}
/**
* 设置:产品描述
*/
public void setChanpinmiaoshu(String chanpinmiaoshu) {
this.chanpinmiaoshu = chanpinmiaoshu;
}
/**
* 获取:产品描述
*/
public String getChanpinmiaoshu() {
return chanpinmiaoshu;
}
/**
* 设置:产品图片
*/
public void setChanpintupian(String chanpintupian) {
this.chanpintupian = chanpintupian;
}
/**
* 获取:产品图片
*/
public String getChanpintupian() {
return chanpintupian;
}
/**
* 设置:农户账号
*/
public void setNonghuzhanghao(String nonghuzhanghao) {
this.nonghuzhanghao = nonghuzhanghao;
}
/**
* 获取:农户账号
*/
public String getNonghuzhanghao() {
return nonghuzhanghao;
}
/**
* 设置:农户姓名
*/
public void setNonghuxingming(String nonghuxingming) {
this.nonghuxingming = nonghuxingming;
}
/**
* 获取:农户姓名
*/
public String getNonghuxingming() {
return nonghuxingming;
}
/**
* 设置:最近点击时间
*/
public void setClicktime(Date clicktime) {
this.clicktime = clicktime;
}
/**
* 获取:最近点击时间
*/
public Date getClicktime() {
return clicktime;
}
/**
* 设置:点击次数
*/
public void setClicknum(Integer clicknum) {
this.clicknum = clicknum;
}
/**
* 获取:点击次数
*/
public Integer getClicknum() {
return clicknum;
}
/**
* 设置:用户id
*/
public void setUserid(Long userid) {
this.userid = userid;
}
/**
* 获取:用户id
*/
public Long getUserid() {
return userid;
}
}