src/main/java/org/springblade/modules/desk/mapper/FarmMapper.xml
src/main/java/org/springblade/modules/develop/mapper/FarmMapper.xml
src/main/java/org/springblade/modules/farm/controller/FarmController.java
New file @@ -0,0 +1,121 @@ /* * 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.Farm; import org.springblade.modules.farm.service.FarmService; import org.springblade.modules.farm.vo.FarmVO; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; /** * 农场控制器 * @since 2022-05-10 * @author zhongrj */ @RestController @AllArgsConstructor @RequestMapping("/farm") public class FarmController extends BladeController { private final FarmService farmService; /** * 详情 */ @GetMapping("/detail") @ApiOperationSupport(order = 1) @ApiOperation(value = "详情", notes = "传入farm") public R<Farm> detail(Farm farm) { Farm detail = farmService.getOne(Condition.getQueryWrapper(farm)); return R.data(detail); } /** * 分页 */ @GetMapping("/list") @ApiOperationSupport(order = 2) @ApiOperation(value = "分页", notes = "传入farm") public R<IPage<Farm>> list(Farm farm, Query query) { IPage<Farm> 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<FarmVO>> page(FarmVO farm, Query query) { IPage<FarmVO> pages = farmService.selectFarmPage(Condition.getPage(query), farm); return R.data(pages); } /** * 新增 */ @PostMapping("/save") @ApiOperationSupport(order = 4) @ApiOperation(value = "新增", notes = "传入farm") public R save(@Valid @RequestBody Farm farm) { return R.status(farmService.save(farm)); } /** * 修改 */ @PostMapping("/update") @ApiOperationSupport(order = 5) @ApiOperation(value = "修改", notes = "传入farm") public R update(@Valid @RequestBody Farm farm) { return R.status(farmService.updateById(farm)); } /** * 新增或修改 */ @PostMapping("/submit") @ApiOperationSupport(order = 6) @ApiOperation(value = "新增或修改", notes = "传入farm") public R submit(@Valid @RequestBody Farm 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))); } } src/main/java/org/springblade/modules/farm/entity/Farm.java
New file @@ -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-10 * @author zhongrj */ @Data @TableName("sys_farm") public class Farm implements Serializable { private static final long serialVersionUID = 1L; /** * 主键id */ @TableId(value = "id",type = IdType.AUTO) private Integer id; /** * 农场名称 */ private Integer farmName; /** * 农场地址 */ private String farmAddress; /** * 土地流转面积 */ private String farmArea; /** * 口号 */ private String slogan; /** * 介绍 */ private String introduce; /** * 农场环境照片(多张) */ private String picture; /** * 农场位置(面) */ private String position; /** * 租户id */ private String tenantId; /** * 创建时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date createTime; } src/main/java/org/springblade/modules/farm/mapper/FarmMapper.java
New file @@ -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.springblade.modules.farm.entity.Farm; import org.springblade.modules.farm.vo.FarmVO; import java.util.List; /** * 农场Mapper 接口 * @since 2022-05-10 * @author zhongrj */ public interface FarmMapper extends BaseMapper<Farm> { /** * 自定义分页 * * @param page * @param farm * @return */ List<FarmVO> selectFarmPage(IPage page, FarmVO farm); } src/main/java/org/springblade/modules/farm/mapper/FarmMapper.xml
New file @@ -0,0 +1,10 @@ <?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.FarmMapper"> <!--自定义查询农场分页数据--> <select id="selectFarmPage" resultType="org.springblade.modules.farm.vo.FarmVO"> select * from sys_farm where 1=1 </select> </mapper> src/main/java/org/springblade/modules/farm/service/FarmService.java
New file @@ -0,0 +1,26 @@ 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.Farm; import org.springblade.modules.farm.vo.FarmVO; /** * 农场服务类 * @since 2022-05-10 * @author zhongrj */ public interface FarmService extends IService<Farm> { /** * 自定义分页 * * @param page * @param farm * @return */ IPage<FarmVO> selectFarmPage(IPage<FarmVO> page, FarmVO farm); } src/main/java/org/springblade/modules/farm/service/impl/FarmServiceImpl.java
New file @@ -0,0 +1,45 @@ /* * 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.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springblade.modules.farm.entity.Farm; import org.springblade.modules.farm.mapper.FarmMapper; import org.springblade.modules.farm.service.FarmService; import org.springblade.modules.farm.vo.FarmVO; import org.springframework.stereotype.Service; /** * 农场服务实现类 * @since 2022-05-10 * @author zhongrj */ @Service public class FarmServiceImpl extends ServiceImpl<FarmMapper, Farm> implements FarmService { /** * 自定义分页 * @param page * @param farm * @return */ @Override public IPage<FarmVO> selectFarmPage(IPage<FarmVO> page, FarmVO farm) { return page.setRecords(baseMapper.selectFarmPage(page, farm)); } } src/main/java/org/springblade/modules/farm/vo/FarmVO.java
New file @@ -0,0 +1,29 @@ package org.springblade.modules.farm.vo; import io.swagger.annotations.ApiModel; import lombok.Data; import lombok.EqualsAndHashCode; import org.springblade.modules.resource.entity.Oss; /** * OssVO * * @author Chill */ @Data @EqualsAndHashCode(callSuper = true) @ApiModel(value = "OssVO对象", description = "对象存储表") public class FarmVO extends Oss { private static final long serialVersionUID = 1L; /** * 分类名 */ private String categoryName; /** * 是否启用 */ private String statusName; } src/main/resources/application-test.yml
@@ -14,9 +14,9 @@ # nodes: 127.0.0.1:7001,127.0.0.1:7002,127.0.0.1:7003 # commandTimeout: 5000 datasource: url: jdbc:mysql://localhost:3306/bladex_boot?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true url: jdbc:mysql://36.134.81.48:3306/zhny?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true username: root password: root password: jfpt123 #第三方登陆 social: @@ -32,7 +32,7 @@ ##将docker脚本部署的redis服务映射为宿主机ip ##生产环境推荐使用阿里云高可用redis服务并设置密码 address: redis://127.0.0.1:6379 password: 123456 password: #本地文件上传 file: remote-mode: true src/main/resources/application.yml
@@ -1,6 +1,6 @@ #服务器配置 server: port: 80 port: 89 undertow: threads: # 设置IO线程数, 它主要执行非阻塞的任务,它们会负责多个连接, 默认设置每个CPU核心一个线程 src/test/java/org/springblade/test/BladeTest.java
@@ -1,46 +1,46 @@ package org.springblade.test; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import org.junit.Test; import org.junit.runner.RunWith; import org.springblade.core.test.BladeBootTest; import org.springblade.core.test.BladeSpringRunner; import org.springblade.core.tool.utils.StringUtil; import org.springblade.flow.engine.entity.FlowModel; import org.springblade.flow.engine.service.FlowEngineService; import org.springframework.beans.factory.annotation.Autowired; import java.util.List; /** * Blade单元测试 * * @author Chill */ @RunWith(BladeSpringRunner.class) @BladeBootTest(appName = "blade-runner", enableLoader = true) public class BladeTest { @Autowired private FlowEngineService service; @Test public void contextLoads() { System.out.println("=====数据迁移启动====="); // 获取 ACT_DE_MODEL 表需要转换的数据 List<FlowModel> list = service.list(); // 循环转换 list.forEach(flowModel -> { if (StringUtil.isBlank(flowModel.getModelEditorXml())) { service.update(Wrappers.<FlowModel>lambdaUpdate() .set(FlowModel::getModelEditorXml, new String(service.getModelEditorXML(flowModel))) .ge(FlowModel::getId, flowModel.getId()) ); } }); System.out.println("=====数据迁移完毕====="); } } //package org.springblade.test; // //import com.baomidou.mybatisplus.core.toolkit.Wrappers; //import org.junit.Test; //import org.junit.runner.RunWith; //import org.springblade.core.test.BladeBootTest; //import org.springblade.core.test.BladeSpringRunner; //import org.springblade.core.tool.utils.StringUtil; //import org.springblade.flow.engine.entity.FlowModel; //import org.springblade.flow.engine.service.FlowEngineService; //import org.springframework.beans.factory.annotation.Autowired; // //import java.util.List; // ///** // * Blade单元测试 // * // * @author Chill // */ //@RunWith(BladeSpringRunner.class) //@BladeBootTest(appName = "blade-runner", enableLoader = true) //public class BladeTest { // // @Autowired // private FlowEngineService service; // // @Test // public void contextLoads() { // System.out.println("=====数据迁移启动====="); // // // 获取 ACT_DE_MODEL 表需要转换的数据 // List<FlowModel> list = service.list(); // // 循环转换 // list.forEach(flowModel -> { // if (StringUtil.isBlank(flowModel.getModelEditorXml())) { // service.update(Wrappers.<FlowModel>lambdaUpdate() // .set(FlowModel::getModelEditorXml, new String(service.getModelEditorXML(flowModel))) // .ge(FlowModel::getId, flowModel.getId()) // ); // } // }); // // System.out.println("=====数据迁移完毕====="); // } // //}