123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- package com.ruoyi.web.controller.system;
- import java.util.Arrays;
- import java.util.Date;
- import java.util.List;
- import java.util.stream.Collectors;
- import javax.servlet.http.HttpServletResponse;
- import com.ruoyi.common.utils.DateUtils;
- import com.ruoyi.system.domain.vo.CollectionsVo;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import org.springframework.beans.BeanUtils;
- import org.springframework.security.access.prepost.PreAuthorize;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import com.ruoyi.common.annotation.Log;
- import com.ruoyi.common.core.controller.BaseController;
- import com.ruoyi.common.core.domain.AjaxResult;
- import com.ruoyi.common.enums.BusinessType;
- import com.ruoyi.system.domain.PostCollectionsSystem;
- import com.ruoyi.system.service.IPostCollectionsSystemService;
- import com.ruoyi.common.utils.poi.ExcelUtil;
- import com.ruoyi.common.core.page.TableDataInfo;
- /**
- * 藏品套系Controller
- *
- * @author ruoyi
- * @date 2023-02-15
- */
- @Api(tags = "PostCollectionsSystemController",description = "藏品套系")
- @RestController
- @RequestMapping("/system/system")
- public class PostCollectionsSystemController extends BaseController
- {
- @Autowired
- private IPostCollectionsSystemService postCollectionsSystemService;
- /**
- * 查询藏品套系列表
- */
- @ApiOperation("查询藏品套系列表")
- @PreAuthorize("@ss.hasPermi('system:system:list')")
- @GetMapping("/list")
- public TableDataInfo list(PostCollectionsSystem postCollectionsSystem)
- {
- startPage();
- List<CollectionsVo> list = postCollectionsSystemService.selectPostCollectionsSystemListPage(postCollectionsSystem);
- return getDataTable(list);
- }
- /**
- * 导出藏品套系列表
- */
- @ApiOperation("导入藏品套系列表")
- @PreAuthorize("@ss.hasPermi('system:system:export')")
- @Log(title = "藏品套系", businessType = BusinessType.EXPORT)
- @PostMapping("/export")
- public void export(HttpServletResponse response, PostCollectionsSystem postCollectionsSystem,int type)
- {
- List<PostCollectionsSystem> list = postCollectionsSystemService.selectPostCollectionsSystemList(postCollectionsSystem);
- ExcelUtil<PostCollectionsSystem> util = new ExcelUtil<PostCollectionsSystem>(PostCollectionsSystem.class);
- util.exportExcel(response, list, "藏品套系数据");
- }
- /**
- * 获取藏品套系详细信息
- */
- @ApiOperation("获取藏品套系详细信息")
- @PreAuthorize("@ss.hasPermi('system:system:query')")
- @GetMapping(value = "/{id}")
- public AjaxResult getInfo(@PathVariable("id") Long id)
- {
- return success(postCollectionsSystemService.selectPostCollectionsSystemById(id));
- }
- /**
- * 新增藏品套系
- */
- @ApiOperation("新增藏品套系")
- @PreAuthorize("@ss.hasPermi('system:system:add')")
- @Log(title = "藏品套系", businessType = BusinessType.INSERT)
- @PostMapping
- public AjaxResult add(@RequestBody PostCollectionsSystem postCollectionsSystem)
- {
- if (!getUsername().equals("admin")){
- //warn:601
- return warn("仅管理员拥有该权限");
- }
- //截止时间早于起售时间
- if (postCollectionsSystem.getStartTime().after(postCollectionsSystem.getEndTime())){
- return warn("请设置正确的套系时间");
- }
- //当套系售卖截止时间早于创建时间
- if (postCollectionsSystem.getEndTime().before(DateUtils.getNowDate())){
- return warn("请设置正确的套系时间");
- }
- //判断套系名称是否重复
- if (postCollectionsSystemService.selectPostCollectionsSystemByName(postCollectionsSystem) > 0){
- return warn("该套系名称已存在");
- }
- return toAjax(postCollectionsSystemService.insertPostCollectionsSystem(postCollectionsSystem));
- }
- /**
- * 修改藏品套系
- */
- @ApiOperation("修改藏品套系")
- @PreAuthorize("@ss.hasPermi('system:system:edit')")
- @Log(title = "藏品套系", businessType = BusinessType.UPDATE)
- @PutMapping
- public AjaxResult edit(@RequestBody PostCollectionsSystem postCollectionsSystem)
- {
- return toAjax(postCollectionsSystemService.updatePostCollectionsSystem(postCollectionsSystem));
- }
- /**
- * 删除藏品套系
- */
- @ApiOperation("删除藏品套系")
- @PreAuthorize("@ss.hasPermi('system:system:remove')")
- @Log(title = "藏品套系", businessType = BusinessType.DELETE)
- @DeleteMapping("/{ids}")
- public AjaxResult remove(@PathVariable Long[] ids)
- {
- return toAjax(postCollectionsSystemService.deletePostCollectionsSystemByIds(ids));
- }
- /**
- * 根据套系名称进行查询
- * @param title
- * @param TimeLeft
- * @param TimeRight
- * @return
- */
- @ApiOperation("根据套系名称进行查询")
- @PreAuthorize("@ss.hasPermi('system:collections:queryCollections')")
- @GetMapping("/queryCollections")
- public TableDataInfo list(@RequestParam(value="title",required = false)String title,
- @RequestParam(value="TimeLeft",required = false) Date TimeLeft,
- @RequestParam(value="TimeRight",required = false) Date TimeRight)
- {
- startPage();
- List<PostCollectionsSystem> list= postCollectionsSystemService.selectByTitleAndTime(title,TimeLeft,TimeRight);
- return getDataTable(list);
- }
- }
|