主播信息管理功能实现
This commit is contained in:
@@ -44,6 +44,11 @@
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-spring-boot-starter-biz-tenant</artifactId>
|
||||
</dependency>
|
||||
<!-- excel依赖 -->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-spring-boot-starter-excel</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
package cn.iocoder.yudao.module.tkdata.controller.admin;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - Test")
|
||||
@RestController
|
||||
@RequestMapping("/demo/test")
|
||||
@Validated
|
||||
public class DemoTestController {
|
||||
|
||||
// 这个构造方法,只是方便大家,验证 Controller 有生效
|
||||
public DemoTestController() {
|
||||
System.out.println(getClass() + "生效啦!!!");
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获取 test 信息")
|
||||
public CommonResult<String> get() {
|
||||
return success("true");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package cn.iocoder.yudao.module.tkdata.controller.admin.newhosts;
|
||||
|
||||
import cn.iocoder.yudao.module.tkdata.controller.admin.newhosts.vo.NewHostsPageReqVO;
|
||||
import cn.iocoder.yudao.module.tkdata.controller.admin.newhosts.vo.NewHostsRespVO;
|
||||
import cn.iocoder.yudao.module.tkdata.controller.admin.newhosts.vo.NewHostsSaveReqVO;
|
||||
import cn.iocoder.yudao.module.tkdata.dal.dataobject.newhosts.NewHostsDO;
|
||||
import cn.iocoder.yudao.module.tkdata.service.newhosts.NewHostsService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
|
||||
|
||||
@Tag(name = "管理后台 - 主播数据")
|
||||
@RestController
|
||||
@RequestMapping("/server/new-hosts")
|
||||
@Validated
|
||||
public class NewHostsController {
|
||||
|
||||
@Resource
|
||||
private NewHostsService newHostsService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建主播数据")
|
||||
@PreAuthorize("@ss.hasPermission('server:new-hosts:create')")
|
||||
public CommonResult<Long> createNewHosts(@Valid @RequestBody NewHostsSaveReqVO createReqVO) {
|
||||
return success(newHostsService.createNewHosts(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新主播数据")
|
||||
@PreAuthorize("@ss.hasPermission('server:new-hosts:update')")
|
||||
public CommonResult<Boolean> updateNewHosts(@Valid @RequestBody NewHostsSaveReqVO updateReqVO) {
|
||||
newHostsService.updateNewHosts(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除主播数据")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('server:new-hosts:delete')")
|
||||
public CommonResult<Boolean> deleteNewHosts(@RequestParam("id") Long id) {
|
||||
newHostsService.deleteNewHosts(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-list")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除主播数据")
|
||||
@PreAuthorize("@ss.hasPermission('server:new-hosts:delete')")
|
||||
public CommonResult<Boolean> deleteNewHostsList(@RequestParam("ids") List<Long> ids) {
|
||||
newHostsService.deleteNewHostsListByIds(ids);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得主播数据")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "80")
|
||||
@PreAuthorize("@ss.hasPermission('server:new-hosts:query')")
|
||||
public CommonResult<NewHostsRespVO> getNewHosts(@RequestParam("id") Long id) {
|
||||
NewHostsDO newHosts = newHostsService.getNewHosts(id);
|
||||
return success(BeanUtils.toBean(newHosts, NewHostsRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得主播数据分页")
|
||||
@PreAuthorize("@ss.hasPermission('server:new-hosts:query')")
|
||||
public CommonResult<PageResult<NewHostsRespVO>> getNewHostsPage(@Valid NewHostsPageReqVO pageReqVO) {
|
||||
PageResult<NewHostsDO> pageResult = newHostsService.getNewHostsPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, NewHostsRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出主播数据 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('server:new-hosts:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportNewHostsExcel(@Valid NewHostsPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<NewHostsDO> list = newHostsService.getNewHostsPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "主播数据.xls", "数据", NewHostsRespVO.class,
|
||||
BeanUtils.toBean(list, NewHostsRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package cn.iocoder.yudao.module.tkdata.controller.admin.newhosts.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 主播数据分页 Request VO")
|
||||
@Data
|
||||
public class NewHostsPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "主播id", example = "306")
|
||||
private String hostsId;
|
||||
|
||||
@Schema(description = "主播等级")
|
||||
private String hostsLevel;
|
||||
|
||||
@Schema(description = "主播金币")
|
||||
private Integer hostsCoins;
|
||||
|
||||
@Schema(description = "邀请类型", example = "1")
|
||||
private Integer invitationType;
|
||||
|
||||
@Schema(description = "在线人数")
|
||||
private Integer onlineFans;
|
||||
|
||||
@Schema(description = "粉丝数量")
|
||||
private Integer fans;
|
||||
|
||||
@Schema(description = "关注数量")
|
||||
private Integer fllowernum;
|
||||
|
||||
@Schema(description = "昨日金币")
|
||||
private Integer yesterdayCoins;
|
||||
|
||||
@Schema(description = "主播国家")
|
||||
private String country;
|
||||
|
||||
@Schema(description = "直播类型 娱乐,游戏 ")
|
||||
private String hostsKind;
|
||||
|
||||
@Schema(description = "是否已经分配给员工")
|
||||
private Integer isAssigned;
|
||||
|
||||
@Schema(description = "数据插入时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "用户 Id", example = "10967")
|
||||
private Long userId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package cn.iocoder.yudao.module.tkdata.controller.admin.newhosts.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 主播数据 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class NewHostsRespVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "17212")
|
||||
@ExcelProperty("主键")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "主播id", example = "306")
|
||||
@ExcelProperty("主播id")
|
||||
private String hostsId;
|
||||
|
||||
@Schema(description = "主播等级")
|
||||
@ExcelProperty("主播等级")
|
||||
private String hostsLevel;
|
||||
|
||||
@Schema(description = "主播金币")
|
||||
@ExcelProperty("主播金币")
|
||||
private Integer hostsCoins;
|
||||
|
||||
@Schema(description = "邀请类型", example = "1")
|
||||
@ExcelProperty("邀请类型")
|
||||
private Integer invitationType;
|
||||
|
||||
@Schema(description = "在线人数")
|
||||
@ExcelProperty("在线人数")
|
||||
private Integer onlineFans;
|
||||
|
||||
@Schema(description = "粉丝数量")
|
||||
@ExcelProperty("粉丝数量")
|
||||
private Integer fans;
|
||||
|
||||
@Schema(description = "关注数量")
|
||||
@ExcelProperty("关注数量")
|
||||
private Integer fllowernum;
|
||||
|
||||
@Schema(description = "昨日金币")
|
||||
@ExcelProperty("昨日金币")
|
||||
private Integer yesterdayCoins;
|
||||
|
||||
@Schema(description = "主播国家")
|
||||
@ExcelProperty("主播国家")
|
||||
private String country;
|
||||
|
||||
@Schema(description = "直播类型 娱乐,游戏 ")
|
||||
@ExcelProperty("直播类型 娱乐,游戏 ")
|
||||
private String hostsKind;
|
||||
|
||||
@Schema(description = "是否已经分配给员工")
|
||||
@ExcelProperty("是否已经分配给员工")
|
||||
private Integer isAssigned;
|
||||
|
||||
@Schema(description = "数据插入时间")
|
||||
@ExcelProperty("数据插入时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "用户 Id", example = "10967")
|
||||
@ExcelProperty("用户 Id")
|
||||
private Long userId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package cn.iocoder.yudao.module.tkdata.controller.admin.newhosts.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 主播数据新增/修改 Request VO")
|
||||
@Data
|
||||
public class NewHostsSaveReqVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "17212")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "主播id", example = "306")
|
||||
private String hostsId;
|
||||
|
||||
@Schema(description = "主播等级")
|
||||
private String hostsLevel;
|
||||
|
||||
@Schema(description = "主播金币")
|
||||
private Integer hostsCoins;
|
||||
|
||||
@Schema(description = "邀请类型", example = "1")
|
||||
private Integer invitationType;
|
||||
|
||||
@Schema(description = "在线人数")
|
||||
private Integer onlineFans;
|
||||
|
||||
@Schema(description = "粉丝数量")
|
||||
private Integer fans;
|
||||
|
||||
@Schema(description = "关注数量")
|
||||
private Integer fllowernum;
|
||||
|
||||
@Schema(description = "昨日金币")
|
||||
private Integer yesterdayCoins;
|
||||
|
||||
@Schema(description = "主播国家")
|
||||
private String country;
|
||||
|
||||
@Schema(description = "直播类型 娱乐,游戏 ")
|
||||
private String hostsKind;
|
||||
|
||||
@Schema(description = "是否已经分配给员工")
|
||||
private Integer isAssigned;
|
||||
|
||||
@Schema(description = "用户 Id", example = "10967")
|
||||
private Long userId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package cn.iocoder.yudao.module.tkdata.dal.dataobject.newhosts;
|
||||
|
||||
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 主播数据 DO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("server_new_hosts")
|
||||
@KeySequence("server_new_hosts_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class NewHostsDO extends TenantBaseDO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 主播id
|
||||
*/
|
||||
private String hostsId;
|
||||
/**
|
||||
* 主播等级
|
||||
*/
|
||||
private String hostsLevel;
|
||||
/**
|
||||
* 主播金币
|
||||
*/
|
||||
private Integer hostsCoins;
|
||||
/**
|
||||
* 邀请类型
|
||||
*/
|
||||
private Integer invitationType;
|
||||
/**
|
||||
* 在线人数
|
||||
*/
|
||||
private Integer onlineFans;
|
||||
/**
|
||||
* 粉丝数量
|
||||
*/
|
||||
private Integer fans;
|
||||
/**
|
||||
* 关注数量
|
||||
*/
|
||||
private Integer fllowernum;
|
||||
/**
|
||||
* 昨日金币
|
||||
*/
|
||||
private Integer yesterdayCoins;
|
||||
/**
|
||||
* 主播国家
|
||||
*/
|
||||
private String country;
|
||||
/**
|
||||
* 直播类型 娱乐,游戏
|
||||
*/
|
||||
private String hostsKind;
|
||||
/**
|
||||
* 是否已经分配给员工
|
||||
*/
|
||||
private Integer isAssigned;
|
||||
/**
|
||||
* 用户 Id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package cn.iocoder.yudao.module.tkdata.dal.mysql.newhosts;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.tkdata.dal.dataobject.newhosts.NewHostsDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.tkdata.controller.admin.newhosts.vo.*;
|
||||
|
||||
/**
|
||||
* 主播数据 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface NewHostsMapper extends BaseMapperX<NewHostsDO> {
|
||||
|
||||
default PageResult<NewHostsDO> selectPage(NewHostsPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<NewHostsDO>()
|
||||
.eqIfPresent(NewHostsDO::getHostsId, reqVO.getHostsId())
|
||||
.eqIfPresent(NewHostsDO::getHostsLevel, reqVO.getHostsLevel())
|
||||
.eqIfPresent(NewHostsDO::getHostsCoins, reqVO.getHostsCoins())
|
||||
.eqIfPresent(NewHostsDO::getInvitationType, reqVO.getInvitationType())
|
||||
.eqIfPresent(NewHostsDO::getOnlineFans, reqVO.getOnlineFans())
|
||||
.eqIfPresent(NewHostsDO::getFans, reqVO.getFans())
|
||||
.eqIfPresent(NewHostsDO::getFllowernum, reqVO.getFllowernum())
|
||||
.eqIfPresent(NewHostsDO::getYesterdayCoins, reqVO.getYesterdayCoins())
|
||||
.eqIfPresent(NewHostsDO::getCountry, reqVO.getCountry())
|
||||
.eqIfPresent(NewHostsDO::getHostsKind, reqVO.getHostsKind())
|
||||
.eqIfPresent(NewHostsDO::getIsAssigned, reqVO.getIsAssigned())
|
||||
.betweenIfPresent(NewHostsDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(NewHostsDO::getUserId, reqVO.getUserId())
|
||||
.orderByDesc(NewHostsDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package cn.iocoder.yudao.module.tkdata.enums;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
|
||||
|
||||
/**
|
||||
* Infra 错误码枚举类
|
||||
*
|
||||
* infra 系统,使用 1-001-000-000 段
|
||||
*/
|
||||
public interface ErrorCodeConstants {
|
||||
|
||||
ErrorCode NEW_HOSTS_NOT_EXISTS = new ErrorCode(1_001_101_000, "主播数据不存在");
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package cn.iocoder.yudao.module.tkdata.service.newhosts;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.module.tkdata.controller.admin.newhosts.vo.NewHostsPageReqVO;
|
||||
import cn.iocoder.yudao.module.tkdata.controller.admin.newhosts.vo.NewHostsSaveReqVO;
|
||||
import cn.iocoder.yudao.module.tkdata.dal.dataobject.newhosts.NewHostsDO;
|
||||
|
||||
/**
|
||||
* 主播数据 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface NewHostsService {
|
||||
|
||||
/**
|
||||
* 创建主播数据
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createNewHosts(@Valid NewHostsSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新主播数据
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateNewHosts(@Valid NewHostsSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除主播数据
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteNewHosts(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除主播数据
|
||||
*
|
||||
* @param ids 编号
|
||||
*/
|
||||
void deleteNewHostsListByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得主播数据
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 主播数据
|
||||
*/
|
||||
NewHostsDO getNewHosts(Long id);
|
||||
|
||||
/**
|
||||
* 获得主播数据分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 主播数据分页
|
||||
*/
|
||||
PageResult<NewHostsDO> getNewHostsPage(NewHostsPageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package cn.iocoder.yudao.module.tkdata.service.newhosts;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.module.tkdata.controller.admin.newhosts.vo.NewHostsPageReqVO;
|
||||
import cn.iocoder.yudao.module.tkdata.controller.admin.newhosts.vo.NewHostsSaveReqVO;
|
||||
import cn.iocoder.yudao.module.tkdata.dal.dataobject.newhosts.NewHostsDO;
|
||||
import cn.iocoder.yudao.module.tkdata.dal.mysql.newhosts.NewHostsMapper;
|
||||
import cn.iocoder.yudao.module.tkdata.enums.ErrorCodeConstants;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.diffList;
|
||||
|
||||
|
||||
/**
|
||||
* 主播数据 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class NewHostsServiceImpl implements NewHostsService {
|
||||
|
||||
@Resource
|
||||
private NewHostsMapper newHostsMapper;
|
||||
|
||||
@Override
|
||||
public Long createNewHosts(NewHostsSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
NewHostsDO newHosts = BeanUtils.toBean(createReqVO, NewHostsDO.class);
|
||||
newHostsMapper.insert(newHosts);
|
||||
// 返回
|
||||
return newHosts.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNewHosts(NewHostsSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateNewHostsExists(updateReqVO.getId());
|
||||
// 更新
|
||||
NewHostsDO updateObj = BeanUtils.toBean(updateReqVO, NewHostsDO.class);
|
||||
newHostsMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteNewHosts(Long id) {
|
||||
// 校验存在
|
||||
validateNewHostsExists(id);
|
||||
// 删除
|
||||
newHostsMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteNewHostsListByIds(List<Long> ids) {
|
||||
// 校验存在
|
||||
validateNewHostsExists(ids);
|
||||
// 删除
|
||||
newHostsMapper.deleteByIds(ids);
|
||||
}
|
||||
|
||||
private void validateNewHostsExists(List<Long> ids) {
|
||||
List<NewHostsDO> list = newHostsMapper.selectByIds(ids);
|
||||
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
|
||||
throw exception(ErrorCodeConstants.NEW_HOSTS_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateNewHostsExists(Long id) {
|
||||
if (newHostsMapper.selectById(id) == null) {
|
||||
throw exception(ErrorCodeConstants.NEW_HOSTS_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NewHostsDO getNewHosts(Long id) {
|
||||
return newHostsMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<NewHostsDO> getNewHostsPage(NewHostsPageReqVO pageReqVO) {
|
||||
PageResult<NewHostsDO> newHostsDOPageResult = newHostsMapper.selectPage(pageReqVO);
|
||||
return newHostsDOPageResult;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.tkdata.dal.mysql.newhosts.NewHostsMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user