From b4935d5c9546c3ce70d48fd72403f07846913ab9 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Fri, 13 May 2022 16:11:55 +0800
Subject: [PATCH] 农事基础操作接口新增
---
src/main/java/org/springblade/modules/farm/controller/FarmingRecordController.java | 125 +++++++++++++++++
src/main/java/org/springblade/modules/farm/mapper/FarmingRecordMapper.xml | 26 +++
src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java | 10 +
src/main/java/org/springblade/modules/farm/mapper/FarmingRecordMapper.java | 42 ++++++
src/main/java/org/springblade/modules/farm/entity/FarmingRecord.java | 80 +++++++++++
src/main/java/org/springblade/modules/farm/vo/FarmingRecordVO.java | 20 ++
src/main/java/org/springblade/modules/farm/service/FarmingRecordService.java | 24 +++
src/main/java/org/springblade/modules/farm/service/impl/FarmRecordServiceImpl.java | 28 ++++
src/main/java/org/springblade/modules/system/controller/UserController.java | 10 +
src/main/java/org/springblade/modules/system/service/IUserService.java | 7 +
10 files changed, 372 insertions(+), 0 deletions(-)
diff --git a/src/main/java/org/springblade/modules/farm/controller/FarmingRecordController.java b/src/main/java/org/springblade/modules/farm/controller/FarmingRecordController.java
new file mode 100644
index 0000000..abb4766
--- /dev/null
+++ b/src/main/java/org/springblade/modules/farm/controller/FarmingRecordController.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.farm.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.AllArgsConstructor;
+import org.springblade.core.boot.ctrl.BladeController;
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.modules.farm.entity.FarmingRecord;
+import org.springblade.modules.farm.service.FarmingRecordService;
+import org.springblade.modules.farm.vo.FarmingRecordVO;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+import java.util.Date;
+
+/**
+ * 农事记录控制器
+ * @since 2022-05-13
+ * @author zhongrj
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/farmingRecord")
+public class FarmingRecordController extends BladeController {
+
+ private final FarmingRecordService farmService;
+
+ /**
+ * 详情
+ */
+ @GetMapping("/detail")
+ @ApiOperationSupport(order = 1)
+ @ApiOperation(value = "详情", notes = "传入farm")
+ public R<FarmingRecord> detail(FarmingRecord farm) {
+ FarmingRecord detail = farmService.getOne(Condition.getQueryWrapper(farm));
+ return R.data(detail);
+ }
+
+ /**
+ * 分页
+ */
+ @GetMapping("/list")
+ @ApiOperationSupport(order = 2)
+ @ApiOperation(value = "分页", notes = "传入farm")
+ public R<IPage<FarmingRecord>> list(FarmingRecord farm, Query query) {
+ IPage<FarmingRecord> pages = farmService.page(Condition.getPage(query), Condition.getQueryWrapper(farm));
+ return R.data(pages);
+ }
+
+ /**
+ * 自定义分页
+ */
+ @GetMapping("/page")
+ @ApiOperationSupport(order = 3)
+ @ApiOperation(value = "分页", notes = "传入farm")
+ public R<IPage<FarmingRecordVO>> page(FarmingRecordVO farm, Query query) {
+ IPage<FarmingRecordVO> pages = farmService.selectFarmingRecordPage(Condition.getPage(query), farm);
+ return R.data(pages);
+ }
+
+ /**
+ * 新增
+ */
+ @PostMapping("/save")
+ @ApiOperationSupport(order = 4)
+ @ApiOperation(value = "新增", notes = "传入farm")
+ public R save(@Valid @RequestBody FarmingRecord farm) {
+ farm.setCreateTime(new Date());
+ return R.status(farmService.save(farm));
+ }
+
+ /**
+ * 修改
+ */
+ @PostMapping("/update")
+ @ApiOperationSupport(order = 5)
+ @ApiOperation(value = "修改", notes = "传入farm")
+ public R update(@Valid @RequestBody FarmingRecord farm) {
+ //更新并返回
+ return R.status(farmService.updateById(farm));
+ }
+
+ /**
+ * 新增或修改
+ */
+ @PostMapping("/submit")
+ @ApiOperationSupport(order = 6)
+ @ApiOperation(value = "新增或修改", notes = "传入farm")
+ public R submit(@Valid @RequestBody FarmingRecord farm) {
+ return R.status(farmService.saveOrUpdate(farm));
+ }
+
+
+ /**
+ * 删除
+ */
+ @PostMapping("/remove")
+ @ApiOperationSupport(order = 7)
+ @ApiOperation(value = "逻辑删除", notes = "传入ids")
+ public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
+ return R.status(farmService.removeByIds(Func.toLongList(ids)));
+ }
+
+}
diff --git a/src/main/java/org/springblade/modules/farm/entity/FarmingRecord.java b/src/main/java/org/springblade/modules/farm/entity/FarmingRecord.java
new file mode 100644
index 0000000..e50f524
--- /dev/null
+++ b/src/main/java/org/springblade/modules/farm/entity/FarmingRecord.java
@@ -0,0 +1,80 @@
+package org.springblade.modules.farm.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 农事记录表实体类
+ * @since 2022-05-13
+ * @author zhongrj
+ */
+@Data
+@TableName("sys_farming_record")
+public class FarmingRecord implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键id
+ */
+ @TableId(value = "id",type = IdType.AUTO)
+ private Integer id;
+
+ /**
+ * 土地id
+ */
+ private String landId;
+
+ /**
+ * 农事类型 (0:施肥 1:翻耕 2:灌溉 3:起垄(整畦)4:用药 5:追肥 6:投料 7:除草 8: 修剪 9: 浸种 10:拌种 )
+ */
+ private String type;
+
+
+ /**
+ * 作业方式(0:人工 1:机械)
+ */
+ private String jobWay;
+
+ /**
+ * 操作时间
+ */
+ @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
+ @DateTimeFormat(pattern = "yyyy-MM-dd")
+ private Date time;
+
+ /**
+ * 操作人
+ */
+ private String operator;
+
+ /**
+ * 图片
+ */
+ private String tp;
+
+ /**
+ * 备注
+ */
+ private String remarks;
+
+ /**
+ * 农资id
+ */
+ private String stockId;
+
+ /**
+ * 创建时间
+ */
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private Date createTime;
+
+}
diff --git a/src/main/java/org/springblade/modules/farm/mapper/FarmingRecordMapper.java b/src/main/java/org/springblade/modules/farm/mapper/FarmingRecordMapper.java
new file mode 100644
index 0000000..dd20fb3
--- /dev/null
+++ b/src/main/java/org/springblade/modules/farm/mapper/FarmingRecordMapper.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.farm.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.apache.ibatis.annotations.Param;
+import org.springblade.modules.farm.entity.FarmingRecord;
+import org.springblade.modules.farm.vo.FarmingRecordVO;
+
+import java.util.List;
+
+/**
+ * 农事记录Mapper 接口
+ * @since 2022-05-13
+ * @author zhongrj
+ */
+public interface FarmingRecordMapper extends BaseMapper<FarmingRecord> {
+
+ /**
+ * 自定义分页
+ *
+ * @param page
+ * @param farm
+ * @return
+ */
+ List<FarmingRecordVO> selectFarmingRecordPage(@Param("page") IPage page,@Param("farmingRecord") FarmingRecordVO farm);
+}
diff --git a/src/main/java/org/springblade/modules/farm/mapper/FarmingRecordMapper.xml b/src/main/java/org/springblade/modules/farm/mapper/FarmingRecordMapper.xml
new file mode 100644
index 0000000..e7bd370
--- /dev/null
+++ b/src/main/java/org/springblade/modules/farm/mapper/FarmingRecordMapper.xml
@@ -0,0 +1,26 @@
+<?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="org.springblade.modules.farm.mapper.FarmingRecordMapper">
+
+ <!--自定义查询农事记录分页数据-->
+ <select id="selectFarmingRecordPage" resultType="org.springblade.modules.farm.vo.FarmingRecordVO">
+ select sfr.*,sl.land_name landName from sys_farming_record sfr
+ left join sys_land sl on sl.id = sfr.land_id
+ where 1=1
+ <if test="farmingRecord.landId!=null and farmingRecord.landId!=''">
+ and sfr.land_id = #{farmingRecord.landId}
+ </if>
+ <if test="farmingRecord.type!=null and farmingRecord.type!=''">
+ and sfr.type = #{farmingRecord.type}
+ </if>
+ <if test="farmingRecord.stockId!=null and farmingRecord.stockId!=''">
+ and sfr.stock_id = #{farmingRecord.stockId}
+ </if>
+ <if test="farmingRecord.jobWay!=null and farmingRecord.jobWay!=''">
+ and sfr.job_way = #{farmingRecord.jobWay}
+ </if>
+ <if test="farmingRecord.operator!=null and farmingRecord.operator!=''">
+ and sfr.operator = #{farmingRecord.operator}
+ </if>
+ </select>
+</mapper>
diff --git a/src/main/java/org/springblade/modules/farm/service/FarmingRecordService.java b/src/main/java/org/springblade/modules/farm/service/FarmingRecordService.java
new file mode 100644
index 0000000..649b669
--- /dev/null
+++ b/src/main/java/org/springblade/modules/farm/service/FarmingRecordService.java
@@ -0,0 +1,24 @@
+
+package org.springblade.modules.farm.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.springblade.modules.farm.entity.FarmingRecord;
+import org.springblade.modules.farm.vo.FarmingRecordVO;
+
+/**
+ * 农事记录服务类
+ * @since 2022-05-13
+ * @author zhongrj
+ */
+public interface FarmingRecordService extends IService<FarmingRecord> {
+
+ /**
+ * 自定义分页
+ *
+ * @param page
+ * @param farm
+ * @return
+ */
+ IPage<FarmingRecordVO> selectFarmingRecordPage(IPage<FarmingRecordVO> page, FarmingRecordVO farm);
+}
diff --git a/src/main/java/org/springblade/modules/farm/service/impl/FarmRecordServiceImpl.java b/src/main/java/org/springblade/modules/farm/service/impl/FarmRecordServiceImpl.java
new file mode 100644
index 0000000..ecdbb73
--- /dev/null
+++ b/src/main/java/org/springblade/modules/farm/service/impl/FarmRecordServiceImpl.java
@@ -0,0 +1,28 @@
+package org.springblade.modules.farm.service.impl;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springblade.modules.farm.entity.FarmingRecord;
+import org.springblade.modules.farm.mapper.FarmingRecordMapper;
+import org.springblade.modules.farm.service.FarmingRecordService;
+import org.springblade.modules.farm.vo.FarmingRecordVO;
+import org.springframework.stereotype.Service;
+
+/**
+ * 农事记录服务实现类
+ * @since 2022-05-13
+ * @author zhongrj
+ */
+@Service
+public class FarmRecordServiceImpl extends ServiceImpl<FarmingRecordMapper, FarmingRecord> implements FarmingRecordService {
+
+ /**
+ * 自定义分页
+ * @param page
+ * @param farm
+ * @return
+ */
+ @Override
+ public IPage<FarmingRecordVO> selectFarmingRecordPage(IPage<FarmingRecordVO> page, FarmingRecordVO farm) {
+ return page.setRecords(baseMapper.selectFarmingRecordPage(page, farm));
+ }
+}
diff --git a/src/main/java/org/springblade/modules/farm/vo/FarmingRecordVO.java b/src/main/java/org/springblade/modules/farm/vo/FarmingRecordVO.java
new file mode 100644
index 0000000..b44ad9c
--- /dev/null
+++ b/src/main/java/org/springblade/modules/farm/vo/FarmingRecordVO.java
@@ -0,0 +1,20 @@
+package org.springblade.modules.farm.vo;
+
+import lombok.Data;
+import org.springblade.modules.farm.entity.Farm;
+import org.springblade.modules.farm.entity.FarmingRecord;
+
+/**
+ * 农事记录VO
+ * @since 2022-05-13
+ * @author zhongrj
+ */
+@Data
+public class FarmingRecordVO extends FarmingRecord {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 地块名称
+ */
+ private String landName;
+}
diff --git a/src/main/java/org/springblade/modules/system/controller/UserController.java b/src/main/java/org/springblade/modules/system/controller/UserController.java
index 82139b1..402b73f 100644
--- a/src/main/java/org/springblade/modules/system/controller/UserController.java
+++ b/src/main/java/org/springblade/modules/system/controller/UserController.java
@@ -333,4 +333,14 @@
return R.success("操作成功");
}
+ /**
+ * 查询用户信息
+ * @param user
+ * @return
+ */
+ @GetMapping("/getUserList")
+ public R getUserList(User user){
+ return R.data(userService.getUserList(user));
+ }
+
}
diff --git a/src/main/java/org/springblade/modules/system/service/IUserService.java b/src/main/java/org/springblade/modules/system/service/IUserService.java
index 932d0a5..364bf2c 100644
--- a/src/main/java/org/springblade/modules/system/service/IUserService.java
+++ b/src/main/java/org/springblade/modules/system/service/IUserService.java
@@ -206,4 +206,11 @@
* @return
*/
UserVO platformDetail(User user);
+
+ /**
+ * 查询用户信息
+ * @param user
+ * @return
+ */
+ List<User> getUserList(User user);
}
diff --git a/src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java b/src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
index 6dc569d..42e567f 100644
--- a/src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
+++ b/src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
@@ -19,6 +19,7 @@
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.AllArgsConstructor;
@@ -426,4 +427,13 @@
return userVO;
}
+ /**
+ * 查询用户信息
+ * @param user
+ * @return
+ */
+ @Override
+ public List<User> getUserList(User user) {
+ return list(new QueryWrapper<>(user));
+ }
}
--
Gitblit v1.9.3