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.IdentificationVo;
|
import com.gear.admin.vo.swx.MarketCantractsVo;
|
import com.gear.common.builder.WhereBuilder;
|
import com.gear.common.vo.Result;
|
import com.gear.finance.domain.FinanceIdentificationRecord;
|
import com.gear.swx.domain.*;
|
import com.gear.swx.service.ISwxUserService;
|
import io.jsonwebtoken.lang.Collections;
|
import org.apache.logging.log4j.util.Strings;
|
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.service.ISwxIdentificationService;
|
import com.gear.common.utils.poi.ExcelUtil;
|
|
/**
|
* 认证记录Controller
|
*
|
* @author czx
|
* @date 2023-11-25
|
*/
|
@RestController
|
@RequestMapping("/swx/identification")
|
public class SwxIdentificationController extends BaseController
|
{
|
@Autowired
|
private ISwxIdentificationService swxIdentificationService;
|
|
@Autowired
|
private ISwxUserService swxUserService;
|
|
|
/**
|
* 查询认证记录列表
|
*/
|
@PreAuthorize("@ss.hasPermi('swx:identification:list')")
|
@GetMapping("/list")
|
public Result<IPage<IdentificationVo>> list(IdentificationVo swxIdentification,
|
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize){
|
|
|
QueryWrapper<SwxIdentification> queryWrapper = new QueryWrapper<>();
|
if(!Strings.isEmpty(swxIdentification.getPhone()) || !Strings.isEmpty(swxIdentification.getUserName())){
|
QueryWrapper<SwxUser> userQueryWrapper = new QueryWrapper<>();
|
if(!Strings.isEmpty(swxIdentification.getUserName())){
|
userQueryWrapper.lambda().like(SwxUser::getUserName,swxIdentification.getUserName());
|
}
|
if(!Strings.isEmpty(swxIdentification.getPhone())){
|
userQueryWrapper.lambda().like(SwxUser::getPhone,swxIdentification.getPhone());
|
}
|
|
List<SwxUser> list = swxUserService.list(userQueryWrapper);
|
List<String> ids = new ArrayList<>();
|
if(!Collections.isEmpty(list)){
|
for (SwxUser item : list){
|
ids.add(item.getId());
|
}
|
}else{
|
ids.add("");
|
}
|
queryWrapper.lambda().in(SwxIdentification::getUserId,ids);
|
}
|
if(swxIdentification.getStatus() != null){
|
queryWrapper.lambda().eq(SwxIdentification::getStatus,swxIdentification.getStatus());
|
}
|
queryWrapper.lambda().orderByDesc(SwxIdentification::getCreateTime);
|
Page<SwxIdentification> page = new Page<SwxIdentification>(pageNo, pageSize);
|
IPage<SwxIdentification> pageList = swxIdentificationService.page(page, queryWrapper);
|
IPage<IdentificationVo> result = new Page<>();
|
List<IdentificationVo> records = new ArrayList<>();
|
for(SwxIdentification item : pageList.getRecords()){
|
IdentificationVo vo = new IdentificationVo();
|
BeanUtils.copyProperties(item,vo);
|
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);
|
}
|
|
/**
|
* 导出认证记录列表
|
*/
|
@PreAuthorize("@ss.hasPermi('swx:identification:export')")
|
@Log(title = "认证记录", businessType = BusinessType.EXPORT)
|
@PostMapping("/export")
|
public void export(HttpServletResponse response, SwxIdentification swxIdentification){
|
QueryWrapper<SwxIdentification> queryWrapper = WhereBuilder.build(swxIdentification);
|
List<SwxIdentification> list = swxIdentificationService.list(queryWrapper);
|
ExcelUtil<SwxIdentification> util = new ExcelUtil<SwxIdentification>(SwxIdentification.class);
|
util.exportExcel(response, list, "认证记录数据");
|
}
|
|
/**
|
* 获取认证记录详细信息
|
*/
|
@PreAuthorize("@ss.hasPermi('swx:identification:query')")
|
@GetMapping(value = "/{id}")
|
public Result<IdentificationVo> getInfo(@PathVariable("id") String id){
|
IdentificationVo vo = new IdentificationVo();
|
SwxIdentification swxIdentification = swxIdentificationService.getById(id);
|
|
if(swxIdentification==null) {
|
return Result.error("未找到对应数据");
|
}
|
BeanUtils.copyProperties(swxIdentification,vo);
|
SwxUser swxUser = swxUserService.getById(swxIdentification.getUserId());
|
vo.setUserName(swxUser.getUserName());
|
return Result.OK(vo);
|
}
|
|
|
|
/**
|
* 修改认证记录
|
*/
|
@PreAuthorize("@ss.hasPermi('swx:identification:edit')")
|
@Log(title = "认证记录", businessType = BusinessType.UPDATE)
|
@PutMapping
|
public Result<String> edit(@RequestBody SwxIdentification swxIdentification){
|
//判断如果修改状态的话,那么将用户的认证记录状态也修改
|
if (swxIdentification.getStatus() != null){
|
SwxIdentification old = swxIdentificationService.getById(swxIdentification.getId());
|
SwxUser swxUser = swxUserService.getById(old.getUserId());
|
if (swxUser != null){
|
swxUser.setIdefinderStatus(swxIdentification.getStatus());
|
swxUserService.updateById(swxUser);
|
}
|
}
|
swxIdentificationService.updateById(swxIdentification);
|
return Result.ok("编辑成功!");
|
}
|
|
|
/**
|
* 新增实名认证记录
|
*/
|
@PreAuthorize("@ss.hasPermi('swx:identification:add')")
|
@Log(title = "实名认证记录", businessType = BusinessType.INSERT)
|
@PostMapping
|
public Result<String> add(@RequestBody SwxIdentification swxIdentification){
|
swxIdentificationService.save(swxIdentification);
|
return Result.ok("添加成功!");
|
}
|
|
}
|