New file |
| | |
| | | package com.moral.api.controller; |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.Map; |
| | | |
| | | import javax.validation.Valid; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.moral.api.entity.Divisor; |
| | | import com.moral.api.mapper.DivisorMapper; |
| | | import com.moral.api.service.DivisorService; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.constant.ResultMessage; |
| | | |
| | | /** |
| | | * Description //todo |
| | | * |
| | | * @author swb |
| | | * @ClassName DivisorController |
| | | * @date 2023.12.06 14:15 |
| | | */ |
| | | |
| | | @Slf4j |
| | | @Api(tags = {"因子配置"}) |
| | | @RestController |
| | | @RequestMapping(value = "/divisor") |
| | | public class DivisorController { |
| | | |
| | | |
| | | @Autowired |
| | | private DivisorService divisorService; |
| | | |
| | | |
| | | |
| | | @PostMapping("insert") |
| | | @ApiOperation("新增") |
| | | public ResultMessage insert(@Valid @RequestBody Divisor divisor){ |
| | | QueryWrapper<Divisor> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("organization_id", divisor.getOrganizationId()).eq("is_del", Constants.NOT_DELETE); |
| | | if (divisorService.getOne(queryWrapper) != null) { |
| | | return ResultMessage.fail(ResponseCodeEnum.MAC_IS_EXIST.getCode(), ResponseCodeEnum.MAC_IS_EXIST.getMsg()); |
| | | } |
| | | divisorService.insert(divisor); |
| | | return ResultMessage.ok(); |
| | | } |
| | | |
| | | |
| | | @PostMapping("update") |
| | | @ApiOperation("修改") |
| | | public ResultMessage update(@Valid @RequestBody Divisor divisor){ |
| | | |
| | | QueryWrapper<Divisor> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("organization_id", divisor.getOrganizationId()).eq("is_del", Constants.NOT_DELETE); |
| | | if (divisorService.getOne(queryWrapper) != null) { |
| | | return ResultMessage.fail(ResponseCodeEnum.MAC_IS_EXIST.getCode(), ResponseCodeEnum.MAC_IS_EXIST.getMsg()); |
| | | } |
| | | divisorService.update(divisor); |
| | | return ResultMessage.ok(); |
| | | } |
| | | |
| | | @GetMapping("delete") |
| | | @ApiOperation("删除") |
| | | public ResultMessage delete(@RequestParam @ApiParam(value = "id",name = "主键id") Integer id){ |
| | | divisorService.delete(id); |
| | | return ResultMessage.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | @GetMapping("select") |
| | | @ApiOperation("详情") |
| | | public ResultMessage select(@RequestParam @ApiParam(value = "id",name = "主键id") Integer id){ |
| | | Divisor divisor = divisorService.queryById(id); |
| | | return ResultMessage.ok(ObjectUtils.isEmpty(divisor)?"0":divisor); |
| | | } |
| | | |
| | | |
| | | @GetMapping("page") |
| | | @ApiOperation("分页") |
| | | public ResultMessage page(@RequestParam @ApiParam(value = "mac",name = "mac号") String mac, |
| | | @RequestParam @ApiParam(value = "page",name = "页码") String page, |
| | | @RequestParam @ApiParam(value = "size",name = "条数") String size) { |
| | | Map<String, Object> select = divisorService.select(mac, page, size); |
| | | return ResultMessage.ok(ObjectUtils.isEmpty(select)?"0":select); |
| | | } |
| | | |
| | | } |