代码生成器优化

This commit is contained in:
wangqiy 2025-04-17 16:00:55 +08:00
parent 740235038a
commit 34dd2e3306
16 changed files with 2456 additions and 105 deletions

View File

@ -0,0 +1,146 @@
package com.agri.web.controller.business;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import cn.hutool.core.convert.Convert;
import com.agri.business.domain.dto.CultivationBreedingBaseDto;
import com.agri.common.utils.ApiUtils;
import com.agri.common.utils.DateReplaceUtil;
import com.agri.common.utils.bean.BeanUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
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.RestController;
import com.agri.common.annotation.Log;
import com.agri.common.core.controller.BaseController;
import com.agri.common.core.domain.AjaxResult;
import com.agri.common.enums.BusinessType;
import com.agri.business.domain.CultivationBreedingBase;
import com.agri.business.service.ICultivationBreedingBaseService;
import com.agri.common.utils.poi.ExcelUtil;
import com.agri.common.core.page.TableDataInfo;
/**
* 种养殖基地Controller
*
* @author wqy
* @date 2025-04-17
*/
@Api(tags = "种养殖基地")
@RestController
@RequestMapping(value = "/cultivationBreedingBase", produces = "application/json")
public class CultivationBreedingBaseController extends BaseController
{
@Autowired
private ICultivationBreedingBaseService cultivationBreedingBaseService;
/**
* 查询种养殖基地列表
*/
@ApiOperation("查询种养殖基地列表")
@PreAuthorize("@ss.hasPermi('business:base:list')")
@GetMapping("/list")
public String list(CultivationBreedingBaseDto cultivationBreedingBaseDto) {
startPage();
List<CultivationBreedingBase> list = getList(cultivationBreedingBaseDto, true);
return getApiDataTable(list);
}
private List<CultivationBreedingBase> getList(CultivationBreedingBaseDto cultivationBreedingBaseDto, boolean isPage) {
if (isPage) {
startPage();
}
Map<String, Object> params = new HashMap<String, Object>();
params.put("createTimes", cultivationBreedingBaseDto.getCreateTimes());
params.put("createTimee", cultivationBreedingBaseDto.getCreateTimee());
DateReplaceUtil.spliceTime_00_00_00(params, "createTimes");
DateReplaceUtil.spliceTime_23_59_59(params, "createTimee");
List<CultivationBreedingBase> list = cultivationBreedingBaseService.findListByParam(params);
return list;
}
/**
* 导出条件搜索出的种养殖基地数据列表
*/
@PreAuthorize("@ss.hasPermi('business:base:export')")
@Log(title = "种养殖基地", businessType = BusinessType.EXPORT)
@PostMapping("/export")
@ApiOperation("导出")
public String export(CultivationBreedingBaseDto cultivationBreedingBaseDto) {
List<CultivationBreedingBase> list = getList(cultivationBreedingBaseDto, false);
cultivationBreedingBaseService.exportCultivationBreedingBaseExcel(list, 2);
return ApiUtils.success("操作成功,请到文件导出记录中下载");
}
/**
* 导出选中的种养殖基地数据列表
*/
@PreAuthorize("@ss.hasPermi('business:base:exportSelected')")
@Log(title = "种养殖基地", businessType = BusinessType.EXPORT)
@PostMapping("/exportSelected")
@ApiOperation("导入")
public String exportSelected(@RequestBody List<CultivationBreedingBase> list) {
cultivationBreedingBaseService.exportCultivationBreedingBaseExcel(list, 2);
return ApiUtils.success("操作成功,请到文件导出记录中下载");
}
/**
* 获取种养殖基地详细信息
*/
@ApiOperation("获取种养殖基地详细信息")
@PreAuthorize("@ss.hasPermi('business:base:query')")
@GetMapping(value = "/{id}")
public String getInfo(@PathVariable("id") Long id) {
return ApiUtils.successData(cultivationBreedingBaseService.find(id));
}
/**
* 新增种养殖基地
*/
@ApiOperation("新增种养殖基地")
@PreAuthorize("@ss.hasPermi('business:base:add')")
@Log(title = "种养殖基地", businessType = BusinessType.INSERT)
@PostMapping
public String add(@RequestBody CultivationBreedingBaseDto cultivationBreedingBaseDto) {
CultivationBreedingBase cultivationBreedingBase = new CultivationBreedingBase();
BeanUtils.copyProperties(cultivationBreedingBaseDto, cultivationBreedingBase);
cultivationBreedingBaseService.save(cultivationBreedingBase);
return ApiUtils.success();
}
/**
* 修改种养殖基地
*/
@ApiOperation("修改种养殖基地")
@PreAuthorize("@ss.hasPermi('business:base:edit')")
@Log(title = "种养殖基地", businessType = BusinessType.UPDATE)
@PutMapping
public String edit(@RequestBody CultivationBreedingBaseDto cultivationBreedingBaseDto) {
CultivationBreedingBase cultivationBreedingBase = new CultivationBreedingBase();
BeanUtils.copyProperties(cultivationBreedingBaseDto, cultivationBreedingBase);
cultivationBreedingBaseService.update(cultivationBreedingBase);
return ApiUtils.success();
}
/**
* 删除种养殖基地
*/
@ApiOperation("删除种养殖基地")
@PreAuthorize("@ss.hasPermi('business:base:remove')")
@Log(title = "种养殖基地", businessType = BusinessType.DELETE)
@PostMapping( "/remove")
public String remove(String ids) {
Long rows = cultivationBreedingBaseService.deleteByIds(Convert.toLongArray(ids));
return rows > 0 ? ApiUtils.success() : ApiUtils.error();
}
}

View File

@ -156,6 +156,13 @@
<artifactId>hutool-all</artifactId>
<version>5.7.18</version>
</dependency>
<!-- SpringBoot集成mybatisplus框架 -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.3.1</version>
</dependency>
</dependencies>
</project>

View File

@ -3,6 +3,9 @@ package com.agri.common.core.controller;
import java.beans.PropertyEditorSupport;
import java.util.Date;
import java.util.List;
import com.agri.common.utils.ApiUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.WebDataBinder;
@ -89,6 +92,18 @@ public class BaseController
return rspData;
}
/**
* 前后台分离获取表格数据
* @param list
* @return
*/
protected String getApiDataTable(List<?> list) {
Page page = new Page();
page.setRecords(list);
page.setTotal(list.size());
return ApiUtils.successData(page);
}
/**
* 返回成功
*/

View File

@ -0,0 +1,171 @@
package com.agri.common.utils;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import com.agri.common.exception.BusinessException;
import lombok.Data;
import java.text.ParseException;
import java.util.Date;
import java.util.Map;
@Data
public class DateReplaceUtil {
private String paramKey;
private String startKey;
private String endKey;
public static final String TIME_00_00_00 = " 00:00:00";
public static final String TIME_23_59_59 = " 23:59:59";
public DateReplaceUtil() {}
public DateReplaceUtil(String paramKey, String startKey, String endKey) {
this.paramKey = paramKey;
this.startKey = startKey;
this.endKey = endKey;
}
/**
* 把map中的参数替换为拼接 00:00:00的数据
* @param paramMap
* @param key
*/
public static void spliceTime_00_00_00(Map<String, Object> paramMap, String key) {
if (StringUtils.isEmpty(key)) {
// throw new BusinessException("时间转化参数不能为空");
return;
}
String value = MapUtil.getStr(paramMap, key);
if (StringUtils.isNotEmpty(value)) {
paramMap.put(key, value+TIME_00_00_00);
}
}
/**
* 把map中的参数替换为拼接 23:59:59的数据
* @param paramMap
* @param key
*/
public static void spliceTime_23_59_59(Map<String, Object> paramMap, String key) {
if (StringUtils.isEmpty(key)) {
// throw new BusinessException("时间转化参数不能为空");
return;
}
String value = MapUtil.getStr(paramMap, key);
if (StringUtils.isNotEmpty(value)) {
paramMap.put(key, value+TIME_23_59_59);
}
}
/**
* 把map中的参数替换为另一个起始时间段的数据, paramKey格式 --
* @param paramMap
* @param data
*/
public static void spliceTimeSection(Map<String, Object> paramMap, DateReplaceUtil data) {
if (StringUtils.isEmpty(data.getParamKey()) || StringUtils.isEmpty(data.getStartKey()) || StringUtils.isEmpty(data.getEndKey())) {
throw new BusinessException("时间转化参数不能为空");
}
String value = MapUtil.getStr(paramMap, data.getParamKey());
if (StringUtils.isNotEmpty(value)) {
paramMap.remove(data.getParamKey());
paramMap.put(data.getStartKey(), value+TIME_00_00_00);
paramMap.put(data.getEndKey(), value+TIME_23_59_59);
}
}
/**
* --日格式拼接 00:00:00
* @param time
* @return
*/
public static String addTime_00_00_00(String time) {
if (StringUtils.isEmpty(time)) {
throw new BusinessException("时间转化参数不能为空");
}
return time + TIME_00_00_00;
}
/**
* --日格式拼接 23:59:59
* @param time
* @return
*/
public static String addTime_23_59_59(String time) {
if (StringUtils.isEmpty(time)) {
throw new BusinessException("时间转化参数不能为空");
}
return time + TIME_23_59_59;
}
/**
* 入参年- 换成查询这个月的起止时间范围
* 把map中的参数替换为另一个起始时间段的数据, paramKey格式 -
* @param paramMap
* @param data
*/
public static void spliceTimeYM(Map<String, Object> paramMap, DateReplaceUtil data) {
if (StringUtils.isEmpty(data.getParamKey()) || StringUtils.isEmpty(data.getStartKey()) || StringUtils.isEmpty(data.getEndKey())) {
throw new BusinessException("时间转化参数不能为空");
}
try {
String value = MapUtil.getStr(paramMap, data.getParamKey());
if (StringUtils.isNotEmpty(value)) {
String startTimeStr = value + "-01" + TIME_00_00_00;
Date startTime = Dateutil.dateParse(startTimeStr, Dateutil.DATE_TIME_PATTERN);
int daysOfMonth = Dateutil.getDaysOfMonth(startTime);
int month = Dateutil.getMonth(startTime);
int year = Dateutil.getYear(startTime);
String endTimeStr = year + "-" + (month < 10? "0"+month:month) + "-" + (daysOfMonth < 10? "0"+daysOfMonth:daysOfMonth) + TIME_23_59_59;
paramMap.remove(data.getParamKey());
paramMap.put(data.getStartKey(), startTimeStr);
paramMap.put(data.getEndKey(), endTimeStr);
}
} catch (ParseException e) {
throw new BusinessException("格式错误");
}
}
/**
* @param map
* @param dateType 日期类型 1-今天(默认) 2-近七天 3-近半月 4-近一月 5-自定义时间范围
* @param startTime 搜索开始时间(yyyy-MM-dd)
* @param endTime 搜索结束时间(yyyy-MM-dd)
*/
public static void dateParamAnalysis(Map<String, Object> map, Integer dateType, String startTime, String endTime) {
String data = DateUtil.format(new Date(), "yyyy-MM-dd 23:59:59");
switch (dateType) {
case 2:
map.put("startTime", DateUtil.format(DateUtil.offsetDay(new Date(), -7), "yyyy-MM-dd 00:00:00"));
map.put("endTime", data);
break;
case 3:
map.put("startTime", DateUtil.format(DateUtil.offsetDay(new Date(), -15), "yyyy-MM-dd 00:00:00"));
map.put("endTime", data);
break;
case 4:
map.put("startTime", DateUtil.format(DateUtil.offsetDay(new Date(), -30), "yyyy-MM-dd 00:00:00"));
map.put("endTime", data);
break;
case 5:
if (StringUtils.isEmpty(startTime) || StringUtils.isEmpty(endTime)) {
throw new BusinessException("自定义时间参数错误");
}
map.put("startTime", startTime + " 00:00:00");
map.put("endTime", endTime + " 23:59:59");
break;
default:
map.put("startTime", DateUtil.format(new Date(), "yyyy-MM-dd 00:00:00"));
map.put("endTime", data);
break;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -193,26 +193,24 @@ public class VelocityUtils {
templates.add("vm/java/service.java.vm");
templates.add("vm/java/serviceImpl.java.vm");
templates.add("vm/java/controller.java.vm");
templates.add("vm/java/vo.java.vm");
// templates.add("vm/java/vo.java.vm");
templates.add("vm/java/dto.java.vm");
templates.add("vm/java/exportdto.java.vm");
// templates.add("vm/java/exportdto.java.vm");
templates.add("vm/xml/mapper.xml.vm");
templates.add("vm/js/api.js.vm");
if (GenConstants.TPL_CRUD.equals(tplCategory))
{
templates.add("vm/html/list.html.vm");
templates.add("vm/vue/index.vue.vm");
}
else if (GenConstants.TPL_TREE.equals(tplCategory))
{
templates.add("vm/html/tree.html.vm");
templates.add("vm/html/list-tree.html.vm");
templates.add("vm/vue/index-tree.vue.vm");
}
else if (GenConstants.TPL_SUB.equals(tplCategory))
{
templates.add("vm/html/list.html.vm");
templates.add("vm/vue/index.vue.vm");
templates.add("vm/java/sub-domain.java.vm");
}
templates.add("vm/html/add.html.vm");
templates.add("vm/html/edit.html.vm");
templates.add("vm/sql/sql.vm");
return templates;
}
@ -229,29 +227,6 @@ public class VelocityUtils {
String packageName = genTable.getPackageName();
// 模块名
String moduleName = genTable.getModuleName();
// boolean isSupplyBusiness = false;
// if (genTable.getTableName().startsWith("t_supply") || genTable.getTableName().startsWith("t_purchase")) {
// isSupplyBusiness = true;
// }
// if (isSupplyBusiness) {
// packageName = "com.shidian.supply";
// }
// boolean isTeamBuy = false;
// if (genTable.getTableName().startsWith("t_team")) {
// isTeamBuy = true;
// }
// if (isTeamBuy) {
// packageName = "com.shidian.teambuy";
// }
// // 是否是心选业务
// boolean isXinxuan = false;
// if (genTable.getTableName().startsWith("t_xinxuan")) {
// isXinxuan = true;
// }
// if (isXinxuan) {
// packageName = "com.shidian.xinxuan";
// moduleName = "xinxuan";
// }
// 大写类名
String className = genTable.getClassName();
@ -260,21 +235,19 @@ public class VelocityUtils {
String javaPath = PROJECT_PATH + "/" + StringUtils.replace(packageName, ".", "/");
String mybatisPath = MYBATIS_PATH + "/" + moduleName;
String htmlPath = TEMPLATES_PATH + "/" + moduleName + "/" + businessName;
// String htmlPath = TEMPLATES_PATH + "/" + moduleName + "/" + businessName;
String vuePath = "vue";
if (template.equals("domain.java.vm"))
{
fileName = StringUtils.format("{}/domain/{}.java", javaPath, className);
// if (isSupplyBusiness || isTeamBuy || isXinxuan) {
// fileName = StringUtils.format("{}/domain/entity/{}.java", javaPath, className);
// }
}
if (template.equals("dto.java.vm")){
fileName = StringUtils.format("{}/domain/dto/{}Dto.java", javaPath, className);
}
if (template.equals("sub-domain.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory()))
{
fileName = StringUtils.format("{}/domain/{}.java", javaPath, genTable.getSubTable().getClassName());
// if (isSupplyBusiness || isTeamBuy || isXinxuan) {
// fileName = StringUtils.format("{}/domain/entity/{}.java", javaPath, genTable.getSubTable().getClassName());
// }
}
else if (template.equals("mapper.java.vm"))
{
@ -290,48 +263,24 @@ public class VelocityUtils {
}
else if (template.equals("controller.java.vm"))
{
String controllerJavaPath = PROJECT_PATH + "/" + "com/shidian/web/controller/business";
// if (isSupplyBusiness) {
// controllerJavaPath = PROJECT_PATH + "/" + "com/shidian/web/controller/business/supply";
// }
// if (isTeamBuy) {
// controllerJavaPath = PROJECT_PATH + "/" + "com/shidian/web/controller/business/teambuy";
// }
// if (isXinxuan) {
// controllerJavaPath = PROJECT_PATH + "/" + "com/shidian/web/controller/xinxuan";
// }
String controllerJavaPath = PROJECT_PATH + "/" + "com/agri/web/controller/business";
fileName = StringUtils.format("{}/{}Controller.java", controllerJavaPath, className);
}
else if (template.equals("mapper.xml.vm"))
{
fileName = StringUtils.format("{}/{}Mapper.xml", mybatisPath, className);
// if (isSupplyBusiness) {
// fileName = StringUtils.format("{}/{}Mapper.xml", "supply", className);
// } else if (isTeamBuy) {
// fileName = StringUtils.format("{}/{}Mapper.xml", "teambuy", className);
// } else if (isXinxuan) {
// fileName = StringUtils.format("{}/{}Mapper.xml", "xinxuan", className);
// }
}
else if (template.equals("list.html.vm"))
else if (template.contains("api.js.vm"))
{
fileName = StringUtils.format("{}/{}.html", htmlPath, businessName);
fileName = StringUtils.format("{}/api/{}/{}.js", vuePath, moduleName, businessName);
}
else if (template.equals("list-tree.html.vm"))
else if (template.contains("index.vue.vm"))
{
fileName = StringUtils.format("{}/{}.html", htmlPath, businessName);
fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
}
else if (template.equals("tree.html.vm"))
else if (template.contains("index-tree.vue.vm"))
{
fileName = StringUtils.format("{}/tree.html", htmlPath);
}
else if (template.equals("add.html.vm"))
{
fileName = StringUtils.format("{}/add.html", htmlPath);
}
else if (template.equals("edit.html.vm"))
{
fileName = StringUtils.format("{}/edit.html", htmlPath);
fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
}
else if (template.equals("sql.vm"))
{

View File

@ -1,7 +1,14 @@
package ${packageName}.controller;
import java.util.HashMap;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
import cn.hutool.core.convert.Convert;
import com.agri.business.domain.dto.CultivationBreedingBaseDto;
import com.agri.common.utils.ApiUtils;
import com.agri.common.utils.DateReplaceUtil;
import com.agri.common.utils.bean.BeanUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
@ -32,9 +39,9 @@ import com.agri.common.core.page.TableDataInfo;
* @author ${author}
* @date ${datetime}
*/
@Api(tags = "${moduleName}-${functionName}")
@Api(tags = "${functionName}")
@RestController
@RequestMapping("/${moduleName}/${businessName}")
@RequestMapping(value = "/${className}", produces = "application/json")
public class ${ClassName}Controller extends BaseController
{
@Autowired
@ -47,32 +54,55 @@ public class ${ClassName}Controller extends BaseController
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
@GetMapping("/list")
#if($table.crud || $table.sub)
public TableDataInfo list(${ClassName} ${className})
{
public String list(${ClassName}Dto ${className}Dto) {
startPage();
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
return getDataTable(list);
List<${ClassName}> list = getList(${className}Dto, true);
return getApiDataTable(list);
}
#elseif($table.tree)
public AjaxResult list(${ClassName} ${className})
public AjaxResult list(${ClassName}Dto ${className}Dto)
{
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
return AjaxResult.success(list);
List<${ClassName}> list = getList(${className}Dto, true);
return getApiDataTable(list);
}
#end
private List<${ClassName}> getList(${ClassName}Dto ${className}Dto, boolean isPage) {
if (isPage) {
startPage();
}
Map<String, Object> params = new HashMap<String, Object>();
params.put("createTimes", ${className}Dto.getCreateTimes());
params.put("createTimee", ${className}Dto.getCreateTimee());
DateReplaceUtil.spliceTime_00_00_00(params, "createTimes");
DateReplaceUtil.spliceTime_23_59_59(params, "createTimee");
List<${ClassName}> list = ${className}Service.findListByParam(params);
return list;
}
/**
* 导出${functionName}列表
* 导出条件搜索出的${functionName}数据列表
*/
@ApiOperation("导出${functionName}列表")
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')")
@Log(title = "${functionName}", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ${ClassName} ${className})
{
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class);
util.exportExcel(response, list, "${functionName}数据");
@ApiOperation("导出")
public String export(${ClassName}Dto ${className}Dto) {
List<${ClassName}> list = getList(${className}Dto, false);
${className}Service.export${ClassName}Excel(list, 2);
return ApiUtils.success("操作成功,请到文件导出记录中下载");
}
/**
* 导出选中的${functionName}数据列表
*/
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:exportSelected')")
@Log(title = "${functionName}", businessType = BusinessType.EXPORT)
@PostMapping("/exportSelected")
@ApiOperation("导入")
public String exportSelected(@RequestBody List<${ClassName}> list) {
${className}Service.export${ClassName}Excel(list, 2);
return ApiUtils.success("操作成功,请到文件导出记录中下载");
}
/**
@ -81,9 +111,8 @@ public class ${ClassName}Controller extends BaseController
@ApiOperation("获取${functionName}详细信息")
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
@GetMapping(value = "/{${pkColumn.javaField}}")
public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
{
return AjaxResult.success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}));
public String getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) {
return ApiUtils.successData(${className}Service.find(${pkColumn.javaField}));
}
/**
@ -93,9 +122,11 @@ public class ${ClassName}Controller extends BaseController
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')")
@Log(title = "${functionName}", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ${ClassName} ${className})
{
return toAjax(${className}Service.insert${ClassName}(${className}));
public String add(@RequestBody ${ClassName}Dto ${className}Dto) {
${ClassName} ${className} = new ${ClassName}();
BeanUtils.copyProperties(${className}Dto, ${className});
${className}Service.save(${className});
return ApiUtils.success();
}
/**
@ -105,9 +136,11 @@ public class ${ClassName}Controller extends BaseController
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')")
@Log(title = "${functionName}", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody ${ClassName} ${className})
{
return toAjax(${className}Service.update${ClassName}(${className}));
public String edit(@RequestBody ${ClassName}Dto ${className}Dto) {
${ClassName} ${className} = new ${ClassName}();
BeanUtils.copyProperties(${className}Dto, ${className});
${className}Service.update(${className});
return ApiUtils.success();
}
/**
@ -116,9 +149,9 @@ public class ${ClassName}Controller extends BaseController
@ApiOperation("删除${functionName}")
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')")
@Log(title = "${functionName}", businessType = BusinessType.DELETE)
@DeleteMapping("/{${pkColumn.javaField}s}")
public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s)
{
return toAjax(${className}Service.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s));
@PostMapping( "/remove")
public String remove(String ids) {
Long rows = ${className}Service.deleteByIds(Convert.toLongArray(ids));
return rows > 0 ? ApiUtils.success() : ApiUtils.error();
}
}

View File

@ -15,6 +15,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.format.annotation.DateTimeFormat;
/**
* ${functionName}
@ -24,9 +25,6 @@ import io.swagger.annotations.ApiModelProperty;
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName(value = "${tableName}" )
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(value = "${functionName}" , description = "${functionName}" )
public class ${ClassName}Dto implements Serializable {
@ -43,4 +41,14 @@ public class ${ClassName}Dto implements Serializable {
#end
#end
/** 开始时间 */
@ApiModelProperty(value = "开始时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTimes;
/** 结束时间 */
@ApiModelProperty(value = "结束时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTimee;
}

View File

@ -24,9 +24,6 @@ import io.swagger.annotations.ApiModelProperty;
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName(value = "${tableName}")
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(value = "${functionName}", description = "${functionName}")
public class ${ClassName}Vo implements Serializable {

View File

@ -0,0 +1,118 @@
package com.agri.business.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.io.Serializable;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* 种养殖基地
*
* @author wqy
* @date 2025-04-17
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName(value = "t_cultivation_breeding_base")
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(value="种养殖基地",description="种养殖基地")
public class CultivationBreedingBase implements Serializable {
private static final long serialVersionUID = 1L;
/** 唯一标识每个基地的主键ID */
@ApiModelProperty(value = "唯一标识每个基地的主键ID")
private Long id;
/** 种养殖基地的名称 */
@ApiModelProperty(value = "种养殖基地的名称")
private String baseName;
/** 对应分类表中的ID */
@ApiModelProperty(value = "对应分类表中的ID")
private Long categoryId;
/** 基地类型(种植基地、养殖基地、综合基地) */
@ApiModelProperty(value = "基地类型(种植基地、养殖基地、综合基地)")
private String baseType;
/** 基地所在省份的行政区域编码 */
@ApiModelProperty(value = "基地所在省份的行政区域编码")
private String provinceCode;
/** 基地所在省份的名称 */
@ApiModelProperty(value = "基地所在省份的名称")
private String provinceName;
/** 基地所在市的行政区域编码 */
@ApiModelProperty(value = "基地所在市的行政区域编码")
private String cityCode;
/** 基地所在市的名称 */
@ApiModelProperty(value = "基地所在市的名称")
private String cityName;
/** 基地所在区/县的行政区域编码 */
@ApiModelProperty(value = "基地所在区/县的行政区域编码")
private String districtCode;
/** 基地所在区/县的名称 */
@ApiModelProperty(value = "基地所在区/县的名称")
private String districtName;
/** 种养殖基地的详细地址 */
@ApiModelProperty(value = "种养殖基地的详细地址")
private String address;
/** 基地的联系人姓名 */
@ApiModelProperty(value = "基地的联系人姓名")
private String contactPerson;
/** 基地的联系电话 */
@ApiModelProperty(value = "基地的联系电话")
private String contactPhone;
/** 对基地的详细描述,可为空 */
@ApiModelProperty(value = "对基地的详细描述,可为空")
private String description;
/** 种养殖基地的面积(单位:平方米) */
@ApiModelProperty(value = "种养殖基地的面积(单位:平方米)")
private BigDecimal area;
/** 面积单位 */
@ApiModelProperty(value = "面积单位")
private String unit;
/** 记录基地创建的时间 */
@ApiModelProperty(value = "记录基地创建的时间")
private Date createdAt;
/** 记录基地最后更新的时间 */
@ApiModelProperty(value = "记录基地最后更新的时间")
private Date updatedAt;
/** 1表示启用0表示禁用 */
@ApiModelProperty(value = "1表示启用0表示禁用")
private Integer status;
/** 地块ID */
@ApiModelProperty(value = "地块ID")
private String landId;
/** 地块名称 */
@ApiModelProperty(value = "地块名称")
private String landName;
}

View File

@ -0,0 +1,125 @@
package com.agri.business.domain.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.io.Serializable;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.format.annotation.DateTimeFormat;
/**
* 种养殖基地
*
* @author wqy
* @date 2025-04-17
*/
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(value = "种养殖基地" , description = "种养殖基地" )
public class CultivationBreedingBaseDto implements Serializable {
private static final long serialVersionUID = 1L;
/** 唯一标识每个基地的主键ID */
@ApiModelProperty(value = "唯一标识每个基地的主键ID")
private Long id;
/** 种养殖基地的名称 */
@ApiModelProperty(value = "种养殖基地的名称")
private String baseName;
/** 对应分类表中的ID */
@ApiModelProperty(value = "对应分类表中的ID")
private Long categoryId;
/** 基地类型(种植基地、养殖基地、综合基地) */
@ApiModelProperty(value = "基地类型(种植基地、养殖基地、综合基地)")
private String baseType;
/** 基地所在省份的行政区域编码 */
@ApiModelProperty(value = "基地所在省份的行政区域编码")
private String provinceCode;
/** 基地所在省份的名称 */
@ApiModelProperty(value = "基地所在省份的名称")
private String provinceName;
/** 基地所在市的行政区域编码 */
@ApiModelProperty(value = "基地所在市的行政区域编码")
private String cityCode;
/** 基地所在市的名称 */
@ApiModelProperty(value = "基地所在市的名称")
private String cityName;
/** 基地所在区/县的行政区域编码 */
@ApiModelProperty(value = "基地所在区/县的行政区域编码")
private String districtCode;
/** 基地所在区/县的名称 */
@ApiModelProperty(value = "基地所在区/县的名称")
private String districtName;
/** 种养殖基地的详细地址 */
@ApiModelProperty(value = "种养殖基地的详细地址")
private String address;
/** 基地的联系人姓名 */
@ApiModelProperty(value = "基地的联系人姓名")
private String contactPerson;
/** 基地的联系电话 */
@ApiModelProperty(value = "基地的联系电话")
private String contactPhone;
/** 对基地的详细描述,可为空 */
@ApiModelProperty(value = "对基地的详细描述,可为空")
private String description;
/** 种养殖基地的面积(单位:平方米) */
@ApiModelProperty(value = "种养殖基地的面积(单位:平方米)")
private BigDecimal area;
/** 面积单位 */
@ApiModelProperty(value = "面积单位")
private String unit;
/** 记录基地创建的时间 */
@ApiModelProperty(value = "记录基地创建的时间")
private Date createdAt;
/** 记录基地最后更新的时间 */
@ApiModelProperty(value = "记录基地最后更新的时间")
private Date updatedAt;
/** 1表示启用0表示禁用 */
@ApiModelProperty(value = "1表示启用0表示禁用")
private Integer status;
/** 地块ID */
@ApiModelProperty(value = "地块ID")
private String landId;
/** 地块名称 */
@ApiModelProperty(value = "地块名称")
private String landName;
/** 开始时间 */
@ApiModelProperty(value = "开始时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTimes;
/** 结束时间 */
@ApiModelProperty(value = "结束时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTimee;
}

View File

@ -0,0 +1,113 @@
package com.agri.business.domain.vo;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* 种养殖基地
*
* @author wqy
* @date 2025-04-17
*/
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(value="种养殖基地",description="种养殖基地")
public class CultivationBreedingBaseVo implements Serializable {
private static final long serialVersionUID = 1L;
/** 唯一标识每个基地的主键ID */
@ApiModelProperty(value = "唯一标识每个基地的主键ID")
private Long id;
/** 种养殖基地的名称 */
@ApiModelProperty(value = "种养殖基地的名称")
private String baseName;
/** 对应分类表中的ID */
@ApiModelProperty(value = "对应分类表中的ID")
private Long categoryId;
/** 基地类型(种植基地、养殖基地、综合基地) */
@ApiModelProperty(value = "基地类型(种植基地、养殖基地、综合基地)")
private String baseType;
/** 基地所在省份的行政区域编码 */
@ApiModelProperty(value = "基地所在省份的行政区域编码")
private String provinceCode;
/** 基地所在省份的名称 */
@ApiModelProperty(value = "基地所在省份的名称")
private String provinceName;
/** 基地所在市的行政区域编码 */
@ApiModelProperty(value = "基地所在市的行政区域编码")
private String cityCode;
/** 基地所在市的名称 */
@ApiModelProperty(value = "基地所在市的名称")
private String cityName;
/** 基地所在区/县的行政区域编码 */
@ApiModelProperty(value = "基地所在区/县的行政区域编码")
private String districtCode;
/** 基地所在区/县的名称 */
@ApiModelProperty(value = "基地所在区/县的名称")
private String districtName;
/** 种养殖基地的详细地址 */
@ApiModelProperty(value = "种养殖基地的详细地址")
private String address;
/** 基地的联系人姓名 */
@ApiModelProperty(value = "基地的联系人姓名")
private String contactPerson;
/** 基地的联系电话 */
@ApiModelProperty(value = "基地的联系电话")
private String contactPhone;
/** 对基地的详细描述,可为空 */
@ApiModelProperty(value = "对基地的详细描述,可为空")
private String description;
/** 种养殖基地的面积(单位:平方米) */
@ApiModelProperty(value = "种养殖基地的面积(单位:平方米)")
private BigDecimal area;
/** 面积单位 */
@ApiModelProperty(value = "面积单位")
private String unit;
/** 记录基地创建的时间 */
@ApiModelProperty(value = "记录基地创建的时间")
private Date createdAt;
/** 记录基地最后更新的时间 */
@ApiModelProperty(value = "记录基地最后更新的时间")
private Date updatedAt;
/** 1表示启用0表示禁用 */
@ApiModelProperty(value = "1表示启用0表示禁用")
private Integer status;
/** 地块ID */
@ApiModelProperty(value = "地块ID")
private String landId;
/** 地块名称 */
@ApiModelProperty(value = "地块名称")
private String landName;
}

View File

@ -0,0 +1,17 @@
package com.agri.business.mapper;
import java.util.List;
import com.agri.common.dao.BaseDao;
import com.agri.business.domain.CultivationBreedingBase;
import org.apache.ibatis.annotations.Mapper;
/**
* 种养殖基地Mapper接口
*
* @author wqy
* @since 2025-04-17
*/
@Mapper
public interface CultivationBreedingBaseMapper extends BaseDao<CultivationBreedingBase> {
}

View File

@ -0,0 +1,22 @@
package com.agri.business.service;
import java.util.List;
import com.agri.business.domain.CultivationBreedingBase;
import com.agri.common.service.BaseService;
/**
* 种养殖基地Service接口
*
* @author wqy
* @since 2025-04-17
*/
public interface ICultivationBreedingBaseService extends BaseService<CultivationBreedingBase> {
/**
* 导出种养殖基地数据列表
* @param list 数据列表
* @param sourceType 1-总后台 2-集货中心 3-基地供应商后台
*/
void exportCultivationBreedingBaseExcel(List<CultivationBreedingBase> list, Integer sourceType);
}

View File

@ -0,0 +1,44 @@
package com.agri.business.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.agri.business.mapper.CultivationBreedingBaseMapper;
import com.agri.business.domain.CultivationBreedingBase;
import com.agri.business.service.ICultivationBreedingBaseService;
import com.agri.common.service.impl.BaseServiceImpl;
import com.agri.common.enums.ExportEnum;
/**
* 种养殖基地Service业务层处理
*
* @author wqy
* @since 2025-04-17
*/
@Service
public class CultivationBreedingBaseServiceImpl extends BaseServiceImpl<CultivationBreedingBase> implements ICultivationBreedingBaseService {
@Autowired
private CultivationBreedingBaseMapper cultivationBreedingBaseMapper;
// @Autowired
// private IExportService exportService;
/**
* 导出种养殖基地数据列表
* @param list 数据列表
* @param sourceType 1-总后台 2-集货中心 3-基地供应商后台
*/
@Override
public void exportCultivationBreedingBaseExcel(List<CultivationBreedingBase> list, Integer sourceType) {
/*if (list == null || list.size() == 0) {
throw new BusinessException("没有要导出的记录");
}
List<CultivationBreedingBaseExportDto> exportList = CultivationBreedingBaseExportDto.build(list);
ExcelUtil<CultivationBreedingBaseExportDto> util = new ExcelUtil<>(CultivationBreedingBaseExportDto.class);
String sheetName = ExportEnum.APP_USER_EXPORT.getDesc();
int code = ExportEnum.APP_USER_EXPORT.getCode()
Workbook workHook = util.getWorkHook(exportList, sheetName);
exportService.exportRecord(workHook, sheetName, code, sourceType);*/
}
}

View File

@ -0,0 +1,327 @@
<?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="com.agri.business.mapper.CultivationBreedingBaseMapper">
<resultMap type="com.agri.business.domain.CultivationBreedingBase" id="CultivationBreedingBaseResult">
<result property="id" column="id"/>
<result property="baseName" column="base_name"/>
<result property="categoryId" column="category_id"/>
<result property="baseType" column="base_type"/>
<result property="provinceCode" column="province_code"/>
<result property="provinceName" column="province_name"/>
<result property="cityCode" column="city_code"/>
<result property="cityName" column="city_name"/>
<result property="districtCode" column="district_code"/>
<result property="districtName" column="district_name"/>
<result property="address" column="address"/>
<result property="contactPerson" column="contact_person"/>
<result property="contactPhone" column="contact_phone"/>
<result property="description" column="description"/>
<result property="area" column="area"/>
<result property="unit" column="unit"/>
<result property="createdAt" column="created_at"/>
<result property="updatedAt" column="updated_at"/>
<result property="status" column="status"/>
<result property="landId" column="land_id"/>
<result property="landName" column="land_name"/>
</resultMap>
<sql id="base_column">
<trim suffixOverrides=",">
id
,base_name
,category_id
,base_type
,province_code
,province_name
,city_code
,city_name
,district_code
,district_name
,address
,contact_person
,contact_phone
,description
,area
,unit
,created_at
,updated_at
,status
,land_id
,land_name
</trim>
</sql>
<sql id="base_value">
<trim suffixOverrides=",">
#{id}
,#{baseName}
,#{categoryId}
,#{baseType}
,#{provinceCode}
,#{provinceName}
,#{cityCode}
,#{cityName}
,#{districtCode}
,#{districtName}
,#{address}
,#{contactPerson}
,#{contactPhone}
,#{description}
,#{area}
,#{unit}
,#{createdAt}
,#{updatedAt}
,#{status}
,#{landId}
,#{landName}
</trim>
</sql>
<sql id="where_column">
<if test="id != null and id != ''">
AND id = #{id}
</if>
<if test="baseName != null and baseName != ''">
AND base_name = #{baseName}
</if>
<if test="baseNameLike != null and baseNameLike != ''">
AND base_name like CONCAT('%', #{baseNameLike}, '%')
</if>
<if test="categoryId != null and categoryId != ''">
AND category_id = #{categoryId}
</if>
<if test="baseType != null and baseType != ''">
AND base_type = #{baseType}
</if>
<if test="provinceCode != null and provinceCode != ''">
AND province_code = #{provinceCode}
</if>
<if test="provinceName != null and provinceName != ''">
AND province_name = #{provinceName}
</if>
<if test="cityCode != null and cityCode != ''">
AND city_code = #{cityCode}
</if>
<if test="cityName != null and cityName != ''">
AND city_name = #{cityName}
</if>
<if test="districtCode != null and districtCode != ''">
AND district_code = #{districtCode}
</if>
<if test="districtName != null and districtName != ''">
AND district_name = #{districtName}
</if>
<if test="address != null and address != ''">
AND address = #{address}
</if>
<if test="contactPerson != null and contactPerson != ''">
AND contact_person = #{contactPerson}
</if>
<if test="contactPhone != null and contactPhone != ''">
AND contact_phone = #{contactPhone}
</if>
<if test="description != null and description != ''">
AND description = #{description}
</if>
<if test="area != null and area != ''">
AND area = #{area}
</if>
<if test="unit != null and unit != ''">
AND unit = #{unit}
</if>
<if test="createdAt != null and createdAt != ''">
AND created_at = #{createdAt}
</if>
<if test="createdAts != null and createdAts != ''">
AND created_at <![CDATA[>=]]> #{createdAts}
</if>
<if test="createdAte != null and createdAte != ''">
AND created_at <![CDATA[<=]]> #{createdAte}
</if>
<if test="idInList != null">
AND id in
<if test="idInList.size() > 0">
<foreach collection="idInList" item="idInListItem" index="index" open="(" separator="," close=")">
#{idInListItem}
</foreach>
</if>
<if test="idInList.size() == 0">
(-1)
</if>
</if>
<if test="updatedAt != null and updatedAt != ''">
AND updated_at = #{updatedAt}
</if>
<if test="status != null and status != ''">
AND status = #{status}
</if>
<if test="landId != null and landId != ''">
AND land_id = #{landId}
</if>
<if test="landName != null and landName != ''">
AND land_name = #{landName}
</if>
</sql>
<sql id="set_column">
<if test="id != null">
id = #{id},
</if>
<if test="baseName != null">
base_name = #{baseName},
</if>
<if test="categoryId != null">
category_id = #{categoryId},
</if>
<if test="baseType != null">
base_type = #{baseType},
</if>
<if test="provinceCode != null">
province_code = #{provinceCode},
</if>
<if test="provinceName != null">
province_name = #{provinceName},
</if>
<if test="cityCode != null">
city_code = #{cityCode},
</if>
<if test="cityName != null">
city_name = #{cityName},
</if>
<if test="districtCode != null">
district_code = #{districtCode},
</if>
<if test="districtName != null">
district_name = #{districtName},
</if>
<if test="address != null">
address = #{address},
</if>
<if test="contactPerson != null">
contact_person = #{contactPerson},
</if>
<if test="contactPhone != null">
contact_phone = #{contactPhone},
</if>
<if test="description != null">
description = #{description},
</if>
<if test="area != null">
area = #{area},
</if>
<if test="unit != null">
unit = #{unit},
</if>
<if test="createdAt != null">
created_at = #{createdAt},
</if>
<if test="updatedAt != null">
updated_at = #{updatedAt},
</if>
<if test="status != null">
status = #{status},
</if>
<if test="landId != null">
land_id = #{landId},
</if>
<if test="landName != null">
land_name = #{landName},
</if>
</sql>
<!-- 查找单条 -->
<select id="find" resultMap="CultivationBreedingBaseResult">
select
<include refid="base_column"/>
from t_cultivation_breeding_base
where id = #{id}
</select>
<!-- 插入 -->
<insert id="insert" parameterType="com.agri.business.domain.CultivationBreedingBase">
<selectKey resultType="java.lang.Long" order="AFTER" keyProperty="id">
SELECT LAST_INSERT_ID() AS id
</selectKey>
INSERT into t_cultivation_breeding_base
(<include refid="base_column"/>)
VALUES
(<include refid="base_value"/>)
</insert>
<!-- 更新 -->
<update id="update" parameterType="com.agri.business.domain.CultivationBreedingBase">
update t_cultivation_breeding_base
<set>
<include refid="set_column"/>
</set>
where id = #{id}
</update>
<!-- 查询所有 -->
<select id="findAll" resultMap="CultivationBreedingBaseResult">
SELECT
<include refid="base_column"/>
FROM t_cultivation_breeding_base
</select>
<!-- 通过参数查找单条 -->
<select id="findByParam" resultMap="CultivationBreedingBaseResult">
SELECT
<include refid="base_column"/>
FROM t_cultivation_breeding_base
<where>
<include refid="where_column"/>
</where>
</select>
<!-- 通过参数查找集合 -->
<select id="findListByParam" resultMap="CultivationBreedingBaseResult">
SELECT
<include refid="base_column"/>
FROM t_cultivation_breeding_base
<where>
<include refid="where_column"/>
</where>
<if test="order != null and order != ''">
order by ${order}
</if>
<if test="offset != null and offset >= 0 and limit != null and limit > 0">
limit #{offset},#{limit}
</if>
</select>
<!-- 删除单条记录 -->
<delete id="delete">
DELETE FROM t_cultivation_breeding_base
WHERE id = #{id}
</delete>
<!-- 统计记录数 -->
<select id="count" resultType="long">
SELECT COUNT(id) FROM t_cultivation_breeding_base
<where>
<include refid="where_column"/>
</where>
</select>
<!-- 通过参数删除 -->
<delete id="deleteByParam">
DELETE FROM t_cultivation_breeding_base
<where>
<include refid="where_column"/>
</where>
</delete>
<!-- 通过id数组删除多条记录 -->
<delete id="deleteByIds">
DELETE FROM t_cultivation_breeding_base
WHERE id IN
<foreach item="id" index="index" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>