mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-20 10:13:28 +08:00
up
This commit is contained in:
parent
d698d549b5
commit
8be3879c68
@ -0,0 +1,105 @@
|
||||
package org.dromara.question.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.question.domain.vo.RewardsVo;
|
||||
import org.dromara.question.domain.bo.RewardsBo;
|
||||
import org.dromara.question.service.IRewardsService;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 奖品管理
|
||||
*
|
||||
* @author lvxudong
|
||||
* @date 2023-11-27
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/question/rewards")
|
||||
public class RewardsController extends BaseController {
|
||||
|
||||
private final IRewardsService rewardsService;
|
||||
|
||||
/**
|
||||
* 查询奖品管理列表
|
||||
*/
|
||||
@SaCheckPermission("question:rewards:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<RewardsVo> list(RewardsBo bo, PageQuery pageQuery) {
|
||||
return rewardsService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出奖品管理列表
|
||||
*/
|
||||
@SaCheckPermission("question:rewards:export")
|
||||
@Log(title = "奖品管理", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(RewardsBo bo, HttpServletResponse response) {
|
||||
List<RewardsVo> list = rewardsService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "奖品管理", RewardsVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取奖品管理详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("question:rewards:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<RewardsVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(rewardsService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增奖品管理
|
||||
*/
|
||||
@SaCheckPermission("question:rewards:add")
|
||||
@Log(title = "奖品管理", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody RewardsBo bo) {
|
||||
return toAjax(rewardsService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改奖品管理
|
||||
*/
|
||||
@SaCheckPermission("question:rewards:edit")
|
||||
@Log(title = "奖品管理", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody RewardsBo bo) {
|
||||
return toAjax(rewardsService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除奖品管理
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("question:rewards:remove")
|
||||
@Log(title = "奖品管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(rewardsService.deleteWithValidByIds(List.of(ids), true));
|
||||
}
|
||||
}
|
||||
@ -3,6 +3,7 @@ package org.dromara.question.domain;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@ -13,7 +14,7 @@ import java.util.Date;
|
||||
**/
|
||||
@Data
|
||||
@TableName("f_options")
|
||||
public class Options {
|
||||
public class Options implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
|
||||
@ -0,0 +1,61 @@
|
||||
package org.dromara.question.domain;
|
||||
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 奖品管理对象 f_rewards
|
||||
*
|
||||
* @author lvxudong
|
||||
* @date 2023-11-27
|
||||
*/
|
||||
@Data
|
||||
@TableName("f_rewards")
|
||||
public class Rewards implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 奖励类型
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 奖励名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 奖励图片
|
||||
*/
|
||||
private String image;
|
||||
|
||||
/**
|
||||
* 图片描述
|
||||
*/
|
||||
private String imgDescribe;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Date updateTime;
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
package org.dromara.question.domain.bo;
|
||||
|
||||
import org.dromara.question.domain.Rewards;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* 奖品管理业务对象 f_rewards
|
||||
*
|
||||
* @author lvxudong
|
||||
* @date 2023-11-27
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = Rewards.class, reverseConvertGenerate = false)
|
||||
public class RewardsBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@NotNull(message = "不能为空", groups = { EditGroup.class })
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 奖励类型
|
||||
*/
|
||||
@NotNull(message = "奖励类型不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 奖励名称
|
||||
*/
|
||||
@NotBlank(message = "奖励名称不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 奖励图片
|
||||
*/
|
||||
@NotBlank(message = "奖励图片不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String image;
|
||||
|
||||
/**
|
||||
* 图片描述
|
||||
*/
|
||||
@NotBlank(message = "图片描述不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String imgDescribe;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
package org.dromara.question.domain.vo;
|
||||
|
||||
import org.dromara.question.domain.Rewards;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 奖品管理视图对象 f_rewards
|
||||
*
|
||||
* @author lvxudong
|
||||
* @date 2023-11-27
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = Rewards.class)
|
||||
public class RewardsVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ExcelProperty(value = "")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 奖励类型
|
||||
*/
|
||||
private Integer type;
|
||||
@ExcelProperty(value = "奖励类型")
|
||||
private String typeName;
|
||||
|
||||
/**
|
||||
* 奖励名称
|
||||
*/
|
||||
@ExcelProperty(value = "奖励名称")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 奖励图片
|
||||
*/
|
||||
@ExcelProperty(value = "奖励图片")
|
||||
private String image;
|
||||
|
||||
/**
|
||||
* 图片描述
|
||||
*/
|
||||
@ExcelProperty(value = "图片描述")
|
||||
private String imgDescribe;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
package org.dromara.question.emum;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author : lvxudong
|
||||
* @date : 2023/11/27 17:14
|
||||
* @enum : RewardsEnum
|
||||
* @description :
|
||||
**/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum RewardsEnum {
|
||||
|
||||
/**
|
||||
* 正常
|
||||
*/
|
||||
EXCHANGE_VOUCHER(1, "兑换券奖励"),
|
||||
/**
|
||||
* 停用
|
||||
*/
|
||||
CHARACTERS(2, "文字奖励"),
|
||||
;
|
||||
|
||||
private final Integer code;
|
||||
private final String name;
|
||||
|
||||
public static String getNameByValue(Integer value) {
|
||||
if (value == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return enumList.stream().filter(e -> e.getCode().equals(value)).findAny().map(RewardsEnum::getName).orElse("");
|
||||
}
|
||||
|
||||
private static final List<RewardsEnum> enumList;
|
||||
|
||||
static {
|
||||
enumList = new ArrayList<>();
|
||||
Collections.addAll(enumList, RewardsEnum.values());
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package org.dromara.question.mapper;
|
||||
|
||||
import org.dromara.question.domain.Rewards;
|
||||
import org.dromara.question.domain.vo.RewardsVo;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
/**
|
||||
* 奖品管理Mapper接口
|
||||
*
|
||||
* @author lvxudong
|
||||
* @date 2023-11-27
|
||||
*/
|
||||
public interface RewardsMapper extends BaseMapperPlus<Rewards, RewardsVo> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
package org.dromara.question.service;
|
||||
|
||||
import org.dromara.question.domain.Rewards;
|
||||
import org.dromara.question.domain.vo.RewardsVo;
|
||||
import org.dromara.question.domain.bo.RewardsBo;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 奖品管理Service接口
|
||||
*
|
||||
* @author lvxudong
|
||||
* @date 2023-11-27
|
||||
*/
|
||||
public interface IRewardsService {
|
||||
|
||||
/**
|
||||
* 查询奖品管理
|
||||
*/
|
||||
RewardsVo queryById(Long id);
|
||||
|
||||
/**
|
||||
* 查询奖品管理列表
|
||||
*/
|
||||
TableDataInfo<RewardsVo> queryPageList(RewardsBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询奖品管理列表
|
||||
*/
|
||||
List<RewardsVo> queryList(RewardsBo bo);
|
||||
|
||||
/**
|
||||
* 新增奖品管理
|
||||
*/
|
||||
Boolean insertByBo(RewardsBo bo);
|
||||
|
||||
/**
|
||||
* 修改奖品管理
|
||||
*/
|
||||
Boolean updateByBo(RewardsBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除奖品管理信息
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
@ -0,0 +1,115 @@
|
||||
package org.dromara.question.service.impl;
|
||||
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.question.emum.RewardsEnum;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.question.domain.bo.RewardsBo;
|
||||
import org.dromara.question.domain.vo.RewardsVo;
|
||||
import org.dromara.question.domain.Rewards;
|
||||
import org.dromara.question.mapper.RewardsMapper;
|
||||
import org.dromara.question.service.IRewardsService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 奖品管理Service业务层处理
|
||||
*
|
||||
* @author lvxudong
|
||||
* @date 2023-11-27
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class RewardsServiceImpl implements IRewardsService {
|
||||
|
||||
private final RewardsMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询奖品管理
|
||||
*/
|
||||
@Override
|
||||
public RewardsVo queryById(Long id){
|
||||
return baseMapper.selectVoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询奖品管理列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<RewardsVo> queryPageList(RewardsBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<Rewards> lqw = buildQueryWrapper(bo);
|
||||
Page<RewardsVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
TableDataInfo<RewardsVo> build = TableDataInfo.build(result);
|
||||
build.getRows().forEach(p-> p.setTypeName(RewardsEnum.getNameByValue(p.getType())));
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询奖品管理列表
|
||||
*/
|
||||
@Override
|
||||
public List<RewardsVo> queryList(RewardsBo bo) {
|
||||
LambdaQueryWrapper<Rewards> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<Rewards> buildQueryWrapper(RewardsBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<Rewards> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(bo.getType() != null, Rewards::getType, bo.getType());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getName()), Rewards::getName, bo.getName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getImage()), Rewards::getImage, bo.getImage());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getImgDescribe()), Rewards::getImgDescribe, bo.getImgDescribe());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增奖品管理
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(RewardsBo bo) {
|
||||
Rewards add = MapstructUtils.convert(bo, Rewards.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改奖品管理
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(RewardsBo bo) {
|
||||
Rewards update = MapstructUtils.convert(bo, Rewards.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(Rewards entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除奖品管理
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
<?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="org.dromara.question.mapper.RewardsMapper">
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue
Block a user