优化
This commit is contained in:
@ -195,4 +195,5 @@ public interface ErrorCodeConstants {
|
||||
|
||||
ErrorCode FACE_DEVICE_INFO_EXISTS = new ErrorCode(1_002_040_003, "设备码已存在");
|
||||
|
||||
ErrorCode DISH_IMAGE_NOT_EXISTS = new ErrorCode(1_002_040_004, "本周菜单不存在");
|
||||
}
|
||||
|
@ -0,0 +1,98 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.dishimage;
|
||||
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dishimage.vo.DishImagePageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dishimage.vo.DishImageRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dishimage.vo.DishImageSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dishimage.DishImageDO;
|
||||
import cn.iocoder.yudao.module.system.service.dishimage.DishImageService;
|
||||
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.operatelog.core.annotations.OperateLog;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
|
||||
|
||||
@Tag(name = "管理后台 - 本周菜单")
|
||||
@RestController
|
||||
@RequestMapping("/t/dish-image")
|
||||
@Validated
|
||||
public class DishImageController {
|
||||
|
||||
@Resource
|
||||
private DishImageService dishImageService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建本周菜单")
|
||||
@PreAuthorize("@ss.hasPermission('t:dish-image:create')")
|
||||
public CommonResult<Integer> createDishImage(@Valid @RequestBody DishImageSaveReqVO createReqVO) {
|
||||
return success(dishImageService.createDishImage(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新本周菜单")
|
||||
@PreAuthorize("@ss.hasPermission('t:dish-image:update')")
|
||||
public CommonResult<Boolean> updateDishImage(@Valid @RequestBody DishImageSaveReqVO updateReqVO) {
|
||||
dishImageService.updateDishImage(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除本周菜单")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('t:dish-image:delete')")
|
||||
public CommonResult<Boolean> deleteDishImage(@RequestParam("id") Integer id) {
|
||||
dishImageService.deleteDishImage(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得本周菜单")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('t:dish-image:query')")
|
||||
public CommonResult<DishImageRespVO> getDishImage(@RequestParam("id") Integer id) {
|
||||
DishImageDO dishImage = dishImageService.getDishImage(id);
|
||||
return success(BeanUtils.toBean(dishImage, DishImageRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得本周菜单分页")
|
||||
@PreAuthorize("@ss.hasPermission('t:dish-image:query')")
|
||||
public CommonResult<PageResult<DishImageRespVO>> getDishImagePage(@Valid DishImagePageReqVO pageReqVO) {
|
||||
PageResult<DishImageDO> pageResult = dishImageService.getDishImagePage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, DishImageRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出本周菜单 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('t:dish-image:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportDishImageExcel(@Valid DishImagePageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<DishImageDO> list = dishImageService.getDishImagePage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "本周菜单.xls", "数据", DishImageRespVO.class,
|
||||
BeanUtils.toBean(list, DishImageRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.dishimage.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
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class DishImagePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "名字", example = "张三")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "开始日期")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private String[] startDate;
|
||||
|
||||
@Schema(description = "结束日期")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private String[] endDate;
|
||||
|
||||
@Schema(description = "地址", example = "https://www.iocoder.cn")
|
||||
private String imageUrl;
|
||||
|
||||
@Schema(description = "备注", example = "随便")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.dishimage.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
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 DishImageRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17200")
|
||||
@ExcelProperty("编号")
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "名字", example = "张三")
|
||||
@ExcelProperty("名字")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "开始日期")
|
||||
@ExcelProperty("开始日期")
|
||||
private String startDate;
|
||||
|
||||
@Schema(description = "结束日期")
|
||||
@ExcelProperty("结束日期")
|
||||
private String endDate;
|
||||
|
||||
@Schema(description = "地址", example = "https://www.iocoder.cn")
|
||||
@ExcelProperty("地址")
|
||||
private String imageUrl;
|
||||
|
||||
@Schema(description = "备注", example = "随便")
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.dishimage.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 DishImageSaveReqVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17200")
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "名字", example = "张三")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "开始日期")
|
||||
private String startDate;
|
||||
|
||||
@Schema(description = "结束日期")
|
||||
private String endDate;
|
||||
|
||||
@Schema(description = "地址", example = "https://www.iocoder.cn")
|
||||
private String imageUrl;
|
||||
|
||||
@Schema(description = "备注", example = "随便")
|
||||
private String remark;
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package cn.iocoder.yudao.module.system.dal.dataobject.dishimage;
|
||||
|
||||
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("t_dish_image")
|
||||
@KeySequence("t_dish_image_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DishImageDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@TableId
|
||||
private Integer id;
|
||||
/**
|
||||
* 名字
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 开始日期
|
||||
*/
|
||||
private String startDate;
|
||||
/**
|
||||
* 结束日期
|
||||
*/
|
||||
private String endDate;
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
private String imageUrl;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package cn.iocoder.yudao.module.system.dal.mysql.dishimage;
|
||||
|
||||
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.system.controller.admin.dishimage.vo.DishImagePageReqVO;
|
||||
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dishimage.DishImageDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
||||
/**
|
||||
* 本周菜单 Mapper
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
@Mapper
|
||||
public interface DishImageMapper extends BaseMapperX<DishImageDO> {
|
||||
|
||||
default PageResult<DishImageDO> selectPage(DishImagePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<DishImageDO>()
|
||||
.likeIfPresent(DishImageDO::getName, reqVO.getName())
|
||||
.betweenIfPresent(DishImageDO::getStartDate, reqVO.getStartDate())
|
||||
.betweenIfPresent(DishImageDO::getEndDate, reqVO.getEndDate())
|
||||
.eqIfPresent(DishImageDO::getImageUrl, reqVO.getImageUrl())
|
||||
.eqIfPresent(DishImageDO::getRemark, reqVO.getRemark())
|
||||
.betweenIfPresent(DishImageDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(DishImageDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package cn.iocoder.yudao.module.system.service.dishimage;
|
||||
|
||||
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.system.controller.admin.dishimage.vo.DishImagePageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dishimage.vo.DishImageSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dishimage.DishImageDO;
|
||||
|
||||
/**
|
||||
* 本周菜单 Service 接口
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
public interface DishImageService {
|
||||
|
||||
/**
|
||||
* 创建本周菜单
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Integer createDishImage(@Valid DishImageSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新本周菜单
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateDishImage(@Valid DishImageSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除本周菜单
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteDishImage(Integer id);
|
||||
|
||||
/**
|
||||
* 获得本周菜单
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 本周菜单
|
||||
*/
|
||||
DishImageDO getDishImage(Integer id);
|
||||
|
||||
/**
|
||||
* 获得本周菜单分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 本周菜单分页
|
||||
*/
|
||||
PageResult<DishImageDO> getDishImagePage(DishImagePageReqVO pageReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package cn.iocoder.yudao.module.system.service.dishimage;
|
||||
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dishimage.vo.DishImagePageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dishimage.vo.DishImageSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dishimage.DishImageDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.dishimage.DishImageMapper;
|
||||
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.module.system.enums.ErrorCodeConstants.DISH_IMAGE_NOT_EXISTS;
|
||||
|
||||
|
||||
/**
|
||||
* 本周菜单 Service 实现类
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class DishImageServiceImpl implements DishImageService {
|
||||
|
||||
@Resource
|
||||
private DishImageMapper dishImageMapper;
|
||||
|
||||
@Override
|
||||
public Integer createDishImage(DishImageSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
DishImageDO dishImage = BeanUtils.toBean(createReqVO, DishImageDO.class);
|
||||
dishImageMapper.insert(dishImage);
|
||||
// 返回
|
||||
return dishImage.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDishImage(DishImageSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateDishImageExists(updateReqVO.getId());
|
||||
// 更新
|
||||
DishImageDO updateObj = BeanUtils.toBean(updateReqVO, DishImageDO.class);
|
||||
dishImageMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDishImage(Integer id) {
|
||||
// 校验存在
|
||||
validateDishImageExists(id);
|
||||
// 删除
|
||||
dishImageMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateDishImageExists(Integer id) {
|
||||
if (dishImageMapper.selectById(id) == null) {
|
||||
throw exception(DISH_IMAGE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DishImageDO getDishImage(Integer id) {
|
||||
return dishImageMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<DishImageDO> getDishImagePage(DishImagePageReqVO pageReqVO) {
|
||||
return dishImageMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user