diff --git a/february-fault-server/src/main/java/com/february/fault/controller/FaultTypeController.java b/february-fault-server/src/main/java/com/february/fault/controller/FaultTypeController.java new file mode 100644 index 0000000..3228d26 --- /dev/null +++ b/february-fault-server/src/main/java/com/february/fault/controller/FaultTypeController.java @@ -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 findById(@RequestParam Integer faultTypeId){ + log.info("功能名称:根据id查询故障类型信息,请求路径:{},请求方式:{}",request.getRequestURI(),request.getMethod()); + Result result=faultTypeService.findById(faultTypeId); + log.info("响应结果:{}",result); + return result; + } +} diff --git a/february-fault-server/src/main/java/com/february/fault/mapper/FaultTypeMapper.java b/february-fault-server/src/main/java/com/february/fault/mapper/FaultTypeMapper.java new file mode 100644 index 0000000..5e5a910 --- /dev/null +++ b/february-fault-server/src/main/java/com/february/fault/mapper/FaultTypeMapper.java @@ -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 { +} diff --git a/february-fault-server/src/main/java/com/february/fault/service/FaultTypeService.java b/february-fault-server/src/main/java/com/february/fault/service/FaultTypeService.java new file mode 100644 index 0000000..44b2b9a --- /dev/null +++ b/february-fault-server/src/main/java/com/february/fault/service/FaultTypeService.java @@ -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 { + Result findById(Integer faultTypeId); +} diff --git a/february-fault-server/src/main/java/com/february/fault/service/impl/FaultTypeServiceImpl.java b/february-fault-server/src/main/java/com/february/fault/service/impl/FaultTypeServiceImpl.java new file mode 100644 index 0000000..a4d21af --- /dev/null +++ b/february-fault-server/src/main/java/com/february/fault/service/impl/FaultTypeServiceImpl.java @@ -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 implements FaultTypeService { + @Autowired + private FaultTypeMapper faultTypeMapper; + @Override + public Result findById(Integer faultTypeId) { + QueryWrapper faultTypeQueryWrapper = new QueryWrapper<>(); + QueryWrapper faultTypeId1 = faultTypeQueryWrapper.eq("fault_type_id", faultTypeId); + FaultType faultType = faultTypeMapper.selectOne(faultTypeId1); + return Result.success(faultType); + } +}