| | |
| | | package com.jilongda.manage.controller; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.jilongda.common.basic.ApiResult; |
| | | import com.jilongda.common.basic.PageInfo; |
| | | import com.jilongda.manage.model.TMaterial; |
| | | import com.jilongda.manage.query.TMaterialQuery; |
| | | import com.jilongda.manage.service.TMaterialService; |
| | | import com.jilongda.manage.vo.TMaterialVO; |
| | | 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> |
| | | * 镜架/镜片品牌表 前端控制器 |
| | | * 材质表 前端控制器 |
| | | * </p> |
| | | * |
| | | * @author 无关风月 |
| | | * @since 2024-12-09 |
| | | */ |
| | | @Api(tags = "材质管理") |
| | | @RestController |
| | | @RequestMapping("/t-material") |
| | | public class TMaterialController { |
| | | |
| | | @Autowired |
| | | private TMaterialService materialService; |
| | | |
| | | /** |
| | | * 获取材质列表 |
| | | */ |
| | | @ApiOperation(value = "获取材质分页列表") |
| | | @PostMapping(value = "/pageList") |
| | | public ApiResult<PageInfo<TMaterialVO>> pageList(@RequestBody TMaterialQuery query) { |
| | | return ApiResult.success(materialService.pageList(query)); |
| | | } |
| | | |
| | | /** |
| | | * 获取材质列表 |
| | | */ |
| | | @ApiOperation(value = "获取材质列表") |
| | | @PostMapping(value = "/list") |
| | | public ApiResult<List<TMaterial>> list(@RequestBody TMaterialQuery query) { |
| | | List<TMaterial> list = materialService.list(Wrappers.lambdaQuery(TMaterial.class) |
| | | .eq(TMaterial::getStatus, 1)); |
| | | return ApiResult.success(list); |
| | | } |
| | | |
| | | /** |
| | | * 添加材质 |
| | | */ |
| | | @ApiOperation(value = "添加材质") |
| | | @PostMapping(value = "/add") |
| | | public ApiResult<String> add(@Validated @RequestBody TMaterial dto) { |
| | | Boolean flag = materialService.isExit(dto.getId(), dto.getName()); |
| | | if(flag){ |
| | | return ApiResult.failed("材质名称已存在"); |
| | | } |
| | | materialService.save(dto); |
| | | return ApiResult.success(); |
| | | } |
| | | |
| | | @ApiOperation(value = "修改材质") |
| | | @PostMapping(value = "/update") |
| | | public ApiResult<String> update(@Validated @RequestBody TMaterial dto) { |
| | | Boolean flag = materialService.isExit(dto.getId(), dto.getName()); |
| | | if(flag){ |
| | | return ApiResult.failed("材质名称已存在"); |
| | | } |
| | | materialService.updateById(dto); |
| | | return ApiResult.success(); |
| | | } |
| | | |
| | | /** |
| | | * 材质启用禁用 |
| | | */ |
| | | @ApiOperation(value = "材质启用禁用") |
| | | @GetMapping(value = "/upAndDown") |
| | | public ApiResult<Boolean> upAndDown(@RequestParam Long id, |
| | | @RequestParam Integer status) { |
| | | return ApiResult.success(materialService.upAndDown(id,status)); |
| | | } |
| | | |
| | | @ApiOperation(value = "删除材质") |
| | | @DeleteMapping(value = "/deleteById") |
| | | public ApiResult<Boolean> deleteById(@RequestParam Long id) { |
| | | return ApiResult.success(materialService.removeById(id)); |
| | | } |
| | | |
| | | @ApiOperation(value = "批量删除材质") |
| | | @DeleteMapping(value = "/deleteByIds") |
| | | public ApiResult<Boolean> deleteByIds(@RequestBody List<Long> ids) { |
| | | return ApiResult.success(materialService.removeByIds(ids)); |
| | | } |
| | | |
| | | @ApiOperation(value = "查询材质详情") |
| | | @GetMapping(value = "/getDetailById") |
| | | public ApiResult<TMaterial> getDetailById(@RequestParam Long id) { |
| | | return ApiResult.success(materialService.getById(id)); |
| | | } |
| | | |
| | | } |
| | | |