parent
6b82aa61d7
commit
6049fbbde9
@ -0,0 +1,95 @@
|
||||
package com.chanko.yunxi.mes.module.heli.controller.admin.equip;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.CommonResult;
|
||||
import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils;
|
||||
import static com.chanko.yunxi.mes.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import com.chanko.yunxi.mes.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import com.chanko.yunxi.mes.framework.operatelog.core.annotations.OperateLog;
|
||||
import static com.chanko.yunxi.mes.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import com.chanko.yunxi.mes.module.heli.controller.admin.equip.vo.*;
|
||||
import com.chanko.yunxi.mes.module.heli.dal.dataobject.equip.EquipDO;
|
||||
import com.chanko.yunxi.mes.module.heli.service.equip.EquipService;
|
||||
|
||||
@Tag(name = "管理后台 - 设备信息")
|
||||
@RestController
|
||||
@RequestMapping("/heli/equip")
|
||||
@Validated
|
||||
public class EquipController {
|
||||
|
||||
@Resource
|
||||
private EquipService equipService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建设备信息")
|
||||
@PreAuthorize("@ss.hasPermission('heli:equip:create')")
|
||||
public CommonResult<Long> createEquip(@Valid @RequestBody EquipSaveReqVO createReqVO) {
|
||||
return success(equipService.createEquip(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新设备信息")
|
||||
@PreAuthorize("@ss.hasPermission('heli:equip:update')")
|
||||
public CommonResult<Boolean> updateEquip(@Valid @RequestBody EquipSaveReqVO updateReqVO) {
|
||||
equipService.updateEquip(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除设备信息")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('heli:equip:delete')")
|
||||
public CommonResult<Boolean> deleteEquip(@RequestParam("id") Long id) {
|
||||
equipService.deleteEquip(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得设备信息")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('heli:equip:query')")
|
||||
public CommonResult<EquipRespVO> getEquip(@RequestParam("id") Long id) {
|
||||
EquipDO equip = equipService.getEquip(id);
|
||||
return success(BeanUtils.toBean(equip, EquipRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得设备信息分页")
|
||||
@PreAuthorize("@ss.hasPermission('heli:equip:query')")
|
||||
public CommonResult<PageResult<EquipRespVO>> getEquipPage(@Valid EquipPageReqVO pageReqVO) {
|
||||
PageResult<EquipDO> pageResult = equipService.getEquipPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, EquipRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出设备信息 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('heli:equip:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportEquipExcel(@Valid EquipPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<EquipDO> list = equipService.getEquipPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "设备信息.xls", "数据", EquipRespVO.class,
|
||||
BeanUtils.toBean(list, EquipRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.chanko.yunxi.mes.module.heli.dal.mysql.equip;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
|
||||
import com.chanko.yunxi.mes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.chanko.yunxi.mes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.chanko.yunxi.mes.module.heli.dal.dataobject.equip.EquipDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import com.chanko.yunxi.mes.module.heli.controller.admin.equip.vo.*;
|
||||
|
||||
/**
|
||||
* 设备信息 Mapper
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
@Mapper
|
||||
public interface EquipMapper extends BaseMapperX<EquipDO> {
|
||||
|
||||
default PageResult<EquipDO> selectPage(EquipPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<EquipDO>()
|
||||
.eqIfPresent(EquipDO::getId, reqVO.getId())
|
||||
.likeIfPresent(EquipDO::getName, reqVO.getName())
|
||||
.eqIfPresent(EquipDO::getMouldTypeId, reqVO.getMouldTypeId())
|
||||
.eqIfPresent(EquipDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(EquipDO::getCreator, reqVO.getCreator())
|
||||
.betweenIfPresent(EquipDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(EquipDO::getUpdater, reqVO.getUpdater())
|
||||
.betweenIfPresent(EquipDO::getUpdateTime, reqVO.getUpdateTime())
|
||||
.eqIfPresent(EquipDO::getDeleted, reqVO.getDeleted())
|
||||
.orderByDesc(EquipDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package com.chanko.yunxi.mes.module.heli.service.equip;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import com.chanko.yunxi.mes.module.heli.controller.admin.equip.vo.*;
|
||||
import com.chanko.yunxi.mes.module.heli.dal.dataobject.equip.EquipDO;
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 设备信息 Service 接口
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
public interface EquipService {
|
||||
|
||||
/**
|
||||
* 创建设备信息
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createEquip(@Valid EquipSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新设备信息
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateEquip(@Valid EquipSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除设备信息
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteEquip(Long id);
|
||||
|
||||
/**
|
||||
* 获得设备信息
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 设备信息
|
||||
*/
|
||||
EquipDO getEquip(Long id);
|
||||
|
||||
/**
|
||||
* 获得设备信息分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 设备信息分页
|
||||
*/
|
||||
PageResult<EquipDO> getEquipPage(EquipPageReqVO pageReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package com.chanko.yunxi.mes.module.heli.service.equip;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import com.chanko.yunxi.mes.module.heli.controller.admin.equip.vo.*;
|
||||
import com.chanko.yunxi.mes.module.heli.dal.dataobject.equip.EquipDO;
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
|
||||
import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils;
|
||||
|
||||
import com.chanko.yunxi.mes.module.heli.dal.mysql.equip.EquipMapper;
|
||||
|
||||
import static com.chanko.yunxi.mes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.chanko.yunxi.mes.module.heli.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 设备信息 Service 实现类
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class EquipServiceImpl implements EquipService {
|
||||
|
||||
@Resource
|
||||
private EquipMapper equipMapper;
|
||||
|
||||
@Override
|
||||
public Long createEquip(EquipSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
EquipDO equip = BeanUtils.toBean(createReqVO, EquipDO.class);
|
||||
equipMapper.insert(equip);
|
||||
// 返回
|
||||
return equip.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEquip(EquipSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateEquipExists(updateReqVO.getId());
|
||||
// 更新
|
||||
EquipDO updateObj = BeanUtils.toBean(updateReqVO, EquipDO.class);
|
||||
equipMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteEquip(Long id) {
|
||||
// 校验存在
|
||||
validateEquipExists(id);
|
||||
// 删除
|
||||
equipMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateEquipExists(Long id) {
|
||||
if (equipMapper.selectById(id) == null) {
|
||||
throw exception(EQUIP_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EquipDO getEquip(Long id) {
|
||||
return equipMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<EquipDO> getEquipPage(EquipPageReqVO pageReqVO) {
|
||||
return equipMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
import request from '@/config/axios'
|
||||
|
||||
export interface EquipVO {
|
||||
id: number
|
||||
name: string
|
||||
mouldTypeId: number
|
||||
status: number
|
||||
}
|
||||
|
||||
// 查询设备信息分页
|
||||
export const getEquipPage = async (params) => {
|
||||
return await request.get({ url: `/heli/equip/page`, params })
|
||||
}
|
||||
|
||||
// 查询设备信息详情
|
||||
export const getEquip = async (id: number) => {
|
||||
return await request.get({ url: `/heli/equip/get?id=` + id })
|
||||
}
|
||||
|
||||
// 新增设备信息
|
||||
export const createEquip = async (data: EquipVO) => {
|
||||
return await request.post({ url: `/heli/equip/create`, data })
|
||||
}
|
||||
|
||||
// 修改设备信息
|
||||
export const updateEquip = async (data: EquipVO) => {
|
||||
return await request.put({ url: `/heli/equip/update`, data })
|
||||
}
|
||||
|
||||
// 删除设备信息
|
||||
export const deleteEquip = async (id: number) => {
|
||||
return await request.delete({ url: `/heli/equip/delete?id=` + id })
|
||||
}
|
||||
|
||||
// 导出设备信息 Excel
|
||||
export const exportEquip = async (params) => {
|
||||
return await request.download({ url: `/heli/equip/export-excel`, params })
|
||||
}
|
Loading…
Reference in new issue