MyBatisPlus实现故障类型查询
parent
0d84a6d188
commit
e1be9bffb7
|
@ -0,0 +1,40 @@
|
|||
package com.february.fault.controller;
|
||||
|
||||
/**
|
||||
* @program: february-fault-information
|
||||
* @description: 故障类型
|
||||
* @author: Mr.Wang
|
||||
* @create: 2023-11-21 19:59
|
||||
**/
|
||||
|
||||
import com.february.fault.domain.FaultType;
|
||||
import com.february.fault.result.Result;
|
||||
import com.february.fault.service.FaultTypeService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 故障类型
|
||||
*/
|
||||
@Log4j2
|
||||
@RestController
|
||||
@RequestMapping("/faultType")
|
||||
public class FaultTypeController {
|
||||
@Autowired
|
||||
private FaultTypeService faultTypeService;
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
@PostMapping("/findById")
|
||||
public Result<FaultType> findById(@RequestParam Integer faultTypeId){
|
||||
log.info("功能名称:根据id查询故障类型信息,请求路径:{},请求方式:{}",request.getRequestURI(),request.getMethod());
|
||||
Result<FaultType> result=faultTypeService.findById(faultTypeId);
|
||||
log.info("响应结果:{}",result);
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.february.fault.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.february.fault.domain.FaultType;
|
||||
|
||||
/**
|
||||
* @program: february-fault-information
|
||||
* @description:
|
||||
* @author: Mr.Wang
|
||||
* @create: 2023-11-21 20:01
|
||||
**/
|
||||
public interface FaultTypeMapper extends BaseMapper<FaultType> {
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.february.fault.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.february.fault.domain.FaultType;
|
||||
import com.february.fault.result.Result;
|
||||
|
||||
/**
|
||||
* @program: february-fault-information
|
||||
* @description:
|
||||
* @author: Mr.Wang
|
||||
* @create: 2023-11-21 20:00
|
||||
**/
|
||||
public interface FaultTypeService extends IService<FaultType> {
|
||||
Result<FaultType> findById(Integer faultTypeId);
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.february.fault.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.february.fault.domain.FaultType;
|
||||
import com.february.fault.mapper.FaultTypeMapper;
|
||||
import com.february.fault.result.Result;
|
||||
import com.february.fault.service.FaultTypeService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @program: february-fault-information
|
||||
* @description:
|
||||
* @author: Mr.Wang
|
||||
* @create: 2023-11-21 20:00
|
||||
**/
|
||||
@Log4j2
|
||||
@Service
|
||||
public class FaultTypeServiceImpl extends ServiceImpl<FaultTypeMapper, FaultType> implements FaultTypeService {
|
||||
@Autowired
|
||||
private FaultTypeMapper faultTypeMapper;
|
||||
@Override
|
||||
public Result<FaultType> findById(Integer faultTypeId) {
|
||||
QueryWrapper<FaultType> faultTypeQueryWrapper = new QueryWrapper<>();
|
||||
QueryWrapper<FaultType> faultTypeId1 = faultTypeQueryWrapper.eq("fault_type_id", faultTypeId);
|
||||
FaultType faultType = faultTypeMapper.selectOne(faultTypeId1);
|
||||
return Result.success(faultType);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue