| | |
| | | package com.jilongda.manage.controller; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.jilongda.common.basic.ApiResult; |
| | | import com.jilongda.common.basic.PageInfo; |
| | | import com.jilongda.manage.model.TSupplier; |
| | | import com.jilongda.manage.query.TSupplierQuery; |
| | | import com.jilongda.manage.service.TSupplierService; |
| | | import com.jilongda.manage.vo.TSupplierVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @author 无关风月 |
| | | * @since 2024-12-09 |
| | | */ |
| | | @Api(tags = "供应商管理") |
| | | @RestController |
| | | @RequestMapping("/t-supplier") |
| | | public class TSupplierController { |
| | | @Autowired |
| | | private TSupplierService supplierService; |
| | | |
| | | /** |
| | | * 获取供应商列表 |
| | | */ |
| | | @ApiOperation(value = "获取供应商分页列表") |
| | | @PostMapping(value = "/pageList") |
| | | public ApiResult<PageInfo<TSupplierVO>> pageList(@RequestBody TSupplierQuery query) { |
| | | return ApiResult.success(supplierService.pageList(query)); |
| | | } |
| | | |
| | | /** |
| | | * 获取供应商列表 |
| | | */ |
| | | @ApiOperation(value = "获取供应商列表") |
| | | @PostMapping(value = "/list") |
| | | public ApiResult<List<TSupplier>> list(@RequestBody TSupplierQuery query) { |
| | | LambdaQueryWrapper<TSupplier> wrapper = new LambdaQueryWrapper<>(); |
| | | if(StringUtils.hasLength(query.getName())){ |
| | | wrapper.like(TSupplier::getName, query.getName()); |
| | | } |
| | | wrapper.eq(TSupplier::getStatus, 1); |
| | | List<TSupplier> list = supplierService.list(wrapper); |
| | | return ApiResult.success(list); |
| | | } |
| | | |
| | | /** |
| | | * 添加供应商 |
| | | */ |
| | | @ApiOperation(value = "添加供应商") |
| | | @PostMapping(value = "/add") |
| | | public ApiResult<String> add(@Validated @RequestBody TSupplier dto) { |
| | | Boolean flag = supplierService.isExit(dto.getId(), dto.getName()); |
| | | if(flag){ |
| | | return ApiResult.failed("供应商名称已存在"); |
| | | } |
| | | supplierService.save(dto); |
| | | return ApiResult.success(); |
| | | } |
| | | |
| | | @ApiOperation(value = "修改供应商") |
| | | @PostMapping(value = "/update") |
| | | public ApiResult<String> update(@Validated @RequestBody TSupplier dto) { |
| | | Boolean flag = supplierService.isExit(dto.getId(), dto.getName()); |
| | | if(flag){ |
| | | return ApiResult.failed("供应商名称已存在"); |
| | | } |
| | | supplierService.updateById(dto); |
| | | return ApiResult.success(); |
| | | } |
| | | |
| | | /** |
| | | * 供应商启用禁用 |
| | | */ |
| | | @ApiOperation(value = "供应商启用禁用") |
| | | @GetMapping(value = "/upAndDown") |
| | | public ApiResult<Boolean> upAndDown(@RequestParam Long id, |
| | | @RequestParam Integer status) { |
| | | return ApiResult.success(supplierService.upAndDown(id,status)); |
| | | } |
| | | |
| | | @ApiOperation(value = "删除供应商") |
| | | @DeleteMapping(value = "/deleteById") |
| | | public ApiResult<Boolean> deleteById(@RequestParam Long id) { |
| | | return ApiResult.success(supplierService.removeById(id)); |
| | | } |
| | | |
| | | @ApiOperation(value = "批量删除供应商") |
| | | @DeleteMapping(value = "/deleteByIds") |
| | | public ApiResult<Boolean> deleteByIds(@RequestBody List<Long> ids) { |
| | | return ApiResult.success(supplierService.removeByIds(ids)); |
| | | } |
| | | |
| | | @ApiOperation(value = "查询供应商详情") |
| | | @GetMapping(value = "/getDetailById") |
| | | public ApiResult<TSupplier> getDetailById(@RequestParam Long id) { |
| | | return ApiResult.success(supplierService.getById(id)); |
| | | } |
| | | } |
| | | |