# jn_fengcheng **Repository Path**: gjs777/jn_fengcheng ## Basic Information - **Project Name**: jn_fengcheng - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-11-23 - **Last Updated**: 2023-11-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 凤城项目 ## 端口 1. fengcheng-gateway(7050): 网关模块 2. fengcheng-springbootadmin(7052):监控模块 3. fengcheng-user(7051): 用户模块 3. fengcheng-server(7054): 业务模块 3. fengcheng-system(7053): 系统模块 4. xxj-job-admin(7016):定时任务 5. fengcheng-common:公共模块 6. fengcheng-common-api -- 远程方法调用公共模块:openfeign接口以及fallback工厂 7. fengcheng-common-redis -- redis配置类 8. fengcheng-common-security -- 权限校验 9. fengcheng-common-core -- 公共服务模块包括:常量,异常,统一返回值,工具类 10. fengcheng-common-druid --集成druid连接池监控(访问地址http://ip:9009/{moudle名称}/druid/login.html),账号admin,密码geovis@123 11. fengcheng-common-xxljob --任务调度公共moudle 12. fengcheng-common-system:系统功能模块 目前有操作记录日志功能,有需求可以继续写 13. fengcheng-common-log --公共模块,操作记录功能 使用方法,引入log,core,api,security公共模块后 在需要记录操作的接口上使用注解@com.geovis.log.annotation.Log注解,信息title为模块名(自定义),businessType为操作类型(自定义) 其他参数可进入源码查看 14.docker_portainer(7055)--docker管理模块 username:admin password:geovis@123 15:docker仓库(5000) # 注意 ## 1 跨站点拦截 fengcheng-common-security模块 该模块除了权限校验,用户校验机制外,与安全有关的跨站点配置也在该模块。 config包里的RefererInterceptor是跨站点校验统一拦截器,WebConfig是将拦截器注入spring生效。 拦截器的白名单在该模块下的application-referer.yml中配置 其他模块在使用这个基础模块之后,(已调整为选配,不引入则不生效)配置文件需要引入application-referer.yml,示例:spring.profiles.include=referer ## 2 缓存机制 fengcheng-common-redis模块 针对缓存机制,可以使用redis自己去写,也可以使用spring提供的spring-boot-starter-cache机制,这个配置在redis模块已经配置完成, 使用时注意两点:1.在对应启动类上加注解@EnableCaching开启缓存机制 2.在需要缓存的方法上加:@Cacheable(cacheNames = "monthReportCalendar",keyGenerator = "sdKeyGenerator") cacheNames的名称根据类和方法随便起,不要重复; key生成机制keyGenerator = "myKeyGenerator"可以自定义一个注入到ioc容器,然后换名字即可,名为myKeyGenerator的key生成器定义在redis模块的config包CacheManagerConfig类里面,可以写多个根据名字使用 ## 3 api成批分配问题 对于post请求使用body参数的时候,多传参数后台是需要禁止的,否则属于高危漏洞,禁止的方法很简单,spring2以后序列化json使用的谷歌的Jackson2ObjectMapperBuilderCustomizer, 只需要在core核心模块内的config包下JsonSerializeConfig类中修改jackson2ObjectMapperBuilderCustomizer方法,使用代码builder.featuresToEnable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);来禁止请求接口时传来多余的参数 ## 微服务框架 1. 网关:gateway--webflux 2. 注册中心: nacos 3. 负载均衡: ribbon 4. 配置中心: nacos 5. 远程方法调用: feign 6. 权限: springSecurity ##docker部署注意事项 代码中有的功能需要访问外部域名,docker部署前需要配置域名服务和网络转发 ###1.centos配置转发 查看是否开启转发:cat /proc/sys/net/ipv4/ip_forward 看输出结果,如果返回是0则未开启ip转发 开启方法: vim /etc/sysctl.conf net.ipv4.ip_forward = 1 使配置生效 sysctl -p ###2.配置docker dns 编辑配置文件daemon.json vi /etc/docker/daemon.json 在dns后面添加dns地址,如下面的"202.102.134.68" ```json { "dns": [ "172.10.0.1", "202.102.134.68"] } ```