1、增加是否为开发阶段的配置,基于此配置,进行判断,若开发阶段设置临时数据源名称,及不进行登录及权限验证。
2、分配各个子系统id生成器的后缀
1 文件已重命名
23个文件已修改
13个文件已添加
1个文件已删除
| | |
| | | <orderEntry type="library" name="Maven: io.swagger.core.v3:swagger-models:2.2.9" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.security:spring-security-core:6.1.2" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.security:spring-security-crypto:6.1.2" level="project" /> |
| | | <orderEntry type="library" name="Maven: mysql:mysql-connector-java:5.1.48" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.mysql:mysql-connector-j:8.0.33" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.alibaba:druid-spring-boot-starter:1.2.20" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.alibaba:druid:1.2.20" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:2.0.7" level="project" /> |
| | |
| | | |
| | | <!--mysql驱å¨--> |
| | | <dependency> |
| | | <groupId>mysql</groupId> |
| | | <artifactId>mysql-connector-java</artifactId> |
| | | <!--对åºèªå·±çµèå®è£
çmysqlçæ¬--> |
| | | <groupId>com.mysql</groupId> |
| | | <artifactId>mysql-connector-j</artifactId> |
| | | </dependency> |
| | | |
| | | <!--druid-spring-bootè¿æ¥æ± --> |
| | | <dependency> |
| | | <groupId>com.alibaba</groupId> |
| | |
| | | @Target(ElementType.METHOD) |
| | | @Inherited |
| | | public @interface SsoAop { |
| | | String value() default "" ; |
| | | //ä¼å
级1(æé«)ï¼å¦æå
¶æå¼ï¼åä¸å¨å¤æä»¥ä¸åéåå¼ |
| | | String power() default "" ; |
| | | //ä¼å
级2ï¼æ¥æå
¨é¨æéæå¯ , 妿å
¶æå¼ï¼åä¸å¨å¤æä»¥ä¸åéåå¼ |
| | |
| | | import com.dy.common.multiDataSource.DataSourceContext; |
| | | import com.dy.common.webFilter.UserTokenContext; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.mysql.jdbc.StringUtils; |
| | | import com.mysql.cj.util.StringUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.aspectj.lang.ProceedingJoinPoint; |
| | | import org.aspectj.lang.annotation.Around; |
| | |
| | | @Component |
| | | public class SsoAspect { |
| | | |
| | | @Value("${pipIrr.global.dev}") |
| | | public String isDevStage ;//æ¯å¦ä¸ºå¼åé¶æ®µ |
| | | |
| | | @Value("${pipIrr.sso.checkUrl}") |
| | | public String SsoCheckUrl ; |
| | | |
| | |
| | | |
| | | @Around("dyPointCut()") |
| | | public Object execute(ProceedingJoinPoint point) throws Throwable { |
| | | MethodSignature signature = (MethodSignature) point.getSignature(); |
| | | Method method = signature.getMethod(); |
| | | SsoAop aop = method.getAnnotation(SsoAop.class) ; |
| | | if (Objects.nonNull(aop)){ |
| | | String token = UserTokenContext.get() ; |
| | | String power = aop.power() ; |
| | | String[] allPower = aop.ifAllPower() ; |
| | | String[] anyPower = aop.ifAnyPower() ; |
| | | Object rObj = this.check(token, power, allPower, anyPower); |
| | | if(rObj != null){ |
| | | if(rObj instanceof SsoVo ssoVo){ |
| | | if(ssoVo.logined){ |
| | | if(ssoVo.hasPower){ |
| | | if(!StringUtils.isNullOrEmpty(ssoVo.dataSourceName)){ |
| | | DataSourceContext.set(ssoVo.dataSourceName); |
| | | return point.proceed(); |
| | | if(isDevStage != null && !isDevStage.trim().equals("") && isDevStage.trim().equalsIgnoreCase("true")){ |
| | | return point.proceed(); |
| | | }else{ |
| | | MethodSignature signature = (MethodSignature) point.getSignature(); |
| | | Method method = signature.getMethod(); |
| | | SsoAop aop = method.getAnnotation(SsoAop.class) ; |
| | | if (Objects.nonNull(aop)){ |
| | | String power = aop.value() ; |
| | | if(power.trim().equals("")){ |
| | | power = aop.power() ; |
| | | } |
| | | if(power.trim().equals("-1")){ |
| | | //ä¸è¿è¡ç»å½åæééªè¯ |
| | | return point.proceed(); |
| | | }else{ |
| | | String[] allPower = aop.ifAllPower() ; |
| | | String[] anyPower = aop.ifAnyPower() ; |
| | | String token = UserTokenContext.get() ; |
| | | Object rObj = this.check(token, power, allPower, anyPower); |
| | | if(rObj != null){ |
| | | if(rObj instanceof SsoVo ssoVo){ |
| | | if(ssoVo.logined){ |
| | | if(ssoVo.hasPower){ |
| | | if(!StringUtils.isNullOrEmpty(ssoVo.dataSourceName)){ |
| | | DataSourceContext.set(ssoVo.dataSourceName); |
| | | return point.proceed(); |
| | | }else{ |
| | | //æ æ°æ®æº |
| | | return BaseResponseUtils.buildError("å端系ç»åºéï¼æªå¾å°å½åç»å½ç¨æ·æå±æºææ ç¾ï¼æ°æ®æºåï¼") ; |
| | | } |
| | | }else{ |
| | | //æ æé |
| | | return BaseResponseUtils.buildNoPower() ; |
| | | } |
| | | }else{ |
| | | //æ æ°æ®æº |
| | | return BaseResponseUtils.buildError("å端系ç»åºéï¼æªå¾å°å½åç»å½ç¨æ·æå±æºææ ç¾ï¼æ°æ®æºåï¼") ; |
| | | //æªç»å½ |
| | | return BaseResponseUtils.buildToLogin() ; |
| | | } |
| | | }else{ |
| | | //æ æé |
| | | return BaseResponseUtils.buildNoPower() ; |
| | | return rObj ; |
| | | } |
| | | }else{ |
| | | //æªç»å½ |
| | | return BaseResponseUtils.buildToLogin() ; |
| | | return BaseResponseUtils.buildError("å端系ç»åºéï¼checkæ¹æ³è¿ånull") ; |
| | | } |
| | | }else{ |
| | | return rObj ; |
| | | } |
| | | }else{ |
| | | return BaseResponseUtils.buildError("å端系ç»åºéï¼checkæ¹æ³è¿ånull") ; |
| | | //å·²ç»è¿å
¥æ³¨è§£å¤çäºï¼è¿å¾ä¸å°æ³¨è§£ï¼è¿ç§æ
嵿¯ä¸å¯è½çã |
| | | return BaseResponseUtils.buildError("å端系ç»åºéï¼DyAop注解为null") ; |
| | | } |
| | | }else{ |
| | | //å·²ç»è¿å
¥æ³¨è§£å¤çäºï¼è¿å¾ä¸å°æ³¨è§£ï¼è¿ç§æ
嵿¯ä¸å¯è½çã |
| | | return BaseResponseUtils.buildError("å端系ç»åºéï¼DyAop注解为null") ; |
| | | } |
| | | } |
| | | |
| | |
| | | package com.dy.common.aop; |
| | | |
| | | import org.springframework.boot.web.client.RestTemplateBuilder; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | /** |
| | | * 为SsoAspect访é®åç¹ç»å½ç³»ç»æä¾ RestTemplate |
| | | */ |
| | | @Configuration |
| | | public class SsoRestTemplateConfiguration { |
| | | |
| | | @Bean |
| | | public RestTemplate restTemplate(RestTemplateBuilder builder){ |
| | | return builder.build(); |
| | | public RestTemplate restTemplate(){ |
| | | return new RestTemplate(); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.dy.common.multiDataSource; |
| | | |
| | | import com.dy.common.contant.Constant; |
| | | import com.mysql.jdbc.StringUtils; |
| | | import com.mysql.cj.util.StringUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.aspectj.lang.ProceedingJoinPoint; |
| | | import org.aspectj.lang.annotation.Around; |
New file |
| | |
| | | package com.dy.common.webFilter; |
| | | |
| | | import com.dy.common.multiDataSource.DataSourceContext; |
| | | import jakarta.servlet.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import java.io.IOException; |
| | | |
| | | @Slf4j |
| | | public class DevOfDataSourceNameSetFilter implements Filter { |
| | | private String devOfDataSourceName ; |
| | | @Override |
| | | public void init(FilterConfig filterConfig) throws ServletException { |
| | | devOfDataSourceName = filterConfig.getInitParameter("dataSourceName"); |
| | | log.info("å¼åé¶æ®µï¼è®¾ç½®æ°æ®æºå称为:" + devOfDataSourceName); |
| | | } |
| | | @Override |
| | | public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { |
| | | log.info("å¼åé¶æ®µï¼è®¾ç½®æ°æ®æºå称为:" + devOfDataSourceName); |
| | | DataSourceContext.set(devOfDataSourceName); |
| | | filterChain.doFilter(servletRequest, servletResponse); |
| | | } |
| | | |
| | | @Override |
| | | public void destroy() { |
| | | } |
| | | } |
File was renamed from pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/webFilter/UserTokerFilter.java |
| | |
| | | import com.dy.common.contant.Constant; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.mysql.jdbc.StringUtils; |
| | | import com.mysql.cj.util.StringUtils ; |
| | | import jakarta.servlet.*; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | |
| | | import java.io.PrintWriter; |
| | | |
| | | @Slf4j |
| | | public class UserTokerFilter implements Filter { |
| | | public class UserTokenFilter implements Filter { |
| | | @Override |
| | | public void init(FilterConfig filterConfig) throws ServletException { |
| | | //log.info("UserTokerFilter init: name:" + filterConfig.getInitParameter("name")); |
| | | } |
| | | |
| | | @Override |
| | |
| | | }else{ |
| | | PrintWriter pw = null ; |
| | | try { |
| | | BaseResponse res = BaseResponseUtils.buildToLogin() ; |
| | | BaseResponse<?> res = BaseResponseUtils.buildToLogin() ; |
| | | String jsonString = JSON.toJSONString(res); |
| | | response.setCharacterEncoding("UTF-8"); |
| | | response.setContentType("application/json; charset=utf-8"); |
| | |
| | | |
| | | /** |
| | | * è§£æç³»ç»é
ç½® |
| | | * @return |
| | | */ |
| | | private void init(ServletContext con){ |
| | | try { |
| | |
| | | if(!NumUtil.isPlusIntNumber(idSuffix)){ |
| | | throw new Exception("é
ç½®IDåç¼æ ¼å¼ä¸æ£ç¡®") ; |
| | | }else{ |
| | | IDLongGenerator.setSuffix(Integer.valueOf(idSuffix)); |
| | | IDLongGenerator.setSuffix(Integer.parseInt(idSuffix)); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:3.1.3" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.28" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.9.20" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-log4j2:3.1.3" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-slf4j2-impl:2.20.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-log4j2:2.7.9" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-slf4j-impl:2.20.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.20.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:2.0.7" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-core:2.20.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-jul:2.20.0" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:2.0.7" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.15.2" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.15.2" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.15.2" level="project" /> |
| | |
| | | <orderEntry type="library" name="Maven: com.alibaba.fastjson2:fastjson2:2.0.40" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.alibaba.fastjson2:fastjson2-extension-spring6:2.0.40" level="project" /> |
| | | <orderEntry type="library" name="Maven: com.alibaba.fastjson2:fastjson2-extension:2.0.40" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.mapstruct:mapstruct:1.5.5.Final" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.mapstruct:mapstruct-processor:1.5.5.Final" level="project" /> |
| | | </component> |
| | | </module> |
| | |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-web</artifactId> |
| | | <version>3.1.3</version> |
| | | <exclusions> |
| | | <exclusion> |
| | | <groupId>org.springframework.boot</groupId> |
| | |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-devtools</artifactId> |
| | | <version>3.1.3</version> |
| | | <scope>runtime</scope> |
| | | </dependency> |
| | | <!-- lombok --> |
| | | <dependency> |
| | | <groupId>org.projectlombok</groupId> |
| | | <artifactId>lombok</artifactId> |
| | | <version>1.18.28</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.aspectj</groupId> |
| | | <artifactId>aspectjweaver</artifactId> |
| | | <version>1.9.20</version> |
| | | </dependency> |
| | | <!--log4j2æ¥å¿--> |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-log4j2</artifactId> |
| | | <version>2.7.9</version> |
| | | </dependency> |
| | | <!-- ç¨äºè¾¨è®¤log4j2.ymlæä»¶ --> |
| | | <dependency> |
| | | <groupId>com.fasterxml.jackson.dataformat</groupId> |
| | | <artifactId>jackson-dataformat-yaml</artifactId> |
| | | <version>2.15.2</version> |
| | | </dependency> |
| | | <!--mybatis-plus-spring-boot--> |
| | | <dependency> |
| | | <groupId>com.baomidou</groupId> |
| | | <artifactId>mybatis-plus-boot-starter</artifactId> |
| | | <version>3.5.3.2</version> |
| | | </dependency> |
| | | <!-- é¿éfastjson --> |
| | | <dependency> |
| | | <groupId>cglib</groupId> |
| | | <artifactId>cglib</artifactId> |
| | | <version>3.3.0</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.alibaba.fastjson2</groupId> |
| | | <artifactId>fastjson2</artifactId> |
| | | <version>2.0.40</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.alibaba.fastjson2</groupId> |
| | | <artifactId>fastjson2-extension-spring6</artifactId> |
| | | <version>2.0.40</version> |
| | | </dependency> |
| | | |
| | | <!-- vo poè½¬æ¢ å
¨å±æ²¡æä¸é¢ä¾èµï¼æä»¥æ¤å¤å¿
é¡»å çæ¬å·--> |
| | | <dependency> |
| | | <groupId>org.mapstruct</groupId> |
| | | <artifactId>mapstruct</artifactId> |
| | | <version>1.5.5.Final</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.mapstruct</groupId> |
| | | <artifactId>mapstruct-processor</artifactId> |
| | | <version>1.5.5.Final</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <build> |
| | | <plugins> |
| | | <plugin> |
| | | <!-- spring bootæä¾çmavenæå
æä»¶ --> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-maven-plugin</artifactId> |
| | | <configuration> |
| | | <excludes> |
| | | <exclude> |
| | | <groupId>org.projectlombok</groupId> |
| | | <artifactId>lombok</artifactId> |
| | | </exclude> |
| | | </excludes> |
| | | </configuration> |
| | | </plugin> |
| | | <plugin> |
| | | <!-- mavenéæ§è¡æµè¯ç¨ä¾çæä»¶ --> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-surefire-plugin</artifactId> |
| | | <configuration> |
| | | <skipTests>true</skipTests> |
| | | </configuration> |
| | | </plugin> |
| | | <plugin> |
| | | <!-- 强å¶è®¾å® javaç¼è¯çæ¬ï¼è¿è¡ç¯å¢çæ¬ --> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-compiler-plugin</artifactId> |
| | | </plugin> |
| | | </plugins> |
| | | </build> |
| | | </project> |
New file |
| | |
| | | package com.dy.pipIrrGlobal.daoBa; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.dy.pipIrrGlobal.pojoBa.BaDistrict; |
| | | import com.dy.pipIrrGlobal.pojoBa.BaPrivilege; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | @Mapper |
| | | public interface BaDistrictMapper extends BaseMapper<BaPrivilege> { |
| | | /** |
| | | * delete by primary key |
| | | * @param id primaryKey |
| | | * @return deleteCount |
| | | */ |
| | | int deleteByPrimaryKey(Long id); |
| | | |
| | | /** |
| | | * insert record to table |
| | | * @param record the record |
| | | * @return insert count |
| | | */ |
| | | int insert(BaDistrict record); |
| | | |
| | | /** |
| | | * insert record to table selective |
| | | * @param record the record |
| | | * @return insert count |
| | | */ |
| | | int insertSelective(BaDistrict record); |
| | | |
| | | /** |
| | | * select by primary key |
| | | * @param id primary key |
| | | * @return object by primary key |
| | | */ |
| | | BaDistrict selectByPrimaryKey(Long id); |
| | | |
| | | /** |
| | | * update record selective |
| | | * @param record the updated record |
| | | * @return update count |
| | | */ |
| | | int updateByPrimaryKeySelective(BaDistrict record); |
| | | |
| | | /** |
| | | * update record |
| | | * @param record the updated record |
| | | * @return update count |
| | | */ |
| | | int updateByPrimaryKey(BaDistrict record); |
| | | } |
| | |
| | | import com.dy.pipIrrGlobal.pojoDemo.DemoMp; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * æ¼ç¤ºæ²¡æDemoMpMapper.xmlå®ç°æ¹å¼ |
| | | */ |
| | | @Mapper |
| | | public interface DemoMpMapper extends BaseMapper<DemoMp> { |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrGlobal.pojoBa; |
| | | |
| | | 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 com.dy.pipIrrGlobal.util.DistrictLevel; |
| | | import lombok.*; |
| | | |
| | | @TableName(value="ba_district", autoResultMap = true) |
| | | @Data |
| | | @Builder |
| | | @ToString |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class BaDistrict implements BaseEntity { |
| | | |
| | | public static final long serialVersionUID = 202311081046001L; |
| | | |
| | | @JSONField(serializeUsing= ObjectWriterImplToString.class) |
| | | @TableId(type = IdType.INPUT) |
| | | public Long id ; |
| | | |
| | | public String name; |
| | | |
| | | public DistrictLevel level; |
| | | |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrGlobal.util; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.EnumValue; |
| | | import com.dy.common.mybatis.envm.IEnum; |
| | | |
| | | /** |
| | | * è¡æ¿åºåçº§å« |
| | | * Provinces, cities, counties, towns, and village groups |
| | | */ |
| | | public enum DistrictLevel implements IEnum { |
| | | |
| | | City((byte)1, "å¸"), |
| | | County((byte)2, "å¿"), |
| | | Town((byte)3, "é"), |
| | | Village((byte)4, "æ"), |
| | | Group((byte)5, "ç»"); |
| | | |
| | | @EnumValue |
| | | public Byte code ; |
| | | public String name ; |
| | | |
| | | DistrictLevel(Byte code, String name){ |
| | | this.code = code ; |
| | | this.name = name ; |
| | | } |
| | | |
| | | @Override |
| | | public Byte getCode() { |
| | | return this.code ; |
| | | } |
| | | |
| | | @Override |
| | | public String getName() { |
| | | return this.name ; |
| | | } |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrGlobal.util; |
| | | |
| | | import org.mapstruct.Named; |
| | | import org.springframework.stereotype.Component; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * Mappingéç¨è½¬æ¢ |
| | | */ |
| | | @Component |
| | | @SuppressWarnings("") |
| | | public class TypeConversionDistrict { |
| | | /** |
| | | * @param obj åæ° |
| | | * @return è½¬æ¢æç对象 |
| | | */ |
| | | @Named("districtLevelByteToObj") |
| | | public DistrictLevel converseDistrictLevel(Object obj) { |
| | | if (Objects.isNull(obj)) { |
| | | return null; |
| | | }else{ |
| | | byte sourceObj = (obj instanceof Byte?(Byte)obj: DistrictLevel.City.code); |
| | | DistrictLevel rObj = null ; |
| | | if(sourceObj == DistrictLevel.City.code){ |
| | | rObj = DistrictLevel.City ; |
| | | }else if(sourceObj == DistrictLevel.County.code){ |
| | | rObj = DistrictLevel.County ; |
| | | }else if(sourceObj == DistrictLevel.Town.code){ |
| | | rObj = DistrictLevel.Town ; |
| | | }else if(sourceObj == DistrictLevel.Village.code){ |
| | | rObj = DistrictLevel.Village ; |
| | | }else if(sourceObj == DistrictLevel.Group.code){ |
| | | rObj = DistrictLevel.Group ; |
| | | } |
| | | return rObj ; |
| | | } |
| | | } |
| | | } |
| | |
| | | default-enum-type-handler: com.dy.common.mybatis.envm.EnumCodeTypeHandler |
| | | |
| | | pipIrr: |
| | | global: |
| | | dev: true #æ¯å¦å¼åé¶æ®µï¼trueæfalse |
| | | dsName: ym #å¼åé¶æ®µï¼è®¾ç½®ä¸´æ¶çæ°æ®åºåç§° |
| | | demo: |
| | | webPort: 8000 |
| | | actutorPort: 9000 |
New file |
| | |
| | | <?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.daoBa.BaDistrictMapper"> |
| | | <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoBa.BaDistrict"> |
| | | <!--@mbg.generated--> |
| | | <!--@Table ba_district--> |
| | | <id column="id" jdbcType="BIGINT" property="id" /> |
| | | <result column="name" jdbcType="VARCHAR" property="name" /> |
| | | <result property="level" column="level" typeHandler="com.dy.common.mybatis.envm.EnumCodeTypeHandler" javaType="com.dy.pipIrrGlobal.util.DistrictLevel"/> |
| | | |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | <!--@mbg.generated--> |
| | | id, `name`, `level` |
| | | </sql> |
| | | <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> |
| | | <!--@mbg.generated--> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from ba_district |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> |
| | | <!--@mbg.generated--> |
| | | delete from ba_district |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoBa.BaDistrict"> |
| | | <!--@mbg.generated--> |
| | | insert into ba_district (id, `name`, `level` |
| | | ) |
| | | values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{level,jdbcType=TINYINT} |
| | | ) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoBa.BaDistrict"> |
| | | <!--@mbg.generated--> |
| | | insert into ba_district |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | id, |
| | | </if> |
| | | <if test="name != null"> |
| | | `name`, |
| | | </if> |
| | | <if test="level != null"> |
| | | `level`, |
| | | </if> |
| | | </trim> |
| | | <trim prefix="values (" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | #{id,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="name != null"> |
| | | #{name,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="level != null"> |
| | | #{level,jdbcType=TINYINT}, |
| | | </if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoBa.BaDistrict"> |
| | | <!--@mbg.generated--> |
| | | update ba_district |
| | | <set> |
| | | <if test="name != null"> |
| | | `name` = #{name,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="level != null"> |
| | | `level` = #{level,jdbcType=TINYINT}, |
| | | </if> |
| | | </set> |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoBa.BaDistrict"> |
| | | <!--@mbg.generated--> |
| | | update ba_district |
| | | set `name` = #{name,jdbcType=VARCHAR}, |
| | | `level` = #{level,jdbcType=TINYINT} |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | </mapper> |
| | |
| | | <result property="password" column="password"/> |
| | | <result property="orgTag" column="orgTag"/> |
| | | <result property="supperAdmin" column="supperAdmin"/> |
| | | <result property="disabled" column="deleted"/> |
| | | <result property="disabled" column="disabled" typeHandler="com.dy.common.mybatis.envm.EnumCodeTypeHandler" javaType="com.dy.common.mybatis.envm.Disabled"/> |
| | | <result property="deleted" column="deleted" typeHandler="com.dy.common.mybatis.envm.EnumCodeTypeHandler" javaType="com.dy.common.mybatis.envm.Deleted"/> |
| | | </resultMap> |
| | | |
| | | <resultMap id="login" type="com.dy.pipIrrGlobal.pojoBa.BaUser"> |
| | |
| | | |
| | | <sql id="Base_Column_List"> |
| | | <!--@mbg.generated--> |
| | | id, name, phone, password, orgTag, supperAdmin, deleted |
| | | id, name, phone, password, orgTag, supperAdmin, disabled, deleted |
| | | </sql> |
| | | |
| | | <sql id="Login_Column_List"> |
New file |
| | |
| | | package com.dy.pipIrrBase.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; |
| | | |
| | | @Configuration |
| | | public class WebFilterConfiguration { |
| | | |
| | | @Value("${pipIrr.global.dev}") |
| | | public String isDevStage ;//æ¯å¦ä¸ºå¼åé¶æ®µ |
| | | @Value("${pipIrr.global.dsName}") |
| | | public String dsName ;//å¼åé¶æ®µçæ°æ®æºåç§° |
| | | |
| | | /** |
| | | * DevOfDataSourceNameSetFilterä¸UserTokenFilteråªè½ä¸ä¸ªè¢«é
ç½®ä¸ï¼ |
| | | * æä»¥ä»ä»¬ç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; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrBase.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; |
| | | |
| | | @Configuration |
| | | public class WebListenerConfiguration { |
| | | |
| | | /** |
| | | * å¯å¨é¡ºåº |
| | | */ |
| | | //private static final int order_config = 0 ; |
| | | private static final int order_idSetSuffix = 1 ; |
| | | |
| | | /* |
| | | * è§£æåç§***.configé
ç½®çConfigListenerï¼ææ¶ä¸éç¨æ¤ç§é
ç½®æ¹å¼ |
| | | * |
| | | @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> reqSsoListener() { |
| | | ServletListenerRegistrationBean<GenerateIdSetSuffixListener> listenerRegistrationBean = new ServletListenerRegistrationBean<>(); |
| | | listenerRegistrationBean.setListener(new GenerateIdSetSuffixListener()); |
| | | listenerRegistrationBean.setOrder(order_idSetSuffix); |
| | | return listenerRegistrationBean; |
| | | } |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrBase.district; |
| | | |
| | | import com.dy.common.aop.SsoAop; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.common.webUtil.ResultCodeMsg; |
| | | import com.dy.pipIrrGlobal.pojoBa.BaDistrict; |
| | | import com.dy.pipIrrGlobal.util.DistrictLevel; |
| | | 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.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.validation.BindingResult; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | @Slf4j |
| | | @Tag(name = "è¡æ¿åºå管ç", description = "è¡æ¿åºåå¢å æ¹æ¥çæä½") |
| | | @RestController |
| | | @RequestMapping(path="district") |
| | | @SuppressWarnings("unchecked")//javaçæ¬è¶é«ï¼å¯¹æ³å约æè¶ä¸¥ï¼æä»¥é
ç½®SuppressWarnings("unchecked") |
| | | public class DistrictCtrl { |
| | | |
| | | private DistrictSv sv ; |
| | | |
| | | @Autowired |
| | | private void setSv(DistrictSv sv){ |
| | | this.sv = sv ; |
| | | } |
| | | |
| | | /** |
| | | * 客æ·ç«¯è¯·æ±å¾å°ææè¡æ¿åºåçº§å«æ°æ® |
| | | * @return ææè¡æ¿åºåçº§å«æ°æ® |
| | | */ |
| | | @Operation(summary = "è¡æ¿åºå级å«", description = "è¿åææè¡æ¿åºåçº§å«æ°æ®") |
| | | @ApiResponses(value = { |
| | | @ApiResponse( |
| | | responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, |
| | | description = "è¿åææè¡æ¿åºåçº§å«æ°æ®ï¼BaseResponse.content:[ { \"code\":1, \"name\":\"å¸\" }, { \"code\":2, \"name\":\"å¿\" }]ï¼", |
| | | content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, |
| | | schema = @Schema(implementation = DistrictLevel.class))} |
| | | ) |
| | | }) |
| | | @GetMapping(path = "allLevel") |
| | | public BaseResponse<List<DistrictLevel>> allDistrictLevels(){ |
| | | List<DistrictLevel> list = Arrays.asList(DistrictLevel.City, DistrictLevel.County, DistrictLevel.Town, DistrictLevel.Village, DistrictLevel.Group) ; |
| | | return BaseResponseUtils.buildSuccess(list); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * ä¿åè¡æ¿åº |
| | | * @param vo ä¿åè¡æ¿åºform表å对象 |
| | | * @return æ¯å¦æå |
| | | */ |
| | | @Operation(summary = "ä¿åè¡æ¿åº", description = "æäº¤è¡æ¿åºæ°æ®ï¼form表åï¼ï¼è¿è¡ä¿å") |
| | | @ApiResponses(value = { |
| | | @ApiResponse( |
| | | responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, |
| | | description = "ä¿åè¡æ¿åºè¿åï¼trueï¼æåï¼falseï¼å¤±è´¥ï¼æ°æ®åºç±»çcontentï¼", |
| | | content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, |
| | | schema = @Schema(implementation = Boolean.class))} |
| | | ) |
| | | }) |
| | | @PostMapping(path = "save", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
| | | @SsoAop("-1")//@SsoAop(power = "-1") |
| | | public BaseResponse<Boolean> save(@Parameter(description = "formè¡¨åæ°æ®", required = true) @Valid DistrictVo vo, @Parameter(hidden = true) BindingResult bindingResult){ |
| | | if(bindingResult != null && bindingResult.hasErrors()){ |
| | | return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | } |
| | | BaDistrict po = DistrictVoMapper.INSTANCT.convert(vo); |
| | | int count; |
| | | try { |
| | | count = this.sv.save(po); |
| | | } catch (Exception e) { |
| | | log.error("ä¿åè¡æ¿åºå¼å¸¸", e); |
| | | return BaseResponseUtils.buildException(e.getMessage()) ; |
| | | } |
| | | if(count <= 0){ |
| | | return BaseResponseUtils.buildSuccess(true) ; |
| | | }else{ |
| | | return BaseResponseUtils.buildSuccess(true) ; |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrBase.district; |
| | | |
| | | import com.dy.pipIrrGlobal.daoBa.BaDistrictMapper; |
| | | import com.dy.pipIrrGlobal.pojoBa.BaDistrict; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Slf4j |
| | | @Service |
| | | public class DistrictSv { |
| | | |
| | | private BaDistrictMapper baDistrictMapper ; |
| | | |
| | | @Autowired |
| | | private void setBaDistrictMapper(BaDistrictMapper baDistrictMapper){ |
| | | this.baDistrictMapper = baDistrictMapper ; |
| | | } |
| | | |
| | | |
| | | public int save(BaDistrict po){ |
| | | return this.baDistrictMapper.insert(po) ; |
| | | } |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrBase.district; |
| | | |
| | | import jakarta.validation.constraints.Max; |
| | | import jakarta.validation.constraints.Min; |
| | | import lombok.*; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import org.hibernate.validator.constraints.Length; |
| | | |
| | | @Data |
| | | @ToString |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | @Builder |
| | | @Schema(name = "è¡æ¿åºåå¼å¯¹è±¡") |
| | | public class DistrictVo { |
| | | @Schema(description = "è¡æ¿åºåç§°", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotEmpty(message = "è¡æ¿åºåç§°ä¸è½ä¸ºç©º") //ä¸è½ä¸ºç©ºä¹ä¸è½ä¸ºnull |
| | | @Length(message = "è¡æ¿åºåç§°å°äº{max}å", min = 1, max = 25) |
| | | public String name ; |
| | | |
| | | @Schema(description = "è¡æ¿åºçº§å«", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "è¡æ¿åºçº§å«ä¸è½ä¸ºç©º") //ä¸è½ä¸ºç©ºä¹ä¸è½ä¸ºnull |
| | | @Max(message = "è¡æ¿åºçº§å«ä¸æ£ç¡®", value = 10) |
| | | @Min(message = "è¡æ¿åºçº§å«ä¸æ£ç¡®",value = 0) |
| | | public Byte level ; |
| | | |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrBase.district; |
| | | |
| | | import com.dy.pipIrrGlobal.pojoBa.BaDistrict; |
| | | import com.dy.pipIrrGlobal.util.TypeConversionDistrict; |
| | | import org.mapstruct.Mapper; |
| | | import org.mapstruct.Mapping; |
| | | import org.mapstruct.factory.Mappers; |
| | | |
| | | @Mapper(uses = {TypeConversionDistrict.class}) |
| | | public interface DistrictVoMapper { |
| | | DistrictVoMapper INSTANCT = Mappers.getMapper(DistrictVoMapper.class); |
| | | /** |
| | | * vo转po |
| | | * @param vo å¼å¯¹è±¡ |
| | | * @return po |
| | | */ |
| | | @Mapping(target = "id", ignore = true) |
| | | @Mapping(target = "name", source = "name") |
| | | @Mapping(target = "level", source = "level", qualifiedByName = "districtLevelByteToObj") |
| | | BaDistrict convert(DistrictVo vo); |
| | | } |
| | |
| | | package com.dy.pipIrrDemo.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; |
| | | |
| | | @Configuration |
| | | @SuppressWarnings("unchecked")//ä¸å æ¤æ³¨è§£ï¼ç¼è¯æ¶è¦åï¼â使ç¨äºæªç»æ£æ¥æä¸å®å
¨çæä½ãâ |
| | | public class WebFilterConfiguration { |
| | | |
| | | private static final int orger_demoSetDataSourceFilter = 1 ; |
| | | @Value("${pipIrr.global.dev}") |
| | | public String isDevStage ;//æ¯å¦ä¸ºå¼åé¶æ®µ |
| | | @Value("${pipIrr.global.dsName}") |
| | | public String dsName ;//å¼åé¶æ®µçæ°æ®æºåç§° |
| | | |
| | | /** |
| | | * DevOfDataSourceNameSetFilterä¸UserTokenFilteråªè½ä¸ä¸ªè¢«é
ç½®ä¸ï¼ |
| | | * æä»¥ä»ä»¬çorder齿¯1 |
| | | */ |
| | | private static final int order_UserTokenFilter = 1 ;//ä¸ä¸é¢ |
| | | private static final int order_DevOfDataSourceNameSetFilter = 1 ; |
| | | |
| | | |
| | | @Bean |
| | | public DemoSetDataSourceFilter getDemoSetDataSourceFilter(){ |
| | | return new DemoSetDataSourceFilter() ; |
| | | } |
| | | |
| | | @Bean |
| | | public FilterRegistrationBean<? extends Filter> reqDemoSetDataSourceFilter(DemoSetDataSourceFilter filter) { |
| | | FilterRegistrationBean<DemoSetDataSourceFilter> filterRegistrationBean = new FilterRegistrationBean(); |
| | | |
| | | filterRegistrationBean.setFilter(filter); |
| | | filterRegistrationBean.addUrlPatterns("/*");//é
ç½®è¿æ»¤è§å |
| | | filterRegistrationBean.addInitParameter("name","I am DemoSetDataSourceFilter");//设置initåæ° |
| | | filterRegistrationBean.setName("demoSetDataSourceFilter");//è®¾ç½®è¿æ»¤å¨åç§° |
| | | filterRegistrationBean.setOrder(orger_demoSetDataSourceFilter);//æ§è¡æ¬¡åº |
| | | |
| | | 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; |
| | | } |
| | | |
| | |
| | | package com.dy.pipIrrDemo.config; |
| | | |
| | | import com.dy.common.webListener.ConfigListener; |
| | | import com.dy.common.webListener.GenerateIdSetSuffixListener; |
| | | import jakarta.servlet.ServletContextListener; |
| | | import org.springframework.boot.web.servlet.ServletListenerRegistrationBean; |
| | |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | @Configuration |
| | | @SuppressWarnings("unchecked")//ä¸å ç¼è¾æ¶è¦åï¼â使ç¨äºæªç»æ£æ¥æä¸å®å
¨çæä½ãâ |
| | | //@SuppressWarnings("unchecked")//ä¸å ç¼è¾æ¶è¦åï¼â使ç¨äºæªç»æ£æ¥æä¸å®å
¨çæä½ãâ |
| | | public class WebListenerConfiguration { |
| | | |
| | | /** |
| | | * å¯å¨é¡ºåº |
| | | */ |
| | | private static final int order_config = 1 ; |
| | | //private static final int order_config = 1 ; |
| | | private static final int order_idSetSuffix = 2 ; |
| | | |
| | | // @Bean |
| | |
| | | @Bean |
| | | public ServletListenerRegistrationBean<? extends ServletContextListener> reqSsoListener() { |
| | | ServletListenerRegistrationBean<GenerateIdSetSuffixListener> listenerRegistrationBean = new ServletListenerRegistrationBean<>(); |
| | | GenerateIdSetSuffixListener listener = new GenerateIdSetSuffixListener(); |
| | | listenerRegistrationBean.setListener(listener); |
| | | listenerRegistrationBean.setListener(new GenerateIdSetSuffixListener()); |
| | | listenerRegistrationBean.setOrder(order_idSetSuffix); |
| | | return listenerRegistrationBean; |
| | | } |
| | |
| | | context-path: /demo #web访é®ä¸ä¸æè·¯å¾ |
| | | context-parameters: |
| | | #GenerateIdSetSuffixListenerä¸åºç¨ï¼åå¼èå´æ¯0-99 |
| | | idSuffix: 1 |
| | | idSuffix: 99 |
| | | #ConfigListenerä¸åºç¨ |
| | | #configFileNames: config-global.xml,config-demo.xml |
| | | |
| | |
| | | package com.dy.pipIrrDemo.mp; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.dy.common.multiDataSource.DataSourceContext; |
| | | import com.dy.pipIrrGlobal.daoDemo.DemoMpMapper; |
| | | import com.dy.pipIrrGlobal.pojoDemo.DemoMp; |
| | |
| | | context-path: /gis #web访é®ä¸ä¸æè·¯å¾ |
| | | context-parameters: |
| | | #GenerateIdSetSuffixListenerä¸åºç¨ï¼åå¼èå´æ¯0-99 |
| | | idSuffix: 1 |
| | | idSuffix: 4 |
| | | #ConfigListenerä¸åºç¨ |
| | | #configFileNames: config-global.xml,config-demo.xml |
| | |
| | | context-path: /remote #web访é®ä¸ä¸æè·¯å¾ |
| | | context-parameters: |
| | | #GenerateIdSetSuffixListenerä¸åºç¨ï¼åå¼èå´æ¯0-99 |
| | | idSuffix: 1 |
| | | idSuffix: 2 |
| | | #ConfigListenerä¸åºç¨ |
| | | #configFileNames: config-global.xml,config-demo.xml |
| | |
| | | if(userPo.supperAdmin != null && userPo.supperAdmin == 1){ |
| | | vo.hasPower = true ; |
| | | }else{ |
| | | if(userPo.privileges != null && userPo.privileges.size() > 0){ |
| | | vo.hasPower = this.hasOnePrivilege(privilege, userPo) ; |
| | | if(!vo.hasPower){ |
| | | vo.hasPower = this.hasAllPrivilege(allPrivilege, userPo) ; |
| | | if(privilege.equals("-1")){ |
| | | //æ éæééªè¯ |
| | | vo.hasPower = true ; |
| | | }else{ |
| | | if(userPo.privileges != null && userPo.privileges.size() > 0){ |
| | | vo.hasPower = this.hasOnePrivilege(privilege, userPo) ; |
| | | if(!vo.hasPower){ |
| | | vo.hasPower = this.hasAnyPrivilege(anyPrivilege, userPo) ; |
| | | vo.hasPower = this.hasAllPrivilege(allPrivilege, userPo) ; |
| | | if(!vo.hasPower){ |
| | | vo.hasPower = this.hasAnyPrivilege(anyPrivilege, userPo) ; |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | context-path: /sso #web访é®ä¸ä¸æè·¯å¾ |
| | | context-parameters: |
| | | #GenerateIdSetSuffixListenerä¸åºç¨ï¼åå¼èå´æ¯0-99 |
| | | IdSuffix: 0 |
| | | IdSuffix: 3 |
| | | #ConfigListenerä¸åºç¨ |
| | | configFileNames: config-global.xml,config-sso.xml |
| | |
| | | |
| | | <!--mysql驱å¨--> |
| | | <dependency> |
| | | <groupId>mysql</groupId> |
| | | <artifactId>mysql-connector-java</artifactId> |
| | | <groupId>com.mysql</groupId> |
| | | <artifactId>mysql-connector-j</artifactId> |
| | | <version>8.0.33</version> |
| | | </dependency> |
| | | <!--druid-spring-bootè¿æ¥æ± --> |
| | |
| | | <version>2.0.40</version> |
| | | </dependency> |
| | | |
| | | <!-- vo poè½¬æ¢ --> |
| | | <!-- vo poè½¬æ¢ å
¨å±æ²¡æä¸é¢ä¾èµï¼æä»¥æ¤å¤å¿
é¡»å çæ¬å·--> |
| | | <dependency> |
| | | <groupId>org.mapstruct</groupId> |
| | | <artifactId>mapstruct</artifactId> |
| | |
| | | |
| | | <!--mysql驱å¨--> |
| | | <dependency> |
| | | <groupId>mysql</groupId> |
| | | <artifactId>mysql-connector-java</artifactId> |
| | | <groupId>com.mysql</groupId> |
| | | <artifactId>mysql-connector-j</artifactId> |
| | | <!--对åºèªå·±çµèå®è£
çmysqlçæ¬--> |
| | | <version>8.0.33</version> |
| | | <type>pom</type> |
| | |
| | | <type>pom</type> |
| | | <scope>import</scope> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | </dependencyManagement> |
| | | |
| | |
| | | |
| | | |
| | | <!--mysql驱å¨--> |
| | | <dependency> |
| | | <groupId>mysql</groupId> |
| | | <artifactId>mysql-connector-java</artifactId> |
| | | </dependency> |
| | | |
| | | <!--druid-spring-bootè¿æ¥æ± --> |
| | | <dependency> |
| | | <groupId>com.alibaba</groupId> |
New file |
| | |
| | | https://docs.qq.com/doc/DRHBkeVlCekp1d1RU |