分配主播功能实现
This commit is contained in:
@@ -49,6 +49,11 @@
|
|||||||
<groupId>cn.iocoder.boot</groupId>
|
<groupId>cn.iocoder.boot</groupId>
|
||||||
<artifactId>yudao-spring-boot-starter-excel</artifactId>
|
<artifactId>yudao-spring-boot-starter-excel</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.iocoder.boot</groupId>
|
||||||
|
<artifactId>yudao-module-infra</artifactId>
|
||||||
|
<version>2.6.0-jdk8-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
|||||||
@@ -0,0 +1,112 @@
|
|||||||
|
package cn.iocoder.yudao.module.tkdata.controller.admin.employeehosts;
|
||||||
|
|
||||||
|
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.*;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.tkdata.controller.admin.employeehosts.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.tkdata.dal.dataobject.employeehosts.EmployeeHostsDO;
|
||||||
|
import cn.iocoder.yudao.module.tkdata.service.employeehosts.EmployeeHostsService;
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - 员工分配主播表")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/server/employee-hosts")
|
||||||
|
@Validated
|
||||||
|
public class EmployeeHostsController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private EmployeeHostsService employeeHostsService;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@Operation(summary = "创建员工分配主播")
|
||||||
|
@PreAuthorize("@ss.hasPermission('server:employee-hosts:create')")
|
||||||
|
public CommonResult<Long> createEmployeeHosts(@Valid @RequestBody EmployeeHostsSaveReqVO createReqVO) {
|
||||||
|
return success(employeeHostsService.createEmployeeHosts(createReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新员工分配主播")
|
||||||
|
@PreAuthorize("@ss.hasPermission('server:employee-hosts:update')")
|
||||||
|
public CommonResult<Boolean> updateEmployeeHosts(@Valid @RequestBody EmployeeHostsSaveReqVO updateReqVO) {
|
||||||
|
employeeHostsService.updateEmployeeHosts(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
@Operation(summary = "删除员工分配主播")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('server:employee-hosts:delete')")
|
||||||
|
public CommonResult<Boolean> deleteEmployeeHosts(@RequestParam("id") Long id) {
|
||||||
|
employeeHostsService.deleteEmployeeHosts(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete-list")
|
||||||
|
@Parameter(name = "ids", description = "编号", required = true)
|
||||||
|
@Operation(summary = "批量删除员工分配主播")
|
||||||
|
@PreAuthorize("@ss.hasPermission('server:employee-hosts:delete')")
|
||||||
|
public CommonResult<Boolean> deleteEmployeeHostsList(@RequestParam("ids") List<Long> ids) {
|
||||||
|
employeeHostsService.deleteEmployeeHostsListByIds(ids);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得员工分配主播")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('server:employee-hosts:query')")
|
||||||
|
public CommonResult<EmployeeHostsRespVO> getEmployeeHosts(@RequestParam("id") Long id) {
|
||||||
|
EmployeeHostsDO employeeHosts = employeeHostsService.getEmployeeHosts(id);
|
||||||
|
return success(BeanUtils.toBean(employeeHosts, EmployeeHostsRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得员工分配主播分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('server:employee-hosts:query')")
|
||||||
|
public CommonResult<PageResult<EmployeeHostsRespVO>> getEmployeeHostsPage(@Valid EmployeeHostsPageReqVO pageReqVO) {
|
||||||
|
PageResult<EmployeeHostsDO> pageResult = employeeHostsService.getEmployeeHostsPage(pageReqVO);
|
||||||
|
return success(BeanUtils.toBean(pageResult, EmployeeHostsRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/export-excel")
|
||||||
|
@Operation(summary = "导出员工分配主播Excel")
|
||||||
|
@PreAuthorize("@ss.hasPermission('server:employee-hosts:export')")
|
||||||
|
@ApiAccessLog(operateType = EXPORT)
|
||||||
|
public void exportEmployeeHostsExcel(@Valid EmployeeHostsPageReqVO pageReqVO,
|
||||||
|
HttpServletResponse response) throws IOException {
|
||||||
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
|
List<EmployeeHostsDO> list = employeeHostsService.getEmployeeHostsPage(pageReqVO).getList();
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "员工分配主播.xls", "数据", EmployeeHostsRespVO.class,
|
||||||
|
BeanUtils.toBean(list, EmployeeHostsRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/allocation")
|
||||||
|
@Parameter(name = "hostsList", description = "主播信息List", required = true)
|
||||||
|
@Operation(summary = "批量分配主播给员工")
|
||||||
|
@PreAuthorize("@ss.hasPermission('server:employee-hosts:allocation')")
|
||||||
|
public CommonResult<Integer> deleteNewHostsList(@RequestBody List<EmployeeHostsSaveReqVO> hostsList) {
|
||||||
|
return success(employeeHostsService.allocationHostsEmployee(hostsList));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package cn.iocoder.yudao.module.tkdata.controller.admin.employeehosts.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 EmployeeHostsPageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "主播id", example = "26407")
|
||||||
|
private String hostsId;
|
||||||
|
|
||||||
|
@Schema(description = "用户 Id", example = "22763")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@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 = "操作状态", example = "1")
|
||||||
|
private Integer operationStatus;
|
||||||
|
|
||||||
|
@Schema(description = "数据插入时间")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private LocalDateTime[] createTime;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
package cn.iocoder.yudao.module.tkdata.controller.admin.employeehosts.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 EmployeeHostsRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "14489")
|
||||||
|
@ExcelProperty("主键")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "主播id", requiredMode = Schema.RequiredMode.REQUIRED, example = "26407")
|
||||||
|
@ExcelProperty("主播id")
|
||||||
|
private String hostsId;
|
||||||
|
|
||||||
|
@Schema(description = "用户 Id", example = "22763")
|
||||||
|
@ExcelProperty("用户 Id")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@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 = "操作状态", example = "1")
|
||||||
|
@ExcelProperty("操作状态")
|
||||||
|
private Integer operationStatus;
|
||||||
|
|
||||||
|
@Schema(description = "数据插入时间")
|
||||||
|
@ExcelProperty("数据插入时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package cn.iocoder.yudao.module.tkdata.controller.admin.employeehosts.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 EmployeeHostsSaveReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "14489")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "主播id", requiredMode = Schema.RequiredMode.REQUIRED, example = "26407")
|
||||||
|
@NotEmpty(message = "主播id不能为空")
|
||||||
|
private String hostsId;
|
||||||
|
|
||||||
|
@Schema(description = "用户 Id", example = "22763")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@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 = "操作状态", example = "1")
|
||||||
|
private Integer operationStatus;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.tkdata.controller.admin.newhosts;
|
package cn.iocoder.yudao.module.tkdata.controller.admin.newhosts;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.tkdata.controller.admin.newhosts.vo.AllocationHostsSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.tkdata.controller.admin.newhosts.vo.NewHostsPageReqVO;
|
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.NewHostsRespVO;
|
||||||
import cn.iocoder.yudao.module.tkdata.controller.admin.newhosts.vo.NewHostsSaveReqVO;
|
import cn.iocoder.yudao.module.tkdata.controller.admin.newhosts.vo.NewHostsSaveReqVO;
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package cn.iocoder.yudao.module.tkdata.controller.admin.newhosts.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @author: ziin
|
||||||
|
* @date: 2025/6/17 14:18
|
||||||
|
*/
|
||||||
|
@Schema(description = "管理后台 - 分配主播数据新增Request VO")
|
||||||
|
@Data
|
||||||
|
public class AllocationHostsSaveReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "主播id", example = "306")
|
||||||
|
private String hostsId;
|
||||||
|
|
||||||
|
@Schema(description = "主播等级")
|
||||||
|
private String hostsLevel;
|
||||||
|
|
||||||
|
@Schema(description = "主播金币")
|
||||||
|
private Integer hostsCoins;
|
||||||
|
|
||||||
|
@Schema(description = "邀请类型", example = "0")
|
||||||
|
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 = "是否已经分配给员工", example = "0")
|
||||||
|
private Integer isAssigned;
|
||||||
|
|
||||||
|
@Schema(description = "用户 Id", example = "10967")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package cn.iocoder.yudao.module.tkdata.dal.dataobject.employeehosts;
|
||||||
|
|
||||||
|
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_employee_hosts")
|
||||||
|
@KeySequence("server_employee_hosts_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class EmployeeHostsDO extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 主播id
|
||||||
|
*/
|
||||||
|
private String hostsId;
|
||||||
|
/**
|
||||||
|
* 用户 Id
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
/**
|
||||||
|
* 主播等级
|
||||||
|
*/
|
||||||
|
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 operationStatus;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package cn.iocoder.yudao.module.tkdata.dal.mysql.employeehosts;
|
||||||
|
|
||||||
|
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.employeehosts.EmployeeHostsDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import cn.iocoder.yudao.module.tkdata.controller.admin.employeehosts.vo.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 员工分配主播表,结构和主播表相同,多了user_id 字段来区分所属员工 Mapper
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface EmployeeHostsMapper extends BaseMapperX<EmployeeHostsDO> {
|
||||||
|
|
||||||
|
default PageResult<EmployeeHostsDO> selectPage(EmployeeHostsPageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<EmployeeHostsDO>()
|
||||||
|
.likeIfPresent(EmployeeHostsDO::getHostsId, reqVO.getHostsId())
|
||||||
|
.eqIfPresent(EmployeeHostsDO::getUserId, reqVO.getUserId())
|
||||||
|
.eqIfPresent(EmployeeHostsDO::getHostsLevel, reqVO.getHostsLevel())
|
||||||
|
.eqIfPresent(EmployeeHostsDO::getHostsCoins, reqVO.getHostsCoins())
|
||||||
|
.eqIfPresent(EmployeeHostsDO::getInvitationType, reqVO.getInvitationType())
|
||||||
|
.eqIfPresent(EmployeeHostsDO::getOnlineFans, reqVO.getOnlineFans())
|
||||||
|
.eqIfPresent(EmployeeHostsDO::getFans, reqVO.getFans())
|
||||||
|
.eqIfPresent(EmployeeHostsDO::getFllowernum, reqVO.getFllowernum())
|
||||||
|
.eqIfPresent(EmployeeHostsDO::getYesterdayCoins, reqVO.getYesterdayCoins())
|
||||||
|
.eqIfPresent(EmployeeHostsDO::getCountry, reqVO.getCountry())
|
||||||
|
.eqIfPresent(EmployeeHostsDO::getHostsKind, reqVO.getHostsKind())
|
||||||
|
.eqIfPresent(EmployeeHostsDO::getOperationStatus, reqVO.getOperationStatus())
|
||||||
|
.betweenIfPresent(EmployeeHostsDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.orderByDesc(EmployeeHostsDO::getId));
|
||||||
|
}
|
||||||
|
|
||||||
|
int insertIgnore(EmployeeHostsDO bean);
|
||||||
|
|
||||||
|
int batchInsertIgnore(List<EmployeeHostsDO> list);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@ import cn.iocoder.yudao.framework.common.exception.ErrorCode;
|
|||||||
*/
|
*/
|
||||||
public interface ErrorCodeConstants {
|
public interface ErrorCodeConstants {
|
||||||
|
|
||||||
ErrorCode NEW_HOSTS_NOT_EXISTS = new ErrorCode(1_001_101_000, "主播数据不存在");
|
//===============主播信息 1_001_300_000=================
|
||||||
|
ErrorCode NEW_HOSTS_NOT_EXISTS = new ErrorCode(1_001_301_000, "主播数据不存在");
|
||||||
|
ErrorCode EMPLOYEE_HOSTS_NOT_EXISTS = new ErrorCode(1_001_301_001, "分配员工数据不存在");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package cn.iocoder.yudao.module.tkdata.service.employeehosts;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.*;
|
||||||
|
import cn.iocoder.yudao.module.tkdata.controller.admin.employeehosts.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.tkdata.dal.dataobject.employeehosts.EmployeeHostsDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 员工分配主播表,结构和主播表相同,多了user_id 字段来区分所属员工 Service 接口
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public interface EmployeeHostsService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建员工分配主播表,结构和主播表相同,多了user_id 字段来区分所属员工
|
||||||
|
*
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
Long createEmployeeHosts(@Valid EmployeeHostsSaveReqVO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新员工分配主播表,结构和主播表相同,多了user_id 字段来区分所属员工
|
||||||
|
*
|
||||||
|
* @param updateReqVO 更新信息
|
||||||
|
*/
|
||||||
|
void updateEmployeeHosts(@Valid EmployeeHostsSaveReqVO updateReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除员工分配主播表,结构和主播表相同,多了user_id 字段来区分所属员工
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
*/
|
||||||
|
void deleteEmployeeHosts(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除员工分配主播表,结构和主播表相同,多了user_id 字段来区分所属员工
|
||||||
|
*
|
||||||
|
* @param ids 编号
|
||||||
|
*/
|
||||||
|
void deleteEmployeeHostsListByIds(List<Long> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得员工分配主播表,结构和主播表相同,多了user_id 字段来区分所属员工
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 员工分配主播表,结构和主播表相同,多了user_id 字段来区分所属员工
|
||||||
|
*/
|
||||||
|
EmployeeHostsDO getEmployeeHosts(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得员工分配主播表,结构和主播表相同,多了user_id 字段来区分所属员工分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 员工分配主播表,结构和主播表相同,多了user_id 字段来区分所属员工分页
|
||||||
|
*/
|
||||||
|
PageResult<EmployeeHostsDO> getEmployeeHostsPage(EmployeeHostsPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
Integer allocationHostsEmployee(List<EmployeeHostsSaveReqVO> hostsList);
|
||||||
|
}
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
package cn.iocoder.yudao.module.tkdata.service.employeehosts;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
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.module.tkdata.controller.admin.employeehosts.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.tkdata.dal.dataobject.employeehosts.EmployeeHostsDO;
|
||||||
|
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 cn.iocoder.yudao.module.tkdata.dal.mysql.employeehosts.EmployeeHostsMapper;
|
||||||
|
|
||||||
|
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;
|
||||||
|
import static cn.iocoder.yudao.module.tkdata.enums.ErrorCodeConstants.EMPLOYEE_HOSTS_NOT_EXISTS;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 员工分配主播表,结构和主播表相同,多了user_id 字段来区分所属员工 Service 实现类
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
public class EmployeeHostsServiceImpl implements EmployeeHostsService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private EmployeeHostsMapper employeeHostsMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long createEmployeeHosts(EmployeeHostsSaveReqVO createReqVO) {
|
||||||
|
// 插入
|
||||||
|
EmployeeHostsDO employeeHosts = BeanUtils.toBean(createReqVO, EmployeeHostsDO.class);
|
||||||
|
employeeHostsMapper.insert(employeeHosts);
|
||||||
|
// 返回
|
||||||
|
return employeeHosts.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateEmployeeHosts(EmployeeHostsSaveReqVO updateReqVO) {
|
||||||
|
// 校验存在
|
||||||
|
validateEmployeeHostsExists(updateReqVO.getId());
|
||||||
|
// 更新
|
||||||
|
EmployeeHostsDO updateObj = BeanUtils.toBean(updateReqVO, EmployeeHostsDO.class);
|
||||||
|
employeeHostsMapper.updateById(updateObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteEmployeeHosts(Long id) {
|
||||||
|
// 校验存在
|
||||||
|
validateEmployeeHostsExists(id);
|
||||||
|
// 删除
|
||||||
|
employeeHostsMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteEmployeeHostsListByIds(List<Long> ids) {
|
||||||
|
// 校验存在
|
||||||
|
validateEmployeeHostsExists(ids);
|
||||||
|
// 删除
|
||||||
|
employeeHostsMapper.deleteByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateEmployeeHostsExists(List<Long> ids) {
|
||||||
|
List<EmployeeHostsDO> list = employeeHostsMapper.selectByIds(ids);
|
||||||
|
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
|
||||||
|
throw exception(EMPLOYEE_HOSTS_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateEmployeeHostsExists(Long id) {
|
||||||
|
if (employeeHostsMapper.selectById(id) == null) {
|
||||||
|
throw exception(EMPLOYEE_HOSTS_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EmployeeHostsDO getEmployeeHosts(Long id) {
|
||||||
|
return employeeHostsMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<EmployeeHostsDO> getEmployeeHostsPage(EmployeeHostsPageReqVO pageReqVO) {
|
||||||
|
return employeeHostsMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer allocationHostsEmployee(List<EmployeeHostsSaveReqVO> hostsList) {
|
||||||
|
int count = 0;
|
||||||
|
// for (EmployeeHostsSaveReqVO employeeHostsSaveReqVO : hostsList) {
|
||||||
|
// int i = employeeHostsMapper.insertIgnore();
|
||||||
|
// count += i;
|
||||||
|
// }
|
||||||
|
ArrayList<EmployeeHostsDO> employeeHostsDOS = new ArrayList<>();
|
||||||
|
for (EmployeeHostsSaveReqVO employeeHostsSaveReqVO : hostsList) {
|
||||||
|
employeeHostsDOS.add(BeanUtils.toBean(employeeHostsSaveReqVO, EmployeeHostsDO.class));
|
||||||
|
}
|
||||||
|
return employeeHostsMapper.batchInsertIgnore(employeeHostsDOS);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import java.util.*;
|
|||||||
import javax.validation.*;
|
import javax.validation.*;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.module.tkdata.controller.admin.newhosts.vo.AllocationHostsSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.tkdata.controller.admin.newhosts.vo.NewHostsPageReqVO;
|
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.controller.admin.newhosts.vo.NewHostsSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.tkdata.dal.dataobject.newhosts.NewHostsDO;
|
import cn.iocoder.yudao.module.tkdata.dal.dataobject.newhosts.NewHostsDO;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.tkdata.service.newhosts;
|
package cn.iocoder.yudao.module.tkdata.service.newhosts;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.iocoder.yudao.module.tkdata.controller.admin.newhosts.vo.AllocationHostsSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.tkdata.controller.admin.newhosts.vo.NewHostsPageReqVO;
|
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.controller.admin.newhosts.vo.NewHostsSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.tkdata.dal.dataobject.newhosts.NewHostsDO;
|
import cn.iocoder.yudao.module.tkdata.dal.dataobject.newhosts.NewHostsDO;
|
||||||
@@ -9,19 +10,16 @@ import cn.iocoder.yudao.module.tkdata.enums.ErrorCodeConstants;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
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 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.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.convertList;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.diffList;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
<?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.employeehosts.EmployeeHostsMapper">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||||
|
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||||
|
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||||
|
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||||
|
-->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 使用 IGNORE 关键字忽略重复插入 -->
|
||||||
|
<insert id="insertIgnore" parameterType="cn.iocoder.yudao.module.tkdata.dal.dataobject.employeehosts.EmployeeHostsDO">
|
||||||
|
INSERT IGNORE INTO server_employee_hosts
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="hostsId != null">hosts_id,</if>
|
||||||
|
<if test="userId != null">user_id,</if>
|
||||||
|
<if test="hostsLevel != null">hosts_level,</if>
|
||||||
|
<if test="hostsCoins != null">hosts_coins,</if>
|
||||||
|
<if test="invitationType != null">Invitation_type,</if>
|
||||||
|
<if test="onlineFans != null">online_fans,</if>
|
||||||
|
<if test="fans != null">fans,</if>
|
||||||
|
<if test="fllowernum != null">fllowernum,</if>
|
||||||
|
<if test="yesterdayCoins != null">yesterday_coins,</if>
|
||||||
|
<if test="country != null">country,</if>
|
||||||
|
<if test="operationStatus != null">operation_status,</if>
|
||||||
|
<if test="hostsKind != null">hosts_kind</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="hostsId != null">#{hostsId},</if>
|
||||||
|
<if test="userId != null">#{userId},</if>
|
||||||
|
<if test="hostsLevel != null">#{hostsLevel},</if>
|
||||||
|
<if test="hostsCoins != null">#{hostsCoins},</if>
|
||||||
|
<if test="invitationType != null">#{invitationType},</if>
|
||||||
|
<if test="onlineFans != null">#{onlineFans},</if>
|
||||||
|
<if test="fans != null">#{fans},</if>
|
||||||
|
<if test="fllowernum != null">#{fllowernum},</if>
|
||||||
|
<if test="yesterdayCoins != null">#{yesterdayCoins},</if>
|
||||||
|
<if test="country != null">#{country},</if>
|
||||||
|
<if test="operationStatus != null">#{operationStatus},</if>
|
||||||
|
<if test="hostsKind != null">#{hostsKind}</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!-- 批量插入忽略重复 -->
|
||||||
|
<insert id="batchInsertIgnore" parameterType="java.util.List">
|
||||||
|
INSERT IGNORE INTO server_employee_hosts
|
||||||
|
(hosts_id, user_id, hosts_level, hosts_coins, Invitation_type,
|
||||||
|
online_fans, fans, fllowernum, yesterday_coins, country,
|
||||||
|
operation_status, hosts_kind)
|
||||||
|
VALUES
|
||||||
|
<foreach collection="list" item="item" separator=",">
|
||||||
|
(#{item.hostsId}, #{item.userId}, #{item.hostsLevel}, #{item.hostsCoins}, #{item.invitationType},
|
||||||
|
#{item.onlineFans}, #{item.fans}, #{item.fllowernum}, #{item.yesterdayCoins}, #{item.country},
|
||||||
|
#{item.operationStatus}, #{item.hostsKind})
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user