Commit 65baa188 authored by yaobaizheng's avatar yaobaizheng

替换雪花id

parent 0f3b7bbf
......@@ -14,7 +14,10 @@ import java.util.Date;
public class DevelopmentInfoListVO implements Serializable {
@ApiModelProperty(value = "主键id")
private Integer id;
private Long id;
@ApiModelProperty(value = "业务id")
private Long businessId;
/**
* 所属都市圈id
......
......@@ -15,7 +15,10 @@ public class ParkInfoListVO implements Serializable {
* 主键id
*/
@ApiModelProperty(value = "主键id")
private Integer id;
private Long id;
@ApiModelProperty(value = "业务id")
private Long businessId;
/**
* 园区名称
......
package com.lyy.admin.common.config;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.Arrays;
/**
* @author: zhouxudong
* @version: 1.0
* @createTime: 2023/11/17 16:46
* @description:
*/
@Slf4j
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
private final String[] createNeedToFill = {
"createBy", "createTime", "updateBy", "updateTime", "version","businessId"
};
private final String[] updateNeedToFill = {"updateBy", "updateTime"};
private final Class[] ignoreAutoFillEntity = {};
@Override
public void insertFill(MetaObject metaObject) {
if (!ignoreAutoFill(metaObject)) {
autofill(metaObject, createNeedToFill);
}
}
@Override
public void updateFill(MetaObject metaObject) {
if (!ignoreAutoFill(metaObject)) {
autofill(metaObject, updateNeedToFill);
}
}
private void autofill(MetaObject metaObject, String[] arrayNeedToFill) {
Arrays.stream(arrayNeedToFill)
.forEach(
property -> {
if (metaObject.hasSetter(property)) {
// if (property.endsWith("By")) {
// this.setFieldValByName(property, "", metaObject);
// }
// if (property.endsWith("Time")) {
// this.setFieldValByName(property, LocalDateTime.now(), metaObject);
// }
// if (property.equals("version")) {
// this.setFieldValByName(property, 1, metaObject);
// }
if (property.equals("businessId")) {
Snowflake snowflake = IdUtil.getSnowflake();
this.setFieldValByName(property, snowflake.nextId(), metaObject);
}
}
});
}
private Boolean ignoreAutoFill(MetaObject metaObject) {
return Arrays.stream(ignoreAutoFillEntity)
.anyMatch(entity -> metaObject.getOriginalObject().getClass() == entity);
}
}
package com.lyy.admin.common.constant;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.Version;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.*;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @Author:zhouxudong
* @version: 1.0
* @Date: 2023/11/23 16:57
* @Description:
*/
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@ToString
public abstract class BaseEntity extends Model implements Serializable {
@TableField(
value = "business_id",
fill = FieldFill.INSERT
)
protected Long businessId;
}
......@@ -106,8 +106,8 @@ public class ApiController extends BaseController {
@GetMapping("/park/detail/{id}")
@ApiOperation(value = "园区详情信息", notes = "rest风格传参,将参数拼接在url上")
@ApiImplicitParam(name = "id", value = "园区id", type = "Integer")
public ParkInfoAllVO parkDetail(@PathVariable Integer id) {
@ApiImplicitParam(name = "id", value = "园区id", type = "Long")
public ParkInfoAllVO parkDetail(@PathVariable Long id) {
return parkInfoService.getParkInfo(id, 0, true);
}
......@@ -138,8 +138,8 @@ public class ApiController extends BaseController {
}
@GetMapping("/development/detail/{id}")
@ApiOperation(value = "开发区详情",notes = "rest风格传参,将参数拼接在url上")
@ApiImplicitParam(name = "id", value = "开发区id", type = "Integer")
public DevelopmentInfoAllVO developmentDetail(@PathVariable Integer id) {
@ApiImplicitParam(name = "id", value = "开发区id", type = "Long")
public DevelopmentInfoAllVO developmentDetail(@PathVariable Long id) {
return developmentInfoService.getDevelopmentInfo(id,0,true);
}
......
......@@ -55,8 +55,9 @@ public class DevelopmentInfoController extends BaseController {
List<DevelopmentInfoListVO> developmentInfoVOs = developmentInfos.stream().map(developmentInfo -> {
DevelopmentInfoListVO developmentInfoVO = new DevelopmentInfoListVO();
BeanUtils.copyProperties(developmentInfo, developmentInfoVO);
developmentInfoVO.setId(developmentInfo.getBusinessId());
if(login){
boolean existInfo = developmentInfoSerivce.isExistInfo(getUserInfo().getUserId(), developmentInfoVO.getId());
boolean existInfo = developmentInfoSerivce.isExistInfo(getUserInfo().getUserId(), developmentInfo.getId());
if (existInfo) {
developmentInfoVO.setIsCollection(DevelopmentStatusEnum.IS_COLLECTION_1.getCode());
} else {
......@@ -70,8 +71,8 @@ public class DevelopmentInfoController extends BaseController {
@GetMapping("/get/{id}")
@ResponseBody
@ApiOperation(value = "某个开发区信息",notes = "rest风格传参,将参数拼接在url上")
@ApiImplicitParam(name = "id", value = "开发区id", type = "Integer")
public DevelopmentInfoAllVO get(@PathVariable Integer id) {
@ApiImplicitParam(name = "id", value = "开发区id", type = "Long")
public DevelopmentInfoAllVO get(@PathVariable Long id) {
return developmentInfoSerivce.getDevelopmentInfo(id,getUserInfo().getUserId(),getUserInfo().getIsMembership());
}
......
......@@ -65,6 +65,7 @@ public class ParkInfoController extends BaseController {
List<ParkInfoListVO> parkInfoListVOs = lists.stream().map(parkInfo -> {
ParkInfoListVO parkInfoListVO = new ParkInfoListVO();
BeanUtils.copyProperties(parkInfo, parkInfoListVO);
parkInfoListVO.setId(parkInfoListVO.getBusinessId());
//是否收藏
if (login) {
boolean existInfo = parkInfoService.isExistInfo(getUserInfo().getUserId(), parkInfo.getId());
......@@ -84,8 +85,8 @@ public class ParkInfoController extends BaseController {
@GetMapping("/get/{id}")
@ResponseBody
@ApiOperation(value = "获取某个园区信息", notes = "rest风格传参,将参数拼接在url上")
@ApiImplicitParam(name = "id", value = "园区id", type = "Integer")
public ParkInfoAllVO get(@PathVariable Integer id) {
@ApiImplicitParam(name = "id", value = "园区id", type = "Long")
public ParkInfoAllVO get(@PathVariable Long id) {
return parkInfoService.getParkInfo(id, getUserInfo().getUserId(), getUserInfo().getIsMembership());
}
......
......@@ -9,6 +9,7 @@ import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import com.lyy.admin.common.constant.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -19,7 +20,7 @@ import javax.validation.constraints.NotNull;
*/
@TableName(value = "carrier_info")
@Data
public class CarrierInfo implements Serializable {
public class CarrierInfo extends BaseEntity implements Serializable {
@TableId(type = IdType.AUTO)
@ApiModelProperty(hidden = true)
......
......@@ -4,6 +4,7 @@ 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 com.lyy.admin.common.constant.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
......@@ -18,7 +19,7 @@ import java.util.Date;
*/
@TableName(value ="development_info")
@Data
public class DevelopmentInfo implements Serializable {
public class DevelopmentInfo extends BaseEntity implements Serializable {
/**
* 主键id
*/
......
......@@ -4,6 +4,7 @@ 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 com.lyy.admin.common.constant.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -18,7 +19,7 @@ import java.time.LocalDateTime;
@TableName(value = "development_industrial_land_info")
@Data
@ApiModel(value = "土地信息")
public class LandInfoEntity implements Serializable {
public class LandInfoEntity extends BaseEntity implements Serializable {
/** 主键id */
@TableId(type = IdType.AUTO)
@ApiModelProperty(value = "id")
......
......@@ -7,6 +7,7 @@ import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import com.lyy.admin.common.constant.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -16,7 +17,7 @@ import lombok.Data;
*/
@TableName(value ="park_info")
@Data
public class ParkInfo implements Serializable {
public class ParkInfo extends BaseEntity implements Serializable {
/**
* 主键id
*/
......
......@@ -26,7 +26,7 @@ public interface DevelopmentInfoService extends IService<DevelopmentInfo> {
public List<DevelopmentInfo> selectDevelopmentInfoDraftList(DevelopmentInfoParam developmentInfoParam);
public DevelopmentInfoAllVO getDevelopmentInfo(Integer id, Integer userId, Boolean isMembership);
public DevelopmentInfoAllVO getDevelopmentInfo(Long businessId, Integer userId, Boolean isMembership);
public List<DevelopmentInfoListVO> selectDevelopmentInfoCollectionList(DevelopmentInfoCollectionParam developmentInfoParam);
......
package com.lyy.admin.service.developmentinfo.impl;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
......@@ -235,13 +237,16 @@ public class DevelopmentInfoServiceImpl extends ServiceImpl<DevelopmentInfoMappe
}
@Override
public DevelopmentInfoAllVO getDevelopmentInfo(Integer id, Integer userId, Boolean isMembership) {
public DevelopmentInfoAllVO getDevelopmentInfo(Long businessId, Integer userId, Boolean isMembership) {
//通过用户id获取会员信息
// boolean flag = sysMembershipInfoService.isMemberShip(userId);
boolean flag = isMembership;
DevelopmentInfoAllVO developmentInfoAllVO = new DevelopmentInfoAllVO();
DevelopmentInfo developmentInfo = developmentInfoMapper.selectById(id);
// DevelopmentInfo developmentInfo = developmentInfoMapper.selectById(id);
LambdaQueryWrapper<DevelopmentInfo> DILambdaQueryWrapper = new LambdaQueryWrapper<>();
DILambdaQueryWrapper.eq(DevelopmentInfo::getBusinessId, businessId);
DevelopmentInfo developmentInfo = developmentInfoMapper.selectOne(DILambdaQueryWrapper);
Integer id = developmentInfo.getId();
if(developmentInfo==null){
throw new APIException(APIExceptionEnum.NOTEXISTS_EXCEPTION);
}
......@@ -459,9 +464,9 @@ public class DevelopmentInfoServiceImpl extends ServiceImpl<DevelopmentInfoMappe
if(developmentInfoSaveVO.getDevelopmentInfo().getStatus() == DevelopmentStatusEnum.STATUS_RZZ.getCode()){
developmentInfo.setSubmitTime(new Date());
}
this.saveOrUpdate(developmentInfo);
Integer id = developmentInfo.getId();
saveOrUpdateCommon(developmentInfoSaveVO, id);
return true;
}
......@@ -717,6 +722,8 @@ public class DevelopmentInfoServiceImpl extends ServiceImpl<DevelopmentInfoMappe
}
}
}
......
......@@ -25,7 +25,7 @@ public interface ParkInfoService extends IService<ParkInfo> {
public List<ParkInfo> selectParkInfoListVO(ParkInfoParam parkInfoParam);
public List<ParkInfo> selectParkInfoDraftListVO(ParkInfoParam parkInfoParam);
public List<ParkInfo> selectHotParkInfoListVO();
public ParkInfoAllVO getParkInfo(Integer id, Integer userId, Boolean isMemberShip);
public ParkInfoAllVO getParkInfo(Long businessId, Integer userId, Boolean isMemberShip);
public List<ParkInfoListVO> selectParkInfoAuthenticationList(ParkInfoAuthenticationParam parkInfoAuthenticationParam);
public List<ParkInfoListVO> selectParkInfoCollectionList(ParkInfoCollectionParam parkInfoParam);
public Boolean saveParkInfo(ParkInfoAllSaveVO parkInfoAllVO, Integer userId,String userName);
......
......@@ -2,6 +2,8 @@ package com.lyy.admin.service.parkinfo.impl;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
......@@ -277,13 +279,18 @@ public class ParkInfoServiceImpl extends ServiceImpl<ParkInfoMapper, ParkInfo> i
}
@Override
public ParkInfoAllVO getParkInfo(Integer id, Integer userId, Boolean isMemberShip) {
public ParkInfoAllVO getParkInfo(Long businessId, Integer userId, Boolean isMemberShip) {
//通过用户id获取会员信息
// boolean flag = sysMembershipInfoService.isMemberShip(userId);
boolean flag = isMemberShip;
ParkInfoAllVO parkInfoAllVO = new ParkInfoAllVO();
//获取园区基本信息
ParkInfo parkInfo = parkInfoMapper.selectById(id);
// ParkInfo parkInfo = parkInfoMapper.selectById(id);
LambdaQueryWrapper<ParkInfo> PILambdaQueryWrapper = new LambdaQueryWrapper<>();
PILambdaQueryWrapper.eq(ParkInfo::getBusinessId, businessId);
ParkInfo parkInfo = parkInfoMapper.selectOne(PILambdaQueryWrapper);
Integer id = parkInfo.getId();
parkInfo.setFloorArea(parkInfo.getFloorArea() == null ? new BigDecimal(0.0) : NumberUtil.div(parkInfo.getFloorArea(), 10000, 4));
if (parkInfo == null) {
throw new APIException(APIExceptionEnum.NOTEXISTS_EXCEPTION);
......@@ -442,6 +449,7 @@ public class ParkInfoServiceImpl extends ServiceImpl<ParkInfoMapper, ParkInfo> i
if (parkInfoAllVO.getParkInfo().getStatus() == DevelopmentStatusEnum.STATUS_RZZ.getCode()) {
parkInfo.setSubmitTime(new Date());
}
this.saveOrUpdate(parkInfo);
Integer id = parkInfo.getId();
......@@ -486,11 +494,6 @@ public class ParkInfoServiceImpl extends ServiceImpl<ParkInfoMapper, ParkInfo> i
parkInfo.setSubmitTime(new Date());
}
//校验是否已认证
// if(isAlreadyAuthentication(parkInfo)){
// throw new APIException(APIExceptionEnum.ALREADY_AUTH);
// }
this.saveOrUpdate(parkInfo);
Integer id = parkInfo.getId();
......@@ -572,7 +575,7 @@ public class ParkInfoServiceImpl extends ServiceImpl<ParkInfoMapper, ParkInfo> i
parkPolicyInfoService.saveBatch(parkInfoAllVO.getParkPolicyInfos());
//载体信息
parkInfoAllVO.getCarrierInfos().stream().forEach(e -> e.setParkId(id));
parkInfoAllVO.getCarrierInfos().stream().forEach(e ->e.setParkId(id));
carrierInfoService.saveBatch(parkInfoAllVO.getCarrierInfos());
//污水处理类型 污水处理价格
......
......@@ -24,6 +24,7 @@
<result property="electricity" column="electricity" jdbcType="VARCHAR"/>
<result property="gas" column="gas" jdbcType="TINYINT"/>
<result property="heating" column="heating" jdbcType="TINYINT"/>
<result property="businessId" column="business_id" jdbcType="BIGINT"/>
</resultMap>
<sql id="Base_Column_List">
......
......@@ -35,6 +35,7 @@
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="businessId" column="business_id" jdbcType="BIGINT"/>
</resultMap>
<sql id="Base_Column_List">
......
......@@ -78,6 +78,7 @@
<result property="establishTime" column="establish_time" jdbcType="VARCHAR"/>
<result property="provinceLevel" column="province_level" jdbcType="VARCHAR"/>
<result property="countryLevel" column="country_level" jdbcType="VARCHAR"/>
<result property="businessId" column="business_id" jdbcType="BIGINT"/>
</resultMap>
<sql id="Base_Column_List">
......
......@@ -71,6 +71,7 @@
<result property="status" column="status" jdbcType="INTEGER"/>
<result property="enterprise" column="enterprise" jdbcType="VARCHAR"/>
<result property="mirrorId" column="mirror_id" jdbcType="INTEGER"/>
<result property="businessId" column="business_id" jdbcType="BIGINT"/>
</resultMap>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment