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

佛山高端网站制作公司哪家好广州各区最新动态

佛山高端网站制作公司哪家好,广州各区最新动态,世界科技与发展论坛,桓台网站建设Vue3java开发系统组队功能 需求分析 创建用户可以创建一个队伍#xff08;一个房间队长#xff09;#xff0c;设置队伍人数#xff0c;队伍名称#xff08;标题#xff09;#xff0c;描述#xff0c;超时时间。搜索加入#xff0c;用户可以加入未满的队伍#xf…Vue3java开发系统组队功能 需求分析 创建用户可以创建一个队伍一个房间队长设置队伍人数队伍名称标题描述超时时间。搜索加入用户可以加入未满的队伍其他人未满未过期是否需要队长同意分享队伍邀请人员显示队伍人数聊天修改队伍信息退出解散 系统接口设计 判断请求参数是否为空是否登录未登录直接跳转到登录不允许创建校验信息 队伍人数大于1小于20队伍名称20队伍人数412是否公开int不穿默认位0公开如果是加密状态一定3要有密码且密码32超时时间当前时间校验用户最多创建5个队伍 插入队伍信息到队伍表插入用户 队伍关系到关系表 实现 1. 库表设计10min 数据库表设计,队伍表队伍用户表-- 队伍表 create table team (id bigint auto_increment comment idprimary key,name varchar(256) not null comment 队伍名称,description varchar(1024) null comment 描述,maxNum int default 1 not null comment 最大人数,expireTime datetime null comment 过期时间,userId bigint comment 用户id,status int default 0 not null comment 0 - 公开1 - 私有2 - 加密,password varchar(512) null comment 密码,createTime datetime default CURRENT_TIMESTAMP null comment 创建时间,updateTime datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP,isDelete tinyint default 0 not null comment 是否删除 )comment 队伍;-- 用户队伍关系表 create table user_team (id bigint auto_increment comment idprimary key,userId bigint comment 用户id,teamId bigint comment 队伍id,joinTime datetime null comment 加入时间,createTime datetime default CURRENT_TIMESTAMP null comment 创建时间,updateTime datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP,isDelete tinyint default 0 not null comment 是否删除 )comment 用户队伍关系;2. 增删改查代码实现10min 使用mybatisX-generation插件自动生成实体类服务层持久层代码队伍基本增删改查代码编写/*** 队伍接口*/ RestController RequestMapping(/team) CrossOrigin(origins {http://localhost:5173}, allowCredentials true) Slf4j //lombok的注解可以在类中使用log打日志 public class TeamController {Resourceprivate UserService userService;Resourceprivate TeamService teamService;/*** 增加队伍* param team* return*/PostMapping(/add)public BaseResponseLong addTeam(RequestBody Team team){//接收前端传来队伍的信息if(team null){throw new BusinessException(ErrorCode.PARAMS_ERROR);}boolean save teamService.save(team);//teamService继承自Iservices的接口,底层实现了serviceImpl//需要返回新生成数据的id,使用mybatis的组件回写if(!save){throw new BusinessException(ErrorCode.SYSTEM_ERROR,插入失败);}return ResultUtils.success(team.getId());}/*** 删除队伍** param id* return*/PostMapping(/delete)public BaseResponseBoolean deleteTeam(RequestBody long id){//接收前端传来队伍的信息if(id 0){throw new BusinessException(ErrorCode.PARAMS_ERROR);}boolean result teamService.removeById(id);//teamService继承自Iservices的接口,底层实现了serviceImpl//需要返回新生成数据的id,使用mybatis的组件回写if(!result){throw new BusinessException(ErrorCode.SYSTEM_ERROR,删除失败);}return ResultUtils.success(true);}/*** 改动队伍** param team* return*/PostMapping(/delete)public BaseResponseBoolean updateTeam(RequestBody Team team){//接收前端传来队伍的信息if(team null){throw new BusinessException(ErrorCode.PARAMS_ERROR);}boolean result teamService.updateById(team);//teamService继承自Iservices的接口,底层实现了serviceImpl//需要返回新生成数据的id,使用mybatis的组件回写if(!result){throw new BusinessException(ErrorCode.SYSTEM_ERROR,更新失败);}return ResultUtils.success(true);}/*** 查询队伍** param id* return*/GetMapping(/delete)public BaseResponseTeam getTeamById(RequestBody long id){//接收前端传来队伍id的信息if(id 0){throw new BusinessException(ErrorCode.PARAMS_ERROR);}Team team teamService.getById(id);//teamService继承自Iservices的接口,底层实现了serviceImpl//需要返回新生成数据的id,使用mybatis的组件回写if(team null){throw new BusinessException(ErrorCode.NULL_ERROR,数据为空);}return ResultUtils.success(team);} } 查询队伍列表功能实现 新建TeamQuery业务请求参数封装类作为作为参数 原因 1. 请求参数和实体类不一样 2. 有些参数用不到 3. 多个实体类映射到同一个字段 4. 有些字段要隐藏不返回到前端代码实现/*** 队伍查询封装类*/ EqualsAndHashCode(callSuper true) Data public class TeamQuery extends PageRequest {/*** id*/TableId(type IdType.AUTO)private Long id;/*** 队伍名称*/private String name;/*** 描述*/private String description;/*** 最大人数*/private Integer maxNum;/*** 用户id*/private Long userId;/*** 0 - 公开1 - 私有2 - 加密*/private Integer status; }实现查询队伍列表/*** 查询组队列表* param teamQuery* return*/ GetMapping(/list) //新建teamQuery业务请求参数封装类作为原因1.请求参数和实体类不一样2.有些参数用不到3.有些字段要隐藏不返回到前端 public BaseResponseListTeam listTeams(TeamQuery teamQuery){if (teamQuery null){throw new BusinessException(ErrorCode.PARAMS_ERROR);}Team team new Team();BeanUtils.copyProperties(team,teamQuery);QueryWrapperTeam queryWrapper new QueryWrapper();ListTeam teamList teamService.list(queryWrapper);return ResultUtils.success(teamList); }分页查询队伍列表功能实现 新建请求分页类/*** 分页请求类** author Erha*/ Data public class PageRequest implements Serializable {//使对象序列化保持唯一private static final long serialVersionUID -9075033996918167511L;/*** 页面大小*/protected int pageSize;/*** 当前第几页*/protected int pageNum; }分页查询队伍实现代码/*** 分页查询组队列表* param teamQuery* return*/ GetMapping(/list/page) public BaseResponsePageTeam listTeamsByPage(TeamQuery teamQuery){if(teamQuery null){throw new BusinessException(ErrorCode.PARAMS_ERROR);}Team team new Team();BeanUtils.copyProperties(team, teamQuery);//把哪个对象的字段复制到另外一个中PageTeam page new Page(teamQuery.getPageNum(), teamQuery.getPageSize());QueryWrapperTeam queryWrapper new QueryWrapper(team);PageTeam Resultpage teamService.page(page, queryWrapper);return ResultUtils.success(Resultpage);}使用Swaggerknif4j文档接口 3. 业务逻辑30min 创建队伍业务逻辑实现/** * author serendipity * description 针对表【team(队伍)】的数据库操作Service实现 * createDate 2023-11-28 19:33:44 */ Service public class TeamServiceImpl extends ServiceImplTeamMapper, Teamimplements TeamService {Resourceprivate UserTeamService userTeamService;OverrideTransactional(rollbackFor Exception.class)public long addTeam(Team team, User loginUser) {//1.请求参数是否为空if (team null) {throw new BusinessException(ErrorCode.PARAMS_ERROR);}//2.是否登录未登录不允许创建if (loginUser null) {throw new BusinessException(ErrorCode.NO_AUTH);}final long userId loginUser.getId();//3.检验信息//(1).队伍人数1且20int maxNum Optional.ofNullable(team.getMaxNum()).orElse(0);//如果为空直接赋值为0if (maxNum 1 || maxNum 20) {throw new BusinessException(ErrorCode.PARAMS_ERROR, 队伍人数不满足要求);}//(2).队伍标题 20String name team.getName();if (StringUtils.isBlank(name) || name.length() 20) {throw new BusinessException(ErrorCode.PARAMS_ERROR, 队伍标题不满足要求);}// (3) 描述 512String description team.getDescription();if (StringUtils.isNotBlank(description) description.length() 512) {throw new BusinessException(ErrorCode.PARAMS_ERROR, 队伍描述过长);}//(4)status 是否公开不传默认为0int status Optional.ofNullable(team.getStatus()).orElse(0);TeamStatusEnum statusEnum TeamStatusEnum.getEnumByValue(status);if (statusEnum null) {throw new BusinessException(ErrorCode.PARAMS_ERROR, 队伍状态不满足要求);}//(5)如果status是加密状态一定要密码 且密码32String password team.getPassword();if (TeamStatusEnum.SECRET.equals(statusEnum)) {if (StringUtils.isBlank(password) || password.length() 32) {throw new BusinessException(ErrorCode.PARAMS_ERROR, 密码设置不正确);}}//(6)超出时间 当前时间Date expireTime team.getExpireTime();if (new Date().after(expireTime)) {throw new BusinessException(ErrorCode.PARAMS_ERROR, 超出时间 当前时间);}//(7)校验用户最多创建5个队伍//todo 有bug。可能同时创建100个队伍QueryWrapperTeam queryWrapper new QueryWrapper();queryWrapper.eq(userId, userId);long hasTeamNum this.count(queryWrapper);if (hasTeamNum 5) {throw new BusinessException(ErrorCode.PARAMS_ERROR, 用户最多创建5个队伍);}//4.插入队伍消息到队伍表team.setId(null);team.setUserId(userId);boolean result this.save(team);Long teamId team.getId();if (!result || teamId null) {throw new BusinessException(ErrorCode.PARAMS_ERROR, 创建队伍失败);}//5. 插入用户 队伍关系 到关系表UserTeam userTeam new UserTeam();userTeam.setUserId(userId);userTeam.setTeamId(teamId);userTeam.setJoinTime(new Date());result userTeamService.save(userTeam);if (!result) {throw new BusinessException(ErrorCode.PARAMS_ERROR, 创建队伍失败);}return teamId;} }
http://www.huolong8.cn/news/57403/

相关文章:

  • 网站建设的优势与不足wordpress 高德地图
  • 网站设计语言海外 酒店 网站建设
  • 坪山网站建设特色设计公司logo的网站
  • 自己做视频的网站wordpress 加链接
  • 济南优化seo网站建设鞍山网上推广怎么弄?
  • 网站建设源码是什么WordPress如何制作友情链接
  • 公司网站制作计入什么科目营销网站建设一薇
  • 网站关键词代码标志设计logo网站
  • flash个人网站模板西安网站开发公司排名
  • 济南网站开发公司排名怎么做租房网站
  • 文明网站机制建设围场网站建设
  • 长沙网站建设1681989简述seo的优势
  • 南阳网站排名公司结构设计师之家官网
  • 网站开发技术技巧哈尔滨网站建设美丽
  • 网站备案幕布尺寸论坛类的网站怎么做
  • 个人免费自助建站平湖公司做网站
  • 推广网站文案素材网络下载的网站模板能直接上传到虚拟主机
  • 瀑布流网站网络营销是什么的具体应用
  • 汽车制造行业网站模板国内最好的效果图公司
  • 免费网站大全app成都知名网站建设公司
  • 网站建设实训心得php做网站软件定制开发
  • 女生做网站编辑好吗加强网站队伍建设
  • 网站维护和网页维护区别商标自助查询系统官网
  • 网站建设pqiw中装建设股票
  • 建设网站是公司资产怎么介绍自己做的网站效果图
  • 惠州酒店网站建设如何用网站设计制作
  • 电白网站开发公司作文大全网站链接
  • 做网站的公司 苏迪石家庄 外贸网站建设公司
  • 企业网站开源系统销售管理软件有哪些
  • 自己做网站还能挣钱吗湘潭网站建设方案费用