From 274358c3599ba1e641c45734afad76d9be19f864 Mon Sep 17 00:00:00 2001 From: liukewei Date: Tue, 5 Dec 2023 08:45:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81=E7=94=9F?= =?UTF-8?q?=E6=88=90=20=E5=AE=8C=E6=88=90=E9=A3=8E=E9=99=A9=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ehs/EhsMaterialController.java | 13 +- .../web/controller/ehs/EhsRiskController.java | 14 +- .../controller/system/SysDeptController.java | 12 + .../ruoyi/common/constant/GenConstants.java | 9 +- .../ruoyi/common/core/domain/BaseEntity.java | 88 +--- .../CreateAndUpdateMetaObjectHandler.java | 2 + .../generator/domain/GenTableColumn.java | 1 + .../resources/vm/java-plus/controller.java.vm | 141 +++++++ .../resources/vm/java-plus/domain.java.vm | 72 ++++ .../resources/vm/java-plus/mapper.java.vm | 43 ++ .../resources/vm/java-plus/service.java.vm | 64 +++ .../vm/java-plus/serviceImpl.java.vm | 179 +++++++++ .../resources/vm/java-plus/sub-domain.java.vm | 61 +++ .../main/resources/vm/java/controller.java.vm | 87 ++-- .../src/main/resources/vm/java/mapper.java.vm | 23 +- .../main/resources/vm/java/service.java.vm | 90 +++-- .../resources/vm/java/serviceImpl.java.vm | 276 ++++++------- .../main/resources/vm/xml/mapper-plus.xml.vm | 36 ++ .../src/main/resources/vm/xml/mapper.xml.vm | 90 +++-- .../ruoyi/ehsMaterial/domain/EhsMaterial.java | 9 +- .../ehsMaterial/mapper/EhsMaterialMapper.java | 19 +- .../service/IEhsMaterialService.java | 10 +- .../service/impl/EhsMaterialServiceImpl.java | 17 +- .../com/ruoyi/ehsRisk/domain/EhsRisk.java | 1 - .../ruoyi/ehsRisk/mapper/EhsRiskMapper.java | 17 + .../ehsRisk/service/IEhsRiskService.java | 9 +- .../service/impl/EhsRiskServiceImpl.java | 40 +- .../ruoyi/system/mapper/SysDeptMapper.java | 8 + .../ruoyi/system/service/ISysDeptService.java | 7 + .../service/impl/SysDeptServiceImpl.java | 10 + .../mapper/ehs/EhsMaterialMapper.xml | 68 +++- .../resources/mapper/ehs/EhsRiskMapper.xml | 36 +- .../resources/mapper/system/SysDeptMapper.xml | 6 +- ruoyi-ui/src/api/system/dept.js | 10 +- ruoyi-ui/src/store/modules/user.js | 8 + .../ehsMaterial/{ehsMaterial => }/index.vue | 375 ++++++++++-------- ruoyi-ui/src/views/ehs/ehsRisk/index.vue | 28 +- 37 files changed, 1391 insertions(+), 588 deletions(-) create mode 100644 ruoyi-generator/src/main/resources/vm/java-plus/controller.java.vm create mode 100644 ruoyi-generator/src/main/resources/vm/java-plus/domain.java.vm create mode 100644 ruoyi-generator/src/main/resources/vm/java-plus/mapper.java.vm create mode 100644 ruoyi-generator/src/main/resources/vm/java-plus/service.java.vm create mode 100644 ruoyi-generator/src/main/resources/vm/java-plus/serviceImpl.java.vm create mode 100644 ruoyi-generator/src/main/resources/vm/java-plus/sub-domain.java.vm create mode 100644 ruoyi-generator/src/main/resources/vm/xml/mapper-plus.xml.vm rename ruoyi-ui/src/views/ehs/ehsMaterial/{ehsMaterial => }/index.vue (53%) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsMaterialController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsMaterialController.java index a115bc1..1224ca5 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsMaterialController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsMaterialController.java @@ -1,4 +1,4 @@ -package com.ruoyi.web.controller.ehs; +package com.ruoyi.ehsMaterial.controller; import java.util.List; import java.util.Arrays; @@ -28,7 +28,7 @@ import com.ruoyi.common.core.page.TableDataInfo; * 物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”Controller * * @author ruoyi - * @date 2023-12-01 + * @date 2023-12-04 */ @Api(tags="物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”管理") @RestController @@ -41,7 +41,6 @@ public class EhsMaterialController extends BaseController /** * 查询物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”列表 */ - @ApiOperation("查询物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”列表") @PreAuthorize("@ss.hasPermi('ehsMaterial:ehsMaterial:list')") @GetMapping("/list") public TableDataInfo list(EhsMaterial ehsMaterial) @@ -54,7 +53,6 @@ public class EhsMaterialController extends BaseController /** * 导出物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”列表 */ - @ApiOperation("导出物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”列表") @PreAuthorize("@ss.hasPermi('ehsMaterial:ehsMaterial:export')") @Log(title = "物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”", businessType = BusinessType.EXPORT) @PostMapping("/export") @@ -68,12 +66,11 @@ public class EhsMaterialController extends BaseController /** * 获取物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”详细信息 */ - @ApiOperation("获取物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”详细信息") @PreAuthorize("@ss.hasPermi('ehsMaterial:ehsMaterial:query')") @GetMapping(value = "/{materialId}") public AjaxResult getInfo(@PathVariable("materialId") Long materialId) { - return success(ehsMaterialService.getById(materialId)); + return success(ehsMaterialService.selectEhsMaterialByMaterialId(materialId)); } /** @@ -106,9 +103,9 @@ public class EhsMaterialController extends BaseController @ApiOperation("删除物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”") @PreAuthorize("@ss.hasPermi('ehsMaterial:ehsMaterial:remove')") @Log(title = "物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”", businessType = BusinessType.DELETE) - @DeleteMapping("/{materialIds}") + @DeleteMapping("/{materialIds}") public AjaxResult remove(@PathVariable Long[] materialIds) { return toAjax(ehsMaterialService.removeByIds(Arrays.asList(materialIds))); } -} +} \ No newline at end of file diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsRiskController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsRiskController.java index 8348903..70750ab 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsRiskController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsRiskController.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.Arrays; import javax.servlet.http.HttpServletResponse; +import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.ehsRisk.domain.EhsRisk; import com.ruoyi.ehsRisk.service.IEhsRiskService; import org.springframework.security.access.prepost.PreAuthorize; @@ -29,7 +30,7 @@ import com.ruoyi.common.core.page.TableDataInfo; * 风险信息Controller * * @author ruoyi - * @date 2023-11-30 + * @date 2023-12-04 */ @Api(tags="风险信息管理") @RestController @@ -39,10 +40,10 @@ public class EhsRiskController extends BaseController @Autowired private IEhsRiskService ehsRiskService; + /** * 查询风险信息列表 */ - @ApiOperation("查询风险信息列表") @PreAuthorize("@ss.hasPermi('system:risk:list')") @GetMapping("/list") public TableDataInfo list(EhsRisk ehsRisk) @@ -55,12 +56,12 @@ public class EhsRiskController extends BaseController /** * 导出风险信息列表 */ - @ApiOperation("导出风险信息列表") @PreAuthorize("@ss.hasPermi('system:risk:export')") @Log(title = "风险信息", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, EhsRisk ehsRisk) { + List list = ehsRiskService.selectEhsRiskList(ehsRisk); ExcelUtil util = new ExcelUtil(EhsRisk.class); util.exportExcel(response, list, "风险信息数据"); @@ -69,12 +70,11 @@ public class EhsRiskController extends BaseController /** * 获取风险信息详细信息 */ - @ApiOperation("获取风险信息详细信息") @PreAuthorize("@ss.hasPermi('system:risk:query')") @GetMapping(value = "/{riskId}") public AjaxResult getInfo(@PathVariable("riskId") Long riskId) { - return success(ehsRiskService.getById(riskId)); + return success(ehsRiskService.selectEhsRiskByRiskId(riskId)); } /** @@ -107,9 +107,9 @@ public class EhsRiskController extends BaseController @ApiOperation("删除风险信息") @PreAuthorize("@ss.hasPermi('system:risk:remove')") @Log(title = "风险信息", businessType = BusinessType.DELETE) - @DeleteMapping("/{riskIds}") + @DeleteMapping("/{riskIds}") public AjaxResult remove(@PathVariable Long[] riskIds) { return toAjax(ehsRiskService.removeByIds(Arrays.asList(riskIds))); } -} +} \ No newline at end of file diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java index 59e7588..a8233e5 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java @@ -129,4 +129,16 @@ public class SysDeptController extends BaseController deptService.checkDeptDataScope(deptId); return toAjax(deptService.deleteDeptById(deptId)); } + /** + * 查询所有部门数据的id和name + * + * @param dept 部门信息 + * @return 部门信息集合 + */ + @GetMapping("/getAllDeptList") + public AjaxResult selectAllDeptList(SysDept dept) + { + List depts = deptService.selectAllDeptList(dept); + return success(depts); + } } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/GenConstants.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/GenConstants.java index 7d899d4..52fe786 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/constant/GenConstants.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/GenConstants.java @@ -45,18 +45,19 @@ public class GenConstants "bit", "bigint", "float", "double", "decimal" }; /** 页面不需要编辑字段 */ - public static final String[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "del_flag" }; + public static final String[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "del_flag", "create_user_id", "update_user_id" }; /** 页面不需要显示的列表字段 */ public static final String[] COLUMNNAME_NOT_LIST = { "id", "create_by", "create_time", "del_flag", "update_by", - "update_time" }; + "update_time" , "create_user_id", "update_user_id"}; /** 页面不需要查询字段 */ public static final String[] COLUMNNAME_NOT_QUERY = { "id", "create_by", "create_time", "del_flag", "update_by", - "update_time", "remark" }; + "update_time", "remark" , "createUserId", "updateUserId"}; /** Entity基类字段 */ - public static final String[] BASE_ENTITY = { "createBy", "createTime", "updateBy", "updateTime", "remark" }; + public static final String[] BASE_ENTITY = { "createBy", "createTime", "updateBy", "updateTime", "remark", + "deptId", "createUserId", "updateUserId", "deptName" }; /** Tree基类字段 */ public static final String[] TREE_ENTITY = { "parentName", "parentId", "orderNum", "ancestors", "children" }; diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java index be3ba66..74dec0a 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java @@ -9,12 +9,15 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; +import com.ruoyi.common.annotation.Excel; +import lombok.Data; /** * Entity基类 * * @author ruoyi */ +@Data public class BaseEntity implements Serializable { private static final long serialVersionUID = 1L; @@ -33,6 +36,9 @@ public class BaseEntity implements Serializable /** 创建者 */ @TableField(fill = FieldFill.INSERT) private Long deptId; + /** 上报部门 */ + @Excel(name = "上报部门") + private String deptName; /** 创建时间 */ @TableField(fill = FieldFill.INSERT) @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @@ -58,89 +64,7 @@ public class BaseEntity implements Serializable private Map params; - public Long getCreateUserId() { - return createUserId; - } - - public void setCreateUserId(Long createUserId) { - this.createUserId = createUserId; - } - - public Long getDeptId() { - return deptId; - } - - public void setDeptId(Long deptId) { - this.deptId = deptId; - } - - public Long getUpdateUserId() { - return updateUserId; - } - - public void setUpdateUserId(Long updateUserId) { - this.updateUserId = updateUserId; - } - - public String getSearchValue() - { - return searchValue; - } - - public void setSearchValue(String searchValue) - { - this.searchValue = searchValue; - } - - public String getCreateBy() - { - return createBy; - } - - public void setCreateBy(String createBy) - { - this.createBy = createBy; - } - public Date getCreateTime() - { - return createTime; - } - - public void setCreateTime(Date createTime) - { - this.createTime = createTime; - } - - public String getUpdateBy() - { - return updateBy; - } - - public void setUpdateBy(String updateBy) - { - this.updateBy = updateBy; - } - - public Date getUpdateTime() - { - return updateTime; - } - - public void setUpdateTime(Date updateTime) - { - this.updateTime = updateTime; - } - - public String getRemark() - { - return remark; - } - - public void setRemark(String remark) - { - this.remark = remark; - } public Map getParams() { diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/CreateAndUpdateMetaObjectHandler.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/CreateAndUpdateMetaObjectHandler.java index 3e0d363..dd1d6e1 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/CreateAndUpdateMetaObjectHandler.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/CreateAndUpdateMetaObjectHandler.java @@ -59,6 +59,8 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler { // 当前已登录 更新人填充(不管为不为空) if (StringUtils.isNotBlank(username)) { baseEntity.setUpdateBy(username); + Long userId = baseEntity.getCreateUserId()!=null ? baseEntity.getCreateUserId() : SecurityUtils.getUserId(); + baseEntity.setUpdateUserId(userId); } } } catch (Exception e) { diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java index d1733b6..8410533 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java @@ -333,6 +333,7 @@ public class GenTableColumn extends BaseEntity return StringUtils.equalsAnyIgnoreCase(javaField, // BaseEntity "createBy", "createTime", "updateBy", "updateTime", "remark", + "updateUserId", "deptId","createUserId", // TreeEntity "parentName", "parentId", "orderNum", "ancestors"); } diff --git a/ruoyi-generator/src/main/resources/vm/java-plus/controller.java.vm b/ruoyi-generator/src/main/resources/vm/java-plus/controller.java.vm new file mode 100644 index 0000000..1c67102 --- /dev/null +++ b/ruoyi-generator/src/main/resources/vm/java-plus/controller.java.vm @@ -0,0 +1,141 @@ +package ${packageName}.controller; + +import java.util.List; +import java.util.Arrays; +import javax.servlet.http.HttpServletResponse; +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 io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import ${packageName}.domain.${ClassName}; +import ${packageName}.service.I${ClassName}Service; +import com.ruoyi.common.utils.poi.ExcelUtil; +#if($table.crud || $table.sub) +import com.ruoyi.common.core.page.TableDataInfo; +#elseif($table.tree) +#end + +/** + * ${functionName}Controller + * + * @author ${author} + * @date ${datetime} + */ +@Api(tags="${functionName}管理") +@RestController +@RequestMapping("/${moduleName}/${businessName}") +public class ${ClassName}Controller extends BaseController +{ + @Autowired + private I${ClassName}Service ${className}Service; + + /** + * 查询${functionName}列表 + */ + @ApiOperation("查询${functionName}列表") + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')") + @GetMapping("/list") +#if($table.crud || $table.sub) + public TableDataInfo list(${ClassName} ${className}) + { + startPage(); + List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); + return getDataTable(list); + } +#elseif($table.tree) + public AjaxResult list(${ClassName} ${className}) + { + List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); + return success(list); + } +#end + + /** + * 导出${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}数据"); + } + + /** + * 获取${functionName}详细信息 + */ + @ApiOperation("获取${functionName}详细信息") + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')") + @GetMapping(value = "/{${pkColumn.javaField}}") + public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) + { +#if($table.sub) + return success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField})); +#else + return success(${className}Service.getById(${pkColumn.javaField})); +#end + } + + /** + * 新增${functionName} + */ + @ApiOperation("新增${functionName}") + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')") + @Log(title = "${functionName}", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody ${ClassName} ${className}) + { +#if($table.sub) + return toAjax(${className}Service.insert${ClassName}(${className})); +#else + return toAjax(${className}Service.save(${className})); +#end + } + + /** + * 修改${functionName} + */ + @ApiOperation("修改${functionName}") + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')") + @Log(title = "${functionName}", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody ${ClassName} ${className}) + { +#if($table.sub) + return toAjax(${className}Service.update${ClassName}(${className})); +#else + return toAjax(${className}Service.updateById(${className})); +#end + } + + /** + * 删除${functionName} + */ + @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) + { +#if($table.sub) + return toAjax(${className}Service.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s)); +#else + return toAjax(${className}Service.removeByIds(Arrays.asList(${pkColumn.javaField}s))); +#end + } +} diff --git a/ruoyi-generator/src/main/resources/vm/java-plus/domain.java.vm b/ruoyi-generator/src/main/resources/vm/java-plus/domain.java.vm new file mode 100644 index 0000000..d72302e --- /dev/null +++ b/ruoyi-generator/src/main/resources/vm/java-plus/domain.java.vm @@ -0,0 +1,72 @@ +package ${packageName}.domain; + +#foreach ($import in $importList) +import ${import}; +#end +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.ToString; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +#if($table.crud || $table.sub) +import com.ruoyi.common.core.domain.BaseEntity; +#elseif($table.tree) +import com.ruoyi.common.core.domain.TreeEntity; +#end + +/** + * ${functionName}对象 ${tableName} + * + * @author ${author} + * @date ${datetime} + */ +#if($table.crud || $table.sub) +#set($Entity="BaseEntity") +#elseif($table.tree) +#set($Entity="TreeEntity") +#end +@Data +@ToString +@NoArgsConstructor +@Accessors(chain = true) +@TableName("${tableName}") +public class ${ClassName} extends ${Entity} +{ + private static final long serialVersionUID = 1L; + +#foreach ($column in $columns) +#if(!$table.isSuperColumn($column.javaField)) + /** $column.columnComment */ +#if($column.list) +#set($parentheseIndex=$column.columnComment.indexOf("(")) +#if($parentheseIndex != -1) +#set($comment=$column.columnComment.substring(0, $parentheseIndex)) +#else +#set($comment=$column.columnComment) +#end +#if($parentheseIndex != -1) + @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") +#elseif($column.javaType == 'Date') + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd") +#else + @Excel(name = "${comment}") +#end +#end +#if($column.pk) + @TableId(type= IdType.AUTO) +#end + private $column.javaType $column.javaField; + +#end +#end +#if($table.sub) + /** $table.subTable.functionName信息 */ + @TableField(exist = false) + private List<${subClassName}> ${subclassName}List; +#end +} diff --git a/ruoyi-generator/src/main/resources/vm/java-plus/mapper.java.vm b/ruoyi-generator/src/main/resources/vm/java-plus/mapper.java.vm new file mode 100644 index 0000000..a5668c3 --- /dev/null +++ b/ruoyi-generator/src/main/resources/vm/java-plus/mapper.java.vm @@ -0,0 +1,43 @@ +package ${packageName}.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import ${packageName}.domain.${ClassName}; +#if($table.sub) +import java.util.List; +import org.apache.ibatis.annotations.Param; +import ${packageName}.domain.${subClassName}; +#end + +/** + * ${functionName}Mapper接口 + * + * @author ${author} + * @date ${datetime} + */ +public interface ${ClassName}Mapper extends BaseMapper<${ClassName}> { +#if($table.sub) + /** + * 查询${functionName} + * + * @param ${pkColumn.javaField} ${functionName}主键 + * @return ${functionName} + */ + List<${subClassName}> select${subClassName}By${pkColumn.capJavaField}(@Param("${pkColumn.javaField}")${pkColumn.javaType} ${pkColumn.javaField}); + + /** + * 删除${functionName}信息 + * + * @param ${pkColumn.javaField} ${functionName}主键 + * @return 结果 + */ + int delete${subClassName}By${subTableFkClassName}(@Param("${pkColumn.javaField}")${pkColumn.javaType} ${pkColumn.javaField}); + + /** + * 批量新增${subTable.functionName} + * + * @param ${subclassName}List ${subTable.functionName}列表 + * @return 结果 + */ + int batchInsert${subClassName}(List<${subClassName}> ${subclassName}List); +#end +} diff --git a/ruoyi-generator/src/main/resources/vm/java-plus/service.java.vm b/ruoyi-generator/src/main/resources/vm/java-plus/service.java.vm new file mode 100644 index 0000000..b20a712 --- /dev/null +++ b/ruoyi-generator/src/main/resources/vm/java-plus/service.java.vm @@ -0,0 +1,64 @@ +package ${packageName}.service; + +import java.util.List; +import com.baomidou.mybatisplus.extension.service.IService; +import ${packageName}.domain.${ClassName}; + +/** + * ${functionName}Service接口 + * + * @author ${author} + * @date ${datetime} + */ +public interface I${ClassName}Service extends IService<${ClassName}> { + + /** + * 查询${functionName}列表 + * + * @param ${className} ${functionName} + * @return ${functionName}集合 + */ + public List<${ClassName}> select${ClassName}List(${ClassName} ${className}); + +#if($table.sub) + /** + * 查询${functionName} + * + * @param ${pkColumn.javaField} ${functionName}主键 + * @return ${functionName} + */ + public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}); + + /** + * 新增${functionName} + * + * @param ${className} ${functionName} + * @return 结果 + */ + public int insert${ClassName}(${ClassName} ${className}); + + /** + * 修改${functionName} + * + * @param ${className} ${functionName} + * @return 结果 + */ + public int update${ClassName}(${ClassName} ${className}); + + /** + * 批量删除${functionName} + * + * @param ${pkColumn.javaField}s 需要删除的${functionName}主键集合 + * @return 结果 + */ + public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s); + + /** + * 删除${functionName}信息 + * + * @param ${pkColumn.javaField} ${functionName}主键 + * @return 结果 + */ + public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}); +#end +} diff --git a/ruoyi-generator/src/main/resources/vm/java-plus/serviceImpl.java.vm b/ruoyi-generator/src/main/resources/vm/java-plus/serviceImpl.java.vm new file mode 100644 index 0000000..8b3e675 --- /dev/null +++ b/ruoyi-generator/src/main/resources/vm/java-plus/serviceImpl.java.vm @@ -0,0 +1,179 @@ +package ${packageName}.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import org.springframework.stereotype.Service; +import org.springframework.beans.factory.annotation.Autowired; +import com.ruoyi.common.utils.StringUtils; +import java.util.List; +import java.util.Map; +#if($table.sub) +import java.util.Arrays; +import org.springframework.transaction.annotation.Transactional; +import ${packageName}.domain.${subClassName}; +#end +import ${packageName}.mapper.${ClassName}Mapper; +import ${packageName}.domain.${ClassName}; +import ${packageName}.service.I${ClassName}Service; + +/** + * ${functionName}Service业务层处理 + * + * @author ${author} + * @date ${datetime} + */ +@Service +public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${ClassName}> implements I${ClassName}Service { + + @Autowired + private ${ClassName}Mapper ${className}Mapper; + + /** + * 查询${functionName}列表 + * + * @param ${className} ${functionName} + * @return ${functionName} + */ + @Override + public List<${ClassName}> select${ClassName}List(${ClassName} ${className}) + { + List<${ClassName}> ${className}List = ${className}Mapper.selectList(buildQueryWrapper(${className})); +#if($table.sub) + if (StringUtils.isNotNull(${className}List)) { + for (${ClassName} temp : ${className}List) { + List<${subClassName}> ${subclassName}List = ${className}Mapper.select${subClassName}By${pkColumn.capJavaField}(temp.get${pkColumn.capJavaField}()); + temp.set${subClassName}List(${subclassName}List); + } + } +#end + return ${className}List; + } + +#if($table.sub) + /** + * 查询${functionName} + * + * @param ${pkColumn.javaField} ${functionName}主键 + * @return ${functionName} + */ + @Override + public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) + { + ${ClassName} ${className} = ${className}Mapper.selectById(${pkColumn.javaField}); + List<${subClassName}> ${subclassName}List = ${className}Mapper.select${subClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}); + ${className}.set${subClassName}List(${subclassName}List); + return ${className}; + } + + /** + * 新增${functionName} + * + * @param ${className} ${functionName} + * @return 结果 + */ + @Transactional + @Override + public int insert${ClassName}(${ClassName} ${className}) + { + int rows = ${className}Mapper.insert(${className}); + insert${subClassName}(${className}); + return rows; + } + + /** + * 修改${functionName} + * + * @param ${className} ${functionName} + * @return 结果 + */ + @Transactional + @Override + public int update${ClassName}(${ClassName} ${className}) + { + ${className}Mapper.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}()); + insert${subClassName}(${className}); + return ${className}Mapper.updateById(${className}); + } + + /** + * 批量删除${functionName} + * + * @param ${pkColumn.javaField}s 需要删除的${functionName}主键 + * @return 结果 + */ + @Transactional + @Override + public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s) + { + List<${pkColumn.javaType}> ${pkColumn.javaField}List = Arrays.asList(${pkColumn.javaField}s); + for (${pkColumn.javaType} ${pkColumn.javaField} : ${pkColumn.javaField}List) { + ${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField}); + } + return ${className}Mapper.deleteBatchIds(${pkColumn.javaField}List); + } + + /** + * 删除${functionName}信息 + * + * @param ${pkColumn.javaField} ${functionName}主键 + * @return 结果 + */ + @Transactional + @Override + public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) + { + ${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField}); + return ${className}Mapper.deleteById(${pkColumn.javaField}); + } + + /** + * 新增${subTable.functionName}信息 + * + * @param ${className} ${functionName}对象 + */ + private void insert${subClassName}(${ClassName} ${className}) + { + List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List(); + ${pkColumn.javaType} ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}(); + if (StringUtils.isNotNull(${subclassName}List)) { + for (${subClassName} ${subclassName} : ${subclassName}List) { + ${subclassName}.set${subTableFkClassName}(${pkColumn.javaField}); + } + ${className}Mapper.batchInsert${subClassName}(${subclassName}List); + } + } +#end + + private LambdaQueryWrapper<${ClassName}> buildQueryWrapper(${ClassName} query) { + Map params = query.getParams(); + LambdaQueryWrapper<${ClassName}> lqw = Wrappers.lambdaQuery(); +#foreach($column in $columns) + #if($column.query) + #set($queryType=$column.queryType) + #set($javaField=$column.javaField) + #set($javaType=$column.javaType) + #set($columnName=$column.columnName) + #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) + #set($mpMethod=$column.queryType.toLowerCase()) + #if($queryType != 'BETWEEN') + #if($javaType == 'String') + #set($condition='StringUtils.isNotBlank(query.get'+$AttrName+'())') + #else + #set($condition='query.get'+$AttrName+'() != null') + #end + lqw.$mpMethod($condition, ${ClassName}::get$AttrName, query.get$AttrName()); + #else + lqw.between(params.get("begin$AttrName") != null && params.get("end$AttrName") != null, + ${ClassName}::get$AttrName ,params.get("begin$AttrName"), params.get("end$AttrName")); + #end + #end + #if($column.javaField == 'createTime') + #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) + lqw.orderByDesc(${ClassName}::get$AttrName); + #end +#end + return lqw; + } + +} diff --git a/ruoyi-generator/src/main/resources/vm/java-plus/sub-domain.java.vm b/ruoyi-generator/src/main/resources/vm/java-plus/sub-domain.java.vm new file mode 100644 index 0000000..49d8d71 --- /dev/null +++ b/ruoyi-generator/src/main/resources/vm/java-plus/sub-domain.java.vm @@ -0,0 +1,61 @@ +package ${packageName}.domain; + +#foreach ($import in $subImportList) +import ${import}; +#end +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.ToString; +import lombok.experimental.Accessors; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * ${subTable.functionName}对象 ${subTableName} + * + * @author ${author} + * @date ${datetime} + */ +@Data +@ToString +@NoArgsConstructor +@Accessors(chain = true) +@TableName("${subTableName}") +@ApiModel(value = "${subClassName}", description = "${subTable.functionName}实体") +public class ${subClassName} extends BaseEntity +{ + private static final long serialVersionUID = 1L; + +#foreach ($column in $subTable.columns) +#if(!$table.isSuperColumn($column.javaField)) + /** $column.columnComment */ +#if($column.list) +#set($parentheseIndex=$column.columnComment.indexOf("(")) +#if($parentheseIndex != -1) +#set($comment=$column.columnComment.substring(0, $parentheseIndex)) +#else +#set($comment=$column.columnComment) +#end +#if($parentheseIndex != -1) + @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") +#elseif($column.javaType == 'Date') + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd") +#else + @Excel(name = "${comment}") +#end +#end +#if($column.pk) + @TableId(type= IdType.AUTO) +#end + @ApiModelProperty("$column.columnComment") + private $column.javaType $column.javaField; + +#end +#end +} diff --git a/ruoyi-generator/src/main/resources/vm/java/controller.java.vm b/ruoyi-generator/src/main/resources/vm/java/controller.java.vm index 1c67102..f20fd19 100644 --- a/ruoyi-generator/src/main/resources/vm/java/controller.java.vm +++ b/ruoyi-generator/src/main/resources/vm/java/controller.java.vm @@ -41,55 +41,48 @@ public class ${ClassName}Controller extends BaseController @Autowired private I${ClassName}Service ${className}Service; - /** - * 查询${functionName}列表 - */ - @ApiOperation("查询${functionName}列表") - @PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')") - @GetMapping("/list") -#if($table.crud || $table.sub) - public TableDataInfo list(${ClassName} ${className}) - { - startPage(); - List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); - return getDataTable(list); - } -#elseif($table.tree) - public AjaxResult list(${ClassName} ${className}) - { - List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); - return success(list); - } -#end +/** + * 查询${functionName}列表 + */ +@PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')") +@GetMapping("/list") + #if($table.crud || $table.sub) + public TableDataInfo list(${ClassName} ${className}) + { + startPage(); + List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); + return getDataTable(list); + } + #elseif($table.tree) + public AjaxResult list(${ClassName} ${className}) + { + List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); + return success(list); + } + #end - /** - * 导出${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}数据"); - } + /** + * 导出${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}数据"); + } - /** - * 获取${functionName}详细信息 - */ - @ApiOperation("获取${functionName}详细信息") - @PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')") - @GetMapping(value = "/{${pkColumn.javaField}}") - public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) - { -#if($table.sub) - return success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField})); -#else - return success(${className}Service.getById(${pkColumn.javaField})); -#end - } + /** + * 获取${functionName}详细信息 + */ + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')") + @GetMapping(value = "/{${pkColumn.javaField}}") + public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) + { + return success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField})); + } /** * 新增${functionName} diff --git a/ruoyi-generator/src/main/resources/vm/java/mapper.java.vm b/ruoyi-generator/src/main/resources/vm/java/mapper.java.vm index a5668c3..5263953 100644 --- a/ruoyi-generator/src/main/resources/vm/java/mapper.java.vm +++ b/ruoyi-generator/src/main/resources/vm/java/mapper.java.vm @@ -2,6 +2,7 @@ package ${packageName}.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import ${packageName}.domain.${ClassName}; +import java.util.List; #if($table.sub) import java.util.List; import org.apache.ibatis.annotations.Param; @@ -15,14 +16,22 @@ import ${packageName}.domain.${subClassName}; * @date ${datetime} */ public interface ${ClassName}Mapper extends BaseMapper<${ClassName}> { + /** + * 查询${functionName} + * + * @param ${pkColumn.javaField} ${functionName}主键 + * @return ${functionName} + */ + public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}); + + /** + * 查询${functionName}列表 + * + * @param ${className} ${functionName} + * @return ${functionName}集合 + */ + public List<${ClassName}> select${ClassName}List(${ClassName} ${className}); #if($table.sub) - /** - * 查询${functionName} - * - * @param ${pkColumn.javaField} ${functionName}主键 - * @return ${functionName} - */ - List<${subClassName}> select${subClassName}By${pkColumn.capJavaField}(@Param("${pkColumn.javaField}")${pkColumn.javaType} ${pkColumn.javaField}); /** * 删除${functionName}信息 diff --git a/ruoyi-generator/src/main/resources/vm/java/service.java.vm b/ruoyi-generator/src/main/resources/vm/java/service.java.vm index b20a712..7a12ae5 100644 --- a/ruoyi-generator/src/main/resources/vm/java/service.java.vm +++ b/ruoyi-generator/src/main/resources/vm/java/service.java.vm @@ -12,53 +12,55 @@ import ${packageName}.domain.${ClassName}; */ public interface I${ClassName}Service extends IService<${ClassName}> { - /** - * 查询${functionName}列表 - * - * @param ${className} ${functionName} - * @return ${functionName}集合 - */ - public List<${ClassName}> select${ClassName}List(${ClassName} ${className}); + /** + * 查询${functionName} + * + * @param ${pkColumn.javaField} ${functionName}主键 + * @return ${functionName} + */ + public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}); -#if($table.sub) - /** - * 查询${functionName} - * - * @param ${pkColumn.javaField} ${functionName}主键 - * @return ${functionName} - */ - public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}); + /** + * 查询${functionName}列表 + * + * @param ${className} ${functionName} + * @return ${functionName}集合 + */ + public List<${ClassName}> select${ClassName}List(${ClassName} ${className}); - /** - * 新增${functionName} - * - * @param ${className} ${functionName} - * @return 结果 - */ - public int insert${ClassName}(${ClassName} ${className}); + #if($table.sub) - /** - * 修改${functionName} - * - * @param ${className} ${functionName} - * @return 结果 - */ - public int update${ClassName}(${ClassName} ${className}); - /** - * 批量删除${functionName} - * - * @param ${pkColumn.javaField}s 需要删除的${functionName}主键集合 - * @return 结果 - */ - public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s); + /** + * 新增${functionName} + * + * @param ${className} ${functionName} + * @return 结果 + */ + public int insert${ClassName}(${ClassName} ${className}); - /** - * 删除${functionName}信息 - * - * @param ${pkColumn.javaField} ${functionName}主键 - * @return 结果 - */ - public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}); -#end + /** + * 修改${functionName} + * + * @param ${className} ${functionName} + * @return 结果 + */ + public int update${ClassName}(${ClassName} ${className}); + + /** + * 批量删除${functionName} + * + * @param ${pkColumn.javaField}s 需要删除的${functionName}主键集合 + * @return 结果 + */ + public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s); + + /** + * 删除${functionName}信息 + * + * @param ${pkColumn.javaField} ${functionName}主键 + * @return 结果 + */ + public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}); + #end } diff --git a/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm b/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm index 8b3e675..86c67f1 100644 --- a/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm +++ b/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm @@ -8,11 +8,11 @@ import org.springframework.beans.factory.annotation.Autowired; import com.ruoyi.common.utils.StringUtils; import java.util.List; import java.util.Map; -#if($table.sub) -import java.util.Arrays; -import org.springframework.transaction.annotation.Transactional; -import ${packageName}.domain.${subClassName}; -#end + #if($table.sub) + import java.util.Arrays; + import org.springframework.transaction.annotation.Transactional; + import ${packageName}.domain.${subClassName}; + #end import ${packageName}.mapper.${ClassName}Mapper; import ${packageName}.domain.${ClassName}; import ${packageName}.service.I${ClassName}Service; @@ -26,154 +26,142 @@ import ${packageName}.service.I${ClassName}Service; @Service public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${ClassName}> implements I${ClassName}Service { - @Autowired - private ${ClassName}Mapper ${className}Mapper; + @Autowired + private ${ClassName}Mapper ${className}Mapper; - /** - * 查询${functionName}列表 - * - * @param ${className} ${functionName} - * @return ${functionName} - */ - @Override - public List<${ClassName}> select${ClassName}List(${ClassName} ${className}) - { - List<${ClassName}> ${className}List = ${className}Mapper.selectList(buildQueryWrapper(${className})); -#if($table.sub) - if (StringUtils.isNotNull(${className}List)) { - for (${ClassName} temp : ${className}List) { - List<${subClassName}> ${subclassName}List = ${className}Mapper.select${subClassName}By${pkColumn.capJavaField}(temp.get${pkColumn.capJavaField}()); - temp.set${subClassName}List(${subclassName}List); - } - } -#end - return ${className}List; - } + /** + * 查询${functionName} + * + * @param ${pkColumn.javaField} ${functionName}主键 + * @return ${functionName} + */ + @Override + public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) + { + return ${className}Mapper.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}); + } -#if($table.sub) - /** - * 查询${functionName} - * - * @param ${pkColumn.javaField} ${functionName}主键 - * @return ${functionName} - */ - @Override - public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) - { - ${ClassName} ${className} = ${className}Mapper.selectById(${pkColumn.javaField}); - List<${subClassName}> ${subclassName}List = ${className}Mapper.select${subClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}); - ${className}.set${subClassName}List(${subclassName}List); - return ${className}; - } + /** + * 查询${functionName}列表 + * + * @param ${className} ${functionName} + * @return ${functionName} + */ + @Override + public List<${ClassName}> select${ClassName}List(${ClassName} ${className}) + { + return ${className}Mapper.select${ClassName}List(${className}); + } - /** - * 新增${functionName} - * - * @param ${className} ${functionName} - * @return 结果 - */ - @Transactional - @Override - public int insert${ClassName}(${ClassName} ${className}) - { - int rows = ${className}Mapper.insert(${className}); - insert${subClassName}(${className}); - return rows; - } + #if($table.sub) + /** + * 新增${functionName} + * + * @param ${className} ${functionName} + * @return 结果 + */ + @Transactional + @Override + public int insert${ClassName}(${ClassName} ${className}) + { + int rows = ${className}Mapper.insert(${className}); + insert${subClassName}(${className}); + return rows; + } - /** - * 修改${functionName} - * - * @param ${className} ${functionName} - * @return 结果 - */ - @Transactional - @Override - public int update${ClassName}(${ClassName} ${className}) - { - ${className}Mapper.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}()); - insert${subClassName}(${className}); - return ${className}Mapper.updateById(${className}); - } + /** + * 修改${functionName} + * + * @param ${className} ${functionName} + * @return 结果 + */ + @Transactional + @Override + public int update${ClassName}(${ClassName} ${className}) + { + ${className}Mapper.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}()); + insert${subClassName}(${className}); + return ${className}Mapper.updateById(${className}); + } - /** - * 批量删除${functionName} - * - * @param ${pkColumn.javaField}s 需要删除的${functionName}主键 - * @return 结果 - */ - @Transactional - @Override - public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s) - { - List<${pkColumn.javaType}> ${pkColumn.javaField}List = Arrays.asList(${pkColumn.javaField}s); - for (${pkColumn.javaType} ${pkColumn.javaField} : ${pkColumn.javaField}List) { - ${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField}); - } - return ${className}Mapper.deleteBatchIds(${pkColumn.javaField}List); - } + /** + * 批量删除${functionName} + * + * @param ${pkColumn.javaField}s 需要删除的${functionName}主键 + * @return 结果 + */ + @Transactional + @Override + public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s) + { + List<${pkColumn.javaType}> ${pkColumn.javaField}List = Arrays.asList(${pkColumn.javaField}s); + for (${pkColumn.javaType} ${pkColumn.javaField} : ${pkColumn.javaField}List) { + ${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField}); + } + return ${className}Mapper.deleteBatchIds(${pkColumn.javaField}List); + } - /** - * 删除${functionName}信息 - * - * @param ${pkColumn.javaField} ${functionName}主键 - * @return 结果 - */ - @Transactional - @Override - public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) - { - ${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField}); - return ${className}Mapper.deleteById(${pkColumn.javaField}); - } + /** + * 删除${functionName}信息 + * + * @param ${pkColumn.javaField} ${functionName}主键 + * @return 结果 + */ + @Transactional + @Override + public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) + { + ${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField}); + return ${className}Mapper.deleteById(${pkColumn.javaField}); + } - /** - * 新增${subTable.functionName}信息 - * - * @param ${className} ${functionName}对象 - */ - private void insert${subClassName}(${ClassName} ${className}) - { - List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List(); - ${pkColumn.javaType} ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}(); - if (StringUtils.isNotNull(${subclassName}List)) { - for (${subClassName} ${subclassName} : ${subclassName}List) { - ${subclassName}.set${subTableFkClassName}(${pkColumn.javaField}); - } - ${className}Mapper.batchInsert${subClassName}(${subclassName}List); - } - } -#end + /** + * 新增${subTable.functionName}信息 + * + * @param ${className} ${functionName}对象 + */ + private void insert${subClassName}(${ClassName} ${className}) + { + List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List(); + ${pkColumn.javaType} ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}(); + if (StringUtils.isNotNull(${subclassName}List)) { + for (${subClassName} ${subclassName} : ${subclassName}List) { + ${subclassName}.set${subTableFkClassName}(${pkColumn.javaField}); + } + ${className}Mapper.batchInsert${subClassName}(${subclassName}List); + } + } + #end - private LambdaQueryWrapper<${ClassName}> buildQueryWrapper(${ClassName} query) { - Map params = query.getParams(); - LambdaQueryWrapper<${ClassName}> lqw = Wrappers.lambdaQuery(); -#foreach($column in $columns) - #if($column.query) - #set($queryType=$column.queryType) - #set($javaField=$column.javaField) - #set($javaType=$column.javaType) - #set($columnName=$column.columnName) - #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) - #set($mpMethod=$column.queryType.toLowerCase()) - #if($queryType != 'BETWEEN') - #if($javaType == 'String') - #set($condition='StringUtils.isNotBlank(query.get'+$AttrName+'())') - #else - #set($condition='query.get'+$AttrName+'() != null') + private LambdaQueryWrapper<${ClassName}> buildQueryWrapper(${ClassName} query) { + Map params = query.getParams(); + LambdaQueryWrapper<${ClassName}> lqw = Wrappers.lambdaQuery(); + #foreach($column in $columns) + #if($column.query) + #set($queryType=$column.queryType) + #set($javaField=$column.javaField) + #set($javaType=$column.javaType) + #set($columnName=$column.columnName) + #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) + #set($mpMethod=$column.queryType.toLowerCase()) + #if($queryType != 'BETWEEN') + #if($javaType == 'String') + #set($condition='StringUtils.isNotBlank(query.get'+$AttrName+'())') + #else + #set($condition='query.get'+$AttrName+'() != null') + #end + lqw.$mpMethod($condition, ${ClassName}::get$AttrName, query.get$AttrName()); + #else + lqw.between(params.get("begin$AttrName") != null && params.get("end$AttrName") != null, + ${ClassName}::get$AttrName ,params.get("begin$AttrName"), params.get("end$AttrName")); + #end + #end + #if($column.javaField == 'createTime') + #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) + lqw.orderByDesc(${ClassName}::get$AttrName); #end - lqw.$mpMethod($condition, ${ClassName}::get$AttrName, query.get$AttrName()); - #else - lqw.between(params.get("begin$AttrName") != null && params.get("end$AttrName") != null, - ${ClassName}::get$AttrName ,params.get("begin$AttrName"), params.get("end$AttrName")); #end - #end - #if($column.javaField == 'createTime') - #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) - lqw.orderByDesc(${ClassName}::get$AttrName); - #end -#end - return lqw; - } + return lqw; + } } diff --git a/ruoyi-generator/src/main/resources/vm/xml/mapper-plus.xml.vm b/ruoyi-generator/src/main/resources/vm/xml/mapper-plus.xml.vm new file mode 100644 index 0000000..2d07e0b --- /dev/null +++ b/ruoyi-generator/src/main/resources/vm/xml/mapper-plus.xml.vm @@ -0,0 +1,36 @@ + + + + + + #foreach ($column in $columns) + + #end + + + #if($table.sub) + + #foreach ($column in $subTable.columns) + + #end + + + + + + delete from ${subTableName} where ${subTableFkName} = #{${pkColumn.javaField}} + + + + insert into ${subTableName}(#foreach($column in $subTable.columns) $column.columnName#if($foreach.count != $subTable.columns.size()),#end#end) values + + (#foreach($column in $subTable.columns) #{item.$column.javaField}#if($foreach.count != $subTable.columns.size()),#end#end) + + + #end + + diff --git a/ruoyi-generator/src/main/resources/vm/xml/mapper.xml.vm b/ruoyi-generator/src/main/resources/vm/xml/mapper.xml.vm index d48526b..1392ec8 100644 --- a/ruoyi-generator/src/main/resources/vm/xml/mapper.xml.vm +++ b/ruoyi-generator/src/main/resources/vm/xml/mapper.xml.vm @@ -1,36 +1,78 @@ + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> -#foreach ($column in $columns) - -#end - - -#if($table.sub) - - #foreach ($column in $subTable.columns) - + #foreach ($column in $columns) + #end + #if($table.sub) + + + + + + + #foreach ($column in $subTable.columns) + + #end + + #end + + + select#foreach($column in $columns) $column.columnName#if($foreach.count != $columns.size()),#end#end from ${tableName} + - + + + #foreach($column in $columns) + #set($queryType=$column.queryType) + #set($javaField=$column.javaField) + #set($javaType=$column.javaType) + #set($columnName=$column.columnName) + #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) + #if($column.query) + #if($column.queryType == "EQ") + and $columnName = #{$javaField} + #elseif($queryType == "NE") + and $columnName != #{$javaField} + #elseif($queryType == "GT") + and $columnName > #{$javaField} + #elseif($queryType == "GTE") + and $columnName >= #{$javaField} + #elseif($queryType == "LT") + and $columnName < #{$javaField} + #elseif($queryType == "LTE") + and $columnName <= #{$javaField} + #elseif($queryType == "LIKE") + and $columnName like concat('%', #{$javaField}, '%') + #elseif($queryType == "BETWEEN") + and $columnName between #{params.begin$AttrName} and #{params.end$AttrName} + #end + #end + #end + - - delete from ${subTableName} where ${subTableFkName} = #{${pkColumn.javaField}} - + + + - - insert into ${subTableName}(#foreach($column in $subTable.columns) $column.columnName#if($foreach.count != $subTable.columns.size()),#end#end) values - - (#foreach($column in $subTable.columns) #{item.$column.javaField}#if($foreach.count != $subTable.columns.size()),#end#end) - - -#end - + \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/ehsMaterial/domain/EhsMaterial.java b/ruoyi-system/src/main/java/com/ruoyi/ehsMaterial/domain/EhsMaterial.java index dd1ad1b..be5b6af 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/ehsMaterial/domain/EhsMaterial.java +++ b/ruoyi-system/src/main/java/com/ruoyi/ehsMaterial/domain/EhsMaterial.java @@ -15,7 +15,7 @@ import com.ruoyi.common.core.domain.BaseEntity; * 物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”对象 ehs_material * * @author ruoyi - * @date 2023-12-01 + * @date 2023-12-04 */ @Data @ToString @@ -66,13 +66,6 @@ public class EhsMaterial extends BaseEntity @Excel(name = "联系电话") private String tel; - /** 创建者部门 */ - private Long deptId; - /** 创建者id */ - private Long createUserId; - - /** 修改着id */ - private Long updateUserId; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/ehsMaterial/mapper/EhsMaterialMapper.java b/ruoyi-system/src/main/java/com/ruoyi/ehsMaterial/mapper/EhsMaterialMapper.java index 9044773..06fd7d5 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/ehsMaterial/mapper/EhsMaterialMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/ehsMaterial/mapper/EhsMaterialMapper.java @@ -3,11 +3,28 @@ package com.ruoyi.ehsMaterial.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.ehsMaterial.domain.EhsMaterial; +import java.util.List; + /** * 物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”Mapper接口 * * @author ruoyi - * @date 2023-12-01 + * @date 2023-12-04 */ public interface EhsMaterialMapper extends BaseMapper { + /** + * 查询物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资” + * + * @param materialId 物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”主键 + * @return 物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资” + */ + public EhsMaterial selectEhsMaterialByMaterialId(Long materialId); + + /** + * 查询物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”列表 + * + * @param ehsMaterial 物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资” + * @return 物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”集合 + */ + public List selectEhsMaterialList(EhsMaterial ehsMaterial); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/ehsMaterial/service/IEhsMaterialService.java b/ruoyi-system/src/main/java/com/ruoyi/ehsMaterial/service/IEhsMaterialService.java index 8fbbb29..fba5c66 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/ehsMaterial/service/IEhsMaterialService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/ehsMaterial/service/IEhsMaterialService.java @@ -8,10 +8,18 @@ import com.ruoyi.ehsMaterial.domain.EhsMaterial; * 物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”Service接口 * * @author ruoyi - * @date 2023-12-01 + * @date 2023-12-04 */ public interface IEhsMaterialService extends IService { + /** + * 查询物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资” + * + * @param materialId 物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”主键 + * @return 物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资” + */ + public EhsMaterial selectEhsMaterialByMaterialId(Long materialId); + /** * 查询物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”列表 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/ehsMaterial/service/impl/EhsMaterialServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/ehsMaterial/service/impl/EhsMaterialServiceImpl.java index dd81de2..0155774 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/ehsMaterial/service/impl/EhsMaterialServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/ehsMaterial/service/impl/EhsMaterialServiceImpl.java @@ -16,7 +16,7 @@ import com.ruoyi.ehsMaterial.service.IEhsMaterialService; * 物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”Service业务层处理 * * @author ruoyi - * @date 2023-12-01 + * @date 2023-12-04 */ @Service public class EhsMaterialServiceImpl extends ServiceImpl implements IEhsMaterialService { @@ -24,6 +24,18 @@ public class EhsMaterialServiceImpl extends ServiceImpl selectEhsMaterialList(EhsMaterial ehsMaterial) { - List ehsMaterialList = ehsMaterialMapper.selectList(buildQueryWrapper(ehsMaterial)); - return ehsMaterialList; + return ehsMaterialMapper.selectEhsMaterialList(ehsMaterial); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/ehsRisk/domain/EhsRisk.java b/ruoyi-system/src/main/java/com/ruoyi/ehsRisk/domain/EhsRisk.java index 9183f59..af63b47 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/ehsRisk/domain/EhsRisk.java +++ b/ruoyi-system/src/main/java/com/ruoyi/ehsRisk/domain/EhsRisk.java @@ -72,5 +72,4 @@ public class EhsRisk extends BaseEntity /** 联系电话 */ @Excel(name = "联系电话") private String tel2; - } diff --git a/ruoyi-system/src/main/java/com/ruoyi/ehsRisk/mapper/EhsRiskMapper.java b/ruoyi-system/src/main/java/com/ruoyi/ehsRisk/mapper/EhsRiskMapper.java index ec0a2eb..0500c0b 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/ehsRisk/mapper/EhsRiskMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/ehsRisk/mapper/EhsRiskMapper.java @@ -3,6 +3,8 @@ package com.ruoyi.ehsRisk.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.ehsRisk.domain.EhsRisk; +import java.util.List; + /** * 风险信息Mapper接口 * @@ -10,4 +12,19 @@ import com.ruoyi.ehsRisk.domain.EhsRisk; * @date 2023-11-30 */ public interface EhsRiskMapper extends BaseMapper { + /** + * 查询风险信息 + * + * @param riskId 风险信息主键 + * @return 风险信息 + */ + public EhsRisk selectEhsRiskByRiskId(Long riskId); + + /** + * 查询风险信息列表 + * + * @param ehsRisk 风险信息 + * @return 风险信息集合 + */ + public List selectEhsRiskList(EhsRisk ehsRisk); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/ehsRisk/service/IEhsRiskService.java b/ruoyi-system/src/main/java/com/ruoyi/ehsRisk/service/IEhsRiskService.java index 8b29162..8b18d98 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/ehsRisk/service/IEhsRiskService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/ehsRisk/service/IEhsRiskService.java @@ -12,6 +12,14 @@ import com.ruoyi.ehsRisk.domain.EhsRisk; */ public interface IEhsRiskService extends IService { + /** + * 查询风险信息 + * + * @param riskId 风险信息主键 + * @return 风险信息 + */ + public EhsRisk selectEhsRiskByRiskId(Long riskId); + /** * 查询风险信息列表 * @@ -19,5 +27,4 @@ public interface IEhsRiskService extends IService { * @return 风险信息集合 */ public List selectEhsRiskList(EhsRisk ehsRisk); - } diff --git a/ruoyi-system/src/main/java/com/ruoyi/ehsRisk/service/impl/EhsRiskServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/ehsRisk/service/impl/EhsRiskServiceImpl.java index 031e160..9b3e63d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/ehsRisk/service/impl/EhsRiskServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/ehsRisk/service/impl/EhsRiskServiceImpl.java @@ -3,6 +3,7 @@ package com.ruoyi.ehsRisk.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.ehsRisk.domain.EhsRisk; import com.ruoyi.ehsRisk.mapper.EhsRiskMapper; import com.ruoyi.ehsRisk.service.IEhsRiskService; @@ -23,6 +24,17 @@ public class EhsRiskServiceImpl extends ServiceImpl impl @Autowired private EhsRiskMapper ehsRiskMapper; + /** + * 查询风险信息 + * + * @param riskId 风险信息主键 + * @return 风险信息 + */ + @Override + public EhsRisk selectEhsRiskByRiskId(Long riskId) + { + return ehsRiskMapper.selectEhsRiskByRiskId(riskId); + } /** * 查询风险信息列表 @@ -33,8 +45,11 @@ public class EhsRiskServiceImpl extends ServiceImpl impl @Override public List selectEhsRiskList(EhsRisk ehsRisk) { - List ehsRiskList = ehsRiskMapper.selectList(buildQueryWrapper(ehsRisk)); - return ehsRiskList; + if(SecurityUtils.getLoginUser().getUser().getDept().getParentId()!=null && + SecurityUtils.getLoginUser().getUser().getDept().getParentId().longValue()!=0){ + ehsRisk.setDeptId(SecurityUtils.getLoginUser().getUser().getDept().getParentId().longValue()); + } + return ehsRiskMapper.selectEhsRiskList(ehsRisk); } @@ -43,15 +58,18 @@ public class EhsRiskServiceImpl extends ServiceImpl impl LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); lqw.eq(query.getRiskGrade() != null, EhsRisk::getRiskGrade, query.getRiskGrade()); lqw.eq(StringUtils.isNotBlank(query.getReportAddressType()), EhsRisk::getReportAddressType, query.getReportAddressType()); - lqw.eq(StringUtils.isNotBlank(query.getRiskLocation()), EhsRisk::getRiskLocation, query.getRiskLocation()); - lqw.eq(StringUtils.isNotBlank(query.getTel()), EhsRisk::getTel, query.getTel()); - lqw.eq(StringUtils.isNotBlank(query.getPeopleQuantity()), EhsRisk::getPeopleQuantity, query.getPeopleQuantity()); - lqw.eq(StringUtils.isNotBlank(query.getMaterialsQuantity()), EhsRisk::getMaterialsQuantity, query.getMaterialsQuantity()); - lqw.eq(StringUtils.isNotBlank(query.getRepairTeam()), EhsRisk::getRepairTeam, query.getRepairTeam()); - lqw.eq(StringUtils.isNotBlank(query.getPersonResponsible()), EhsRisk::getPersonResponsible, query.getPersonResponsible()); - lqw.eq(StringUtils.isNotBlank(query.getVillagePersonResponsible()), EhsRisk::getVillagePersonResponsible, query.getVillagePersonResponsible()); - lqw.eq(StringUtils.isNotBlank(query.getVillagePersonResponsible2()), EhsRisk::getVillagePersonResponsible2, query.getVillagePersonResponsible2()); - lqw.eq(StringUtils.isNotBlank(query.getTel2()), EhsRisk::getTel2, query.getTel2()); + lqw.like(StringUtils.isNotBlank(query.getRiskLocation()), EhsRisk::getRiskLocation, query.getRiskLocation()); + lqw.like(StringUtils.isNotBlank(query.getTel()), EhsRisk::getTel, query.getTel()); + lqw.between(params.get("beginPeopleQuantity") != null && params.get("endPeopleQuantity") != null, + EhsRisk::getPeopleQuantity ,params.get("beginPeopleQuantity"), params.get("endPeopleQuantity")); + lqw.between(params.get("beginMaterialsQuantity") != null && params.get("endMaterialsQuantity") != null, + EhsRisk::getMaterialsQuantity ,params.get("beginMaterialsQuantity"), params.get("endMaterialsQuantity")); + lqw.between(params.get("beginRepairTeam") != null && params.get("endRepairTeam") != null, + EhsRisk::getRepairTeam ,params.get("beginRepairTeam"), params.get("endRepairTeam")); + lqw.like(StringUtils.isNotBlank(query.getPersonResponsible()), EhsRisk::getPersonResponsible, query.getPersonResponsible()); + lqw.like(StringUtils.isNotBlank(query.getVillagePersonResponsible()), EhsRisk::getVillagePersonResponsible, query.getVillagePersonResponsible()); + lqw.like(StringUtils.isNotBlank(query.getVillagePersonResponsible2()), EhsRisk::getVillagePersonResponsible2, query.getVillagePersonResponsible2()); + lqw.like(StringUtils.isNotBlank(query.getTel2()), EhsRisk::getTel2, query.getTel2()); lqw.orderByDesc(EhsRisk::getCreateTime); return lqw; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java index 384a9b6..c958c88 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java @@ -115,4 +115,12 @@ public interface SysDeptMapper * @return 结果 */ public int deleteDeptById(Long deptId); + + /** + * 查询所有部门数据的id和name + * + * @param dept 部门信息 + * @return 部门信息集合 + */ + public List selectAllDeptList(SysDept dept); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java index f228208..1305f33 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java @@ -121,4 +121,11 @@ public interface ISysDeptService * @return 结果 */ public int deleteDeptById(Long deptId); + /** + * 查询所有部门数据的id和name + * + * @param dept 部门信息 + * @return 部门信息集合 + */ + public List selectAllDeptList(SysDept dept); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java index f7fb088..60d1310 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -335,4 +335,14 @@ public class SysDeptServiceImpl implements ISysDeptService { return getChildList(list, t).size() > 0; } + + /** + * 查询所有部门数据的id和name + * + * @param dept 部门信息 + * @return 部门信息集合 + */ + public List selectAllDeptList(SysDept dept){ + return deptMapper.selectAllDeptList(dept); + } } diff --git a/ruoyi-system/src/main/resources/mapper/ehs/EhsMaterialMapper.xml b/ruoyi-system/src/main/resources/mapper/ehs/EhsMaterialMapper.xml index a70c05b..aa279ce 100644 --- a/ruoyi-system/src/main/resources/mapper/ehs/EhsMaterialMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/ehs/EhsMaterialMapper.xml @@ -1,29 +1,55 @@ + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + select material_id, material_type, class_first, class_second, material_name, material_specs, material_quantity, reserve_location, Manager_person, tel, create_by, create_time, update_by, update_time, remark, dept_id, create_user_id, update_user_id from ehs_material + - + + + + + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/ehs/EhsRiskMapper.xml b/ruoyi-system/src/main/resources/mapper/ehs/EhsRiskMapper.xml index 0914292..a1c88bf 100644 --- a/ruoyi-system/src/main/resources/mapper/ehs/EhsRiskMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/ehs/EhsRiskMapper.xml @@ -2,7 +2,7 @@ - + @@ -22,7 +22,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + + + + + select r.*, d.dept_name + from ehs_risk r left join sys_dept d on r.dept_id = d.dept_id + + + + + diff --git a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml index cf439f6..cdee1a4 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -57,7 +57,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" order by d.parent_id, d.order_num - +