feat(后台管理): 添加banner管理

master
wayn 4 years ago
parent bd66f6ef0c
commit c994fc8e7a

@ -1,15 +1,20 @@
package com.wayn.admin.api.controller.shop;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wayn.admin.api.domain.shop.ShopBanner;
import com.wayn.admin.api.service.shop.IBannerService;
import com.wayn.admin.framework.util.SecurityUtils;
import com.wayn.common.base.BaseController;
import com.wayn.common.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
@RestController
@RequestMapping("shop/banner")
public class BannerController {
public class BannerController extends BaseController {
@Autowired
private IBannerService iBannerService;
@ -17,11 +22,14 @@ public class BannerController {
@GetMapping("/list")
public R list(ShopBanner banner) {
return R.success().add("channelList", iBannerService.list(banner));
Page<ShopBanner> page = getPage();
return R.success().add("page", iBannerService.listPage(page, banner));
}
@PostMapping
public R addChannel(@Validated @RequestBody ShopBanner banner) {
banner.setCreateBy(SecurityUtils.getUsername());
banner.setCreateTime(new Date());
return R.result(iBannerService.save(banner));
}

@ -21,14 +21,15 @@ public class ShopBanner extends BaseEntity implements Serializable {
@NotBlank(message = "标题不能为空")
private String title;
@NotBlank(message = "banner图片不能为空")
private String imgUrl;
private String page;
private String jumpUrl;
private Integer sort;
private Integer status;
/**
* 0 2
*/

@ -1,12 +1,15 @@
package com.wayn.admin.api.mapper.shop;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wayn.admin.api.domain.shop.ShopBanner;
import com.wayn.admin.api.domain.shop.ShopChannel;
import java.util.List;
public interface BannerMapper extends BaseMapper<ShopBanner> {
List<ShopBanner> selectBannerList(ShopBanner banner);
IPage<ShopBanner> selectBannerListPage(Page<ShopBanner> page, ShopBanner banner);
}

@ -1,12 +1,14 @@
package com.wayn.admin.api.service.shop;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.wayn.admin.api.domain.shop.ShopBanner;
import com.wayn.admin.api.domain.shop.ShopChannel;
import java.util.List;
public interface IBannerService extends IService<ShopBanner> {
/**
* banner
*
@ -14,4 +16,13 @@ public interface IBannerService extends IService<ShopBanner> {
* @return banner
*/
List<ShopBanner> list(ShopBanner banner);
/**
* banner
*
* @param page
* @param banner
* @return banner
*/
IPage<ShopBanner> listPage(Page<ShopBanner> page, ShopBanner banner);
}

@ -1,12 +1,12 @@
package com.wayn.admin.api.service.shop.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wayn.admin.api.domain.shop.ShopBanner;
import com.wayn.admin.api.mapper.shop.BannerMapper;
import com.wayn.admin.api.service.shop.IBannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.Banner;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.stereotype.Service;
import java.util.List;
@ -21,4 +21,9 @@ public class BannerServiceImpl extends ServiceImpl<BannerMapper, ShopBanner> imp
public List<ShopBanner> list(ShopBanner banner) {
return bannerMapper.selectBannerList(banner);
}
@Override
public IPage<ShopBanner> listPage(Page<ShopBanner> page, ShopBanner banner) {
return bannerMapper.selectBannerListPage(page, banner);
}
}

@ -7,10 +7,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="com.wayn.admin.api.domain.shop.ShopBanner" id="ShopBannerResult">
<result property="id" column="id" />
<result property="title" column="title" />
<result property="page" column="page" />
<result property="jumpUrl" column="jump_url" />
<result property="imgUrl" column="img_url" />
<result property="sort" column="sort" />
<result property="status" column="status" />
<result property="delFlag" column="del_flag" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
@ -20,7 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectBannerVo">
select b.id, b.title, b.page, b.jump_url, b.img_url, b.sort,
select b.id, b.title,b.jump_url, b.img_url, b.sort, b.status,
b.del_flag, b.create_time, b.update_by, b.update_time, b.remark
from shop_banner b
</sql>
@ -33,5 +33,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
</where>
</select>
<select id="selectBannerListPage" resultMap="ShopBannerResult">
<include refid="selectBannerVo"/>
<where>
<if test="banner.title != null and banner.title != ''">
AND title like concat('%', #{banner.title}, '%')
</if>
<if test="banner.status != null">
AND status = #{banner.status}
</if>
<if test="banner.startTime != null and banner.startTime != ''">
and DATE_FORMAT(create_time,'%Y-%m-%d') <![CDATA[ >= ]]> DATE_FORMAT(#{banner.startTime},'%Y-%m-%d')
</if>
<if test="banner.endTime != null and banner.endTime != ''">
and DATE_FORMAT(create_time,'%Y-%m-%d') <![CDATA[ <= ]]> DATE_FORMAT(#{banner.endTime},'%Y-%m-%d')
</if>
</where>
</select>
</mapper>
Loading…
Cancel
Save