feat:()重构故障代码
parent
b37ff7ca83
commit
90d688f8d2
|
@ -0,0 +1,80 @@
|
|||
package com.muyu.enterprise.controller;
|
||||
|
||||
import cn.hutool.db.Page;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.domain.Fault;
|
||||
import com.muyu.domain.req.MiddleReq;
|
||||
import com.muyu.enterprise.service.FaultService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.muyu.common.core.utils.PageUtils.startPage;
|
||||
|
||||
/**
|
||||
* 故障信息
|
||||
*/
|
||||
@RequestMapping("/fault")
|
||||
@RestController
|
||||
@Log4j2
|
||||
@Tag(name = "故障信息",description = "电子围栏信息展示")
|
||||
public class FaultController {
|
||||
|
||||
@Autowired
|
||||
private FaultService faultService;
|
||||
|
||||
/**
|
||||
* 获取故障列表
|
||||
* @param fault
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
@Operation(description = "获取故障列表")
|
||||
public Result<List<Fault>> list(@RequestBody @Validated Fault fault) {
|
||||
List<Fault> list = faultService.list();
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加故障信息
|
||||
*/
|
||||
@RequestMapping("/add")
|
||||
@Operation(description = "添加故障信息")
|
||||
public Result<String> add(@RequestBody @Validated Fault fault) {
|
||||
faultService.save(fault); //保存故障信息
|
||||
return Result.success("添加成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改故障信息
|
||||
*/
|
||||
@RequestMapping("/{id}")
|
||||
@Operation(description = "修改故障信息") //修改故障信息
|
||||
public Result<String> edit(@PathVariable Integer faultId,
|
||||
@Validated @RequestBody Fault fault) {
|
||||
faultService.updateById(fault); //修改故障信息
|
||||
return Result.success("修改成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除故障信息
|
||||
*/
|
||||
@RequestMapping("/delete/{id}")
|
||||
@Operation(description = "删除故障信息") //删除故障信息
|
||||
public Result<String> delete(@PathVariable Integer faultId) {
|
||||
faultService.removeById(faultId); //删除故障信息
|
||||
return Result.success("删除成功");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.muyu.enterprise.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.domain.Fault;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface FaultMapper extends BaseMapper<Fault> {
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.muyu.enterprise.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.domain.Fault;
|
||||
|
||||
public interface FaultService extends IService<Fault> {
|
||||
}
|
|
@ -14,7 +14,9 @@ import org.springframework.stereotype.Service;
|
|||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class FaultRuleServiceImpl extends ServiceImpl<FaultRuleMapper, FaultRule> implements FaultRuleService {
|
||||
public class FaultRuleServiceImpl
|
||||
extends ServiceImpl<FaultRuleMapper, FaultRule>
|
||||
implements FaultRuleService {
|
||||
|
||||
@Autowired
|
||||
private FaultRuleMapper faultRuleMapper;
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package com.muyu.enterprise.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.domain.Fault;
|
||||
import com.muyu.enterprise.mapper.FaultMapper;
|
||||
import com.muyu.enterprise.service.FaultService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class FaultServiceImpl
|
||||
extends ServiceImpl<FaultMapper, Fault>
|
||||
implements FaultService {
|
||||
|
||||
@Autowired
|
||||
private FaultMapper faultMapper;
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue