
15 changed files with 314 additions and 31 deletions
@ -0,0 +1,23 @@ |
|||
|
|||
|
|||
DROP TABLE IF EXISTS `applet_banner`; |
|||
CREATE TABLE `applet_banner` ( |
|||
`id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT 'ID,唯一编号', |
|||
`sid` VARCHAR(64) NOT NULL COMMENT 'sid', |
|||
`createTime` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP COMMENT '记录创建时间', |
|||
`remarks` VARCHAR(255) NULL DEFAULT NULL COMMENT '备注信息', |
|||
`isEnable` INT(11) NULL DEFAULT '1' COMMENT '是否可用 1显示 2 不显示', |
|||
|
|||
`bannerUrl` VARCHAR(1024) NULL DEFAULT NULL COMMENT '轮播图完整URL', |
|||
`bannerPath` VARCHAR(1024) NULL DEFAULT NULL COMMENT '轮播图相对地址', |
|||
`title` VARCHAR(255) NULL DEFAULT NULL COMMENT '标题', |
|||
`content` TEXT NULL DEFAULT NULL COMMENT '内容', |
|||
`startDate` DATETIME NULL DEFAULT NULL COMMENT '开始时间', |
|||
`endDate` DATETIME NULL DEFAULT NULL COMMENT '结束时间', |
|||
`sort` int DEFAULT 1, |
|||
`releaseTime` DATETIME NULL DEFAULT NULL COMMENT '发布时间', |
|||
`publisher` VARCHAR(255) NULL DEFAULT NULL COMMENT '发布人', |
|||
`isShow` VARCHAR(255) NULL DEFAULT '1' COMMENT '是否显示 1 显示 2不显示', |
|||
PRIMARY KEY (`id`) USING BTREE |
|||
) COMMENT='小程序轮播图' ENGINE=InnoDB; |
|||
|
@ -0,0 +1,2 @@ |
|||
|
|||
alter table lpk_customer convert to character set utf8 collate utf8_general_ci |
@ -0,0 +1,52 @@ |
|||
package com.yxt.yythmall.adminapi; |
|||
|
|||
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.yxt.common.core.query.PagerQuery; |
|||
import com.yxt.common.core.result.ResultBean; |
|||
import com.yxt.yythmall.biz.appletbanner.AppletBanner; |
|||
import com.yxt.yythmall.biz.appletbanner.AppletBannerQuery; |
|||
import com.yxt.yythmall.biz.appletbanner.AppletBannerService; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
@RestController("com.yxt.yythmall.adminapi.BannerRest") |
|||
@RequestMapping("/adminapi/banner") |
|||
public class BannerRest { |
|||
@Autowired |
|||
private AppletBannerService appletBannerService; |
|||
|
|||
|
|||
@ApiOperation("分页列表") |
|||
@PostMapping("/pageList") |
|||
public ResultBean<IPage<AppletBanner>> pageList(@RequestBody PagerQuery<AppletBannerQuery> pq) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
IPage<AppletBanner> page = appletBannerService.pageList(pq); |
|||
return rb.success().setData(page); |
|||
} |
|||
|
|||
@ApiOperation("修改或保存") |
|||
@PostMapping("/saveOrUpdate") |
|||
public ResultBean saveOrUpdate(@RequestBody AppletBanner dto) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
appletBannerService.saveOrUpdate(dto); |
|||
return rb.success(); |
|||
} |
|||
|
|||
@ApiOperation("初始化") |
|||
@GetMapping("/noticeInit/{sid}") |
|||
public ResultBean<AppletBanner> noticeInit(@PathVariable("sid") String sid) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
AppletBanner ab = appletBannerService.fetchBySid(sid); |
|||
return rb.success().setData(ab); |
|||
} |
|||
|
|||
@ApiOperation("是否显示") |
|||
@GetMapping("/isDisplayed/{sid}/{state}") |
|||
public ResultBean isDisplayed(@PathVariable("sid") String sid, @PathVariable("state") String state) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
appletBannerService.updateShowState(sid, state); |
|||
return rb.success().setMsg("更改成功!"); |
|||
} |
|||
} |
@ -0,0 +1,41 @@ |
|||
package com.yxt.yythmall.biz.appletbanner; |
|||
|
|||
import cn.hutool.core.util.IdUtil; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import com.yxt.common.core.domain.EntityWithId; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
import java.util.UUID; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/12/8 9:10 |
|||
*/ |
|||
@Data |
|||
@TableName("applet_banner") |
|||
public class AppletBanner extends EntityWithId { |
|||
|
|||
private String sid = IdUtil.fastSimpleUUID(); |
|||
|
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
|||
private Date createTime = new Date(); |
|||
private String remarks; |
|||
private String isEnable; |
|||
private String title; |
|||
private String content; |
|||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
|||
private Date startDate; |
|||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
|||
private Date endDate; |
|||
private int sort = 1; |
|||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
|||
private Date releaseTime;//发布时间
|
|||
private String publisher;//发布人
|
|||
private String isShow = "1"; |
|||
|
|||
|
|||
private String bannerUrl;//轮播图完整URL
|
|||
private String bannerPath;//轮播图相对地址
|
|||
} |
@ -0,0 +1,8 @@ |
|||
package com.yxt.yythmall.biz.appletbanner; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
@Mapper |
|||
public interface AppletBannerMapper extends BaseMapper<AppletBanner> { |
|||
} |
@ -0,0 +1,16 @@ |
|||
package com.yxt.yythmall.biz.appletbanner; |
|||
|
|||
import com.yxt.common.core.query.Query; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/12/8 9:11 |
|||
*/ |
|||
@Data |
|||
public class AppletBannerQuery implements Query { |
|||
private String startDate; //开始时间
|
|||
private String endDate; //结束时间
|
|||
private String countNumber; //总数
|
|||
private String name; |
|||
} |
@ -0,0 +1,60 @@ |
|||
package com.yxt.yythmall.biz.appletbanner; |
|||
|
|||
import cn.hutool.core.bean.BeanUtil; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|||
import com.yxt.common.base.utils.PagerUtil; |
|||
import com.yxt.common.base.utils.StringUtils; |
|||
import com.yxt.common.core.query.PagerQuery; |
|||
import com.yxt.yythmall.wxapi.vo.WxBannerListVo; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
@Service |
|||
public class AppletBannerService extends ServiceImpl<AppletBannerMapper, AppletBanner> { |
|||
|
|||
public IPage<AppletBanner> pageList(PagerQuery<AppletBannerQuery> pq) { |
|||
AppletBannerQuery query = pq.getParams(); |
|||
IPage<AppletBanner> page = PagerUtil.queryToPage(pq); |
|||
|
|||
QueryWrapper<AppletBanner> qw = new QueryWrapper<>(); |
|||
if (StringUtils.isNotBlank(query.getName())) { |
|||
qw.like("title", query.getName()); |
|||
} |
|||
IPage<AppletBanner> iPage = baseMapper.selectPage(page, qw); |
|||
return iPage; |
|||
} |
|||
|
|||
public AppletBanner fetchBySid(String sid) { |
|||
QueryWrapper<AppletBanner> qw = new QueryWrapper<>(); |
|||
qw.eq("sid", sid); |
|||
List<AppletBanner> list = baseMapper.selectList(qw); |
|||
if (list == null || list.isEmpty()) |
|||
return null; |
|||
return list.get(0); |
|||
} |
|||
|
|||
public void updateShowState(String sid, String state) { |
|||
UpdateWrapper<AppletBanner> uw = new UpdateWrapper<>(); |
|||
uw.set("isShow", state); |
|||
uw.eq("sid", sid); |
|||
baseMapper.update(null, uw); |
|||
} |
|||
|
|||
public List<WxBannerListVo> listWxVo() { |
|||
QueryWrapper<AppletBanner> qw = new QueryWrapper<>(); |
|||
qw.eq("isShow", 1); |
|||
List<AppletBanner> list = baseMapper.selectList(qw); |
|||
List<WxBannerListVo> voList = new ArrayList<>(); |
|||
list.forEach(entity -> { |
|||
WxBannerListVo vo = new WxBannerListVo(); |
|||
BeanUtil.copyProperties(entity, vo); |
|||
voList.add(vo); |
|||
}); |
|||
return voList; |
|||
} |
|||
} |
@ -0,0 +1,36 @@ |
|||
package com.yxt.yythmall.wxapi; |
|||
|
|||
import com.yxt.common.core.result.ResultBean; |
|||
import com.yxt.yythmall.biz.appletbanner.AppletBanner; |
|||
import com.yxt.yythmall.biz.appletbanner.AppletBannerService; |
|||
import com.yxt.yythmall.wxapi.vo.WxBannerListVo; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
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 java.util.List; |
|||
|
|||
@RestController("om.yxt.yythmall.wxapi.WxBannerRest") |
|||
@RequestMapping("/wxapi/banner") |
|||
public class WxBannerRest { |
|||
|
|||
@Autowired |
|||
private AppletBannerService appletBannerService; |
|||
|
|||
@GetMapping("/list") |
|||
public ResultBean<List<WxBannerListVo>> list() { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
List<WxBannerListVo> list = appletBannerService.listWxVo(); |
|||
return rb.success().setData(list); |
|||
} |
|||
|
|||
@GetMapping("/banner/{sid}") |
|||
public ResultBean<AppletBanner> fetchBySid(@PathVariable("sid") String sid) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
AppletBanner entity = appletBannerService.fetchBySid(sid); |
|||
return rb.success().setData(entity); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,13 @@ |
|||
package com.yxt.yythmall.wxapi.vo; |
|||
|
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class WxBannerListVo { |
|||
|
|||
private String sid; |
|||
private String title; |
|||
|
|||
private String bannerUrl;//轮播图完整URL
|
|||
private String bannerPath;//轮播图相对地址
|
|||
} |
Loading…
Reference in new issue