| | |
| | | import cc.mrbird.febs.mall.dto.MallNewsInfoDto; |
| | | import cc.mrbird.febs.mall.entity.MallNewsCategory; |
| | | import cc.mrbird.febs.mall.entity.MallNewsInfo; |
| | | import cc.mrbird.febs.mall.service.IMallNewsCategoryService; |
| | | import cc.mrbird.febs.mall.service.IMallNewsInfoService; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | public class AdminNewsInfoController extends BaseController { |
| | | |
| | | private final IMallNewsInfoService mallNewsInfoService; |
| | | private final IMallNewsCategoryService mallNewsCategoryService; |
| | | |
| | | /** |
| | | * 新闻中心-列表 |
| | |
| | | return new FebsResponse().success().message("新增成功"); |
| | | } |
| | | |
| | | /** |
| | | * 新闻分类-删除 |
| | | */ |
| | | @GetMapping("delNewsCategoryInfo/{id}") |
| | | @ControllerEndpoint(operation = "新闻分类-删除", exceptionMessage = "操作失败") |
| | | public FebsResponse delNewsCategoryInfo(@NotNull(message = "{required}") @PathVariable Long id) { |
| | | return mallNewsInfoService.delNewsCategoryInfo(id); |
| | | } |
| | | |
| | | @GetMapping(value = "findAllCategoryList") |
| | | public FebsResponse findAllCategoryList() { |
| | | List<MallNewsCategory> categories = mallNewsInfoService.findAllCategory(); |
| | | public FebsResponse findAllCategoryList(String code) { |
| | | LambdaQueryWrapper<MallNewsCategory> query = new LambdaQueryWrapper<>(); |
| | | if (StrUtil.isNotBlank(code)) { |
| | | query.eq(MallNewsCategory::getCode, code); |
| | | } |
| | | List<MallNewsCategory> categories = mallNewsCategoryService.list(query); |
| | | return new FebsResponse().success().data(categories); |
| | | } |
| | | |
| | | @PostMapping(value = "/topNews/{id}") |
| | | public FebsResponse topNews(@PathVariable Long id) { |
| | | MallNewsInfo mallNewsInfo = new MallNewsInfo(); |
| | | mallNewsInfo.setIsTop(1); |
| | | mallNewsInfo.setId(id); |
| | | mallNewsInfoService.updateById(mallNewsInfo); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @PostMapping(value = "/unTopNews/{id}") |
| | | public FebsResponse unTopNews(@PathVariable Long id) { |
| | | MallNewsInfo mallNewsInfo = new MallNewsInfo(); |
| | | mallNewsInfo.setIsTop(2); |
| | | mallNewsInfo.setId(id); |
| | | mallNewsInfoService.updateById(mallNewsInfo); |
| | | return new FebsResponse().success(); |
| | | } |
| | | } |