收藏内容
This commit is contained in:
parent
583f8a7718
commit
6fa3b8639f
@ -0,0 +1,118 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.controller.admin.star2;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.iocoder.yudao.module.bpm.convert.star2.Star2Convert;
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.knows.KnowledgeDO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.knows.KnowtypeDO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.service.knows.KnowledgeService;
|
||||||
|
import cn.iocoder.yudao.module.bpm.service.knows.KnowtypeService;
|
||||||
|
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 static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.bpm.controller.admin.star2.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.star2.Star2DO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.service.star2.Star2Service;
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - 我的收藏")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/bpm/star2")
|
||||||
|
@Validated
|
||||||
|
public class Star2Controller {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private Star2Service star2Service;
|
||||||
|
@Resource
|
||||||
|
private KnowledgeService knowledgeService;
|
||||||
|
@Resource
|
||||||
|
private KnowtypeService knowtypeService;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@Operation(summary = "创建我的收藏")
|
||||||
|
@PreAuthorize("@ss.hasPermission('bpm:star2:create')")
|
||||||
|
public CommonResult<Long> createStar2(@Valid @RequestBody Star2SaveReqVO createReqVO) {
|
||||||
|
return success(star2Service.createStar2(createReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新我的收藏")
|
||||||
|
@PreAuthorize("@ss.hasPermission('bpm:star2:update')")
|
||||||
|
public CommonResult<Boolean> updateStar2(@Valid @RequestBody Star2SaveReqVO updateReqVO) {
|
||||||
|
star2Service.updateStar2(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
@Operation(summary = "删除我的收藏")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('bpm:star2:delete')")
|
||||||
|
public CommonResult<Boolean> deleteStar2(@RequestParam("id") Long id) {
|
||||||
|
star2Service.deleteStar2(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得我的收藏")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('bpm:star2:query')")
|
||||||
|
public CommonResult<Star2RespVO> getStar2(@RequestParam("id") Long id) {
|
||||||
|
Star2DO star2 = star2Service.getStar2(id);
|
||||||
|
return success(BeanUtils.toBean(star2, Star2RespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得我的收藏分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('bpm:star2:query')")
|
||||||
|
public CommonResult<PageResult<Star2RespVO>> getStar2Page(@Valid Star2PageReqVO pageReqVO) {
|
||||||
|
PageResult<Star2DO> pageResult = star2Service.getStar2Page(pageReqVO);
|
||||||
|
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||||
|
return success(new PageResult<>(pageResult.getTotal()));
|
||||||
|
}
|
||||||
|
Map<Long, KnowtypeDO> knowTypeMap = knowtypeService.getKnowtypeMap(
|
||||||
|
convertList(pageResult.getList(),Star2DO::getId)
|
||||||
|
);
|
||||||
|
return success(new PageResult<>(Star2Convert.INSTANCE.convertList(pageResult.getList(),knowTypeMap),pageResult.getTotal() ));
|
||||||
|
// return success(BeanUtils.toBean(pageResult, Star2RespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/export-excel")
|
||||||
|
@Operation(summary = "导出我的收藏 Excel")
|
||||||
|
@PreAuthorize("@ss.hasPermission('bpm:star2:export')")
|
||||||
|
@ApiAccessLog(operateType = EXPORT)
|
||||||
|
public void exportStar2Excel(@Valid Star2PageReqVO pageReqVO,
|
||||||
|
HttpServletResponse response) throws IOException {
|
||||||
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
|
List<Star2DO> list = star2Service.getStar2Page(pageReqVO).getList();
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "我的收藏.xls", "数据", Star2RespVO.class,
|
||||||
|
BeanUtils.toBean(list, Star2RespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.convert.star2;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.module.bpm.controller.admin.star2.vo.Star2RespVO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.knows.KnowledgeDO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.knows.KnowtypeDO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.star2.Star2DO;
|
||||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface Star2Convert {
|
||||||
|
Star2Convert INSTANCE = Mappers.getMapper(Star2Convert.class);
|
||||||
|
default List<Star2RespVO> convertList(List<Star2DO> list, Map<Long, KnowtypeDO> knowTypeMap){
|
||||||
|
return list.stream().map(star2DO -> {
|
||||||
|
KnowtypeDO knowtypeDO = knowTypeMap.get(star2DO.getKowsId());
|
||||||
|
return convert(star2DO,knowtypeDO);
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
default Star2RespVO convert(Star2DO star2, KnowtypeDO knowType){
|
||||||
|
Star2RespVO Star2VO = BeanUtils.toBean(star2, Star2RespVO.class);
|
||||||
|
if (knowType != null){
|
||||||
|
Star2VO.setNickName2(knowType.getName());
|
||||||
|
}
|
||||||
|
System.out.println(Star2VO);
|
||||||
|
return Star2VO;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.dal.dataobject.star2;
|
||||||
|
|
||||||
|
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("des_star2")
|
||||||
|
@KeySequence("des_star2_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class Star2DO extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
/**
|
||||||
|
* 知识id
|
||||||
|
*/
|
||||||
|
private Long kowsId;
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user