mirror of
https://gitee.com/y_project/RuoYi-Cloud.git
synced 2026-01-29 21:11:57 +08:00
代码生成工具支持MyBatisDynamicSql
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
package com.ruoyi.wms.controller;
|
||||
|
||||
import com.ruoyi.common.core.web.controller.BaseController;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||
import com.ruoyi.common.log.annotation.Log;
|
||||
import com.ruoyi.common.log.enums.BusinessType;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.wms.domain.UnitInfo;
|
||||
import com.ruoyi.wms.service.IUnitInfoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 单位信息管理Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* created on 2024-02-02
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/UnitInfo")
|
||||
public class UnitInfoController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IUnitInfoService unitInfoService;
|
||||
|
||||
/**
|
||||
* 查询单位信息管理列表
|
||||
*/
|
||||
@RequiresPermissions("wms:UnitInfo:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(UnitInfo unitInfo)
|
||||
{
|
||||
startPage();
|
||||
List<UnitInfo> list = unitInfoService.selectUnitInfoList(unitInfo);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
//TODO 如果要启用导出功能,需要在domain实体类的字段上添加注解:@com.ruoyi.common.core.annotation.Excel(name = "字段名")
|
||||
/*
|
||||
* 导出单位信息管理列表
|
||||
*/
|
||||
// @RequiresPermissions("wms:UnitInfo:export")
|
||||
// @Log(title = "单位信息管理", businessType = BusinessType.EXPORT)
|
||||
// @PostMapping("/export")
|
||||
// public void export(HttpServletResponse response, UnitInfo unitInfo)
|
||||
// {
|
||||
// List<UnitInfo> list = unitInfoService.selectUnitInfoList(unitInfo);
|
||||
// ExcelUtil<UnitInfo> util = new ExcelUtil<>(UnitInfo.class);
|
||||
// util.exportExcel(response, list, "单位信息管理数据");
|
||||
// }
|
||||
|
||||
/**
|
||||
* 获取单位信息管理详细信息
|
||||
*/
|
||||
@RequiresPermissions("wms:UnitInfo:query")
|
||||
@GetMapping(value = "/{orgCd}")
|
||||
public AjaxResult getInfo(@PathVariable("orgCd") String orgCd)
|
||||
{
|
||||
return success(unitInfoService.selectUnitInfoByOrgCd(orgCd));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增单位信息管理
|
||||
*/
|
||||
@RequiresPermissions("wms:UnitInfo:add")
|
||||
@Log(title = "单位信息管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody UnitInfo unitInfo)
|
||||
{
|
||||
return toAjax(unitInfoService.insertUnitInfo(unitInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改单位信息管理
|
||||
*/
|
||||
@RequiresPermissions("wms:UnitInfo:edit")
|
||||
@Log(title = "单位信息管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody UnitInfo unitInfo)
|
||||
{
|
||||
return toAjax(unitInfoService.updateUnitInfo(unitInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除单位信息管理
|
||||
*/
|
||||
@RequiresPermissions("wms:UnitInfo:remove")
|
||||
@Log(title = "单位信息管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{orgCds}")
|
||||
public AjaxResult remove(@PathVariable String[] orgCds)
|
||||
{
|
||||
return toAjax(unitInfoService.deleteUnitInfoByOrgCds(orgCds));
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,8 @@
|
||||
package com.ruoyi.wms.mapper;
|
||||
|
||||
import static com.ruoyi.wms.mapper.UnitInfoDynamicSqlSupport.*;
|
||||
import static org.mybatis.dynamic.sql.SqlBuilder.isEqualTo;
|
||||
|
||||
import com.ruoyi.wms.domain.UnitInfo;
|
||||
import jakarta.annotation.Generated;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Result;
|
||||
import org.apache.ibatis.annotations.ResultMap;
|
||||
import org.apache.ibatis.annotations.Results;
|
||||
import org.apache.ibatis.annotations.SelectProvider;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.mybatis.dynamic.sql.BasicColumn;
|
||||
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
|
||||
@@ -23,11 +13,14 @@ import org.mybatis.dynamic.sql.update.UpdateDSL;
|
||||
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
|
||||
import org.mybatis.dynamic.sql.update.UpdateModel;
|
||||
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
|
||||
import org.mybatis.dynamic.sql.util.mybatis3.CommonCountMapper;
|
||||
import org.mybatis.dynamic.sql.util.mybatis3.CommonDeleteMapper;
|
||||
import org.mybatis.dynamic.sql.util.mybatis3.CommonInsertMapper;
|
||||
import org.mybatis.dynamic.sql.util.mybatis3.CommonUpdateMapper;
|
||||
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;
|
||||
import org.mybatis.dynamic.sql.util.mybatis3.*;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.ruoyi.wms.mapper.UnitInfoDynamicSqlSupport.*;
|
||||
import static org.mybatis.dynamic.sql.SqlBuilder.isEqualTo;
|
||||
|
||||
@Mapper
|
||||
public interface UnitInfoMapper extends CommonCountMapper, CommonDeleteMapper, CommonInsertMapper<UnitInfo>, CommonUpdateMapper {
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.ruoyi.wms.service;
|
||||
|
||||
import com.ruoyi.wms.domain.UnitInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 单位信息管理Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* created on 2024-02-02
|
||||
*/
|
||||
public interface IUnitInfoService {
|
||||
/**
|
||||
* 查询单位信息管理
|
||||
*
|
||||
* @param orgCd 单位信息管理主键
|
||||
* @return 单位信息管理
|
||||
*/
|
||||
UnitInfo selectUnitInfoByOrgCd(String orgCd);
|
||||
|
||||
/**
|
||||
* 查询单位信息管理列表
|
||||
*
|
||||
* @param unitInfo 单位信息管理
|
||||
* @return 单位信息管理集合
|
||||
*/
|
||||
List<UnitInfo> selectUnitInfoList(UnitInfo unitInfo);
|
||||
|
||||
/**
|
||||
* 新增单位信息管理
|
||||
*
|
||||
* @param unitInfo 单位信息管理
|
||||
* @return 结果
|
||||
*/
|
||||
int insertUnitInfo(UnitInfo unitInfo);
|
||||
|
||||
/**
|
||||
* 修改单位信息管理
|
||||
*
|
||||
* @param unitInfo 单位信息管理
|
||||
* @return 结果
|
||||
*/
|
||||
int updateUnitInfo(UnitInfo unitInfo);
|
||||
|
||||
/**
|
||||
* 批量删除单位信息管理
|
||||
*
|
||||
* @param orgCds 需要删除的单位信息管理主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteUnitInfoByOrgCds(String[] orgCds);
|
||||
|
||||
/**
|
||||
* 删除单位信息管理信息
|
||||
*
|
||||
* @param orgCd 单位信息管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteUnitInfoByOrgCd(String orgCd);
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.ruoyi.wms.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.utils.DateUtils;
|
||||
import com.ruoyi.wms.domain.UnitInfo;
|
||||
import com.ruoyi.wms.mapper.UnitInfoDynamicSqlSupport;
|
||||
import com.ruoyi.wms.mapper.UnitInfoMapper;
|
||||
import com.ruoyi.wms.service.IUnitInfoService;
|
||||
import org.mybatis.dynamic.sql.SqlBuilder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 单位信息管理Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* created on 2024-02-02
|
||||
*/
|
||||
@Service
|
||||
public class UnitInfoServiceImpl implements IUnitInfoService {
|
||||
@Autowired
|
||||
private UnitInfoMapper unitInfoMapper;
|
||||
|
||||
/**
|
||||
* 查询单位信息管理
|
||||
*
|
||||
* @param orgCd 单位信息管理主键
|
||||
* @return 单位信息管理
|
||||
*/
|
||||
@Override
|
||||
public UnitInfo selectUnitInfoByOrgCd(String orgCd) {
|
||||
Optional<UnitInfo> result = unitInfoMapper.selectOne(dsl -> dsl.where(UnitInfoDynamicSqlSupport.orgCd, SqlBuilder.isEqualTo(orgCd)));
|
||||
return result.orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询单位信息管理列表
|
||||
*
|
||||
* @param unitInfo 单位信息管理
|
||||
* @return 单位信息管理
|
||||
*/
|
||||
@Override
|
||||
public List<UnitInfo> selectUnitInfoList(UnitInfo unitInfo) {
|
||||
return unitInfoMapper.select(dsl -> dsl
|
||||
.where(UnitInfoDynamicSqlSupport.orgCd, SqlBuilder.isEqualToWhenPresent(unitInfo.getOrgCd()))
|
||||
.and(UnitInfoDynamicSqlSupport.unit, SqlBuilder.isEqualToWhenPresent(unitInfo.getUnit()))
|
||||
.and(UnitInfoDynamicSqlSupport.unitName, SqlBuilder.isEqualToWhenPresent(unitInfo.getUnitName()))
|
||||
.and(UnitInfoDynamicSqlSupport.unitConvRate, SqlBuilder.isEqualToWhenPresent(unitInfo.getUnitConvRate()))
|
||||
.and(UnitInfoDynamicSqlSupport.srcConvUnit, SqlBuilder.isEqualToWhenPresent(unitInfo.getSrcConvUnit()))
|
||||
.and(UnitInfoDynamicSqlSupport.remark1, SqlBuilder.isEqualToWhenPresent(unitInfo.getRemark1()))
|
||||
.and(UnitInfoDynamicSqlSupport.remark2, SqlBuilder.isEqualToWhenPresent(unitInfo.getRemark2()))
|
||||
.and(UnitInfoDynamicSqlSupport.remark3, SqlBuilder.isEqualToWhenPresent(unitInfo.getRemark3()))
|
||||
.and(UnitInfoDynamicSqlSupport.remark4, SqlBuilder.isEqualToWhenPresent(unitInfo.getRemark4()))
|
||||
.and(UnitInfoDynamicSqlSupport.remark5, SqlBuilder.isEqualToWhenPresent(unitInfo.getRemark5()))
|
||||
.and(UnitInfoDynamicSqlSupport.updateCount, SqlBuilder.isEqualToWhenPresent(unitInfo.getUpdateCount()))
|
||||
.and(UnitInfoDynamicSqlSupport.deleteFlag, SqlBuilder.isEqualToWhenPresent(unitInfo.getDeleteFlag()))
|
||||
.and(UnitInfoDynamicSqlSupport.createBy, SqlBuilder.isEqualToWhenPresent(unitInfo.getCreateBy()))
|
||||
.and(UnitInfoDynamicSqlSupport.createTime, SqlBuilder.isEqualToWhenPresent(unitInfo.getCreateTime()))
|
||||
.and(UnitInfoDynamicSqlSupport.updateBy, SqlBuilder.isEqualToWhenPresent(unitInfo.getUpdateBy()))
|
||||
.and(UnitInfoDynamicSqlSupport.updateTime, SqlBuilder.isEqualToWhenPresent(unitInfo.getUpdateTime()))
|
||||
.and(UnitInfoDynamicSqlSupport.remark, SqlBuilder.isEqualToWhenPresent(unitInfo.getRemark()))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增单位信息管理
|
||||
*
|
||||
* @param unitInfo 单位信息管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertUnitInfo(UnitInfo unitInfo) {
|
||||
unitInfo.setCreateTime(DateUtils.getNowDate());
|
||||
return unitInfoMapper.insertSelective(unitInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改单位信息管理
|
||||
*
|
||||
* @param unitInfo 单位信息管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateUnitInfo(UnitInfo unitInfo) {
|
||||
unitInfo.setUpdateTime(DateUtils.getNowDate());
|
||||
return unitInfoMapper.updateByPrimaryKeySelective(unitInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除单位信息管理
|
||||
*
|
||||
* @param orgCds 需要删除的单位信息管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteUnitInfoByOrgCds(String[] orgCds) {
|
||||
|
||||
return unitInfoMapper.delete(dsl -> dsl.where(UnitInfoDynamicSqlSupport.orgCd, SqlBuilder.isIn(orgCds)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除单位信息管理信息
|
||||
*
|
||||
* @param orgCd 单位信息管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteUnitInfoByOrgCd(String orgCd) {
|
||||
return unitInfoMapper.delete(dsl -> dsl.where(UnitInfoDynamicSqlSupport.orgCd, SqlBuilder.isEqualTo(orgCd)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user