当前位置: 首页 > news >正文

黑马头条平台管理实战

黑马头条 08平台管理

  • 1.开始准备和开发思路
    • 1.1.开发网关
    • 1.2编写admin-gateway 代码
  • 2.开发登录微服务
    • 2.1编写登录微服务
  • 3.频道管理
  • 4.敏感词管理
  • 5.用户认证审核
  • 6.自媒体文章人工审核
  • 99. 最后开发中碰到的问题汇总
    • 1.关于nacos 配置 问题
    • 2.在开发频道管理新增频道后端无法接收到前端请求
    • 3.观察了两个方法
    • 4.规范性 dto 和pojo类

程序源码会以压缩包形式放在这 需要的可以取用
需求和接口文档
https://javazhang.lan删zn.com/ix除9CG2k4exxc

https://javazhang.la删nzn.com/iJau除e2k4eyid

1.开始准备和开发思路

(1)发现有登录请求都需要一个网关 作为支撑 , 所以先解决网关问题

1.1.开发网关

待完成项

  1. nacos 写一套配置
  2. 完成网关类编写

学习nacos 配置中 学到了 CORS(跨域资源共享),它是一种安全机制,可以指定哪些外部来源(域、协议或端口)可以访问其资源,当一个网页尝试从不同于他的源(即域名、协议或端口号不同)加载资源,浏览器会检查是否允许这种跨域请求
初步nacos配置

spring:cloud:gateway:globalcors:cors-configurations:'[/**]': #匹配所有请求都处理ocrs跨域问题allowerdOrigins: "*"  #跨域处理哪些请求会被允许 allowedMethods:   #可以跨域请求的方法- GET- POST- PUT- DELETE

编写网关配置类
routes: 下的 是每一个微服务 , 只有编写微服务才有对应的uri 等配置
网关类看懂后, 参考完成的类复制粘贴即可
一共需要 网关 配一套 nacos 微服务也有一套nacos 网关中nacos 嵌套微服务的地址,达到转发的目的

1.2编写admin-gateway 代码

在这里插入图片描述
过滤器 和工具类 可以从wemedia 网关中拷贝一份
AuthorizeFilter 类

package com.heima.admin.gateway.filter;import com.heima.admin.gateway.util.AppJwtUtil;
import io.jsonwebtoken.*;
import org.apache.commons.lang.StringUtils;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.http.HttpStatus;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import java.util.*;public class AuthorizeFilter implements Ordered, GlobalFilter {@Overridepublic Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {//1.获取request 和 response 对象ServerHttpRequest request = exchange.getRequest();ServerHttpResponse response = exchange.getResponse();//2.判断是否是登陆//uri 是完整路径   path 是从完整路径里取到路径if (request.getURI().getPath().contains("/login")){//放行return chain.filter(exchange);}//3.获取tokenString tocken = request.getHeaders().getFirst("token");//4.判断token是否岑在if (StringUtils.isBlank(tocken)){response.setStatusCode(HttpStatus.UNAUTHORIZED);return response.setComplete();}//5.判断token是否有效try {Claims claimsBody = AppJwtUtil.getClaimsBody(tocken);//判断是否过期int i = AppJwtUtil.verifyToken(claimsBody);if (i ==1 || i== 2){response.setStatusCode(HttpStatus.UNAUTHORIZED);return response.setComplete();}//获取用户信息存入hader中Object userId = claimsBody.get("id");ServerHttpRequest serverHttpRequest = request.mutate().headers(httpHeaders -> {httpHeaders.add("userId", userId + "");}).build();//重置请求exchange.mutate().request(serverHttpRequest);}catch (Exception e){e.printStackTrace();}//6.放行return chain.filter(exchange);}/*** 优先级设置 值越小 优先级越大* @return*/@Overridepublic int getOrder() {return 0;}}

AppJwtUtil 类

package com.heima.admin.gateway.util;import io.jsonwebtoken.*;import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import java.util.*;public class AppJwtUtil {//TOKEN的有效期一天private static final int TOKEN_TIME_OUT = 24 * 60 * 60;//加密KEYprivate static final String TOKEN_ENCRY_KEY="MDk4ZjZiY2Q0NjIxZDM3M2NhZGU0ZTgzMjYyN2I0ZjY";//最小刷新间隔Sprivate static final int REFRESH_TIME = 300;//生产IDpublic static String getToken(Long id){Map<String , Object> claimMaps = new HashMap<>();long currentTime = System.currentTimeMillis();claimMaps.put("id",id);return Jwts.builder().setId(UUID.randomUUID().toString()).setIssuedAt(new Date(currentTime)) //签发时间.setSubject("system").setAudience("app").compressWith(CompressionCodecs.GZIP).signWith(SignatureAlgorithm.HS512 , generalKey()).setExpiration(new Date(currentTime + TOKEN_TIME_OUT * 1000))//过期时间戳.addClaims(claimMaps).compact();}/*** 获取token中的claims信息** @param token* @return*/private static Jws<Claims> getJws(String token) {return Jwts.parser().setSigningKey(generalKey()).parseClaimsJws(token);}/*** 获取payload body信息** @param token* @return*/public static Claims getClaimsBody(String token) {try {return getJws(token).getBody();}catch (ExpiredJwtException e){return null;}}/*** 获取hearder body信息** @param token* @return*/public static JwsHeader getHeaderBody(String token) {return getJws(token).getHeader();}/*** 是否过期** @param claims* @return -1:有效,0:有效,1:过期,2:过期*/public static int verifyToken(Claims claims) {if(claims==null){return 1;}try {claims.getExpiration().before(new Date());// 需要自动刷新TOKENif((claims.getExpiration().getTime()-System.currentTimeMillis())>REFRESH_TIME*1000){return -1;}else {return 0;}} catch (ExpiredJwtException ex) {return 1;}catch (Exception e){return 2;}}/*** 由字符串生成加密key** @return*/public static SecretKey generalKey() {byte[] encodedKey = Base64.getEncoder().encode(TOKEN_ENCRY_KEY.getBytes());SecretKey key = new SecretKeySpec(encodedKey, 0, encodedKey.length, "AES");return key;}public static void main(String[] args) {/* Map map = new HashMap();map.put("id","11");*/System.out.println(AppJwtUtil.getToken(1102L));Jws<Claims> jws = AppJwtUtil.getJws("eyJhbGciOiJIUzUxMiIsInppcCI6IkdaSVAifQ.H4sIAAAAAAAAADWLQQqEMAwA_5KzhURNt_qb1KZYQSi0wi6Lf9942NsMw3zh6AVW2DYmDGl2WabkZgreCaM6VXzhFBfJMcMARTqsxIG9Z888QLui3e3Tup5Pb81013KKmVzJTGo11nf9n8v4nMUaEY73DzTabjmDAAAA.4SuqQ42IGqCgBai6qd4RaVpVxTlZIWC826QA9kLvt9d-yVUw82gU47HDaSfOzgAcloZedYNNpUcd18Ne8vvjQA");Claims claims = jws.getBody();System.out.println(claims.get("id"));}
}

主启动类 AdminWebGatewayAplication

package com.heima.admin.gateway;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;@SpringBootApplication
@EnableDiscoveryClient
public class AdminWebGatewayAplication {public static void main(String[] args) {SpringApplication.run(AdminWebGatewayAplication.class,args);}
}

配置文件

server:port: 6001
spring:application:name: leadnews-admin-web-gatewaycloud:nacos:discovery:server-addr: 192.168.200.130:8848config:server-addr: 192.168.200.130:8848file-extension: yml

Nacos 配置

spring:cloud:gateway:globalcors:add-to-simple-url-handler-mapping: truecorsConfigurations:'[/**]':allowedHeaders: "*"allowedOrigins: "*"allowedMethods:- GET- POST- DELETE- PUT- OPTION

2.开发登录微服务

别忘记按照要求 导入pojo类
在这里插入图片描述

2.1编写登录微服务

创建对应模块
在这里插入图片描述

LoginController 代码

package com.heima.adminWeb.controller.v1;import com.heima.adminWeb.service.AwUserService;
import com.heima.model.admin.web.dto.AdminLoginDto;
import com.heima.model.common.dtos.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;@RestController
@RequestMapping("/login")
@Slf4j
public class LoginController {@Autowiredprivate AwUserService awUserService;@PostMapping("/in")public ResponseResult login(@RequestBody AdminLoginDto dto){log.info("dto{}",dto);return   awUserService.login(dto);}
}

AwUserMapper代码

package com.heima.adminWeb.mapper;import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.heima.model.admin.web.pojo.AdUser;
import org.apache.ibatis.annotations.Mapper;@Mapper
public interface AwUserMapper extends BaseMapper<AdUser> {
}

service 和 impl 实现类

package com.heima.adminWeb.service;import com.baomidou.mybatisplus.extension.service.IService;
import com.heima.model.admin.web.dto.AdminLoginDto;
import com.heima.model.admin.web.pojo.AdUser;
import com.heima.model.common.dtos.ResponseResult;public interface AwUserService extends IService<AdUser> {ResponseResult login( AdminLoginDto dto);
}
package com.heima.adminWeb.service.impl;import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heima.adminWeb.mapper.AwUserMapper;
import com.heima.adminWeb.service.AwUserService;
import com.heima.model.admin.web.dto.AdminLoginDto;
import com.heima.model.admin.web.pojo.AdUser;
import com.heima.model.common.dtos.ResponseResult;import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.utils.common.AppJwtUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;import java.util.HashMap;@Service
public class AwUserServiceImpl  extends ServiceImpl<AwUserMapper , AdUser> implements AwUserService {/*** @param dto* @return*/@Overridepublic ResponseResult login(AdminLoginDto dto) {//1.检查参数if (StringUtils.isBlank(dto.getName()) || StringUtils.isBlank(dto.getPassword()) ){return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID);}//检查用户是否存在AdUser adUser = getOne(Wrappers.<AdUser>lambdaQuery().eq(AdUser::getName, dto.getName()));if (adUser == null){return ResponseResult.errorResult(AppHttpCodeEnum.DATA_NOT_EXIST);}//验证密码String salt = adUser.getSalt();String password = dto.getPassword();String pswd = DigestUtils.md5DigestAsHex((password + salt).getBytes());if (pswd.equals(adUser.getPassword())){//返回数据jwtHashMap<String, Object> map = new HashMap<>();map.put("token" , AppJwtUtil.getToken(adUser.getId().longValue()));//删除密码和盐 保护隐私adUser.setSalt("");adUser.setPassword("");map.put("user" , adUser);return ResponseResult.okResult(map);}else{return ResponseResult.errorResult(AppHttpCodeEnum.LOGIN_PASSWORD_ERROR);}}
}

主启动类

package com.heima.adminWeb;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;@SpringBootApplication
@EnableDiscoveryClient
public class AdminWebApplication {public static void main(String[] args) {SpringApplication.run(AdminWebApplication.class , args);}
}

配置文件

server:port: 51809
spring:application:name: leadnews-admin-webcloud:nacos:discovery:server-addr: 192.168.200.130:8848config:server-addr: 192.168.200.130:8848file-extension: yml
logging:level:root: INFOorg.springframework.cloud.gateway: DEBUGorg.springframework.web: DEBUGcom.heima.adminWeb: DEBUGfile:name: ./logs/${spring.application.name}.logpattern:console: "%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{36} - %msg%n"file: "%d{yyyy-MM-dd HH:mm:ss} %-5level [%thread] %logger{36} - %msg%n"

登录Nacos配置
复制粘贴别的配置文件即可 注意数据库改操作数据库名称

spring:kafka:bootstrap-servers: 192.168.200.130:9092producer:retries: 10key-serializer: org.apache.kafka.common.serialization.StringSerializervalue-serializer: org.apache.kafka.common.serialization.StringSerializerdatasource:driver-class-name: com.mysql.jdbc.Driverurl: jdbc:mysql://localhost:3306/leadnews_admin?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTCusername: rootpassword: root
# 设置Mapper接口所对应的XML文件位置,如果你在Mapper接口中有自定义方法,需要进行该配置
mybatis-plus:mapper-locations: classpath*:mapper/*.xml# 设置别名包扫描路径,通过该属性可以给包中的类注册别名type-aliases-package: com.heima.model.media.pojosminio:accessKey: miniosecretKey: minio123bucket: leadnewsendpoint: http://192.168.200.130:9000readPath: http://192.168.200.130:9000
aliyun:accessKeyId: LTAI5tCWHCcfvqQzu8k2oKmXsecret: auoKUFsghimbfVQHpy7gtRyBkoR4vc#aliyun.scenes=porn,terrorism,ad,qrcode,live,logoscenes: terrorismfeign:# 开启feign对hystrix熔断降级的支持hystrix:enabled: true# 修改调用超时时间client:config:default:connectTimeout: 2000readTimeout: 2000

网关Nacos 自媒体微服务是下一节频道管理用到的

spring:cloud:gateway:globalcors:add-to-simple-url-handler-mapping: truecorsConfigurations:'[/**]':allowedHeaders: "*"allowedOrigins: "*"allowedMethods:- GET- POST- DELETE- PUT- OPTIONroutes:# 平台管理登录- id: adminloginuri: lb://leadnews-admin-webpredicates:- Path=/admin/**filters:- StripPrefix= 1#自媒体服务- id: leadnews-wemediauri: lb://leadnews-wemediapredicates:- Path=/wemedia/**filters:- StripPrefix= 1

3.频道管理

增删改查 频道功能 代码一起给出 主要编写图中三个类
在这里插入图片描述
WmchannelController

package com.heima.wemedia.controller.v1;import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmFindDto;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.service.WmChannelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;import javax.annotation.Resource;@RestController
@RequestMapping("/api/v1/channel")
@Slf4j
public class WmchannelController {@Autowiredprivate WmChannelService wmChannelService;;@GetMapping("/channels")public ResponseResult findAll() {return wmChannelService.findAll();}//   频道管理 功能开始//新增频道@PostMapping("/save")public ResponseResult saveChanel(@RequestBody WmChannel wmChannel){return wmChannelService.saveChanel(wmChannel);}//分页查询@PostMapping("/list")public ResponseResult findList(@RequestBody WmFindDto dto){return wmChannelService.findList( dto);}/*** 修改频道*/@PostMapping("/update")public ResponseResult update(@RequestBody WmChannel wmChannel){return wmChannelService.update(wmChannel);}//删除频道@GetMapping("/del/{id}")public ResponseResult remove(@PathVariable Integer id) {return wmChannelService.removeChanel(id);}}

WmChannelService

package com.heima.wemedia.service;import com.baomidou.mybatisplus.extension.service.IService;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmFindDto;
import com.heima.model.wemedia.pojos.WmChannel;
import org.springframework.web.bind.annotation.RequestBody;public interface WmChannelService extends IService<WmChannel> {//查询所有频道public ResponseResult findAll();//查看文章详情public ResponseResult select(Integer id);//保存文章频道public ResponseResult saveChanel( WmChannel wmChannel);/*** 查询所有频道* @param dto* @return*/ResponseResult findList(WmFindDto dto);//修改频道ResponseResult update(WmChannel wmChannel);//删除频道ResponseResult removeChanel(Integer id);}

WmChannelServiceImpl

package com.heima.wemedia.service.impl;import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.wemedia.dtos.WmFindDto;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.model.wemedia.pojos.WmNews;
import com.heima.wemedia.mapper.WmChannelMapper;
import com.heima.wemedia.mapper.WmNewsMapper;
import com.heima.wemedia.service.WmChannelService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;import java.util.Date;@Service
@Transactional
@Slf4j
public class WmChannelServiceImpl extends ServiceImpl<WmChannelMapper, WmChannel> implements WmChannelService {/*** @return*/@Overridepublic ResponseResult findAll() {return ResponseResult.okResult(list());}/*** 查看文章** @param id* @return*/@Overridepublic ResponseResult select(Integer id) {WmChannel byId = super.getById(id);return ResponseResult.okResult(byId);}/*** 保存频道** @param wmChannel* @return*/@Overridepublic ResponseResult saveChanel(WmChannel wmChannel) {if (wmChannel == null || StringUtils.isBlank(wmChannel.getName())) {return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID);}String name = wmChannel.getName();WmChannel one = getOne(Wrappers.<WmChannel>lambdaQuery().eq(WmChannel::getName, name));if (one == null) {wmChannel.setIsDefault(true);wmChannel.setCreatedTime(new Date());save(wmChannel);return ResponseResult.okResult("保存成功");} else {return ResponseResult.errorResult(AppHttpCodeEnum.DATA_EXIST);}}/*** 查询所有频道** @param dto* @return*/@Overridepublic ResponseResult findList(WmFindDto dto) {if (dto == null) {return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID);}//如果当前页是空 那就给一个初始值 , 每页条数也是if (dto.getPage() == null || dto.getSize() == null) {dto.setPage(1);dto.setSize(10);}//开始分页查询Page page = new Page(dto.getPage(), dto.getSize());//构建查询LambdaQueryWrapper<WmChannel> wrapper = new LambdaQueryWrapper();//如果有名称就根据名称查询if (StringUtils.isNoneBlank(dto.getName())) {wrapper.like(WmChannel::getName, dto.getName());}//如果有状态根据状态查询if (dto.getStatus() != null) {wrapper.eq(WmChannel::getStatus, dto.getStatus());}//倒叙wrapper.orderByDesc(WmChannel::getCreatedTime);//开始分页page = page(page, wrapper);//结果返回ResponseResult responseResult = new PageResponseResult(dto.getPage(), dto.getSize(), (int) page.getTotal());responseResult.setData(page.getRecords());return responseResult;}@Autowiredprivate WmNewsMapper wmNewsMapper;/*** 更新频道** @param wmChannel* @return*/@Overridepublic ResponseResult update(WmChannel wmChannel) {if (wmChannel.getId() == null || wmChannel == null) {return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID);}//设置缺少属性wmChannel.setCreatedTime(new Date());wmChannel.setIsDefault(true);//查看是否被引用if (wmChannel.getStatus() == false) {LambdaQueryWrapper<WmNews> query = new LambdaQueryWrapper();query.eq(WmNews::getChannelId, wmChannel.getId());//审核中的文章使用这个频道也不能删除//    List<WmNews> wmNews = wmNewsMapper.selectList(query);int count = wmNewsMapper.selectCount(query);if (count > 0) {return ResponseResult.errorResult(AppHttpCodeEnum.NO_OPERATOR_AUTH, "素材已被引用");}}updateById(wmChannel);return ResponseResult.okResult("更新成功");}/*** 删除频道* @param id* @return*/@Overridepublic ResponseResult removeChanel(Integer id) {if (id == null) {return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID);}WmChannel channel = getById(id);if (channel.getStatus() != false){return ResponseResult.errorResult(AppHttpCodeEnum.NO_OPERATOR_AUTH, "素材已启用无法删除");}removeById(id);return ResponseResult.okResult("删除成功");}
}

4.敏感词管理

nacos 配置不用动 就是最基本增删改查 列出核心代码
AdSensitiveController

package com.heima.wemedia.controller.v1;import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.wemedia.dtos.AdSentiveDto;
import com.heima.model.wemedia.pojos.WmSensitive;
import com.heima.wemedia.service.AdSensitiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;@RestController
@RequestMapping("/api/v1/sensitive")
public class AdSensitiveController {@Autowiredprivate AdSensitiveService adSensitiveService;//新增敏感词@PostMapping("/save")public ResponseResult save(@RequestBody WmSensitive wmSensitive) {return adSensitiveService.saveSensitive(wmSensitive);}@PostMapping("/list")public ResponseResult list(@RequestBody AdSentiveDto dto) {return adSensitiveService.selectList(dto);}@DeleteMapping("/del/{id}")public ResponseResult del(@PathVariable Integer id) {if ( adSensitiveService.removeById(id)){return ResponseResult.okResult("删除成功");}else{return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID,"删除失败");}}@PostMapping("/update")public ResponseResult update(@RequestBody WmSensitive wmSensitive) {return adSensitiveService.updateSensitive(wmSensitive);}}

AdSensitiveService

package com.heima.wemedia.service;import com.baomidou.mybatisplus.extension.service.IService;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.AdSentiveDto;
import com.heima.model.wemedia.pojos.WmSensitive;public interface AdSensitiveService extends IService<WmSensitive> {//新增敏感词ResponseResult saveSensitive(WmSensitive wmSensitive);//分页查询敏感词ResponseResult selectList(AdSentiveDto dto);//修改敏感词ResponseResult updateSensitive(WmSensitive wmSensitive);
}

AdSensitiveServiceImpl

package com.heima.wemedia.service.impl;import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.injector.methods.SelectList;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.wemedia.dtos.AdSentiveDto;
import com.heima.model.wemedia.pojos.WmSensitive;
import com.heima.wemedia.mapper.WmSensitiveMapper;
import com.heima.wemedia.service.AdSensitiveService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;import java.util.Date;@Service
public class AdSensitiveServiceImpl extends ServiceImpl<WmSensitiveMapper , WmSensitive> implements AdSensitiveService {/*** 新增敏感词* @param wmSensitive*/@Overridepublic ResponseResult saveSensitive(WmSensitive wmSensitive) {if(StringUtils.isBlank(wmSensitive.getSensitives())){return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID);}String sensitives = wmSensitive.getSensitives();WmSensitive sensitive = getOne(Wrappers.<WmSensitive>lambdaQuery().eq(WmSensitive::getSensitives, sensitives));if (sensitive != null){return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID,"敏感词已存在");}wmSensitive.setCreatedTime(new Date());save(wmSensitive);return ResponseResult.okResult("新增成功");}/*** 分页查询敏感词* @param dto* @return*/@Overridepublic ResponseResult selectList(AdSentiveDto dto) {//设置初始值if (dto.getPage() == null || dto.getSize() == null){dto.setPage(1);dto.setSize(10);}//开始分页IPage page = new Page(dto.getPage(), dto.getSize());LambdaQueryWrapper<WmSensitive> wrapper = new LambdaQueryWrapper();if (StringUtils.isNoneBlank(dto.getName())){wrapper.like(WmSensitive::getSensitives,dto.getName());}//返回结果page = page(page,wrapper);ResponseResult responseResult = new PageResponseResult(dto.getPage(), dto.getSize(), (int) page.getTotal());responseResult.setData(page.getRecords());return responseResult;}/*** @param wmSensitive* @return*/@Overridepublic ResponseResult updateSensitive(WmSensitive wmSensitive) {if (wmSensitive.getId() == null){return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID);}wmSensitive.setCreatedTime(new Date());updateById(wmSensitive);return ResponseResult.okResult("修改成功");}
}

5.用户认证审核

http://localhost:8803/service_6001/user/api/v1/auth/list
请求路径 , 发现需要经过nacos 设置 可以转发到user微服务 , 不转发自己配一套应该也可以 就是太麻烦 所以直接用

spring:cloud:gateway:globalcors:add-to-simple-url-handler-mapping: truecorsConfigurations:'[/**]':allowedHeaders: "*"allowedOrigins: "*"allowedMethods:- GET- POST- DELETE- PUT- OPTIONroutes:# 平台管理登录- id: adminloginuri: lb://leadnews-admin-webpredicates:- Path=/admin/**filters:- StripPrefix= 1#自媒体服务- id: leadnews-wemediauri: lb://leadnews-wemediapredicates:- Path=/wemedia/**filters:- StripPrefix= 1#用户服务- id: useruri: lb://leadnews-userpredicates:- Path=/user/**filters:- StripPrefix= 1

测试后发现请求成功到达在这里插入图片描述

主要代码如下
AdAuthController

package com.heima.user.controller.v1;import com.heima.model.admin.web.dto.AdUserDto;
import com.heima.model.admin.web.pojo.ApUserRealname;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.user.service.AdUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;@RestController
@RequestMapping("/api/v1/auth")
public class AdAuthController {@Autowiredprivate AdUserService adUserService;//分页查询@PostMapping("/list")public ResponseResult selectList(@RequestBody AdUserDto dto) {return  adUserService.selectList(dto);}@PostMapping("/authFail")public ResponseResult authErrot(@RequestBody ApUserRealname dto){dto.setStatus((short) 2);dto.setReason("审核不通过");return adUserService.authErrot(dto);}@PostMapping("/authPass")public ResponseResult authPass(@RequestBody ApUserRealname dto){dto.setStatus((short) 9);return adUserService.authErrot(dto);}}

AdUserService

package com.heima.user.service;import com.baomidou.mybatisplus.extension.service.IService;
import com.heima.model.admin.web.dto.AdUserDto;
import com.heima.model.admin.web.pojo.AdUser;
import com.heima.model.admin.web.pojo.ApUserRealname;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.pojos.ApUser;public interface AdUserService extends IService<ApUserRealname> {// 分页查询ResponseResult selectList(AdUserDto dto);//审核成功或失败通用ResponseResult authErrot(ApUserRealname dto);
}

impl

package com.heima.user.service.impl;import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heima.model.admin.web.dto.AdUserDto;
import com.heima.model.admin.web.pojo.AdUser;
import com.heima.model.admin.web.pojo.ApUserRealname;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.user.mapper.AdUserMapper;
import com.heima.user.mapper.ApUserRealnameMapper;
import com.heima.user.service.AdUserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.util.Date;@Service
public class AdUserServiceImpl extends ServiceImpl<ApUserRealnameMapper, ApUserRealname> implements AdUserService {/*** @param dto* @return*/@Overridepublic ResponseResult selectList(AdUserDto dto) {if (dto.getPage() == null || dto.getSize() == null){dto.setPage(1);dto.setSize(10);}IPage page = new Page(dto.getPage(), dto.getSize());LambdaQueryWrapper<ApUserRealname> wrapper = new LambdaQueryWrapper();if (dto.getStatus() != null){wrapper.eq(ApUserRealname::getStatus,dto.getStatus());page = page(page ,wrapper);}else{page = page(page);}ResponseResult responseResult = new PageResponseResult(dto.getPage(), dto.getSize(), (int) page.getTotal());responseResult.setData(page.getRecords());return responseResult;}//审核失败逻辑/*** @param dto* @return*/@Overridepublic ResponseResult authErrot(ApUserRealname dto) {if (dto.getId()==null){return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID);}ApUserRealname byId = getById(dto.getId());byId.setStatus(dto.getStatus());if (dto.getReason() != null) {byId.setReason(dto.getReason());}byId.setUpdatedTime(new Date());updateById(byId);return ResponseResult.okResult("修改成功");}
}

6.自媒体文章人工审核

99. 最后开发中碰到的问题汇总

1.关于nacos 配置 问题

这个是正确的 nacos 关于登录的配置


spring:cloud:gateway:globalcors:add-to-simple-url-handler-mapping: truecorsConfigurations:'[/**]':allowedHeaders: "*"allowedOrigins: "*"allowedMethods:- GET- POST- DELETE- PUT- OPTIONroutes:# 平台管理微服务- id: adminuri: lb://leadnews-admin      #这个lb 后面的是 登录微服务的微服务配置文件名称predicates:

routes 的 uri 路径 /service_6001/admin/login/** 我写成这个就无法访问到后端 而写/admin/** 就可以 虽然知道 /admin 匹配更宽泛 但是为什么 我写精准的就不行呢
在这里插入图片描述
在这里插入图片描述

答 :
结合nginx 配置发现
这里的正则表达式~/service_6001/(.*)会匹配以/service_6001/开头的任何URI,并捕获/service_6001/之后的部分作为变量$1。当您将前端请求发送到http://localhost:8803/service_6001/admin/login/in时,该请求会被这个location块捕获,并且$1将等于admin/login/in。

2.在开发频道管理新增频道后端无法接收到前端请求

!!不需要新建一个模块, 用leadnews-wemedia模块就能完成
因为 请求url 根据nginx 配置 会发给 admin-web-gateway 的配置文件
应在配置文件中配置这个路径转发到哪不然后端接收到
http://localhost:8803/service_6001/wemedia/api/v1/channel/save
正确配置

spring:cloud:gateway:globalcors:add-to-simple-url-handler-mapping: truecorsConfigurations:'[/**]':allowedHeaders: "*"allowedOrigins: "*"allowedMethods:- GET- POST- DELETE- PUT- OPTIONroutes:# 平台管理登录- id: adminloginuri: lb://leadnews-admin-webpredicates:- Path=/admin/**filters:- StripPrefix= 1#自媒体服务- id: leadnews-wemedia   #名字自定义不重复即可uri: lb://leadnews-wemedia   #对应wemedia 的微服务配置文件名称predicates:- Path=/wemedia/**filters:- StripPrefix= 1

3.观察了两个方法

selectList
在这里插入图片描述

在这里插入图片描述
selectCount
在这里插入图片描述

4.规范性 dto 和pojo类

pojo用于和数据库交互 dto 用于和前端交互 , 开发时应注意规范性

相关文章:

黑马头条平台管理实战

黑马头条 08平台管理 1.开始准备和开发思路1.1.开发网关1.2编写admin-gateway 代码 2.开发登录微服务2.1编写登录微服务 3.频道管理4.敏感词管理5.用户认证审核6.自媒体文章人工审核99. 最后开发中碰到的问题汇总1.关于nacos 配置 问题2.在开发频道管理新增频道后端无法接收到前…...

电池管理系统(BMS)架构详细解析:原理与器件选型指南

BMS&#xff08;电池管理系统&#xff09;架构详细讲解 从你提供的BMS&#xff08;Battery Management System&#xff09;架构图来看&#xff0c;主要涉及到电池监控模块、通信模块、功率控制模块等部分。下面我将详细讲解该架构的各个功能模块及其工作原理。 1. 电池管理核…...

SpringBoot环境和Maven配置

SpringBoot环境和Maven配置 1. 环境准备2. Maven2.1 什么是Maven2.2 为什么要学 Maven2.3 创建一个 Maven项目2.4 Maven核心功能2.4.1 项目构建2.4.2 依赖管理2.4.3 Maven Help插件 2.5 Maven 仓库2.5.1本地仓库2.5.2 中央仓库2.5.3 私有服务器, 也称为私服 2.6 Maven设置国内源…...

lambda用法及其原理

目录 lambda形式lambda用法1.sort降序2.swap3.捕捉列表 习题解题 lambda形式 [capture-list](parameters)->return type{function boby}[capture-list]&#xff1a;[捕捉列表]用于捕捉函数外的参数&#xff0c;可以为空&#xff0c;但不能省略&#xff1b;(parameters) &am…...

Postgresql源码(139)vim直接修改postgresql表文件的简单实例

1 前言 PG可以用pageinspect方便的读取查看表文件。本篇介绍一种用vim查看、编辑的方法&#xff0c;案例比较简单&#xff0c;主要分享原理。 修改表文件和controlfile是非常危险的行为&#xff0c;请不要在生产尝试。 2 用例 简化问题&#xff0c;用简单编码的数据类型。 d…...

Lianwei 安全周报|2025.1.2

以下是本周「Lianwei周报」&#xff0c;我们总结推荐了本周的政策/标准/指南最新动态、热点资讯和安全事件&#xff0c;保证大家不错过本周的每一个重点&#xff01; 政策/标准/指南最新动态 01 国家数据局等五部门印发《关于促进企业数据资源开发利用的意见》 为充分释放企业…...

Vue3-跨层组件通信Provide/Inject机制详解

Vue 3 中的 Provide 和 Inject 机制是专为跨层级传递数据而设计的&#xff0c;适用于祖先组件和后代组件之间的通信。与props 和 emits 不同&#xff0c;Provide/Inject 可以跨越多个层级进行数据传递&#xff0c;而不需要逐层传递。 1. Provide provide 是一个在祖先组件中提…...

springcloud 介绍

Spring Cloud是一个基于Spring Boot的微服务架构解决方案集合&#xff0c;它提供了一套完整的工具集&#xff0c;用于快速构建分布式系统。在Spring Cloud的架构中&#xff0c;服务被拆分为一系列小型、自治的微服务&#xff0c;每个服务运行在其独立的进程中&#xff0c;并通过…...

css预处理器sass

在前端开发的世界中&#xff0c;CSS 是构建网页样式的基础。然而&#xff0c;随着项目规模的增大&#xff0c;纯 CSS 的编写和维护往往会变得复杂而繁琐。为了解决这些痛点&#xff0c;Sass&#xff08;Syntactically Awesome Style Sheets&#xff09;应运而生。Sass 是一种 C…...

匠人天工Ai浮雕网站创新发布了ZBrush插件,提效500%,为AI+数字雕刻行业带来新的活力

2025年1月6日&#xff0c;杭州——杭州仓颉造梦数字科技公司旗下产品匠人天工近日宣布推出一款创新的ZBrush插件&#xff0c;旨在为AI数字雕刻行业带来前所未有的效率提升。该插件通过一系列智能化功能&#xff0c;大幅简化了数字雕刻的建模流程&#xff0c;使建模效率提高了50…...

解决 Pangolin 版本不兼容导致的编译错误

在使用 Pangolin 库时&#xff0c;有时候会遇到由于版本不兼容而导致的编译错误。本文将通过一个具体的错误案例&#xff0c;展示如何识别和解决这种问题。 问题描述 在编译时&#xff0c;遇到如下编译错误&#xff1a; /usr/local/include/pangolin/gl/glsl.hpp: In member…...

day01_ Java概述丶开发环境的搭建丶常用DOS命令

编程常识 什么是编程&#xff1f; 所谓编程&#xff0c;就是人们可以使用编程语言对计算机下达命令&#xff0c;让计算机完成人们需要的功能。 编程语言的发展历程 第一代&#xff1a;机器语言 &#xff0c;机器语言由数字组成所有指令。计算器解析运行速度&#xff0c;最快…...

进程间通信——网络通信——UDP

进程间通信&#xff08;分类&#xff09;&#xff1a;网络通信、无名管道、有名管道、信号、消息队列、共享内存、信号量集 OSI七层模型&#xff1a;&#xff08;理论模型&#xff09; 应用层 : 要传输的数据信息&#xff0c;如文件传输&#xff0c;电子邮件等 表示层 : 数…...

(六)vForm 动态表单(数据量大,下拉选卡顿问题)

系列文章目录 (一)vForm 动态表单设计器之使用 (二)vForm 动态表单设计器之下拉、选择 (三)vForm 动态表单解决下拉框无数据显示id问题 (四)vForm 动态表单自定义组件、属性 (五)vForm 动态表单文件上传、下载 文章目录 目录 前言 一、组件改造 1.添加分页所需参…...

asp.net core mvc的 ViewBag , ViewData , Module ,TempData

在 ASP.NET MVC 和 ASP.NET Core MVC 中&#xff0c;ViewBag 和 ViewData 是两种用于将数据从控制器传递到视图&#xff08;View&#xff09;的常用方法。它们都允许控制器将动态数据传递给视图&#xff0c;但它们的实现方式有所不同。关于 Module&#xff0c;它通常指的是某种…...

C#语言的软件开发工具

C#语言的软件开发工具 C#语言作为一种现代化的编程语言&#xff0c;凭借其强大的功能和丰富的生态系统&#xff0c;在软件开发领域得到了广泛的应用。随着C#语言的发展&#xff0c;越来越多的开发工具应运而生。本文将详细介绍C#语言常用的开发工具&#xff0c;包括集成开发环…...

iOS - AutoreleasePool

1. 基本数据结构 // AutoreleasePool 的基本结构 struct AutoreleasePoolPage {static pthread_key_t const key AUTORELEASE_POOL_KEY;magic_t const magic;id *next; // 指向下一个可存放对象的地址pthread_t const thread; // 所属线程AutoreleasePoolPage …...

数据仓库建设方案和经验总结

在做数据集成的过程中&#xff0c;往往第二步的需求就是建设数仓由于数据分散在不同的存储环境或数据库中&#xff0c;对于新业务需求的开发需要人工先从不同的数据库中同步、集中、合并等处理&#xff0c;造成资源和人力的浪费。同时&#xff0c;目前的系统架构&#xff0c;无…...

该单据从未生成交易分录

经常听到采购说&#xff0c;采购匹配明细表中没有xx料号的记录&#xff0c;没有xx供应商的记录。它们用这个报表来与供应商对账的。每每以此为借口拖延着货款不付。没有记录出来&#xff0c;原因各种。之前没有记录下来&#xff0c;想不起来。今天重新分析发现其中一个原因&…...

Flink DataSet API

文章目录 DataSet SourcesDataSet TransformationDataSet Sink序列化器样例一&#xff1a;读 csv 文件生成 csv 文件样例二&#xff1a;读 starrocks 写 starrocks样例三&#xff1a;DataSet、Table Sql 处理后写入 StarRocksDataSet<Row> 遍历遇到的坑 分类&#xff1a;…...

Bash Shell的操作环境

目录 1、路径与指令搜寻顺序 2、bash的进站&#xff08;开机&#xff09;与欢迎信息&#xff1a;/etc/issue&#xff0c;/etc/motd &#xff08;1&#xff09;/etc/issue &#xff08;2&#xff09;/etc/motd 3、bash的环境配置文件 &#xff08;1&#xff09;login与non-…...

web自动化测试环境搭建(python环境下selenium)

环境搭建步骤 安装selenium pip install selenium 安装浏览器 安装浏览器驱动 谷歌浏览器&#xff1a;chromdriver.exe ie浏览器:ieserverdriver.exe FireFox浏览器:geckodriver.exe 特别注意⚠️&#xff1a;下载驱动版本必须与浏览器版本一致 下载地址 淘宝镜像&#xff1…...

解决cursor AI编辑器控制台console中文乱码

chcp 查看当前控制台编码 936 &#xff1a; gbk编码 控制台输入&#xff1a;chcp 65001 设置为utf8...

fail api scope is not declared in the privacy agreement微信小程序uniapp 解决录音无法播放、授权

已解决 fail api scope is not declared in the privacy agreement微信小程序uniapp 解决录音无法播放、授权 没有声明内容协议导致的 微信公众平台&#xff1a;https://mp.weixin.qq.com/【1.左下角的-移动过去后会出现 “帐号设置”】 【2.基本设置->服务内容声明->修…...

ArkTs 状态管理装饰器

在构建页面多为静态界面&#xff0c;如果希望构建一个动态的&#xff0c;有交互的界面&#xff0c;就需要引入‘状态’的概念。 一.基本概念 1.状态变量&#xff1a;被状态装饰器装饰的变量&#xff0c;状态变量值的改变或引起UI的渲染更新 2.常规变量&#xff1a;没有被状态…...

Linux CentOS 7系统如何修改panel 重新打开最小化的界面/软件/程序

CentOS 7系统下&#xff0c;部分用户可能一开始打开界面没有类似Windows的下方菜单栏&#xff0c;只有一个浮动的panel。一旦打开软件&#xff0c;然后点击最小化后&#xff0c;找不到重新打开的方法。 右键panel&#xff0c;点击Add New Items… 选择以下三个基本就可以了&am…...

猫的眼睛有几种颜色?

在猫咪神秘而迷人的世界里&#xff0c;它们的眼睛犹如璀璨星辰&#xff0c;闪烁着各异的光芒&#xff0c;颜色丰富多样&#xff0c;令人着迷。 猫眼睛的颜色&#xff0c;粗略一数&#xff0c;常见的便有黄色、蓝色、绿色、棕色&#xff0c;还有那神秘的异瞳。这些色彩并非无端生…...

200道Java面试题(2025)

Java 基础 1. JDK 和 JRE 有什么区别&#xff1f; JDK&#xff1a;Java Development Kit 的简称&#xff0c;Java 开发工具包&#xff0c;提供了 Java 的开发环境和运行环境。 JRE&#xff1a;Java Runtime Environment 的简称&#xff0c;Java 运行环境&#xff0c;为 Java …...

ros2笔记-2.5.3 多线程与回调函数

本节体验下多线程。 python示例 在src/demo_python_pkg/demo_python_pkg/下新建文件&#xff0c;learn_thread.py import threading import requestsclass Download:def download(self,url,callback):print(f线程&#xff1a;{threading.get_ident()} 开始下载&#xff1a;{…...

openwrt nginx UCI配置过程

openwrt 中nginx有2种配置方法&#xff0c;uci nginx uci /etc/config/nginx 如下&#xff1a; option uci_enable true‘ 如果是true就是使用UCI配置&#xff0c;如果 是false&#xff0c;就要使用/etc/nginx/nginx.conf&#xff0c;一般不要修改。 如果用UCI&#xff0c;其…...

【数据结构】双向循环链表的使用

双向循环链表的使用 1.双向循环链表节点设计2.初始化双向循环链表-->定义结构体变量 创建头节点&#xff08;1&#xff09;示例代码&#xff1a;&#xff08;2&#xff09;图示 3.双向循环链表节点头插&#xff08;1&#xff09;示例代码&#xff1a;&#xff08;2&#xff…...

《Python游戏编程入门》注-第9章8

2 游戏信息的显示 在游戏窗口的上部会显示游戏分数、游戏关卡、剩余砖块数以及剩余小球数等信息,如图12所示。 图12 游戏信息显示 使用如图13所示的代码实现以上功能。 图13 显示游戏信息的代码 其中,print_text()函数MyLibrary....

起重机检测数据集VOC+YOLO格式2316张1类别

数据集格式&#xff1a;Pascal VOC格式YOLO格式(不包含分割路径的txt文件&#xff0c;仅仅包含jpg图片以及对应的VOC格式xml文件和yolo格式txt文件) 图片数量(jpg文件个数)&#xff1a;2316 标注数量(xml文件个数)&#xff1a;2316 标注数量(txt文件个数)&#xff1a;2316 …...

20250106面试

rabbitmq如何保证消息不丢失 my&#xff1a; 持久化&#xff0c;包括消息持久化和队列持久化&#xff0c;重启不丢失。持久化到磁盘中的。 消息确认 死信队列&#xff1a;消费失败&#xff08;业务异常/未确认&#xff0c;重试后&#xff0c;会放死信队列&#xff09;&…...

【大数据】(选修)实验4 安装熟悉HBase数据库并实践

实验4 安装熟悉HBase数据库并实践 1、实验目的 (1)理解HBase在Hadoop体系结构中的角色; (2)熟练使用HBase操作常用的Shell命令; (3)熟悉HBase操作常用的Java API。 2、实验平台 操作系统:Linux Hadoop版本:2.6.0或以上版本 HBase版本:1.1.2或以上版本 JDK版…...

使用Python类库pandas操作Excel表格

Date: 2025.01.02 20:33:30 author: lijianzhan 简述&#xff1a;pandas 是处理 Excel 文件的强大工具&#xff0c;它提供了简单易用的接口来读取、操作和写入 Excel 数据。以下是使用 pandas 处理 Excel 文件的详细指南&#xff0c;包括常见操作和示例代码。 安装依赖,pandas …...

【银河麒麟高级服务器操作系统】服务器异常重启故障分析及处理建议

了解更多银河麒麟操作系统全新产品&#xff0c;请点击访问 麒麟软件产品专区&#xff1a;https://product.kylinos.cn 开发者专区&#xff1a;https://developer.kylinos.cn 文档中心&#xff1a;https://document.kylinos.cn 服务器环境以及配置 系统环境 物理机/虚拟机/云…...

香橙派5plus单独编译并安装linux内核无法启动的原因分析与解决记录

1 说明 我依照官方手册编译单独编译linux内核&#xff0c;安装后重启出现内核启动失败的问题,编译和安装步骤如下&#xff1a;# 1. 克隆源码 git clone --depth1 -b orange-pi-6.1-rk35xx https://github.com/orangepi-xunlong/linux-orangepi# 2 配置源码 make rockchip_linu…...

iOS - 消息机制

1. 基本数据结构 // 方法结构 struct method_t {SEL name; // 方法名const char *types; // 类型编码IMP imp; // 方法实现 };// 类结构 struct objc_class {Class isa;Class superclass;cache_t cache; // 方法缓存class_data_bits_t bits; // 类的方法…...

ChatGPT 是通用人工智能吗

ChatGPT 目前并不是通用人工智能&#xff08;AGI, Artificial General Intelligence&#xff09;。它是一种专用人工智能&#xff08;Narrow AI&#xff09;&#xff0c;具体来说是一种基于大规模语言模型&#xff08;如 GPT-4&#xff09;的生成式人工智能&#xff0c;专注于处…...

Bash语言的函数实现

Bash语言的函数实现 引言 Bash&#xff08;Bourne Again SHell&#xff09;是一种在Unix和类Unix系统中广泛使用的命令行解释器。它不仅作为命令行工具使用&#xff0c;同时也被广泛应用于自动化脚本的编写。通过Bash&#xff0c;用户可以创建复杂的脚本&#xff0c;以执行一…...

Haskell语言的多线程编程

Haskell语言的多线程编程 在现代计算机科学中&#xff0c;多线程编程已经成为了提升程序性能的一个重要手段。尤其在我们处理计算密集型任务或 I/O 密集型任务时&#xff0c;合理地利用多核 CPU 的能力可以显著提升程序的执行效率。Haskell作为一种纯函数式编程语言&#xff0…...

Unity的四种数据持久化方式

目录 什么是数据持久化 数据持久化之PlayerPrefs 概述 API及用法 电脑中存放的位置 优缺点 主要用处 封装PlayerPrefs 数据持久化之XML XML是什么 读取XML信息 C#读取XML的方法有几种 读取xml文件信息 读取元素和属性信息 总结 写入XML信息 选择存储目录 存储…...

“霍普夫分岔”理论

庞加莱-安德罗诺夫-霍普夫分岔理论&#xff0c;通称为“霍普夫分岔”理论1&#xff0c;是首先由庞加莱在1892年对平面系统进行研究的2&#xff0c;然后由亚历山大安德罗诺夫&#xff08;Aleksandr Andronov&#xff0c;1901-1952&#xff09;及其合作者在1930年进行了完善和细化…...

10-C语言项目池

C语言项目池 《个人通讯录》 《火车订票系统》 管理员用户1录入火车票信息区间查询/购票2显示火车票信息打印购票信息3查询火车票信息退票4修改火车票信息5添加火车票信息 《学生学籍管理系统》 1录入学生信息2添加学生信息3显示学生信息4查找学生信息5删除学生信息6修改学…...

03、MySQL安全管理和特性解析(DBA运维专用)

03、MySQL安全管理和特性解析 本节主要讲MySQL的安全管理、角色使用、特定场景下的数据库对象、各版本特性以及存储引擎 目录 03、MySQL安全管理和特性解析 1、 用户和权限管理 2、 MySQL角色管理 3、 MySQL密码管理 4、 用户资源限制 5、 忘记root密码处理办法 6、 SQ…...

Ubuntu 下测试 NVME SSD 的读写速度

在 Ubuntu 系统下&#xff0c;测试 NVME SSD 的读写速度&#xff0c;有好多种方法&#xff0c;常用的有如下几种&#xff1a; 1. Gnome-disks Gnome-disks&#xff08;也称为“Disks”&#xff09;是 GNOME 桌面环境中的磁盘管理工具&#xff0c;有图形界面&#xff0c;是测试…...

C++编程进阶:标准库中的迭代器库解析

1. 迭代器库介绍 本文主要聚焦于C++的迭代器库,涵盖了迭代器的概念、分类、相关类型、原语操作、定制点、算法概念与实用工具、适配器、流迭代器、操作以及范围访问等内容,为C++编程中迭代器的使用提供了全面的参考。迭代器是一种抽象概念,它允许以统一的方式处理不同的数据…...

深入解析 JDK Lock:为什么必须在同一线程加锁和解锁?

前言 在多线程编程中&#xff0c;锁是一种常用的机制&#xff0c;用于控制对共享资源的访问&#xff0c;防止竞态条件的出现。Java 中的 Lock 接口提供了比 synchronized 关键字更灵活的锁机制。我们通常会使用 Lock 来确保同一时刻只有一个线程能访问某个共享资源。但是&#…...

下载b站高清视频

需要使用的edge上的一个扩展插件&#xff0c;所以选择使用edge浏览器。 1、在edge浏览器上下载 强力视频下载合并 扩展插件 2、在edge上打开b站&#xff0c;登录自己账号&#xff08;登录后才能下载到高清&#xff01;&#xff01;&#xff09;。打开一个视频&#xff0c;选择自…...