package com.njfu.ia.sys.web;
import com.github.pagehelper.PageInfo;
import com.njfu.ia.sys.domain.*;
import com.njfu.ia.sys.enums.ResultEnum;
import com.njfu.ia.sys.exception.BusinessException;
import com.njfu.ia.sys.service.*;
import com.njfu.ia.sys.utils.PaginationResult;
import com.njfu.ia.sys.utils.Result;
import com.njfu.ia.sys.utils.page.PageOffset;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.List;
/**
* 系统档案管理控制器
*/
@Controller
@RequestMapping("/sys/file")
public class FileController {
@Resource
private BlockService blockService;
@Resource
private SectionService sectionService;
@Resource
private FieldService fieldService;
@Resource
private CropService cropService;
@Resource
private MachineService machineService;
@Resource
private EndDeviceService endDeviceService;
@Resource
private SensorService sensorService;
private static final Logger LOGGER = LoggerFactory.getLogger(FileController.class);
/**
* 地块档案页
*
* @return
*/
@GetMapping("/block")
public String blockFile() {
return "sys/file/block";
}
/**
* 获取地块列表
*
* @param offset
* @param limit
* @param block
* @return
*/
@GetMapping("/block/data")
@PageOffset
public @ResponseBody
PaginationResult getBlocks(Integer offset, Integer limit, Block block) {
List<Block> blocks = blockService.queryBlocks(block);
PageInfo<Block> page = new PageInfo<>(blocks);
return new PaginationResult<>(page.getTotal(), blocks);
}
@GetMapping("/block/section/list")
public @ResponseBody Result listBlocksWithSections() {
try {
List<Block> blocks = blockService.queryBlocksWithSections();
return Result.response(ResultEnum.SUCCESS, null, blocks);
} catch (Exception e) {
LOGGER.error("list blocks with sections Exception", e);
return Result.response(ResultEnum.FAIL);
}
}
/**
* 新增地块信息
*
* @param block
* @return
*/
@PostMapping("/block/add")
public @ResponseBody
Result addBlock(Block block) {
try {
blockService.addBlock(block);
return Result.response(ResultEnum.SUCCESS);
} catch (BusinessException e) {
LOGGER.error(e.getMessage(), e);
return Result.response(ResultEnum.FAIL, e.getMessage(), null);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
return Result.response(ResultEnum.FAIL);
}
}
/**
* 修改地块信息
*
* @param block
* @return
*/
@PostMapping("/block/modify")
public @ResponseBody
Result modifyBlock(Block block) {
try {
blockService.modifyBlock(block);
return Result.response(ResultEnum.SUCCESS);
} catch (BusinessException e) {
LOGGER.error(e.getMessage(), e);
return Result.response(ResultEnum.FAIL, e.getMessage(), null);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
return Result.response(ResultEnum.FAIL);
}
}
/**
* 删除地块信息
*
* @param block
* @return
*/
@PostMapping("/block/remove")
public @ResponseBody
Result removeBlock(Integer id) {
try {
blockService.removeBlock(id);
return Result.response(ResultEnum.SUCCESS);
} catch (BusinessException e) {
LOGGER.error(e.getMessage(), e);
return Result.response(ResultEnum.FAIL, e.getMessage(), null);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
return Result.response(ResultEnum.FAIL);
}
}
/**
* 区块档案页
*
* @return
*/
@GetMapping("/section")
public String sectionFile() {
return "sys/file/section";
}
/**
* 获取区块信息数据
*
* @param offset
* @param limit
* @param section
* @return
*/
@GetMapping("/section/data")
@PageOffset
public @ResponseBody
PaginationResult getSectionData(Integer offset, Integer limit, Section section) {
List<Section> sections = sectionService.querySections(section);
PageInfo<Section> page = new PageInfo<>(sections);
return new PaginationResult(page.getTotal(), sections);
}
/**
* 新增区块信息
*
* @param section
* @return
*/
@PostMapping("/section/add")
public @ResponseBody
Result addSection(Section section) {
try {
sectionService.addSection(section);
return Result.response(ResultEnum.SUCCESS);
} catch (BusinessException e) {
LOGGER.error(e.getMessage(), e);
return Result.response(ResultEnum.FAIL, e.getMessage(), null);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
return Result.response(ResultEnum.FAIL);
}
}
/**
* 修改区块信息
*
* @param section
* @return
*/
@PostMapping("/section/modify")
public @ResponseBody
Result modifySection(Section section) {
try {
sectionService.modifySection(section);
return Result.response(ResultEnum.SUCCESS);
} catch (BusinessException e) {
LOGGER.error(e.getMessage(), e);
return Result.response(ResultEnum.FAIL, e.getMessage(), null);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
return Result.response(ResultEnum.FAIL);
}
}
/**
* 删除区块信息
*
* @param id
* @return
*/
@PostMapping("/section/remove")
public @ResponseBody
Result removeSection(Integer id) {
try {
sectionService.removeSection(id);
return Result.response(ResultEnum.SUCCESS);
} catch (BusinessException e) {
LOGGER.error(e.getMessage(), e);
return Result.response(ResultEnum.FAIL, e.getMessage(), null);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
return Result.response(ResultEnum.FAIL);
}
}
/**
* 大棚档案页
*
* @return
*/
@GetMapping("/field")
public String field() {
return "sys/file/field";
}
/**
* 获取大棚列表
*
* @param offset
* @param limit
* @param field
* @return
*/
@GetMapping("/field/data")
@PageOffset
public @ResponseBody
PaginationResult getFields(Integer offset, Integer limit, Field field) {
List<Field> fields = fieldService.queryFields(field);
PageInfo<Field> page = new PageInfo<>(fields);
return new PaginationResult<>(page.getTotal(), fields);
}
/**
* 新增大棚信息
*
* @param field
* @param block
* @param crop
* @return
*/
@PostMapping("/field/add")
public @ResponseBody
Result addField(Field field, Block block, Crop crop) {
try {
fieldService.addField(field);
return Result.response(ResultEnum.SUCCESS);
} catch
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Java是一种高性能、跨平台的面向对象编程语言。它由Sun Microsystems(现在是Oracle Corporation)的James Gosling等人在1995年推出,被设计为一种简单、健壮、可移植、多线程、动态的语言。Java的主要特点和优势包括以下几个方面: 跨平台性(Write Once, Run Anywhere): Java的代码可以在不同的平台上运行,只需编写一次代码,就可以在任何支持Java的设备上执行。这得益于Java虚拟机(JVM),它充当了代码和底层硬件之间的中介。 面向对象: Java是一种纯粹的面向对象编程语言,支持封装、继承和多态等面向对象的概念。这使得Java编写的代码更加模块化、可维护和可扩展。 多线程支持: Java内置了对多线程的支持,允许程序同时执行多个任务。这对于开发需要高并发性能的应用程序(如服务器端应用、网络应用等)非常重要。 自动内存管理(垃圾回收): Java具有自动内存管理机制,通过垃圾回收器自动回收不再使用的对象,使得开发者不需要手动管理内存,减轻了程序员的负担,同时也减少了内存泄漏的风险。
资源推荐
资源详情
资源评论













格式:zip 资源大小:93.5KB


















收起资源包目录





































































































共 224 条
- 1
- 2
- 3
资源评论

- 这个女人蕉小美2024-09-20总算找到了想要的资源,搞定遇到的大问题,赞赞赞!

JJJ69
- 粉丝: 6464
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- amplify-jvm-1.0.14-sources.jar
- tock-bot-connector-alexa-23.3.1-javadoc.jar
- pact-specification-test_2.10-2.1.13.jar
- 企业数字化转型赋能绿色创新的效果与机制研究(2007-2023年)
- 【Windows装机优化二】Windows update彻底关闭
- xinge0721-educational-robot-42416-1756645248650.zip
- 商道融绿ESG评级数据(2015-2024年)
- AI Agent原生企业落地技术路径之一-CSDN博客.html
- 基于pyhton的语音交互源码.zip
- docker基础命令知识-docker网络
- 政府引导基金数据(1900-2024年)
- 上市公司网络安全治理数据(2007-2023年)
- 基于PyQt5的智能视频压缩工具:融合现代UI与FFmpeg的强大解决方案
- 血玥珏 - IMG转ICON 2.0.0.2
- 维盟FBM550 超神固件 功能齐全
- 基于Zynq7000AP SoC的IEEE1588 PTP协议实现与运行
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
