歌曲管理
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user