feat 修改标准合规评估结果接口

This commit is contained in:
yinglong zhang
2021-06-21 17:49:39 +08:00
parent ee13575b53
commit 487885d859
8 changed files with 298 additions and 6 deletions
@@ -0,0 +1,134 @@
package com.adc.da.slrs.sarPersonalCenter.controller;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.slrs.sarPersonalCenter.entity.SarUserStarEO;
import com.adc.da.slrs.sarPersonalCenter.service.ISarUserStarService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.adc.da.slrs.sarPersonalCenter.entity.SarUserStar;
import io.swagger.annotations.Api;
import com.adc.da.base.web.BaseController;
import java.util.Date;
/**
* <p>
* 前端控制器
* </p>
*
* @author zyl
* @since 2021-06-21
*/
@RestController
@Api(description = "福田标准法规--个人中心--我的收藏")
@RequestMapping("/${restPath}/sarPersonalCenter/sar-user-star")
public class SarUserStarController extends BaseController<SarUserStar> {
@Autowired
private ISarUserStarService iSarUserStarService;
@ApiOperation("获取用户收藏列表")
@GetMapping("/getList")
public ResponseMessage<IPage<SarUserStar>> getUserStarList(SarUserStarEO sarUserStarEO) {
if (sarUserStarEO.getUserId() == null) {
return Result.error("userId不能为空");
} else {
if (sarUserStarEO.getSize() == null || sarUserStarEO.getSize() <= 0) sarUserStarEO.setSize(20);
if (sarUserStarEO.getCurrent() == null || sarUserStarEO.getCurrent() <= 0) sarUserStarEO.setCurrent(1);
QueryWrapper<SarUserStar> wrapper = new QueryWrapper<>();
wrapper.eq("user_id", sarUserStarEO.getUserId());
if(sarUserStarEO.getType()!=null)wrapper.like("type",sarUserStarEO.getType());
if(sarUserStarEO.getName()!=null)wrapper.like("name",sarUserStarEO.getName());
if(sarUserStarEO.getModular()!=null)wrapper.like("modular",sarUserStarEO.getModular());
if(sarUserStarEO.getInfo()!=null)wrapper.like("info",sarUserStarEO.getInfo());
if(sarUserStarEO.getUrl()!=null)wrapper.like("url",sarUserStarEO.getUrl());
IPage<SarUserStar> page = iSarUserStarService.page(new Page<>(sarUserStarEO.getCurrent(), sarUserStarEO.getSize()), wrapper);
while (page.getRecords().remove(null)) ;
return Result.success(page);
}
}
@ApiOperation("批量删除用户收藏")
@PostMapping("/deleteList")
public ResponseMessage<IPage<SarUserStar>> deleteList(@RequestBody SarUserStarEO sarUserStars) {
if (sarUserStars.getUserId() == null) {
return Result.error("userId不能为空");
}
if (!(sarUserStars.getSarUserStars() == null || sarUserStars.getSarUserStars().size() <= 0)) {
for (SarUserStar sarUserStar : sarUserStars.getSarUserStars()) {
if (sarUserStar.getId() != null) {
QueryWrapper<SarUserStar> sarUserStarQueryWrapper = new QueryWrapper<>();
sarUserStarQueryWrapper.eq("id", sarUserStar.getId());
sarUserStarQueryWrapper.eq("user_id", sarUserStars.getUserId());
iSarUserStarService.remove(sarUserStarQueryWrapper);
}
}
}
return getUserStarList(sarUserStars);
}
@ApiOperation("删除用户收藏")
@PostMapping("/delete")
public ResponseMessage<Boolean> deleteById(@RequestBody SarUserStarEO sarUserStars) {
if (sarUserStars.getUserId() == null) {
return Result.error("userId不能为空");
}
if (!(sarUserStars.getId() == null && sarUserStars.getUrl() == null)) {
return Result.error("url或id不能为空");
}
QueryWrapper<SarUserStar> sarUserStarQueryWrapper = new QueryWrapper<>();
if(sarUserStars.getId()!=null)sarUserStarQueryWrapper.eq("id", sarUserStars.getId());
else sarUserStarQueryWrapper.eq("url", sarUserStars.getUrl());
sarUserStarQueryWrapper.eq("user_id", sarUserStars.getUserId());
iSarUserStarService.remove(sarUserStarQueryWrapper);
return Result.success(iSarUserStarService.remove(sarUserStarQueryWrapper));
}
@ApiOperation("添加用户收藏")
@PostMapping("/addStar")
public ResponseMessage<Boolean> addStar(@RequestBody SarUserStar sarUserStar) {
if (sarUserStar.getUserId() == null) {
return Result.error("userId不能为空");
}
if (sarUserStar.getUrl() == null
&& sarUserStar.getModular() == null
&& sarUserStar.getName() == null
&& sarUserStar.getType() == null) {
return Result.error("数据有误");
}
sarUserStar.setId(null);
sarUserStar.setCreateTime(new Date());
return Result.success(iSarUserStarService.save(sarUserStar));
}
@ApiOperation("获取当前用户是否收藏该页面")
@GetMapping("/isStar")
public ResponseMessage<Boolean> isStar(String userId, String url) {
if (userId == null) {
return Result.error("userId不能为空");
}
if (url == null) {
return Result.error("url不能为空");
}
QueryWrapper<SarUserStar> sarUserStarQueryWrapper = new QueryWrapper<>();
sarUserStarQueryWrapper.eq("user_id", userId);
sarUserStarQueryWrapper.eq("url", url);
int count = iSarUserStarService.count(sarUserStarQueryWrapper);
return Result.success(count > 0);
}
}
@@ -0,0 +1,16 @@
package com.adc.da.slrs.sarPersonalCenter.dao;
import com.adc.da.slrs.sarPersonalCenter.entity.SarUserStar;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author zyl
* @since 2021-06-21
*/
public interface SarUserStarDao extends BaseMapper<SarUserStar> {
}
@@ -0,0 +1,55 @@
package com.adc.da.slrs.sarPersonalCenter.entity;
import com.adc.da.base.entity.BaseEntity;
import java.time.LocalDateTime;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
/**
* <p>
*
* </p>
*
* @author zyl
* @since 2021-06-21
*/
@EqualsAndHashCode(callSuper = true)
@Data
@ApiModel(value="SarUserStar对象", description="")
public class SarUserStar extends BaseEntity {
@ApiModelProperty("id")
private String id;
@ApiModelProperty(value = "收藏名")
private String name;
@ApiModelProperty(value = "收藏类型")
private String type;
@ApiModelProperty(value = "收藏具体信息")
private String info;
@ApiModelProperty(value = "用户id")
private String userId;
@ApiModelProperty(value = "所属模块")
private String modular;
@ApiModelProperty(value = "创建时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
@ApiModelProperty(value = "该收藏对应的路由")
private String url;
}
@@ -0,0 +1,25 @@
package com.adc.da.slrs.sarPersonalCenter.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.List;
@Data
@Accessors(chain = true)
@ApiModel(value="SarUserStar批量操作对象", description="")
public class SarUserStarEO extends SarUserStar{
@ApiModelProperty("当页数量")
private Integer size;
@ApiModelProperty("当前页数")
private Integer current;
@ApiModelProperty("操作信息")
private List<SarUserStar> sarUserStars;
}
@@ -0,0 +1,16 @@
package com.adc.da.slrs.sarPersonalCenter.service;
import com.adc.da.slrs.sarPersonalCenter.entity.SarUserStar;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author zyl
* @since 2021-06-21
*/
public interface ISarUserStarService extends IService<SarUserStar> {
}
@@ -0,0 +1,20 @@
package com.adc.da.slrs.sarPersonalCenter.service.impl;
import com.adc.da.slrs.sarPersonalCenter.entity.SarUserStar;
import com.adc.da.slrs.sarPersonalCenter.dao.SarUserStarDao;
import com.adc.da.slrs.sarPersonalCenter.service.ISarUserStarService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author zyl
* @since 2021-06-21
*/
@Service
public class SarUserStarServiceImpl extends ServiceImpl<SarUserStarDao, SarUserStar> implements ISarUserStarService {
}
@@ -61,7 +61,11 @@ public class SarStandardComplianceAssessResultController {
if (eo.getStandNumber() != null && !eo.getStandNumber().trim().equals("")) {
queryWrapper.like("STAND_NUMBER",eo.getStandNumber().trim());
}
return Result.success(iSarStandardComplianceProductAssessService.page(iPage,queryWrapper));
IPage<SarStandardComplianceProductAssess> page = iSarStandardComplianceProductAssessService.page(iPage, queryWrapper);
while(page.getRecords().remove(null));
return Result.success(page);
}else {
if(eo.getPosition()==1){
QueryWrapper<SarInterpretationNationalStandard> queryWrapper = new QueryWrapper<>();
@@ -73,7 +77,10 @@ public class SarStandardComplianceAssessResultController {
if (eo.getStandNumber() != null && !eo.getStandNumber().trim().equals("")) {
queryWrapper.like("STAND_NUMBER",eo.getStandNumber().trim());
}
return Result.success(iSarInterpretationNationalStandardService.page(iPage,queryWrapper));
IPage<SarInterpretationNationalStandard> page = iSarInterpretationNationalStandardService.page(iPage, queryWrapper);
while(page.getRecords().remove(null));
return Result.success(page);
}else{
QueryWrapper<SarInterpretationForeignStandard> queryWrapper = new QueryWrapper<>();
IPage<SarInterpretationForeignStandard> iPage = new Page<>(eo.getCurrent(), eo.getSize());
@@ -84,7 +91,10 @@ public class SarStandardComplianceAssessResultController {
if (eo.getStandNumber() != null && !eo.getStandNumber().trim().equals("")) {
queryWrapper.like("STAND_NUMBER",eo.getStandNumber().trim());
}
return Result.success(iSarInterpretationForeignStandardService.page(iPage,queryWrapper));
IPage<SarInterpretationForeignStandard> page = iSarInterpretationForeignStandardService.page(iPage, queryWrapper);
while(page.getRecords().remove(null));
return Result.success(page);
}
}
}
@@ -96,7 +106,12 @@ public class SarStandardComplianceAssessResultController {
if (eo.getProductName() != null) queryWrapper.like("product_name", eo.getProductName());
if (eo.getStandId() != null) queryWrapper.like("STAND_ID", eo.getStandId());
if (eo.getInterpretationTime() != null) queryWrapper.eq("INTERPRETATION_TIME", eo.getInterpretationTime());
return Result.success(iSarStandardComplianceProductAssessService.page(iPage, queryWrapper));
IPage<SarStandardComplianceProductAssess> page = iSarStandardComplianceProductAssessService.page(iPage, queryWrapper);
while(page.getRecords().remove(null));
return Result.success(page);
}
@ApiOperation(value = "条件查询技术审核符合性清单")
@@ -107,13 +122,19 @@ public class SarStandardComplianceAssessResultController {
QueryWrapper<SarInterpretationNationalStandard> queryWrapper = new QueryWrapper<>();
if (eo.getInterpretationTime() != null) queryWrapper.eq("INTERPRETATION_TIME", eo.getInterpretationTime());
if(eo.getStandId()!=null)queryWrapper.eq("STAND_ID",eo.getStandId());
return Result.success(iSarInterpretationNationalStandardService.page(iPage, queryWrapper));
IPage<SarInterpretationNationalStandard> page = iSarInterpretationNationalStandardService.page(iPage, queryWrapper);
while(page.getRecords().remove(null));
return Result.success(page);
} else {
IPage<SarInterpretationForeignStandard> iPage = new Page<>(eo.getCurrent(), eo.getSize());
QueryWrapper<SarInterpretationForeignStandard> queryWrapper = new QueryWrapper<>();
if (eo.getInterpretationTime() != null) queryWrapper.eq("INTERPRETATION_TIME", eo.getInterpretationTime());
if(eo.getStandId()!=null)queryWrapper.eq("STAND_ID",eo.getStandId());
return Result.success(iSarInterpretationForeignStandardService.page(iPage, queryWrapper));
IPage<SarInterpretationForeignStandard> page = iSarInterpretationForeignStandardService.page(iPage, queryWrapper);
while(page.getRecords().remove(null));
return Result.success(page);
}
}
}
@@ -0,0 +1,5 @@
<?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="com.adc.da.slrs.sarPersonalCenter.dao.SarUserStarDao">
</mapper>