- 新增能耗记录实体类 EmsEnergyConsumption 及相关业务对象、控制器、映射器和服务实现 - 新增能源费率实体类 EmsEnergyRate 及相关业务对象、控制器、映射器和服务实现 - 实现各模块的基础 CRUD 功能,包括分页查询、导出 Excel 等操作 - 配置 MyBatis 映射文件及逻辑删除支持
100 lines
3.6 KiB
Java
100 lines
3.6 KiB
Java
package com.klp.ems.controller;
|
||
|
||
import java.util.List;
|
||
import java.util.Arrays;
|
||
|
||
import lombok.RequiredArgsConstructor;
|
||
import javax.servlet.http.HttpServletResponse;
|
||
import javax.validation.constraints.*;
|
||
import org.springframework.web.bind.annotation.*;
|
||
import org.springframework.validation.annotation.Validated;
|
||
import com.klp.common.annotation.RepeatSubmit;
|
||
import com.klp.common.annotation.Log;
|
||
import com.klp.common.core.controller.BaseController;
|
||
import com.klp.common.core.domain.PageQuery;
|
||
import com.klp.common.core.domain.R;
|
||
import com.klp.common.core.validate.AddGroup;
|
||
import com.klp.common.core.validate.EditGroup;
|
||
import com.klp.common.enums.BusinessType;
|
||
import com.klp.common.utils.poi.ExcelUtil;
|
||
import com.klp.ems.domain.vo.EmsEnergyRateVo;
|
||
import com.klp.ems.domain.bo.EmsEnergyRateBo;
|
||
import com.klp.ems.service.IEmsEnergyRateService;
|
||
import com.klp.common.core.page.TableDataInfo;
|
||
|
||
/**
|
||
* 能源费率(currency 为 INT:0=CNY,1=USD,2=EUR)
|
||
*
|
||
* @author Joshi
|
||
* @date 2025-09-28
|
||
*/
|
||
@Validated
|
||
@RequiredArgsConstructor
|
||
@RestController
|
||
@RequestMapping("/ems/energyRate")
|
||
public class EmsEnergyRateController extends BaseController {
|
||
|
||
private final IEmsEnergyRateService iEmsEnergyRateService;
|
||
|
||
/**
|
||
* 查询能源费率(currency 为 INT:0=CNY,1=USD,2=EUR)列表
|
||
*/
|
||
@GetMapping("/list")
|
||
public TableDataInfo<EmsEnergyRateVo> list(EmsEnergyRateBo bo, PageQuery pageQuery) {
|
||
return iEmsEnergyRateService.queryPageList(bo, pageQuery);
|
||
}
|
||
|
||
/**
|
||
* 导出能源费率(currency 为 INT:0=CNY,1=USD,2=EUR)列表
|
||
*/
|
||
@Log(title = "能源费率(currency 为 INT:0=CNY,1=USD,2=EUR)", businessType = BusinessType.EXPORT)
|
||
@PostMapping("/export")
|
||
public void export(EmsEnergyRateBo bo, HttpServletResponse response) {
|
||
List<EmsEnergyRateVo> list = iEmsEnergyRateService.queryList(bo);
|
||
ExcelUtil.exportExcel(list, "能源费率(currency 为 INT:0=CNY,1=USD,2=EUR)", EmsEnergyRateVo.class, response);
|
||
}
|
||
|
||
/**
|
||
* 获取能源费率(currency 为 INT:0=CNY,1=USD,2=EUR)详细信息
|
||
*
|
||
* @param energyRateId 主键
|
||
*/
|
||
@GetMapping("/{energyRateId}")
|
||
public R<EmsEnergyRateVo> getInfo(@NotNull(message = "主键不能为空")
|
||
@PathVariable Long energyRateId) {
|
||
return R.ok(iEmsEnergyRateService.queryById(energyRateId));
|
||
}
|
||
|
||
/**
|
||
* 新增能源费率(currency 为 INT:0=CNY,1=USD,2=EUR)
|
||
*/
|
||
@Log(title = "能源费率(currency 为 INT:0=CNY,1=USD,2=EUR)", businessType = BusinessType.INSERT)
|
||
@RepeatSubmit()
|
||
@PostMapping()
|
||
public R<Void> add(@Validated(AddGroup.class) @RequestBody EmsEnergyRateBo bo) {
|
||
return toAjax(iEmsEnergyRateService.insertByBo(bo));
|
||
}
|
||
|
||
/**
|
||
* 修改能源费率(currency 为 INT:0=CNY,1=USD,2=EUR)
|
||
*/
|
||
@Log(title = "能源费率(currency 为 INT:0=CNY,1=USD,2=EUR)", businessType = BusinessType.UPDATE)
|
||
@RepeatSubmit()
|
||
@PutMapping()
|
||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody EmsEnergyRateBo bo) {
|
||
return toAjax(iEmsEnergyRateService.updateByBo(bo));
|
||
}
|
||
|
||
/**
|
||
* 删除能源费率(currency 为 INT:0=CNY,1=USD,2=EUR)
|
||
*
|
||
* @param energyRateIds 主键串
|
||
*/
|
||
@Log(title = "能源费率(currency 为 INT:0=CNY,1=USD,2=EUR)", businessType = BusinessType.DELETE)
|
||
@DeleteMapping("/{energyRateIds}")
|
||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||
@PathVariable Long[] energyRateIds) {
|
||
return toAjax(iEmsEnergyRateService.deleteWithValidByIds(Arrays.asList(energyRateIds), true));
|
||
}
|
||
}
|