收藏,暂时没有国内外标准数据表

This commit is contained in:
caozhen
2023-09-07 15:54:44 +08:00
parent 95dc1c7396
commit 4d7ad478c4
6 changed files with 376 additions and 0 deletions
@@ -0,0 +1,74 @@
package com.jero.modules.personal.controller;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import com.jero.common.api.vo.Result;
import com.jero.modules.personal.entity.LawsStandardCollection;
import com.jero.modules.personal.service.ILawsStandardCollectionService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.extern.slf4j.Slf4j;
import com.jero.common.system.base.controller.JeroController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.jero.common.aspect.annotation.AutoLog;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.functions.T;
/**
* @Description: 标准收藏
* @Author: jero-boot
* @Date: 2023-09-07
* @Version: V1.0
*/
@Api(tags="标准收藏")
@RestController
@RequestMapping("/personal/lawsStandardCollection")
@Slf4j
public class LawsStandardCollectionController extends JeroController<LawsStandardCollection, ILawsStandardCollectionService> {
@Autowired
private ILawsStandardCollectionService lawsStandardCollectionService;
/**
* 分页列表查询
*/
@AutoLog(value = "标准收藏-我的收藏分页列表查询")
@ApiOperation(value="标准收藏-分页列表查询", notes="标准收藏-我的收藏分页列表查询")
@GetMapping(value = "/page")
public Result<IPage<LawsStandardCollection>> queryPageList(LawsStandardCollection lawsStandardCollection,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
IPage<LawsStandardCollection> pageList = lawsStandardCollectionService.queryPage(lawsStandardCollection, pageNo, pageSize, req);
return Result.OK(pageList);
}
/**
* 收藏
*/
@AutoLog(value = "标准收藏-收藏")
@ApiOperation(value="标准收藏-收藏", notes="标准收藏-收藏")
@PostMapping(value = "/add")
public Result<T> add(@Validated @RequestBody LawsStandardCollection lawsStandardCollection) {
lawsStandardCollectionService.add(lawsStandardCollection);
return Result.OK("操作成功!");
}
/**
* 取消收藏
*/
@AutoLog(value = "标准收藏-取消收藏")
@ApiOperation(value="标准收藏-取消收藏", notes="标准收藏-取消收藏")
@PostMapping(value = "/delete")
public Result<T> delete(@RequestBody Map<String, String> map) {
if(!map.containsKey("id") || StringUtils.isEmpty(map.get("id"))){
return Result.error("请选择数据!");
}
lawsStandardCollectionService.deleteById(map.get("id"));
return Result.OK("删除成功!");
}
}
@@ -0,0 +1,111 @@
package com.jero.modules.personal.entity;
import java.io.Serializable;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @Description: 标准收藏
* @Author: jero-boot
* @Date: 2023-09-07
* @Version: V1.0
*/
@Data
@TableName("laws_standard_collection")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="laws_standard_collection对象", description="标准收藏")
public class LawsStandardCollection implements Serializable {
private static final long serialVersionUID = 1L;
/**主键*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键")
private String id;
/**收藏人ID*/
@ApiModelProperty(value = "收藏人ID")
private String collectorId;
/**收藏标准来源(1国内、2海外、3企标)*/
@ApiModelProperty(value = "收藏标准来源(1国内、2海外、3企标)")
private String source;
/**标准ID*/
@ApiModelProperty(value = "标准ID")
private String standardId;
/**标准类别(GB、GB/T)*/
@ApiModelProperty(value = "标准类别(GB、GB/T)")
private String standardClass;
/**标准编号*/
@ApiModelProperty(value = "标准编号")
private String standardNumber;
/**标准名称*/
@ApiModelProperty(value = "标准名称")
private String standardName;
/**创建人*/
@ApiModelProperty(value = "创建人")
private String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建日期")
private Date createTime;
/**更新人*/
@ApiModelProperty(value = "更新人")
private String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新日期")
private Date updateTime;
/**所属部门*/
@ApiModelProperty(value = "所属部门")
private String orgCode;
/**发布日期*/
@TableField(exist = false)
@ApiModelProperty(value = "发布日期")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date releaseDate;
/**新车型实施日期*/
@TableField(exist = false)
@ApiModelProperty(value = "新车型实施日期")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date newModelImplementationDate;
/**在产车实施日期*/
@TableField(exist = false)
@ApiModelProperty(value = "在产车实施日期")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date onTheProductionDate;
/**标准状态*/
@TableField(exist = false)
@ApiModelProperty(value = "标准状态")
private String standardState;
}
@@ -0,0 +1,14 @@
package com.jero.modules.personal.mapper;
import com.jero.modules.personal.entity.LawsStandardCollection;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: 标准收藏
* @Author: jero-boot
* @Date: 2023-09-07
* @Version: V1.0
*/
public interface LawsStandardCollectionMapper extends BaseMapper<LawsStandardCollection> {
}
@@ -0,0 +1,16 @@
<?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.jero.modules.personal.mapper.LawsStandardCollectionMapper">
<resultMap id="LawsStandardCollectionResultMap" type="com.jero.modules.personal.entity.LawsStandardCollection">
<id column="id" property="id" />
<result column="create_by" property="createBy" />
<result column="create_time" property="createTime" />
<result column="update_by" property="updateBy" />
<result column="update_time" property="updateTime" />
<result column="org_code" property="orgCode" />
<result column="collector_id" property="collectorId" />
<result column="source" property="source" />
<result column="standard_id" property="standardId" />
<result column="del_flag" property="delFlag" />
</resultMap>
</mapper>
@@ -0,0 +1,38 @@
package com.jero.modules.personal.service;
import com.jero.modules.personal.entity.LawsStandardCollection;
import com.baomidou.mybatisplus.extension.service.IService;
import javax.servlet.http.HttpServletRequest;
import com.baomidou.mybatisplus.core.metadata.IPage;
/**
* @Description: 标准收藏
* @Author: jero-boot
* @Date: 2023-09-07
* @Version: V1.0
*/
public interface ILawsStandardCollectionService extends IService<LawsStandardCollection> {
/**
* 分页查询
*
* @param lawsStandardCollection
* @param pageNo
* @param pageSize
* @param req
* @return
*/
IPage<LawsStandardCollection> queryPage(LawsStandardCollection lawsStandardCollection, Integer pageNo, Integer pageSize, HttpServletRequest req);
/**
* 收藏
*/
void add(LawsStandardCollection lawsStandardCollection);
/**
* 取消收藏
*/
void deleteById(String id);
}
@@ -0,0 +1,123 @@
package com.jero.modules.personal.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jero.common.system.vo.LoginUser;
import com.jero.modules.laws.enterprise.entity.EnterpriseStandard;
import com.jero.modules.laws.enterprise.service.EnterpriseStandardService;
import com.jero.modules.personal.entity.LawsStandardCollection;
import com.jero.modules.personal.mapper.LawsStandardCollectionMapper;
import com.jero.modules.personal.service.ILawsStandardCollectionService;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.jero.common.exception.JeroBootException;
import java.util.Date;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.common.system.query.QueryGenerator;
import javax.servlet.http.HttpServletRequest;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
/**
* @Description: 标准收藏
* @Author: jero-boot
* @Date: 2023-09-07
* @Version: V1.0
*/
@Service
@Transactional(rollbackFor = JeroBootException.class)
public class LawsStandardCollectionServiceImpl extends ServiceImpl<LawsStandardCollectionMapper, LawsStandardCollection> implements ILawsStandardCollectionService {
// @Autowired
// private ILawsDomesticStandardService lawsDomesticStandardService; //国内标准
// @Autowired
// private ILawsOverseasStandardService lawsOverseasStandardService; //海外标准
@Autowired
private EnterpriseStandardService enterpriseStandardService; //企业标准
/**
* 列表查询
*/
@Override
public IPage<LawsStandardCollection> queryPage(LawsStandardCollection lawsStandardCollection, Integer pageNo, Integer pageSize,
HttpServletRequest req) {
//只看我的收藏
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
lawsStandardCollection.setCollectorId(sysUser.getId());
QueryWrapper<LawsStandardCollection> queryWrapper = QueryGenerator.initQueryWrapper(lawsStandardCollection, req.getParameterMap());
Page<LawsStandardCollection> page = new Page<>(pageNo, pageSize);
Page<LawsStandardCollection> collectionPage = page(page, queryWrapper);
// this.standardAssignment(collectionPage.getRecords());
return page(page, queryWrapper);
}
public void standardAssignment(List<LawsStandardCollection> list){
for (LawsStandardCollection collection : list) {
String standardId = collection.getStandardId();
String source = collection.getSource();
if ("1".equals(source)){
//查询国内标准数据,赋值给collection
}
if ("2".equals(source)){
//查询海外标准数据,赋值给collection
}
if ("3".equals(source)){
//查询企业标准数据,赋值给collection
EnterpriseStandard standard = enterpriseStandardService.getById(standardId);
collection.setReleaseDate(standard.getReleaseDate());
}
}
}
/**
* 收藏
*/
@Override
public void add(LawsStandardCollection lawsStandardCollection) {
//下面这些判断是给前端联调时给前端看的
String standardClass = lawsStandardCollection.getStandardClass();
if (StringUtils.isBlank(standardClass)){
throw new JeroBootException("standardClass标准类别参数不能为空");
}
String standardNumber = lawsStandardCollection.getStandardNumber();
if (StringUtils.isBlank(standardNumber)){
throw new JeroBootException("standardNumber标准编号参数不能为空");
}
String standardName = lawsStandardCollection.getStandardName();
if (StringUtils.isBlank(standardName)){
throw new JeroBootException("standardName标准名称参数不能为空");
}
String source1 = lawsStandardCollection.getSource();
if (StringUtils.isBlank(source1)){
throw new JeroBootException("source1收藏标准来源(1国内、2海外、3企标)参数不能为空");
}
String collectionStandardId = lawsStandardCollection.getStandardId();
if (StringUtils.isBlank(collectionStandardId)){
throw new JeroBootException("standardId标准ID(参数不能为空");
}
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
lawsStandardCollection.setCollectorId(sysUser.getId());
Date now = new Date();
lawsStandardCollection.setCreateTime(now);
lawsStandardCollection.setUpdateTime(now);
save(lawsStandardCollection);
}
/**
* 取消收藏
*/
@Override
public void deleteById(String id) {
removeById(id);
}
}