From eb8fb6773ffd8554f509d9d48ef422d096cb7a95 Mon Sep 17 00:00:00 2001 From: Administrator <zhubaomin> Date: 星期四, 21 十二月 2023 10:15:26 +0800 Subject: [PATCH] 2023-12-21 朱宝民 添加分水房添加和查询 --- pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/config/WebFilterConfiguration.java | 52 +++ pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideSv.java | 54 +++ pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrDivideMapper.xml | 287 +++++++++++++++++++ pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/config/WebListenerConfiguration.java | 68 ++++ pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideCtrl.java | 96 ++++++ pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoPr/PrDivide.java | 152 ++++++++++ pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/PipIrrProjectApplication.java | 2 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrDivideMapper.java | 41 ++ pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/result/ProjectResultCode.java | 23 + pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/QueryVo.java | 27 + pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voPr/VoDivide.java | 45 +++ 11 files changed, 846 insertions(+), 1 deletions(-) diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrDivideMapper.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrDivideMapper.java new file mode 100644 index 0000000..5eb7697 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrDivideMapper.java @@ -0,0 +1,41 @@ +package com.dy.pipIrrGlobal.daoPr; + +import com.dy.pipIrrGlobal.pojoPr.PrDivide; +import com.dy.pipIrrGlobal.voPr.VoDivide; + +import java.util.List; +import java.util.Map; + +/** + * @author ZhuBaoMin + * @date 2023/12/21 9:16 + * @LastEditTime 2023/12/21 9:16 + * @Description + */ +public interface PrDivideMapper { + int deleteByPrimaryKey(Long id); + + int insert(PrDivide record); + + int insertSelective(PrDivide record); + + PrDivide selectByPrimaryKey(Long id); + + int updateByPrimaryKeySelective(PrDivide record); + + int updateByPrimaryKey(PrDivide record); + + /** + * 鏍规嵁鎸囧畾鏉′欢鑾峰彇鍒嗘按鎴胯褰曟暟 + * @param params + * @return + */ + Long getRecordCount(Map<?, ?> params); + + /** + * 鏍规嵁鎸囧畾鏉′欢鑾峰彇鍒嗘按鎴胯褰� + * @param params + * @return + */ + List<VoDivide> getDivides(Map<?, ?> params); +} \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoPr/PrDivide.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoPr/PrDivide.java new file mode 100644 index 0000000..6d2dec4 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoPr/PrDivide.java @@ -0,0 +1,152 @@ +package com.dy.pipIrrGlobal.pojoPr; + +/** + * @author ZhuBaoMin + * @date 2023/12/20 20:17 + * @LastEditTime 2023/12/20 20:17 + * @Description + */ + +import com.alibaba.fastjson2.annotation.JSONField; +import com.alibaba.fastjson2.writer.ObjectWriterImplToString; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.dy.common.po.BaseEntity; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import lombok.*; +import org.hibernate.validator.constraints.Length; + +import java.util.Date; + +/** + * 鍒嗘按鎴胯〃 + */ + +@TableName(value="pr_divide", autoResultMap = true) +@Data +@Builder +@ToString +@NoArgsConstructor +@AllArgsConstructor +@Schema(name = "鍒嗘按鎴垮疄浣�") +public class PrDivide implements BaseEntity { + public static final long serialVersionUID = 1L; + /** + * 涓婚敭 + */ + @JSONField(serializeUsing= ObjectWriterImplToString.class) + @TableId(type = IdType.INPUT) + @Schema(description = "瀹炰綋id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + private Long id; + + /** + * 鎵�鍦ㄥ幙 + */ + @JSONField(serializeUsing= ObjectWriterImplToString.class) + @Schema(description = "鎵�鍦ㄥ幙ID", requiredMode = Schema.RequiredMode.REQUIRED) + //@NotEmpty(message = "鎵�鍦ㄥ幙涓嶈兘涓虹┖") + private Long countyid; + + /** + * 鎵�鍦ㄩ晣 + */ + @JSONField(serializeUsing= ObjectWriterImplToString.class) + @Schema(description = "鎵�鍦ㄩ晣ID", requiredMode = Schema.RequiredMode.REQUIRED) + //@NotEmpty(message = "鎵�鍦ㄩ晣涓嶈兘涓虹┖") + private Long townid; + + /** + * 鎵�鍦ㄦ潙 + */ + @JSONField(serializeUsing= ObjectWriterImplToString.class) + @Schema(description = "鎵�鍦ㄦ潙ID", requiredMode = Schema.RequiredMode.REQUIRED) + //@NotEmpty(message = "鎵�鍦ㄦ潙涓嶈兘涓虹┖") + private Long villageid; + + /** + * 鎵�鍦ㄧ墖鍖� + */ + @JSONField(serializeUsing= ObjectWriterImplToString.class) + @Schema(description = "鎵�鍦ㄧ墖鍖篒D", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "鎵�鍦ㄧ墖鍖轰笉鑳戒负绌�") + private Long blockid; + + /** + * 鍒嗘按鍙e悕绉版垨缂栧彿 + */ + @Schema(description = "鍒嗘按鎴垮悕绉�", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "鍒嗘按鎴垮悕绉颁笉鑳戒负绌�") + @Length(message = "鍒嗘按鎴垮悕绉颁笉澶т簬{max}瀛楋紝涓嶅皬浜巤min}瀛�", min = 1, max = 25) + private String name; + + /** + * 瑕嗙洊鏉� + */ + @Schema(description = "瑕嗙洊鏉�", requiredMode = Schema.RequiredMode.REQUIRED) + @Length(message = "瑕嗙洊鏉戜笉澶т簬{max}瀛楋紝涓嶅皬浜巤min}瀛�", min = 1, max = 100) + private String villages; + + /** + * 瑕嗙洊闈㈢Н锛堝钩鏂瑰叕閲岋級 + */ + @Schema(description = "瑕嗙洊闈㈢Н", requiredMode = Schema.RequiredMode.REQUIRED) + private Double area; + + /** + * 璐熻矗浜� + */ + @Schema(description = "璐熻矗浜�", requiredMode = Schema.RequiredMode.REQUIRED) + private String header; + + /** + * 鑱旂郴鐢佃瘽 + */ + @Schema(description = "鑱旂郴鐢佃瘽", requiredMode = Schema.RequiredMode.REQUIRED) + //@NotBlank(message = "鑱旂郴鐢佃瘽涓嶈兘涓虹┖") + @Length(message = "鍐滆仈绯荤數璇濆繀椤粄max}浣嶆暟鎹�", min = 11, max = 11) + private String phone; + + /** + * 缁忓害 + */ + @Schema(description = "缁忓害", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "缁忓害涓嶈兘涓虹┖") + private Double lng; + + /** + * 绾害 + */ + @Schema(description = "缁忓害", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "缁忓害涓嶈兘涓虹┖") + private Double lat; + + /** + * 澶囨敞淇℃伅 + */ + @Schema(description = "澶囨敞", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Length(message = "澶囨敞涓嶅ぇ浜巤max}瀛楋紝涓嶅皬浜巤min}瀛�", min = 1, max = 200) + private String remarks; + + /** + * 鎿嶄綔浜虹紪鍙� + */ + @Schema(description = "鎿嶄綔浜虹紪鍙�", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @NotNull(message = "鎿嶄綔浜虹紪鍙蜂笉鑳戒负绌�") + private Long operator; + + /** + * 鎿嶄綔鏃堕棿 + */ + @Schema(description = "鎿嶄綔鏃堕棿", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + private Date operatedt; + + /** + * 閫昏緫鍒犻櫎鏍囪瘑;0-鏈垹闄わ紝1-鍒犻櫎 + */ + @Schema(description = "鍒犻櫎鏍囪瘑", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + private Byte deleted; + +} \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voPr/VoDivide.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voPr/VoDivide.java new file mode 100644 index 0000000..5973c5c --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voPr/VoDivide.java @@ -0,0 +1,45 @@ +package com.dy.pipIrrGlobal.voPr; + +import com.dy.common.po.BaseEntity; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +/** + * @author ZhuBaoMin + * @date 2023/12/21 9:28 + * @LastEditTime 2023/12/21 9:28 + * @Description + */ + +@Data +@Schema(title = "鍒嗘按鎴胯鍥惧璞�") +public class VoDivide implements BaseEntity { + private static final long serialVersionUID = 1L; + + @Schema(title = "ID") + private Long id; + + @Schema(title = "鍒嗘按鎴垮悕绉�") + private String divideName; + + @Schema(title = "鎵�灞炵墖鍖�") + private String blockName; + + @Schema(title = "璐熻矗浜�") + private String header; + + @Schema(title = "鑱旂郴鐢佃瘽") + private String phone; + + @Schema(title = "褰掑睘鍦�") + private String address; + + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @Schema(title = "鎿嶄綔鏃堕棿") + private Date operateDt; +} diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrDivideMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrDivideMapper.xml new file mode 100644 index 0000000..d9b4ac4 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrDivideMapper.xml @@ -0,0 +1,287 @@ +<?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.dy.pipIrrGlobal.daoPr.PrDivideMapper"> + <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoPr.PrDivide"> + <!--@mbg.generated--> + <!--@Table pr_divide--> + <id column="id" jdbcType="BIGINT" property="id" /> + <result column="countyId" jdbcType="BIGINT" property="countyid" /> + <result column="townId" jdbcType="BIGINT" property="townid" /> + <result column="villageId" jdbcType="BIGINT" property="villageid" /> + <result column="blockId" jdbcType="BIGINT" property="blockid" /> + <result column="name" jdbcType="VARCHAR" property="name" /> + <result column="villages" jdbcType="VARCHAR" property="villages" /> + <result column="area" jdbcType="FLOAT" property="area" /> + <result column="header" jdbcType="VARCHAR" property="header" /> + <result column="phone" jdbcType="VARCHAR" property="phone" /> + <result column="lng" jdbcType="DOUBLE" property="lng" /> + <result column="lat" jdbcType="DOUBLE" property="lat" /> + <result column="remarks" jdbcType="VARCHAR" property="remarks" /> + <result column="operator" jdbcType="BIGINT" property="operator" /> + <result column="operateDt" jdbcType="TIMESTAMP" property="operatedt" /> + <result column="deleted" jdbcType="TINYINT" property="deleted" /> + </resultMap> + <sql id="Base_Column_List"> + <!--@mbg.generated--> + id, countyId, townId, villageId, blockId, `name`, villages, area, `header`, phone, + lng, lat, remarks, `operator`, operateDt, deleted + </sql> + <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> + <!--@mbg.generated--> + select + <include refid="Base_Column_List" /> + from pr_divide + where id = #{id,jdbcType=BIGINT} + </select> + <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> + <!--@mbg.generated--> + delete from pr_divide + where id = #{id,jdbcType=BIGINT} + </delete> + + <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoPr.PrDivide"> + <!--@mbg.generated--> + insert into pr_divide (id, countyId, townId, + villageId, blockId, `name`, + villages, area, `header`, + phone, lng, lat, remarks, + `operator`, operateDt, deleted + ) + values (#{id,jdbcType=BIGINT}, #{countyid,jdbcType=BIGINT}, #{townid,jdbcType=BIGINT}, + #{villageid,jdbcType=BIGINT}, #{blockid,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, + #{villages,jdbcType=VARCHAR}, #{area,jdbcType=FLOAT}, #{header,jdbcType=VARCHAR}, + #{phone,jdbcType=VARCHAR}, #{lng,jdbcType=DOUBLE}, #{lat,jdbcType=DOUBLE}, #{remarks,jdbcType=VARCHAR}, + #{operator,jdbcType=BIGINT}, #{operatedt,jdbcType=TIMESTAMP}, #{deleted,jdbcType=TINYINT} + ) + </insert> + + <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoPr.PrDivide"> + <!--@mbg.generated--> + insert into pr_divide + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null"> + id, + </if> + <if test="countyid != null"> + countyId, + </if> + <if test="townid != null"> + townId, + </if> + <if test="villageid != null"> + villageId, + </if> + <if test="blockid != null"> + blockId, + </if> + <if test="name != null"> + `name`, + </if> + <if test="villages != null"> + villages, + </if> + <if test="area != null"> + area, + </if> + <if test="header != null"> + `header`, + </if> + <if test="phone != null"> + phone, + </if> + <if test="lng != null"> + lng, + </if> + <if test="lat != null"> + lat, + </if> + <if test="remarks != null"> + remarks, + </if> + <if test="operator != null"> + `operator`, + </if> + <if test="operatedt != null"> + operateDt, + </if> + <if test="deleted != null"> + deleted, + </if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null"> + #{id,jdbcType=BIGINT}, + </if> + <if test="countyid != null"> + #{countyid,jdbcType=BIGINT}, + </if> + <if test="townid != null"> + #{townid,jdbcType=BIGINT}, + </if> + <if test="villageid != null"> + #{villageid,jdbcType=BIGINT}, + </if> + <if test="blockid != null"> + #{blockid,jdbcType=BIGINT}, + </if> + <if test="name != null"> + #{name,jdbcType=VARCHAR}, + </if> + <if test="villages != null"> + #{villages,jdbcType=VARCHAR}, + </if> + <if test="area != null"> + #{area,jdbcType=FLOAT}, + </if> + <if test="header != null"> + #{header,jdbcType=VARCHAR}, + </if> + <if test="phone != null"> + #{phone,jdbcType=VARCHAR}, + </if> + <if test="lng != null"> + #{lng,jdbcType=DOUBLE}, + </if> + <if test="lat != null"> + #{lat,jdbcType=DOUBLE}, + </if> + <if test="remarks != null"> + #{remarks,jdbcType=VARCHAR}, + </if> + <if test="operator != null"> + #{operator,jdbcType=BIGINT}, + </if> + <if test="operatedt != null"> + #{operatedt,jdbcType=TIMESTAMP}, + </if> + <if test="deleted != null"> + #{deleted,jdbcType=TINYINT}, + </if> + </trim> + </insert> + <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoPr.PrDivide"> + <!--@mbg.generated--> + update pr_divide + <set> + <if test="countyid != null"> + countyId = #{countyid,jdbcType=BIGINT}, + </if> + <if test="townid != null"> + townId = #{townid,jdbcType=BIGINT}, + </if> + <if test="villageid != null"> + villageId = #{villageid,jdbcType=BIGINT}, + </if> + <if test="blockid != null"> + blockId = #{blockid,jdbcType=BIGINT}, + </if> + <if test="name != null"> + `name` = #{name,jdbcType=VARCHAR}, + </if> + <if test="villages != null"> + villages = #{villages,jdbcType=VARCHAR}, + </if> + <if test="area != null"> + area = #{area,jdbcType=FLOAT}, + </if> + <if test="header != null"> + `header` = #{header,jdbcType=VARCHAR}, + </if> + <if test="phone != null"> + phone = #{phone,jdbcType=VARCHAR}, + </if> + <if test="lng != null"> + lng = #{lng,jdbcType=DOUBLE}, + </if> + <if test="lat != null"> + lat = #{lat,jdbcType=DOUBLE}, + </if> + <if test="remarks != null"> + remarks = #{remarks,jdbcType=VARCHAR}, + </if> + <if test="operator != null"> + `operator` = #{operator,jdbcType=BIGINT}, + </if> + <if test="operatedt != null"> + operateDt = #{operatedt,jdbcType=TIMESTAMP}, + </if> + <if test="deleted != null"> + deleted = #{deleted,jdbcType=TINYINT}, + </if> + </set> + where id = #{id,jdbcType=BIGINT} + </update> + <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoPr.PrDivide"> + <!--@mbg.generated--> + update pr_divide + set countyId = #{countyid,jdbcType=BIGINT}, + townId = #{townid,jdbcType=BIGINT}, + villageId = #{villageid,jdbcType=BIGINT}, + blockId = #{blockid,jdbcType=BIGINT}, + `name` = #{name,jdbcType=VARCHAR}, + villages = #{villages,jdbcType=VARCHAR}, + area = #{area,jdbcType=FLOAT}, + `header` = #{header,jdbcType=VARCHAR}, + phone = #{phone,jdbcType=VARCHAR}, + lng = #{lng,jdbcType=DOUBLE}, + lat = #{lat,jdbcType=DOUBLE}, + remarks = #{remarks,jdbcType=VARCHAR}, + `operator` = #{operator,jdbcType=BIGINT}, + operateDt = #{operatedt,jdbcType=TIMESTAMP}, + deleted = #{deleted,jdbcType=TINYINT} + where id = #{id,jdbcType=BIGINT} + </update> + + <!--鏍规嵁鎸囧畾鏉′欢鑾峰彇鍒嗘按鎴胯褰曟暟--> + <select id="getRecordCount" parameterType="java.util.Map" resultType="java.lang.Long"> + SELECT + COUNT(*) AS recordCount + FROM pr_divide divi + INNER JOIN ba_block blo ON divi.blockId = blo.id + INNER JOIN ba_district country ON divi.countyId = country.id + INNER JOIN ba_district town ON divi.townId = town.id + INNER JOIN ba_district village ON divi.villageid = village.id + , (SELECT @i:=0) AS itable + <where> + <if test = "divideName != null and divideName !=''"> + AND divi.name LIKE CONCAT('%',#{divideName},'%') + </if> + + <if test = "blockName != null and blockName !=''"> + AND blo.name = #{blockName} + </if> + </where> + </select> + + <!--鏍规嵁鎸囧畾鏉′欢鑾峰彇鍒嗘按鎴胯褰�--> + <select id="getDivides" resultType="com.dy.pipIrrGlobal.voPr.VoDivide"> + SELECT + (@i:=@i+1) AS id, + divi.name AS divideName, + blo.`name` AS blockName, + divi.header, + divi.phone, + CONCAT(country.`name`, town.`name`, village.`name`) AS address, + divi.operateDt + FROM pr_divide divi + INNER JOIN ba_block blo ON divi.blockId = blo.id + INNER JOIN ba_district country ON divi.countyId = country.id + INNER JOIN ba_district town ON divi.townId = town.id + INNER JOIN ba_district village ON divi.villageid = village.id + , (SELECT @i:=0) AS itable + <where> + <if test = "divideName != null and divideName !=''"> + AND divi.name LIKE CONCAT('%',#{divideName},'%') + </if> + + <if test = "blockName != null and blockName !=''"> + AND blo.name = #{blockName} + </if> + </where> + ORDER BY divi.operateDt DESC + <if test="pageCurr != null and pageSize != null"> + LIMIT ${pageCurr}, ${pageSize} + </if> + </select> + +</mapper> \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/PipIrrProjectApplication.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/PipIrrProjectApplication.java index 9c32287..f46ea6a 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/PipIrrProjectApplication.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/PipIrrProjectApplication.java @@ -18,7 +18,7 @@ @EnableAspectJAutoProxy @EnableMultiDataSource @ComponentScan(basePackages = {"com.dy.common", "com.dy.pipIrrGlobal", "com.dy.pipIrrProject"}) -@MapperScan({"com.dy.pipIrrGlobal.daoSe", "com.dy.pipIrrGlobal.daoBa"}) +@MapperScan({"com.dy.pipIrrGlobal.daoPr"}) public class PipIrrProjectApplication { public static void main(String[] args) { diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/config/WebFilterConfiguration.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/config/WebFilterConfiguration.java new file mode 100644 index 0000000..8d876fc --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/config/WebFilterConfiguration.java @@ -0,0 +1,52 @@ +package com.dy.pipIrrProject.config; + +import com.dy.common.webFilter.DevOfDataSourceNameSetFilter; +import com.dy.common.webFilter.UserTokenFilter; +import jakarta.servlet.Filter; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @author ZhuBaoMin + * @date 2023/12/20 21:17 + * @LastEditTime 2023/12/20 21:17 + * @Description + */ + +@Configuration +public class WebFilterConfiguration { + + @Value("${pipIrr.global.dev}") + public String isDevStage ;//鏄惁涓哄紑鍙戦樁娈� + @Value("${pipIrr.global.dsName}") + public String dsName ;//寮�鍙戦樁娈电殑鏁版嵁婧愬悕绉� + + /** + * DevOfDataSourceNameSetFilter涓嶶serTokenFilter鍙兘涓�涓閰嶇疆涓婏紝 + * 鎵�浠ヤ粬浠殑order閮芥槸1 + */ + private static final int order_UserTokenFilter = 1 ;//涓庝笅闈� + private static final int order_DevOfDataSourceNameSetFilter = 1 ; + + + @Bean + public FilterRegistrationBean<? extends Filter> RegFilter() { + FilterRegistrationBean<Filter> filterRegistrationBean = new FilterRegistrationBean<>(); + if(this.isDevStage != null && !this.isDevStage.trim().equals("") && this.isDevStage.trim().equalsIgnoreCase("true")){ + filterRegistrationBean.setFilter(new DevOfDataSourceNameSetFilter()); + filterRegistrationBean.addUrlPatterns("/*");//閰嶇疆杩囨护瑙勫垯 + filterRegistrationBean.addInitParameter("dataSourceName",dsName);//璁剧疆init鍙傛暟 + filterRegistrationBean.setName("DevOfDataSourceNameSetFilter");//璁剧疆杩囨护鍣ㄥ悕绉� + filterRegistrationBean.setOrder(order_DevOfDataSourceNameSetFilter);//鎵ц娆″簭 + }else{ + filterRegistrationBean.setFilter(new UserTokenFilter()); + filterRegistrationBean.addUrlPatterns("/*");//閰嶇疆杩囨护瑙勫垯 + filterRegistrationBean.setName("UserTokenFilter");//璁剧疆杩囨护鍣ㄥ悕绉� + filterRegistrationBean.setOrder(order_UserTokenFilter);//鎵ц娆″簭 + } + return filterRegistrationBean; + } + +} \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/config/WebListenerConfiguration.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/config/WebListenerConfiguration.java new file mode 100644 index 0000000..19afd6d --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/config/WebListenerConfiguration.java @@ -0,0 +1,68 @@ +package com.dy.pipIrrProject.config; + +import com.dy.common.webListener.GenerateIdSetSuffixListener; +import jakarta.servlet.ServletContextListener; +import org.springframework.boot.web.servlet.ServletListenerRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @author ZhuBaoMin + * @date 2023/12/5 10:33 + * @LastEditTime 2023/12/5 10:33 + * @Description + */ +@Configuration +public class WebListenerConfiguration { + + /** + * 鍚姩椤哄簭 + */ + //private static final int order_config = 0 ; + private static final int order_idSetSuffix = 1 ; + //private static final int order_init = 2 ; + + /* + * 瑙f瀽鍚勭***.config閰嶇疆鐨凜onfigListener锛屾殏鏃朵笉閲囩敤姝ょ閰嶇疆鏂瑰紡 + * + @Bean + public ConfigListener getGlConfigListener(){ + return new ConfigListener() ; + } + /** + * 澶栭儴鎻愪緵Listener + * @param listener 澶栭儴鎻愪緵Listener + * @return 娉ㄥ唽Bean + @Bean + public ServletListenerRegistrationBean<? extends ServletContextListener> regConfigListener(ConfigListener listener) { + ServletListenerRegistrationBean<ConfigListener> listenerRegistrationBean = new ServletListenerRegistrationBean<>(); + listenerRegistrationBean.setListener(listener); + listenerRegistrationBean.setOrder(order_config); + return listenerRegistrationBean; + } + */ + + /** + * 鍐呴儴鎻愪緵listener锛岃listener鍦ㄧ郴缁熷惎鍔ㄦ椂锛屾牴鎹厤缃� 璁剧疆ID浜х敓鍣ㄧ殑鍚庣紑 + * @return 娉ㄥ唽Bean + */ + @Bean + public ServletListenerRegistrationBean<? extends ServletContextListener> regSsoListener() { + ServletListenerRegistrationBean<GenerateIdSetSuffixListener> listenerRegistrationBean = new ServletListenerRegistrationBean<>(); + listenerRegistrationBean.setListener(new GenerateIdSetSuffixListener()); + listenerRegistrationBean.setOrder(order_idSetSuffix); + return listenerRegistrationBean; + } + +// /** +// * 鍐呴儴鎻愪緵listener锛岃listener鍦ㄧ郴缁熷惎鍔ㄦ椂锛屽垵濮嬪寲鏁版嵁搴撴暟鎹� +// * @return 娉ㄥ唽Bean +// */ +// @Bean +// public ServletListenerRegistrationBean<? extends ServletContextListener> regInitListener() { +// ServletListenerRegistrationBean<InitListener> listenerRegistrationBean = new ServletListenerRegistrationBean<>(); +// listenerRegistrationBean.setListener(new InitListener()); +// listenerRegistrationBean.setOrder(order_init); +// return listenerRegistrationBean; +// } +} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideCtrl.java new file mode 100644 index 0000000..66ef655 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideCtrl.java @@ -0,0 +1,96 @@ +package com.dy.pipIrrProject.divide; + +import com.dy.common.aop.SsoAop; +import com.dy.common.webUtil.BaseResponse; +import com.dy.common.webUtil.BaseResponseUtils; +import com.dy.common.webUtil.QueryResultVo; +import com.dy.common.webUtil.ResultCodeMsg; +import com.dy.pipIrrGlobal.pojoPr.PrDivide; +import com.dy.pipIrrGlobal.voPr.VoDivide; +import com.dy.pipIrrGlobal.voSe.VoActiveCard; +import com.dy.pipIrrProject.result.ProjectResultCode; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.MediaType; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.*; + +import java.time.format.DateTimeFormatter; +import java.util.Date; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * @author ZhuBaoMin + * @date 2023/12/20 20:11 + * @LastEditTime 2023/12/20 20:11 + * @Description + */ + +@Slf4j +@Tag(name = "鍒嗘按鎴跨鐞�", description = "鍒嗘按鎴挎搷浣�") +@RestController +@RequestMapping(path="divide") +@RequiredArgsConstructor +public class DivideCtrl { + private final DivideSv divideSv; + + @Operation(summary = "鑾峰緱涓�椤靛垎姘存埧璁板綍", description = "杩斿洖涓�椤靛垎姘存埧鏁版嵁") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "杩斿洖涓�椤靛紑鍗℃暟鎹紙BaseResponse.content:QueryResultVo[{}]锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = VoActiveCard.class))} + ) + }) + @GetMapping(path = "/getDivides", consumes = MediaType.APPLICATION_JSON_VALUE) + @SsoAop("-1") + public BaseResponse<QueryResultVo<List<VoDivide>>> getDivides(@RequestBody @Parameter(description = "鏌ヨform琛ㄥ崟json鏁版嵁", required = true) QueryVo vo){ + try { + QueryResultVo<List<VoDivide>> res = divideSv.getDivides(vo); + return BaseResponseUtils.buildSuccess(res); + } catch (Exception e) { + log.error("鑾峰彇寮�鍗¤褰曞紓甯�", e); + return BaseResponseUtils.buildException(e.getMessage()) ; + } + } + + @Operation(summary = "娣诲姞鍒嗘按鎴胯褰�", description = "娣诲姞鍒嗘按鎴胯褰�") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = Boolean.class))} + ) + }) + @PostMapping(path = "add", consumes = MediaType.APPLICATION_JSON_VALUE) + @Transactional(rollbackFor = Exception.class) + @SsoAop("-1")//@SsoAop(power = "-1") + public BaseResponse<Boolean> add(@RequestBody @Parameter(description = "form琛ㄥ崟json鏁版嵁", required = true) @Valid PrDivide po, @Parameter(hidden = true) BindingResult bindingResult){ + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + if(bindingResult != null && bindingResult.hasErrors()){ + return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + + Date operateTime = new Date(); + po.setOperatedt(operateTime); + Integer rec = Optional.ofNullable(divideSv.addDivide(po)).orElse(0); + if(rec == 0) { + return BaseResponseUtils.buildFail(ProjectResultCode.DIVIDE_FAIL.getMessage()); + } + return BaseResponseUtils.buildSuccess(true) ; + } + +} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideSv.java new file mode 100644 index 0000000..9633b5f --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideSv.java @@ -0,0 +1,54 @@ +package com.dy.pipIrrProject.divide; + +import com.dy.common.webUtil.QueryResultVo; +import com.dy.pipIrrGlobal.daoPr.PrDivideMapper; +import com.dy.pipIrrGlobal.pojoPr.PrDivide; +import com.dy.pipIrrGlobal.voPr.VoDivide; +import lombok.extern.slf4j.Slf4j; +import org.apache.dubbo.common.utils.PojoUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +/** + * @author ZhuBaoMin + * @date 2023/12/20 20:12 + * @LastEditTime 2023/12/20 20:12 + * @Description 鍒嗘按鎴挎湇鍔$被 + */ + +@Slf4j +@Service +public class DivideSv { + @Autowired + private PrDivideMapper prDivideMapper; + + /** + * 娣诲姞鍒嗘按鎴� + * @param po + * @return + */ + Integer addDivide(PrDivide po) { + return prDivideMapper.insert(po); + } + + /** + * 鏍规嵁鎸囧畾鏉′欢鑾峰彇鍒嗘按鎴胯褰� + * @param queryVo 鏌ヨ瑙嗗浘 + * @return 鍒嗘按鎴胯褰曞垪琛� + */ + public QueryResultVo<List<VoDivide>> getDivides(QueryVo queryVo) { + Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); + + Long itemTotal = prDivideMapper.getRecordCount(params); + + QueryResultVo<List<VoDivide>> rsVo = new QueryResultVo<>() ; + rsVo.pageSize = queryVo.pageSize ; + rsVo.pageCurr = queryVo.pageCurr ; + rsVo.calculateAndSet(itemTotal, params); + rsVo.obj = prDivideMapper.getDivides(params); + return rsVo ; + } +} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/QueryVo.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/QueryVo.java new file mode 100644 index 0000000..3e488ce --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/QueryVo.java @@ -0,0 +1,27 @@ +package com.dy.pipIrrProject.divide; + +import com.dy.common.webUtil.QueryConditionVo; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +/** + * @author ZhuBaoMin + * @date 2023/12/21 9:50 + * @LastEditTime 2023/12/21 9:50 + * @Description + */ + +@Data +@EqualsAndHashCode(callSuper = false) +@ToString(callSuper = true) +@NoArgsConstructor +@AllArgsConstructor +@Builder +@Schema(name = "鍒嗘按鎴挎煡璇㈡潯浠�") +public class QueryVo extends QueryConditionVo { + @Schema(description = "鍐滄埛濮撳悕") + public String divideName; + + @Schema(description = "IC鍗″彿") + public String blockName; +} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/result/ProjectResultCode.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/result/ProjectResultCode.java new file mode 100644 index 0000000..2ebe707 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/result/ProjectResultCode.java @@ -0,0 +1,23 @@ +package com.dy.pipIrrProject.result; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author ZhuBaoMin + * @date 2023/12/21 10:09 + * @LastEditTime 2023/12/21 10:09 + * @Description + */ + +@Getter +@AllArgsConstructor +public enum ProjectResultCode { + /** + * 鍒嗘按鎴� + */ + DIVIDE_FAIL(10001, "鍒嗘按鎴挎坊鍔犲け璐�"); + + private final Integer code; + private final String message; +} -- Gitblit v1.8.0