歌曲管理
This commit is contained in:
parent
fadfe98303
commit
3cdb4edea3
|
|
@ -0,0 +1,66 @@
|
|||
package cn.ysk.cashier.controller.shop;
|
||||
|
||||
import cn.ysk.cashier.annotation.Log;
|
||||
import cn.ysk.cashier.dto.shop.TbShopSongQueryCriteria;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopSong;
|
||||
import cn.ysk.cashier.mybatis.service.TbShopSongService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "歌曲管理")
|
||||
@RequestMapping("/api/tbShopSong")
|
||||
public class TbShopSongController {
|
||||
private final TbShopSongService tbShopSongService;
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation("查询歌曲列表")
|
||||
public ResponseEntity<Object> queryTbShopPurveyor(TbShopSongQueryCriteria criteria){
|
||||
return new ResponseEntity<>(tbShopSongService.queryAll(criteria), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增歌曲:#resources.name")
|
||||
@ApiOperation("新增歌曲")
|
||||
public ResponseEntity<Object> createTbShopPurveyor(@Validated @RequestBody TbShopSong resources){
|
||||
if (StringUtils.isBlank(resources.getName())) {
|
||||
throw new BadRequestException("请填写歌曲名称");
|
||||
}
|
||||
if (StringUtils.isBlank(resources.getSinger())) {
|
||||
throw new BadRequestException("请填写演出歌手名称");
|
||||
}
|
||||
// resources.setSalesNumber(0);
|
||||
resources.setStatus(1);
|
||||
resources.setCreateTime(new Date());
|
||||
return new ResponseEntity<>(tbShopSongService.save(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改歌曲:#resources.name")
|
||||
@ApiOperation("修改歌曲")
|
||||
public ResponseEntity<Object> updateTbShopPurveyor(@Validated @RequestBody TbShopSong resources){
|
||||
resources.setUpdateTime(new Date());
|
||||
tbShopSongService.updateById(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Log("删除歌曲:#ids")
|
||||
@ApiOperation("删除歌曲")
|
||||
public ResponseEntity<Object> deleteTbShopPurveyor(@RequestBody List<Long> ids) {
|
||||
tbShopSongService.removeByIds(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package cn.ysk.cashier.dto.shop;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TbShopSongQueryCriteria {
|
||||
|
||||
private String shopId;
|
||||
private String name;
|
||||
/**
|
||||
* 从1开始
|
||||
*/
|
||||
private Long page = 1L;
|
||||
/**
|
||||
* 展示数量
|
||||
*/
|
||||
private Long size = 10L;
|
||||
}
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
package cn.ysk.cashier.mybatis.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
|
||||
/**
|
||||
* (TbShopSong)表实体类
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-07-06 14:49:47
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class TbShopSong extends Model<TbShopSong> {
|
||||
|
||||
private Integer id;
|
||||
//店铺id
|
||||
private Integer shopId;
|
||||
//歌曲名称
|
||||
private String name;
|
||||
//歌曲图片
|
||||
private String img;
|
||||
//原唱歌手
|
||||
private String originSinger;
|
||||
//演出歌手id
|
||||
private Integer singerId;
|
||||
//演出歌手名称
|
||||
private String singer;
|
||||
//单价
|
||||
private Double price;
|
||||
//点播次数
|
||||
private Integer salesNumber;
|
||||
//歌曲状态:1-开启;0-关闭
|
||||
private Integer status;
|
||||
private Integer sort;
|
||||
//创建时间
|
||||
private Date createTime;
|
||||
//更新时间
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getShopId() {
|
||||
return shopId;
|
||||
}
|
||||
|
||||
public void setShopId(Integer shopId) {
|
||||
this.shopId = shopId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getImg() {
|
||||
return img;
|
||||
}
|
||||
|
||||
public void setImg(String img) {
|
||||
this.img = img;
|
||||
}
|
||||
|
||||
public String getOriginSinger() {
|
||||
return originSinger;
|
||||
}
|
||||
|
||||
public void setOriginSinger(String originSinger) {
|
||||
this.originSinger = originSinger;
|
||||
}
|
||||
|
||||
public Integer getSingerId() {
|
||||
return singerId;
|
||||
}
|
||||
|
||||
public void setSingerId(Integer singerId) {
|
||||
this.singerId = singerId;
|
||||
}
|
||||
|
||||
public String getSinger() {
|
||||
return singer;
|
||||
}
|
||||
|
||||
public void setSinger(String singer) {
|
||||
this.singer = singer;
|
||||
}
|
||||
|
||||
public Double getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(Double price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public Integer getSalesNumber() {
|
||||
return salesNumber;
|
||||
}
|
||||
|
||||
public void setSalesNumber(Integer salesNumber) {
|
||||
this.salesNumber = salesNumber;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public Integer getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public void setSort(Integer sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopSong;
|
||||
|
||||
/**
|
||||
* (TbShopSong)表数据库访问层
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-07-06 14:49:47
|
||||
*/
|
||||
public interface TbShopSongMapper extends BaseMapper<TbShopSong> {
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import cn.ysk.cashier.dto.shop.TbShopSongQueryCriteria;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopSong;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* (TbShopSong)表服务接口
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-07-06 14:49:47
|
||||
*/
|
||||
public interface TbShopSongService extends IService<TbShopSong> {
|
||||
|
||||
Map<String,Object> queryAll(TbShopSongQueryCriteria criteria);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
package cn.ysk.cashier.mybatis.service.impl;
|
||||
|
||||
import cn.ysk.cashier.dto.shop.TbShopSongQueryCriteria;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopSong;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbShopSongMapper;
|
||||
import cn.ysk.cashier.mybatis.service.TbShopSongService;
|
||||
import cn.ysk.cashier.utils.PageUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* (TbShopSong)表服务实现类
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-07-06 14:49:47
|
||||
*/
|
||||
@Service("tbShopSongService")
|
||||
public class TbShopSongServiceImpl extends ServiceImpl<TbShopSongMapper, TbShopSong> implements TbShopSongService {
|
||||
@Autowired
|
||||
private TbShopSongMapper songMapper;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(TbShopSongQueryCriteria criteria) {
|
||||
Page<TbShopSong> page = new Page<>(criteria.getPage(),criteria.getSize());
|
||||
QueryWrapper<TbShopSong> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("shop_id", criteria.getShopId());
|
||||
if (StringUtils.isNotBlank(criteria.getName())) {
|
||||
wrapper.and(w -> w.like("name", criteria.getName())
|
||||
.or()
|
||||
.like("singer", criteria.getName())
|
||||
.or()
|
||||
.like("origin_singer", criteria.getName()));
|
||||
}
|
||||
wrapper.orderByAsc("sort");
|
||||
wrapper.orderByDesc("create_time");
|
||||
Page<TbShopSong> tbShopSongPage = songMapper.selectPage(page, wrapper);
|
||||
return PageUtil.toPage(tbShopSongPage.getRecords(), tbShopSongPage.getTotal());
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue