商户视频号 管理
This commit is contained in:
parent
26a4fd6214
commit
a70deaa375
|
|
@ -0,0 +1,63 @@
|
||||||
|
package cn.ysk.cashier.controller.shop;
|
||||||
|
|
||||||
|
import cn.ysk.cashier.annotation.Log;
|
||||||
|
import cn.ysk.cashier.dto.shop.TbShopVideoQueryCriteria;
|
||||||
|
import cn.ysk.cashier.pojo.shop.TbShopVideo;
|
||||||
|
import cn.ysk.cashier.service.shop.TbShopVideoService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ww
|
||||||
|
**/
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Api(tags = "商户视频号管理")
|
||||||
|
@RequestMapping("/api/tbShopVideo")
|
||||||
|
public class TbShopVideoController {
|
||||||
|
|
||||||
|
private final TbShopVideoService tbShopVideoService;
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
@Log("查询商户视频号")
|
||||||
|
@ApiOperation("查询商户视频号")
|
||||||
|
public ResponseEntity<Object> queryTbShopVideo(TbShopVideoQueryCriteria criteria){
|
||||||
|
return new ResponseEntity<>(tbShopVideoService.queryAllPage(criteria), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
@Log("查询商户视频号")
|
||||||
|
@ApiOperation("查询商户视频号")
|
||||||
|
public Object queryInfo(@PathVariable("id") Integer id){
|
||||||
|
return tbShopVideoService.findById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
@Log("新增商户视频号")
|
||||||
|
@ApiOperation("新增商户视频号")
|
||||||
|
public ResponseEntity<Object> createTbShopVideo(@Validated @RequestBody TbShopVideo resources){
|
||||||
|
return new ResponseEntity<>(tbShopVideoService.create(resources),HttpStatus.CREATED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping
|
||||||
|
@Log("修改商户视频号")
|
||||||
|
@ApiOperation("修改商户视频号")
|
||||||
|
public ResponseEntity<Object> updateTbShopVideo(@Validated @RequestBody TbShopVideo resources){
|
||||||
|
tbShopVideoService.update(resources);
|
||||||
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping
|
||||||
|
@Log("删除商户视频号")
|
||||||
|
@ApiOperation("删除商户视频号")
|
||||||
|
public ResponseEntity<Object> deleteTbShopVideo(@RequestBody Integer[] ids) {
|
||||||
|
tbShopVideoService.deleteAll(ids);
|
||||||
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
package cn.ysk.cashier.dto.shop;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ww
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
public class TbShopVideoDto implements Serializable {
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/** 描述信息 */
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/** 店铺id */
|
||||||
|
private Integer shopId;
|
||||||
|
|
||||||
|
/** 视频号id */
|
||||||
|
private Integer channelId;
|
||||||
|
|
||||||
|
/** 视频id */
|
||||||
|
private Integer videoId;
|
||||||
|
|
||||||
|
/** 视频地址 */
|
||||||
|
private String videoUrl;
|
||||||
|
|
||||||
|
/** 创建时间 */
|
||||||
|
private Timestamp createdTime;
|
||||||
|
|
||||||
|
/** 更新时间 */
|
||||||
|
private Timestamp updateTime;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
package cn.ysk.cashier.dto.shop;
|
||||||
|
|
||||||
|
import cn.ysk.cashier.annotation.Query;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class TbShopVideoQueryCriteria {
|
||||||
|
|
||||||
|
@Query
|
||||||
|
private Integer shopId;
|
||||||
|
|
||||||
|
private Integer pageSize = 10;
|
||||||
|
|
||||||
|
private Integer page = 0;
|
||||||
|
|
||||||
|
private String sort;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
package cn.ysk.cashier.mapper.shop;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.ysk.cashier.base.BaseMapper;
|
||||||
|
import cn.ysk.cashier.dto.shop.TbShopVideoDto;
|
||||||
|
import cn.ysk.cashier.pojo.shop.TbShopVideo;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.ReportingPolicy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ww
|
||||||
|
**/
|
||||||
|
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||||
|
public interface TbShopVideoMapper extends BaseMapper<TbShopVideoDto, TbShopVideo> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
package cn.ysk.cashier.pojo.shop;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import cn.hutool.core.bean.copier.CopyOptions;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ww
|
||||||
|
**/
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
@Table(name="tb_shop_video")
|
||||||
|
public class TbShopVideo implements Serializable {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(name = "`id`")
|
||||||
|
@ApiModelProperty(value = "id")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@Column(name = "`shop_id`")
|
||||||
|
@ApiModelProperty(value = "店铺id")
|
||||||
|
private Integer shopId;
|
||||||
|
|
||||||
|
@Column(name = "`name`")
|
||||||
|
@ApiModelProperty(value = "描述信息")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Column(name = "`channel_id`")
|
||||||
|
@ApiModelProperty(value = "视频号id")
|
||||||
|
private Integer channelId;
|
||||||
|
|
||||||
|
@Column(name = "`video_id`")
|
||||||
|
@ApiModelProperty(value = "视频id")
|
||||||
|
private Integer videoId;
|
||||||
|
|
||||||
|
@Column(name = "`video_url`")
|
||||||
|
@ApiModelProperty(value = "视频地址")
|
||||||
|
private String videoUrl;
|
||||||
|
|
||||||
|
@Column(name = "`created_time`")
|
||||||
|
@ApiModelProperty(value = "创建时间")
|
||||||
|
private Timestamp createdTime;
|
||||||
|
|
||||||
|
@Column(name = "`update_time`")
|
||||||
|
@ApiModelProperty(value = "更新时间")
|
||||||
|
private Timestamp updateTime;
|
||||||
|
|
||||||
|
public void copy(TbShopVideo source){
|
||||||
|
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
package cn.ysk.cashier.repository.shop;
|
||||||
|
|
||||||
|
import cn.ysk.cashier.pojo.shop.TbShopVideo;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
|
||||||
|
public interface TbShopVideoRepository extends JpaRepository<TbShopVideo, Integer>, JpaSpecificationExecutor<TbShopVideo> {
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,75 @@
|
||||||
|
package cn.ysk.cashier.service.impl.shopimpl;
|
||||||
|
|
||||||
|
import cn.ysk.cashier.dto.shop.TbShopVideoDto;
|
||||||
|
import cn.ysk.cashier.dto.shop.TbShopVideoQueryCriteria;
|
||||||
|
import cn.ysk.cashier.mapper.shop.TbShopVideoMapper;
|
||||||
|
import cn.ysk.cashier.pojo.shop.TbShopVideo;
|
||||||
|
import cn.ysk.cashier.repository.shop.TbShopVideoRepository;
|
||||||
|
import cn.ysk.cashier.service.shop.TbShopVideoService;
|
||||||
|
import cn.ysk.cashier.utils.PageUtil;
|
||||||
|
import cn.ysk.cashier.utils.QueryHelp;
|
||||||
|
import cn.ysk.cashier.utils.ValidationUtil;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.domain.Sort;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class TbShopVideoServiceImpl implements TbShopVideoService {
|
||||||
|
|
||||||
|
private final TbShopVideoRepository tbShopVideoRepository;
|
||||||
|
private final TbShopVideoMapper tbShopVideoMapper;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> queryAllPage(TbShopVideoQueryCriteria criteria) {
|
||||||
|
Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getPageSize(), Sort.by("createdTime"));
|
||||||
|
Page<TbShopVideo> page = tbShopVideoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
|
||||||
|
return PageUtil.toPage(page.map(tbShopVideoMapper::toDto));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TbShopVideoDto> queryAll(TbShopVideoQueryCriteria criteria) {
|
||||||
|
return tbShopVideoMapper.toDto(tbShopVideoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public TbShopVideoDto findById(Integer id) {
|
||||||
|
TbShopVideo tbShopVideo = tbShopVideoRepository.findById(id).orElseGet(TbShopVideo::new);
|
||||||
|
ValidationUtil.isNull(tbShopVideo.getId(), "TbShopVideo", "id", id);
|
||||||
|
return tbShopVideoMapper.toDto(tbShopVideo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public TbShopVideoDto create(TbShopVideo resources) {
|
||||||
|
resources.setCreatedTime(new Timestamp(System.currentTimeMillis()));
|
||||||
|
return tbShopVideoMapper.toDto(tbShopVideoRepository.save(resources));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void update(TbShopVideo resources) {
|
||||||
|
TbShopVideo tbShopVideo = tbShopVideoRepository.findById(resources.getId()).orElseGet(TbShopVideo::new);
|
||||||
|
ValidationUtil.isNull(tbShopVideo.getId(), "TbShopVideo", "id", resources.getId());
|
||||||
|
tbShopVideo.copy(resources);
|
||||||
|
tbShopVideo.setUpdateTime(new Timestamp(System.currentTimeMillis()));
|
||||||
|
tbShopVideoRepository.save(tbShopVideo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteAll(Integer[] ids) {
|
||||||
|
for (Integer id : ids) {
|
||||||
|
tbShopVideoRepository.deleteById(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
package cn.ysk.cashier.service.shop;
|
||||||
|
|
||||||
|
import cn.ysk.cashier.dto.shop.TbShopVideoDto;
|
||||||
|
import cn.ysk.cashier.dto.shop.TbShopVideoQueryCriteria;
|
||||||
|
import cn.ysk.cashier.pojo.shop.TbShopVideo;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
public interface TbShopVideoService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询数据分页
|
||||||
|
* @param criteria 条件
|
||||||
|
* @return Map<String,Object>
|
||||||
|
*/
|
||||||
|
Map<String, Object> queryAllPage(TbShopVideoQueryCriteria criteria);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有数据不分页
|
||||||
|
* @param criteria 条件参数
|
||||||
|
* @return List<TbShopVideoDto>
|
||||||
|
*/
|
||||||
|
List<TbShopVideoDto> queryAll(TbShopVideoQueryCriteria criteria);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据ID查询
|
||||||
|
* @param id ID
|
||||||
|
* @return TbShopVideoDto
|
||||||
|
*/
|
||||||
|
TbShopVideoDto findById(Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建
|
||||||
|
* @param resources /
|
||||||
|
* @return TbShopVideoDto
|
||||||
|
*/
|
||||||
|
TbShopVideoDto create(TbShopVideo resources);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑
|
||||||
|
* @param resources /
|
||||||
|
*/
|
||||||
|
void update(TbShopVideo resources);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多选删除
|
||||||
|
* @param ids /
|
||||||
|
*/
|
||||||
|
void deleteAll(Integer[] ids);
|
||||||
|
}
|
||||||
|
|
@ -45,6 +45,10 @@ public class Dict extends BaseEntity implements Serializable {
|
||||||
@OneToMany(mappedBy = "dict",cascade={CascadeType.PERSIST,CascadeType.REMOVE})
|
@OneToMany(mappedBy = "dict",cascade={CascadeType.PERSIST,CascadeType.REMOVE})
|
||||||
private List<DictDetail> dictDetails;
|
private List<DictDetail> dictDetails;
|
||||||
|
|
||||||
|
@Column(name = "dict_name")
|
||||||
|
@ApiModelProperty(value = "字典标识")
|
||||||
|
private String dictName;
|
||||||
|
|
||||||
@NotBlank
|
@NotBlank
|
||||||
@ApiModelProperty(value = "名称")
|
@ApiModelProperty(value = "名称")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,8 @@ public class DictDto extends BaseDTO implements Serializable {
|
||||||
|
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
private String dictName;
|
||||||
|
|
||||||
private List<DictDetailDto> dictDetails;
|
private List<DictDetailDto> dictDetails;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue