10 files modified
2 files added
| | |
| | | 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(); |
| | | } |
| | | } |
| | |
| | | package cc.mrbird.febs.mall.controller; |
| | | |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cc.mrbird.febs.mall.dto.NewsListDto; |
| | | import cc.mrbird.febs.mall.entity.MallNewsInfo; |
| | | import cc.mrbird.febs.mall.service.IApiMallNewsService; |
| | | import cc.mrbird.febs.mall.vo.NewsListVo; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiResponse; |
| | | import io.swagger.annotations.ApiResponses; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | |
| | | private final IApiMallNewsService newsService; |
| | | |
| | | @ApiOperation(value = "新闻分类", notes = "新闻分类") |
| | | @GetMapping(value = "/findNewsInfoCategory") |
| | | public FebsResponse findNewsInfoCategory() { |
| | | return new FebsResponse().success().data(newsService.findNewsCategoryList()); |
| | | } |
| | | |
| | | @ApiOperation(value ="获取新闻列表-分页", notes = "获取新闻列表") |
| | | @ApiResponses({ |
| | | @ApiResponse(code = 200, message = "success", response = NewsListVo.class) |
| | | }) |
| | | @PostMapping(value = "/findNewsInPage") |
| | | public FebsResponse findNewsInPage(@RequestBody NewsListDto newsListDto) { |
| | | return new FebsResponse().success().data(newsService.findNewsInPage(newsListDto)); |
| | | } |
| | | |
| | | @ApiOperation(value = "新闻列表", notes = "新闻列表") |
| | | @ApiResponses({ |
| | | @ApiResponse(code = 200, message = "success", response = NewsListVo.class) |
| | | }) |
| | | @GetMapping(value = "/findNews") |
| | | public FebsResponse findNews() { |
| | | return new FebsResponse().success().data(newsService.list()); |
| | | return new FebsResponse().success().data(newsService.findTopNews()); |
| | | } |
| | | |
| | | @ApiOperation(value = "新闻详情", notes = "新闻详情") |
New file |
| | |
| | | package cc.mrbird.febs.mall.dto; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author wzy |
| | | * @date 2022-05-16 |
| | | **/ |
| | | @Data |
| | | @ApiModel(value = "NewsListDto", description = "新闻列表接口接收参数类") |
| | | public class NewsListDto { |
| | | |
| | | @ApiModelProperty("每页数量") |
| | | private int pageSize = 10; |
| | | |
| | | @ApiModelProperty("页码") |
| | | private int pageNum = 1; |
| | | |
| | | @ApiModelProperty("分类ID") |
| | | private Long categoryId; |
| | | } |
| | |
| | | private String thumb; |
| | | |
| | | private Long categoryId; |
| | | |
| | | private Integer isTop; |
| | | } |
| | |
| | | package cc.mrbird.febs.mall.mapper; |
| | | |
| | | import cc.mrbird.febs.mall.dto.NewsListDto; |
| | | import cc.mrbird.febs.mall.entity.MallNewsInfo; |
| | | import cc.mrbird.febs.mall.vo.AdminMallNewsInfoVo; |
| | | import cc.mrbird.febs.mall.vo.NewsListVo; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | public interface MallNewsInfoMapper extends BaseMapper<MallNewsInfo> { |
| | | |
| | | IPage<AdminMallNewsInfoVo> getNewInfoListInPage(Page<AdminMallNewsInfoVo> page, MallNewsInfo mallNewsInfo); |
| | | |
| | | IPage<NewsListVo> selectNewsVoInPage(Page<NewsListVo> page, @Param("record") MallNewsInfo mallNewsInfo); |
| | | |
| | | } |
| | |
| | | package cc.mrbird.febs.mall.service; |
| | | |
| | | import cc.mrbird.febs.mall.dto.NewsListDto; |
| | | import cc.mrbird.febs.mall.entity.MallNewsCategory; |
| | | import cc.mrbird.febs.mall.entity.MallNewsInfo; |
| | | import cc.mrbird.febs.mall.vo.NewsListVo; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface IApiMallNewsService extends IService<MallNewsInfo> { |
| | | |
| | | List<MallNewsCategory> findNewsCategoryList(); |
| | | |
| | | IPage<NewsListVo> findNewsInPage(NewsListDto newsListDto); |
| | | |
| | | List<NewsListVo> findTopNews(); |
| | | } |
| | |
| | | package cc.mrbird.febs.mall.service.impl; |
| | | |
| | | import cc.mrbird.febs.mall.dto.NewsListDto; |
| | | import cc.mrbird.febs.mall.entity.MallNewsCategory; |
| | | import cc.mrbird.febs.mall.entity.MallNewsInfo; |
| | | import cc.mrbird.febs.mall.mapper.MallNewsCategoryMapper; |
| | | import cc.mrbird.febs.mall.mapper.MallNewsInfoMapper; |
| | | import cc.mrbird.febs.mall.service.IApiMallNewsService; |
| | | import cc.mrbird.febs.mall.vo.NewsListVo; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author wzy |
| | |
| | | @RequiredArgsConstructor |
| | | public class ApiMallNewsServiceImpl extends ServiceImpl<MallNewsInfoMapper, MallNewsInfo> implements IApiMallNewsService { |
| | | |
| | | private final MallNewsCategoryMapper mallNewsCategoryMapper; |
| | | |
| | | @Override |
| | | public List<MallNewsCategory> findNewsCategoryList() { |
| | | return mallNewsCategoryMapper.selectList(null); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<NewsListVo> findNewsInPage(NewsListDto newsListDto) { |
| | | Page<NewsListVo> page = new Page<>(newsListDto.getPageNum(), newsListDto.getPageSize()); |
| | | |
| | | MallNewsInfo mallNewsInfo = new MallNewsInfo(); |
| | | mallNewsInfo.setCategoryId(newsListDto.getCategoryId()); |
| | | return this.baseMapper.selectNewsVoInPage(page, mallNewsInfo); |
| | | } |
| | | |
| | | @Override |
| | | public List<NewsListVo> findTopNews() { |
| | | Page<NewsListVo> page = new Page<>(1, 999); |
| | | MallNewsInfo mallNewsInfo = new MallNewsInfo(); |
| | | mallNewsInfo.setIsTop(1); |
| | | |
| | | IPage<NewsListVo> pageList = this.baseMapper.selectNewsVoInPage(page, mallNewsInfo); |
| | | return pageList.getRecords(); |
| | | } |
| | | } |
| | |
| | | private Integer type; |
| | | |
| | | private String categoryName; |
| | | |
| | | private Integer isTop; |
| | | } |
New file |
| | |
| | | package cc.mrbird.febs.mall.vo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author wzy |
| | | * @date 2022-05-16 |
| | | **/ |
| | | @Data |
| | | @ApiModel(value = "NewsListVo") |
| | | public class NewsListVo { |
| | | |
| | | private Long id; |
| | | |
| | | private Long title; |
| | | |
| | | private String thumb; |
| | | |
| | | private Date createdTime; |
| | | } |
| | |
| | | order by a.CREATED_TIME desc |
| | | </select> |
| | | |
| | | <select id="selectNewsVoInPage" resultType="cc.mrbird.febs.mall.vo.NewsListVo"> |
| | | select * from mall_news_info |
| | | <where> |
| | | 1=1 |
| | | <if test="record.categoryId != null"> |
| | | and category_id=#{record.categoryId} |
| | | </if> |
| | | <if test="record.isTop != null"> |
| | | and is_top=#{record.isTop} |
| | | </if> |
| | | </where> |
| | | order by CREATED_TIME desc |
| | | </select> |
| | | </mapper> |
| | |
| | | .layui-table-cell { |
| | | height: auto; |
| | | } |
| | | .layui-form-onswitch { |
| | | background-color: #5FB878 !important; |
| | | } |
| | | </style> |
| | | <script type="text/html" id="isTopSwitch"> |
| | | {{# if(d.isTop === 1) { }} |
| | | <input type="checkbox" value={{d.id}} lay-text="是|否" checked lay-skin="switch" lay-filter="isTopSwitch"> |
| | | {{# } else { }} |
| | | <input type="checkbox" value={{d.id}} lay-text="是|否" lay-skin="switch" lay-filter="isTopSwitch"> |
| | | {{# } }} |
| | | </script> |
| | | <!-- 表格操作栏 start --> |
| | | <script type="text/html" id="user-option"> |
| | | <span shiro:lacksPermission="user:view,user:update,user:delete"> |
| | |
| | | templet: function (d) { |
| | | return '<a lay-event="seeImgThumb"><img id="seeImgThumb'+d.id+'" src="'+d.thumb+'" alt=""></a>'; |
| | | }, minWidth: 150,align:'center'}, |
| | | {templet: '#isTopSwitch', title: '是否首页显示', minWidth: 120,align:'center'}, |
| | | {field: 'createdTime', title: '创建时间', minWidth: 120,align:'center'}, |
| | | {title: '操作', |
| | | templet: function (d) { |
| | |
| | | }; |
| | | } |
| | | |
| | | form.on('switch(isTopSwitch)', function (data) { |
| | | console.log(data.value); |
| | | if (data.elem.checked) { |
| | | febs.post(ctx + 'admin/news/topNews/' + data.value, null, function () { |
| | | febs.alert.success('设置成功'); |
| | | $query.click(); |
| | | }); |
| | | } else { |
| | | febs.post(ctx + 'admin/news/unTopNews/' + data.value, null, function () { |
| | | febs.alert.success('设置成功'); |
| | | $query.click(); |
| | | }); |
| | | } |
| | | }) |
| | | }) |
| | | </script> |
| | |
| | | var form = layui.form; |
| | | form.render(); |
| | | }); |
| | | |
| | | initUserValue(); |
| | | }); |
| | | |
| | | form.render(); |
| | |
| | | elem: '#febs-form-group-date' |
| | | }); |
| | | |
| | | |
| | | layedit.set({ //设置图片接口 |
| | | uploadImage: { |
| | | url: 'admin/goods/uploadFileBase64', //接口url |
| | | type: 'post', |
| | | } |
| | | }); |
| | | |
| | | //创建一个编辑器 |
| | | var index = layedit.build('lay_edit',{ |
| | | height: 300 |
| | |
| | | }); |
| | | } |
| | | |
| | | |
| | | initUserValue(); |
| | | function initUserValue() { |
| | | console.log(newsInfo); |
| | | var thumb = newsInfo.thumb; |
| | | $('#thumbImage').html('<img src="' + thumb + '" alt="" class="layui-upload-img" style="width: 100px">') |
| | | form.val("newsInfo-update-form", { |
| | |
| | | "thumb": newsInfo.thumb, |
| | | "content": newsInfo.content, |
| | | }); |
| | | |
| | | layedit.setContent(index, newsInfo.content, false); |
| | | } |
| | | }); |
| | | </script> |