package com.gear.admin.controller.swx;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
import javax.servlet.http.HttpServletResponse;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.gear.admin.vo.swx.NftVo;
|
import com.gear.admin.vo.swx.SmartOrderVo;
|
import com.gear.common.builder.WhereBuilder;
|
import com.gear.common.constant.SwxConstons;
|
import com.gear.common.vo.Result;
|
import com.gear.swx.domain.SwxMarketSmart;
|
import com.gear.swx.domain.SwxSmartOrder;
|
import com.gear.swx.domain.SwxUser;
|
import com.gear.swx.service.ISwxUserService;
|
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.gear.common.annotation.Log;
|
import com.gear.common.core.controller.BaseController;
|
import com.gear.common.enums.BusinessType;
|
import com.gear.swx.domain.SwxNft;
|
import com.gear.swx.service.ISwxNftService;
|
import com.gear.common.utils.poi.ExcelUtil;
|
|
/**
|
* nftController
|
*
|
* @author czx
|
* @date 2023-11-18
|
*/
|
@RestController
|
@RequestMapping("/swx/nft")
|
public class SwxNftController extends BaseController
|
{
|
@Autowired
|
private ISwxNftService swxNftService;
|
|
@Autowired
|
private ISwxUserService swxUserService;
|
/**
|
* 查询nft列表
|
*/
|
@PreAuthorize("@ss.hasPermi('swx:nft:list')")
|
@GetMapping("/list")
|
public Result<IPage<NftVo>> list(SwxNft swxNft,
|
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize){
|
QueryWrapper<SwxNft> queryWrapper = WhereBuilder.build(swxNft);
|
queryWrapper.lambda().orderByDesc(SwxNft::getCreateTime);
|
Page<SwxNft> page = new Page<SwxNft>(pageNo, pageSize);
|
IPage<SwxNft> pageList = swxNftService.page(page, queryWrapper);
|
IPage<NftVo> result = new Page<>();
|
List<NftVo> records = new ArrayList<>();
|
for(SwxNft item : pageList.getRecords()){
|
NftVo vo = new NftVo();
|
BeanUtils.copyProperties(item,vo);
|
if(item.getStatus() == SwxConstons.NOMARL_STATUS_NO){
|
SwxUser swxUser = swxUserService.getById(item.getUserId());
|
if (swxUser != null){
|
vo.setUserName(swxUser.getUserName());
|
vo.setPhone(swxUser.getPhone());
|
}
|
}
|
records.add(vo);
|
}
|
result.setRecords(records);
|
result.setCurrent(pageList.getCurrent());
|
result.setPages(pageList.getPages());
|
result.setSize(pageList.getSize());
|
result.setTotal(pageList.getTotal());
|
return Result.OK(result);
|
}
|
|
/**
|
* 导出nft列表
|
*/
|
@PreAuthorize("@ss.hasPermi('swx:nft:export')")
|
@Log(title = "nft", businessType = BusinessType.EXPORT)
|
@PostMapping("/export")
|
public void export(HttpServletResponse response, SwxNft swxNft){
|
QueryWrapper<SwxNft> queryWrapper = WhereBuilder.build(swxNft);
|
List<SwxNft> list = swxNftService.list(queryWrapper);
|
ExcelUtil<SwxNft> util = new ExcelUtil<SwxNft>(SwxNft.class);
|
util.exportExcel(response, list, "nft数据");
|
}
|
|
/**
|
* 获取nft详细信息
|
*/
|
@PreAuthorize("@ss.hasPermi('swx:nft:query')")
|
@GetMapping(value = "/{id}")
|
public Result<NftVo> getInfo(@PathVariable("id") String id){
|
SwxNft swxNft = swxNftService.getById(id);
|
if(swxNft==null) {
|
return Result.error("未找到对应数据");
|
}
|
NftVo vo = new NftVo();
|
BeanUtils.copyProperties(swxNft,vo);
|
SwxUser swxUser = swxUserService.getById(swxNft.getUserId());
|
if (swxUser != null) {
|
vo.setUserName(swxUser.getUserName());
|
vo.setPhone(swxUser.getPhone());
|
}
|
|
return Result.OK(vo);
|
}
|
|
/**
|
* 新增nft
|
*/
|
@PreAuthorize("@ss.hasPermi('swx:nft:add')")
|
@Log(title = "nft", businessType = BusinessType.INSERT)
|
@PostMapping
|
public Result<String> add(@RequestBody SwxNft swxNft){
|
swxNftService.save(swxNft);
|
return Result.ok("添加成功!");
|
}
|
|
/**
|
* 修改nft
|
*/
|
@PreAuthorize("@ss.hasPermi('swx:nft:edit')")
|
@Log(title = "nft", businessType = BusinessType.UPDATE)
|
@PutMapping
|
public Result<String> edit(@RequestBody SwxNft swxNft){
|
swxNftService.updateById(swxNft);
|
return Result.ok("编辑成功!");
|
}
|
|
/**
|
* 删除nft
|
*/
|
@PreAuthorize("@ss.hasPermi('swx:nft:remove')")
|
@Log(title = "nft", businessType = BusinessType.DELETE)
|
@DeleteMapping("/{ids}")
|
public Result<String> remove(@PathVariable List<String> ids){
|
swxNftService.removeBatchByIds(ids);
|
return Result.ok("删除成功!");
|
}
|
}
|