1231123
This commit is contained in:
27
doc/v3.sql
Normal file
27
doc/v3.sql
Normal file
@@ -0,0 +1,27 @@
|
||||
CREATE TABLE `cai_anchor_banner`
|
||||
(
|
||||
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
|
||||
`user_id` bigint NOT NULL COMMENT '用户ID',
|
||||
`anchor_id` bigint NOT NULL COMMENT '主播ID',
|
||||
`open_status` tinyint not null default 1 comment '开启状态',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB COMMENT '主播首页推荐';
|
||||
|
||||
-- 菜单 SQL
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values(1809856380386619394, '主播首页推荐', '1738072642014617602', '1', 'anchorBanner', 'cai/anchorBanner/index', 1, 0, 'C', '0', '0', 'cai:anchorBanner:list', '#', 'admin', sysdate(), '', null, '主播首页推荐菜单');
|
||||
|
||||
-- 按钮 SQL
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values(1809856380386619395, '主播首页推荐查询', 1809856380386619394, '1', '#', '', 1, 0, 'F', '0', '0', 'cai:anchorBanner:query', '#', 'admin', sysdate(), '', null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values(1809856380386619396, '主播首页推荐新增', 1809856380386619394, '2', '#', '', 1, 0, 'F', '0', '0', 'cai:anchorBanner:add', '#', 'admin', sysdate(), '', null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values(1809856380386619397, '主播首页推荐修改', 1809856380386619394, '3', '#', '', 1, 0, 'F', '0', '0', 'cai:anchorBanner:edit', '#', 'admin', sysdate(), '', null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values(1809856380386619398, '主播首页推荐删除', 1809856380386619394, '4', '#', '', 1, 0, 'F', '0', '0', 'cai:anchorBanner:remove', '#', 'admin', sysdate(), '', null, '');
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.ruoyi.web.controller.cai.admin;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.cai.domain.AnchorBanner;
|
||||
import com.ruoyi.cai.service.AnchorBannerService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.annotation.RepeatSubmit;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 主播首页推荐
|
||||
*
|
||||
* @author 77
|
||||
* @date 2024-07-07
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/cai/anchorBanner")
|
||||
public class AnchorBannerController extends BaseController {
|
||||
|
||||
private final AnchorBannerService anchorBannerService;
|
||||
|
||||
/**
|
||||
* 查询主播首页推荐列表
|
||||
*/
|
||||
@SaCheckPermission("cai:anchorBanner:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<AnchorBanner> list(AnchorBanner bo, PageQuery pageQuery) {
|
||||
Page<AnchorBanner> page = anchorBannerService.page(pageQuery.build(), Wrappers.lambdaQuery(bo));
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主播首页推荐详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("cai:anchorBanner:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<AnchorBanner> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable String id) {
|
||||
return R.ok(anchorBannerService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增主播首页推荐
|
||||
*/
|
||||
@SaCheckPermission("cai:anchorBanner:add")
|
||||
@Log(title = "主播首页推荐", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody AnchorBanner bo) {
|
||||
return toAjax(anchorBannerService.saveData(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改主播首页推荐
|
||||
*/
|
||||
@SaCheckPermission("cai:anchorBanner:edit")
|
||||
@Log(title = "主播首页推荐", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody AnchorBanner bo) {
|
||||
return toAjax(anchorBannerService.updateById(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除主播首页推荐
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("cai:anchorBanner:remove")
|
||||
@Log(title = "主播首页推荐", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable String[] ids) {
|
||||
return toAjax(anchorBannerService.removeByIds(Arrays.asList(ids)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.ruoyi.cai.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 主播首页推荐对象 cai_anchor_banner
|
||||
*
|
||||
* @author 77
|
||||
* @date 2024-07-07
|
||||
*/
|
||||
@Data
|
||||
@TableName("cai_anchor_banner")
|
||||
public class AnchorBanner implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
private String id;
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String usercode;
|
||||
/**
|
||||
* 主播ID
|
||||
*/
|
||||
private Long anchorId;
|
||||
/**
|
||||
* 开启状态
|
||||
*/
|
||||
private Integer openStatus;
|
||||
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.ruoyi.cai.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.cai.domain.AnchorBanner;
|
||||
|
||||
/**
|
||||
* 主播首页推荐Mapper接口
|
||||
*
|
||||
* @author 77
|
||||
* @date 2024-07-07
|
||||
*/
|
||||
public interface AnchorBannerMapper extends BaseMapper<AnchorBanner> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.ruoyi.cai.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.cai.domain.AnchorBanner;
|
||||
|
||||
/**
|
||||
* 主播首页推荐Service接口
|
||||
*
|
||||
* @author 77
|
||||
* @date 2024-07-07
|
||||
*/
|
||||
public interface AnchorBannerService extends IService<AnchorBanner> {
|
||||
|
||||
boolean saveData(AnchorBanner bo);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.ruoyi.cai.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.cai.domain.Anchor;
|
||||
import com.ruoyi.cai.domain.AnchorBanner;
|
||||
import com.ruoyi.cai.domain.User;
|
||||
import com.ruoyi.cai.mapper.AnchorBannerMapper;
|
||||
import com.ruoyi.cai.service.AnchorBannerService;
|
||||
import com.ruoyi.cai.service.AnchorService;
|
||||
import com.ruoyi.cai.service.UserService;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 主播首页推荐Service业务层处理
|
||||
*
|
||||
* @author 77
|
||||
* @date 2024-07-07
|
||||
*/
|
||||
@Service
|
||||
public class AnchorBannerServiceImpl extends ServiceImpl<AnchorBannerMapper, AnchorBanner> implements AnchorBannerService {
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private AnchorService anchorService;
|
||||
@Override
|
||||
public boolean saveData(AnchorBanner bo) {
|
||||
User user = userService.getByUserCode(bo.getUsercode());
|
||||
if(user == null){
|
||||
throw new ServiceException("用户不存在");
|
||||
}
|
||||
if(user.getIsAnchor() != 1){
|
||||
throw new ServiceException("非主播无法添加首页推荐");
|
||||
}
|
||||
Anchor anchor = anchorService.getByUserId(user.getId());
|
||||
if(anchor == null){
|
||||
throw new ServiceException("非主播无法添加首页推荐");
|
||||
}
|
||||
bo.setUserId(user.getId());
|
||||
bo.setAnchorId(anchor.getId());
|
||||
this.save(bo);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user