请求 #7

Merged
pzq2ghbx9 merged 2 commits from branch-luoleqi into develop_idea 1 year ago

@ -16,67 +16,55 @@ import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
//等用于处理Web请求映射
import org.springframework.web.bind.annotation.PostMapping;
//专门用于处理HTTP POST请求的映射
import org.springframework.web.bind.annotation.RequestMapping;
//用来处理请求映射的注解
import org.springframework.web.bind.annotation.ResponseBody;
//用于将方法的返回值直接作为响应体写入HTTP响应中
import com.rabbiter.association.entity.Users;
//等导入实体类和工具类。
import com.rabbiter.association.handle.CacheHandle;
//用于处理缓存相关操作
import com.rabbiter.association.utils.IDUtils;
//用于处理各种标识符
import com.rabbiter.association.msg.R;
//R类用于资源的引用管理
import com.rabbiter.association.msg.PageData;
//用于表示页面数据相关的结构
import com.rabbiter.association.entity.Activities;
//导入名为Activities的实体类这个类位于com.rabbiter.association.entity包下
import com.rabbiter.association.service.ActivitiesService;
/**
*ActivitiesServicecom.rabbiter.association.service
*
*
*/
//系统请求响应控制器
//活动信息
@Controller//注解将该类标记为Spring MVC的控制器。
@RequestMapping("/activities")//指定了该控制器处理的基本URL路径为/activities。
public class ActivitiesController extends BaseController {
//定义了名为ActivitiesController的类它继承自BaseController类。
//定义了名为ActivitiesController的类它继承自BaseController类。
protected static final Logger Log = LoggerFactory.getLogger(ActivitiesController.class);
//创建一个Logger对象用于记录ActivitiesController类中的日志信息。
@Autowired
private CacheHandle cacheHandle;
//使用Autowired注解自动注入CacheHandle类型的依赖用于处理缓存相关操作。
//使用Autowired注解自动注入CacheHandle类型的依赖用于处理缓存相关操作。
@Autowired
private UsersService usersService;
//自动注入UsersService用于用户相关业务。
//自动注入UsersService用于用户相关业务。
@Autowired
private ActivitiesService activitiesService;
//自动注入ActivitiesService用于活动相关业务。
//自动注入ActivitiesService用于活动相关业务。
@RequestMapping("")
public String index() {
return "pages/Activities";
}
//当访问根路径(相对于/activities该方法返回名为"pages/Activities"的视图名称。
//当访问根路径(相对于/activities该方法返回名为"pages/Activities"的视图名称。
@GetMapping("/info")
//@GetMapping表示处理HTTP GET请求/info是相对于/activities的路径。
// 该方法用于处理查找指定活动信息的请求接受一个id参数
// 返回包含活动信息的成功响应或者错误响应
@ResponseBody
public R getInfo(String id) {
//在日志中记录查找指定活动信息的操作及对应的id
Log.info("查找指定活动信息ID{}", id);
//通过activitiesService的getOne方法根据id获取活动信息
Activities activities = activitiesService.getOne(id);
//使用R.successData方法将获取到的活动信息包装在成功响应中并返回
return R.successData(activities);
}
//该方法接收一个id参数通过activitiesService.getOne(id)获取指定id的活动信息然后使用R.successData(activities)返回包含活动信息的成功响应。
//该方法接收一个id参数通过activitiesService.getOne(id)获取指定id的活动信息然后使用R.successData(activities)返回包含活动信息的成功响应。
@GetMapping("/page")//处理/page路径的GET请求。
@ResponseBody
public R getPageInfos(Long pageIndex, Long pageSize,
@ -84,67 +72,63 @@ public class ActivitiesController extends BaseController {
//首先通过usersService.getOne(cacheHandle.getUserInfoCache(token))获取用户信息,如果用户不存在则返回登录信息不存在的错误。
Users user = usersService.getOne(cacheHandle.getUserInfoCache(token));
if(ObjectUtils.isEmpty(user)) {
//如果用户为空,表示登录信息不存在,返回错误提示要求重新登录
return R.error("登录信息不存在,请重新登录");
}
// 根据用户类型进行不同的分页查询操作
if (user.getType() == 0) {
//在日志中记录普通用户分页查找活动信息的操作及相关参数
Log.info("分页查找活动信息,当前页码:{}"
+ "每页数据量:{}, 模糊查询,社团名称:{},活动名称:{}", pageIndex,
pageSize, teamName, activeName);
//调用activitiesService的getPageAll方法进行普通的分页查询
PageData page = activitiesService.getPageAll(pageIndex, pageSize, teamName, activeName);
//使用R.successData方法将获取到的分页数据包装在成功响应中并返回
return R.successData(page);
} else {
//在日志中记录特定用户类型分页查找活动信息的操作及相关参数
Log.info("分页查找活动信息,当前页码:{}"
+ "每页数据量:{}, 模糊查询,社团名称:{},活动名称:{}", pageIndex,
pageSize, teamName, activeName);
//调用activitiesService的getPageByUserId方法进行特定用户的分页查询
PageData page = activitiesService.getPageByUserId(pageIndex, pageSize, user.getId(), teamName, activeName);
//使用R.successData方法将获取到的分页数据包装在成功响应中并返回
return R.successData(page);
}
}
//根据用户类型user.getType()不同分别调用activitiesService.getPageAll普通情况或activitiesService.getPageByUserId特定用户类型来进行分页查询活动信息最后返回包含分页数据的成功响应。
//根据用户类型user.getType()不同分别调用activitiesService.getPageAll普通情况或activitiesService.getPageByUserId特定用户类型来进行分页查询活动信息最后返回包含分页数据的成功响应。
@PostMapping("/add")//处理/add路径的POST请求。
@ResponseBody
public R addInfo(Activities activities) {
//使用IDUtils的makeIDByCurrent方法为传入的活动对象设置id
activities.setId(IDUtils.makeIDByCurrent());
//在日志中记录添加活动信息的操作及传入的活动对象参数
Log.info("添加活动信息,传入参数:{}", activities);
//调用activitiesService的add方法添加活动信息
activitiesService.add(activities);
//返回表示操作成功的响应
return R.success();
}
//为传入的Activities对象设置id通过IDUtils.makeIDByCurrent()然后使用activitiesService.add(activities)添加活动信息,最后返回成功响应。
//为传入的Activities对象设置id通过IDUtils.makeIDByCurrent()然后使用activitiesService.add(activities)添加活动信息,最后返回成功响应。
@PostMapping("/upd")//处理/upd路径的POST请求。
@ResponseBody
public R updInfo(Activities activities) {
//在日志中记录修改活动信息的操作及传入的活动对象参数
Log.info("修改活动信息,传入参数:{}", activities);
//调用activitiesService的update方法修改活动信息
activitiesService.update(activities);
//返回表示操作成功的响应
return R.success();
}
//通过activitiesService.update(activities)修改活动信息,然后返回成功响应。
//通过activitiesService.update(activities)修改活动信息,然后返回成功响应。
@PostMapping("/del")//处理/del路径的POST请求。
@ResponseBody
public R delInfo(String id) {
//在日志中记录删除活动信息的操作及对应的id
Log.info("删除活动信息, ID:{}", id);
//通过activitiesService的getOne方法根据id获取要删除的活动信息
Activities activities = activitiesService.getOne(id);
//调用activitiesService的delete方法删除活动信息
activitiesService.delete(activities);
//返回表示操作成功的响应
return R.success();
}
}

@ -1,9 +1,12 @@
// 定义包名和导入所需的类
package com.rabbiter.association.controller;
// 导入日志记录类
import com.rabbiter.association.service.TeamTypesService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// 导入Spring框架的注解用于依赖注入和定义控制器
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@ -11,110 +14,139 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
// 导入工具类用于日期和ID生成
import com.rabbiter.association.utils.DateUtils;
import com.rabbiter.association.utils.IDUtils;
// 导入自定义的消息响应类和分页数据类
import com.rabbiter.association.msg.R;
import com.rabbiter.association.msg.PageData;
// 导入实体类,代表社团类型
import com.rabbiter.association.entity.TeamTypes;
// 导入Java的集合类用于存储社团类型的列表
import java.util.List;
/**
*
*
*/
// 使用@Controller注解定义这是一个Spring MVC控制器
@Controller
// 使用@RequestMapping注解定义类级别的请求映射路径
@RequestMapping("/teamTypes")
public class TeamTypesController extends BaseController {
// 使用LoggerFactory生成一个日志记录器用于记录日志信息
protected static final Logger Log = LoggerFactory.getLogger(TeamTypesController.class);
// 使用@Autowired注解自动注入TeamTypesService服务
@Autowired
private TeamTypesService teamTypesService;
// 定义一个处理GET请求的方法返回社团类型的首页视图
@RequestMapping("")
public String index() {
return "pages/TeamTypes";
}
// 定义一个处理GET请求的方法返回所有社团类型的信息
@GetMapping("/all")
@ResponseBody
public R getAll(){
// 记录查看全部社团类型信息的日志
Log.info("查看全部的社团类型信息");
// 调用服务层方法获取所有社团类型信息
List<TeamTypes> list = teamTypesService.getAll();
// 返回成功响应,包含社团类型列表
return R.successData(list);
}
// 定义一个处理GET请求的方法根据ID返回指定社团类型的信息
@GetMapping("/info")
@ResponseBody
public R getInfo(String id) {
// 记录查找指定社团类型的日志
Log.info("查找指定社团类型ID{}", id);
// 调用服务层方法根据ID获取社团类型信息
TeamTypes teamTypes = teamTypesService.getOne(id);
// 返回成功响应,包含指定社团类型信息
return R.successData(teamTypes);
}
// 定义一个处理GET请求的方法返回社团类型的分页信息
@GetMapping("/page")
@ResponseBody
public R getPageInfos(Long pageIndex, Long pageSize,
TeamTypes teamTypes) {
// 记录分页查找社团类型的日志
Log.info("分页查找社团类型,当前页码:{}"
+ "每页数据量:{}, 模糊查询,附加参数:{}", pageIndex,
pageSize, teamTypes);
// 调用服务层方法获取社团类型的分页信息
PageData page = teamTypesService.getPageInfo(pageIndex, pageSize, teamTypes);
// 返回成功响应,包含分页信息
return R.successData(page);
}
// 定义一个处理POST请求的方法添加新的社团类型信息
@PostMapping("/add")
@ResponseBody
public R addInfo(TeamTypes teamTypes) {
// 为新社团类型生成ID和创建时间
teamTypes.setId(IDUtils.makeIDByCurrent());
teamTypes.setCreateTime(DateUtils.getNowDate());
// 记录添加社团类型的日志
Log.info("添加社团类型,传入参数:{}", teamTypes);
// 调用服务层方法添加社团类型
teamTypesService.add(teamTypes);
// 返回成功响应
return R.success();
}
// 定义一个处理POST请求的方法更新指定的社团类型信息
@PostMapping("/upd")
@ResponseBody
public R updInfo(TeamTypes teamTypes) {
// 记录修改社团类型的日志
Log.info("修改社团类型,传入参数:{}", teamTypes);
// 调用服务层方法更新社团类型
teamTypesService.update(teamTypes);
// 返回成功响应
return R.success();
}
// 定义一个处理POST请求的方法删除指定的社团类型信息
@PostMapping("/del")
@ResponseBody
public R delInfo(String id) {
// 检查是否可以删除社团类型
if(teamTypesService.isRemove(id)){
// 记录删除社团类型的日志
Log.info("删除社团类型, ID:{}", id);
// 根据ID获取社团类型信息
TeamTypes teamTypes = teamTypesService.getOne(id);
// 调用服务层方法删除社团类型
teamTypesService.delete(teamTypes);
// 返回成功响应
return R.success();
}else{
// 如果存在关联社团,返回警告响应
return R.warn("存在关联社团,无法移除");
}
}

@ -1,9 +1,12 @@
// 定义包名,指定控制器所在的包
package com.rabbiter.association.controller;
// 导入日志记录工具类,用于记录日志信息
import com.rabbiter.association.service.UsersService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// 导入Spring框架的注解用于依赖注入和定义控制器
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@ -11,103 +14,127 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
// 导入工具类用于日期和ID生成
import com.rabbiter.association.utils.DateUtils;
import com.rabbiter.association.utils.IDUtils;
// 导入自定义的消息响应类和分页数据类
import com.rabbiter.association.msg.R;
import com.rabbiter.association.msg.PageData;
// 导入实体类,代表系统用户
import com.rabbiter.association.entity.Users;
/**
*
*
*/
// 使用@Controller注解定义这是一个Spring MVC控制器
@Controller
// 使用@RequestMapping注解定义类级别的请求映射路径
@RequestMapping("/users")
public class UsersController extends BaseController {
// 使用LoggerFactory生成一个日志记录器用于记录日志信息
protected static final Logger Log = LoggerFactory.getLogger(UsersController.class);
// 使用@Autowired注解自动注入UsersService服务
@Autowired
private UsersService usersService;
// 定义一个处理GET请求的方法返回系统用户的首页视图
@RequestMapping("")
public String index() {
return "pages/Users";
}
// 定义一个处理GET请求的方法根据ID返回指定系统用户的信息
@GetMapping("/info")
@ResponseBody
public R getInfo(String id) {
// 记录查找指定系统用户的日志
Log.info("查找指定系统用户ID{}", id);
// 调用服务层方法根据ID获取系统用户信息
Users users = usersService.getOne(id);
// 返回成功响应,包含指定系统用户信息
return R.successData(users);
}
// 定义一个处理GET请求的方法返回系统用户的分页信息
@GetMapping("/page")
@ResponseBody
public R getPageInfos(Long pageIndex, Long pageSize,
Users users) {
public R getPageInfos(Long pageIndex, Long pageSize, Users users) {
// 记录分页查找系统用户的日志
Log.info("分页查找系统用户,当前页码:{}"
+ "每页数据量:{}, 模糊查询,附加参数:{}", pageIndex,
pageSize, users);
// 调用服务层方法获取系统用户的分页信息
PageData page = usersService.getPageInfo(pageIndex, pageSize, users);
// 返回成功响应,包含分页信息
return R.successData(page);
}
// 定义一个处理POST请求的方法添加新的系统用户信息
@PostMapping("/add")
@ResponseBody
public R addInfo(Users users) {
// 检查用户名是否已存在
if(usersService.getUserByUserName(users.getUserName()) == null){
// 为新系统用户生成ID和创建时间
users.setId(IDUtils.makeIDByCurrent());
users.setCreateTime(DateUtils.getNowDate());
// 记录添加系统用户的日志
Log.info("添加系统用户,传入参数:{}", users);
// 调用服务层方法添加系统用户
usersService.add(users);
// 返回成功响应
return R.success();
}else{
// 如果用户名已存在,返回警告响应
return R.warn("用户账号已存在,请重新输入");
}
}
// 定义一个处理POST请求的方法更新指定的系统用户信息
@PostMapping("/upd")
@ResponseBody
public R updInfo(Users users) {
// 记录修改系统用户的日志
Log.info("修改系统用户,传入参数:{}", users);
// 调用服务层方法更新系统用户
usersService.update(users);
// 返回成功响应
return R.success();
}
// 定义一个处理POST请求的方法删除指定的系统用户信息
@PostMapping("/del")
@ResponseBody
public R delInfo(String id) {
// 检查是否可以删除系统用户
if(usersService.isRemove(id)){
// 记录删除系统用户的日志
Log.info("删除系统用户, ID:{}", id);
// 根据ID获取系统用户信息
Users users = usersService.getOne(id);
// 调用服务层方法删除系统用户
usersService.delete(users);
// 返回成功响应
return R.success();
}else{
// 如果用户存在关联社团,返回警告响应
return R.warn("用户存在关联社团,无法移除");
}
}

@ -1,79 +1,87 @@
// 定义包名,指定实体类所在的包
package com.rabbiter.association.entity;
// 导入MyBatis Plus框架的注解用于配置表和字段的映射
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
// 导入Java的序列化接口用于定义可序列化的类
import java.io.Serializable;
/**
*
*
*/
// 使用@TableName注解指定该实体类对应的数据库表名
@TableName(value = "team_types")
// 定义实体类TeamTypes并实现Serializable接口使其可序列化
public class TeamTypes implements Serializable {
// 定义serialVersionUID用于序列化版本控制
private static final long serialVersionUID = 1L;
/**
* ID
*/
// 使用@TableId注解指定该字段为表的主键
@TableId(value = "id")
// 定义id属性用于存储记录的ID
private String id;
/**
/**
*
*/
// 使用@TableField注解指定该字段对应的数据库表字段名
@TableField(value = "name")
// 定义name属性用于存储社团类型的名称
private String name;
/**
/**
*
*/
// 使用@TableField注解指定该字段对应的数据库表字段名
@TableField(value = "create_time")
// 定义createTime属性用于存储记录的创建时间
private String createTime;
// 定义getId方法用于获取id属性的值
public String getId(){
return id;
}
// 定义setId方法用于设置id属性的值
public void setId(String id){
this.id = id;
}
// 定义getName方法用于获取name属性的值
public String getName(){
return name;
}
// 定义setName方法用于设置name属性的值
public void setName(String name){
this.name = name;
}
// 定义getCreateTime方法用于获取createTime属性的值
public String getCreateTime(){
return createTime;
}
// 定义setCreateTime方法用于设置createTime属性的值
public void setCreateTime(String createTime){
this.createTime = createTime;
}
// 重写toString方法用于返回实体类的字符串表示形式
@Override
public String toString() {
return "TeamTypes [id=" + id
// 返回包含id、name和createTime属性值的字符串
return "TeamTypes [id=" + id
+ ", name=" + name
+ ", createTime=" + createTime
+ "]";
}
}

@ -1,213 +1,230 @@
// 定义包名,指定实体类所在的包
package com.rabbiter.association.entity;
// 导入MyBatis Plus框架的注解用于配置表和字段的映射
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
// 导入Java的序列化接口用于定义可序列化的类
import java.io.Serializable;
/**
*
*
*/
// 使用@TableName注解指定该实体类对应的数据库表名
@TableName(value = "users")
// 定义实体类Users并实现Serializable接口使其可序列化
public class Users implements Serializable {
// 定义serialVersionUID用于序列化版本控制
private static final long serialVersionUID = 1L;
/**
* ID
*/
// 使用@TableId注解指定该字段为表的主键
@TableId(value = "id")
// 定义id属性用于存储记录的ID
private String id;
/**
/**
*
*/
// 使用@TableField注解指定该字段对应的数据库表字段名
@TableField(value = "user_name")
// 定义userName属性用于存储用户的账号
private String userName;
/**
/**
*
*/
// 使用@TableField注解指定该字段对应的数据库表字段名
@TableField(value = "pass_word")
// 定义passWord属性用于存储用户的密码
private String passWord;
/**
/**
*
*/
// 使用@TableField注解指定该字段对应的数据库表字段名
@TableField(value = "name")
// 定义name属性用于存储用户的姓名
private String name;
/**
/**
*
*/
// 使用@TableField注解指定该字段对应的数据库表字段名
@TableField(value = "gender")
// 定义gender属性用于存储用户的性别
private String gender;
/**
/**
*
*/
// 使用@TableField注解指定该字段对应的数据库表字段名
@TableField(value = "age")
// 定义age属性用于存储用户的年龄
private Integer age;
/**
/**
*
*/
// 使用@TableField注解指定该字段对应的数据库表字段名
@TableField(value = "phone")
// 定义phone属性用于存储用户的联系电话
private String phone;
/**
/**
*
*/
// 使用@TableField注解指定该字段对应的数据库表字段名
@TableField(value = "address")
// 定义address属性用于存储用户的联系地址
private String address;
/**
/**
*
*/
// 使用@TableField注解指定该字段对应的数据库表字段名
@TableField(value = "status")
// 定义status属性用于存储用户的信息状态
private Integer status;
/**
/**
*
*/
// 使用@TableField注解指定该字段对应的数据库表字段名
@TableField(value = "create_time")
// 定义createTime属性用于存储记录的创建时间
private String createTime;
/**
/**
*
*/
// 使用@TableField注解指定该字段对应的数据库表字段名
@TableField(value = "type")
// 定义type属性用于存储用户的身份
private Integer type;
// 定义getId方法用于获取id属性的值
public String getId(){
return id;
}
// 定义setId方法用于设置id属性的值
public void setId(String id){
this.id = id;
}
// 定义getUserName方法用于获取userName属性的值
public String getUserName(){
return userName;
}
// 定义setUserName方法用于设置userName属性的值
public void setUserName(String userName){
this.userName = userName;
}
// 定义getPassWord方法用于获取passWord属性的值
public String getPassWord(){
return passWord;
}
// 定义setPassWord方法用于设置passWord属性的值
public void setPassWord(String passWord){
this.passWord = passWord;
}
// 定义getName方法用于获取name属性的值
public String getName(){
return name;
}
// 定义setName方法用于设置name属性的值
public void setName(String name){
this.name = name;
}
// 定义getGender方法用于获取gender属性的值
public String getGender(){
return gender;
}
// 定义setGender方法用于设置gender属性的值
public void setGender(String gender){
this.gender = gender;
}
// 定义getAge方法用于获取age属性的值
public Integer getAge(){
return age;
}
// 定义setAge方法用于设置age属性的值
public void setAge(Integer age){
this.age = age;
}
// 定义getPhone方法用于获取phone属性的值
public String getPhone(){
return phone;
}
// 定义setPhone方法用于设置phone属性的值
public void setPhone(String phone){
this.phone = phone;
}
// 定义getAddress方法用于获取address属性的值
public String getAddress(){
return address;
}
// 定义setAddress方法用于设置address属性的值
public void setAddress(String address){
this.address = address;
}
// 定义getStatus方法用于获取status属性的值
public Integer getStatus(){
return status;
}
// 定义setStatus方法用于设置status属性的值
public void setStatus(Integer status){
this.status = status;
}
// 定义getCreateTime方法用于获取createTime属性的值
public String getCreateTime(){
return createTime;
}
// 定义setCreateTime方法用于设置createTime属性的值
public void setCreateTime(String createTime){
this.createTime = createTime;
}
// 定义getType方法用于获取type属性的值
public Integer getType(){
return type;
}
// 定义setType方法用于设置type属性的值
public void setType(Integer type){
this.type = type;
}
// 重写toString方法用于返回实体类的字符串表示形式
@Override
public String toString() {
return "Users [id=" + id
// 返回包含所有属性值的字符串
return "Users [id=" + id
+ ", userName=" + userName
+ ", passWord=" + passWord
+ ", name=" + name
@ -220,5 +237,4 @@ public class Users implements Serializable {
+ ", type=" + type
+ "]";
}
}

@ -1,102 +1,127 @@
// 定义包名,指定服务实现类所在的包
package com.rabbiter.association.service.impl;
// 导入MyBatis Plus查询构造器
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
// 导入MyBatis Plus分页插件
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
// 导入服务接口
import com.rabbiter.association.service.TeamTypesService;
// 导入Spring的注解用于定义服务和自动注入
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
// 导入Spring事务注解
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
// 导入数据访问对象DAO
import com.rabbiter.association.dao.TeamsDao;
import com.rabbiter.association.entity.Teams;
import com.rabbiter.association.msg.PageData;
import com.rabbiter.association.entity.TeamTypes;
import com.rabbiter.association.dao.TeamTypesDao;
// 导入工具类
import com.rabbiter.association.utils.StringUtils;
// 导入Java的集合类
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
// 使用@Service注解定义这是一个Spring管理的服务
@Service("teamTypesService")
public class TeamTypesServiceImpl implements TeamTypesService {
// 使用@Qualifier和@Autowired注解自动注入TeamTypesDao
@Autowired
private TeamTypesDao teamTypesDao;
// 使用@Autowired注解自动注入TeamsDao
@Autowired
private TeamsDao teamsDao;
// 事务管理,添加社团类型信息
@Override
@Transactional
public void add(TeamTypes teamTypes) {
// 调用DAO层方法插入社团类型信息
teamTypesDao.insert(teamTypes);
}
// 事务管理,更新社团类型信息
@Override
@Transactional
public void update(TeamTypes teamTypes) {
// 调用DAO层方法更新社团类型信息
teamTypesDao.updateById(teamTypes);
}
// 事务管理,删除社团类型信息
@Override
@Transactional
public void delete(TeamTypes teamTypes) {
// 调用DAO层方法根据ID删除社团类型信息
teamTypesDao.deleteById(teamTypes);
}
// 事务管理,检查是否可以删除社团类型
@Override
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public Boolean isRemove(String typeId){
QueryWrapper<Teams> qw = new QueryWrapper<Teams>();
// 创建查询条件构造器
QueryWrapper<Teams> qw = new QueryWrapper<>();
// 条件类型ID等于传入的typeId
qw.eq("type_id", typeId);
// 调用DAO层方法查询关联的社团数量
return teamsDao.selectCount(qw) <= 0;
}
// 事务管理根据ID获取社团类型信息
@Override
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public TeamTypes getOne(String id) {
QueryWrapper<TeamTypes> qw = new QueryWrapper<TeamTypes>();
// 创建查询条件构造器,并按创建时间降序排列
QueryWrapper<TeamTypes> qw = new QueryWrapper<>();
qw.orderByDesc("create_time");
// 调用DAO层方法根据ID查询社团类型信息
TeamTypes teamTypes = teamTypesDao.selectById(id);
return teamTypes;
}
// 事务管理,获取所有社团类型信息
@Override
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public List<TeamTypes> getAll() {
// 调用DAO层方法查询所有社团类型信息
List<TeamTypes> list = teamTypesDao.selectList(null);
return list;
}
// 事务管理,分页查询社团类型信息
@Override
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public PageData getPageInfo(Long pageIndex, Long pageSize, TeamTypes teamTypes) {
// 创建查询条件构造器
QueryWrapper<TeamTypes> qw = new QueryWrapper<>();
QueryWrapper<TeamTypes> qw = new QueryWrapper<TeamTypes>();
// 如果社团类型名称不为空,则添加模糊查询条件
if (StringUtils.isNotNullOrEmpty(teamTypes.getName())) {
qw.like("name", teamTypes.getName());
}
// 按创建时间降序排列
qw.orderByDesc("create_time");
// 调用DAO层方法进行分页查询
Page<TeamTypes> page =
teamTypesDao.selectPage(new Page<TeamTypes>(pageIndex, pageSize), qw);
teamTypesDao.selectPage(new Page<>(pageIndex, pageSize), qw);
// 转换分页查询结果
return parsePage(page);
}
@ -104,18 +129,21 @@ public class TeamTypesServiceImpl implements TeamTypesService {
*
*/
public PageData parsePage(Page<TeamTypes> p) {
// 创建结果列表
List<Map<String, Object>> resl = new ArrayList<>();
List<Map<String, Object>> resl = new ArrayList<Map<String, Object>>();
// 遍历分页查询结果
for (TeamTypes teamTypes : p.getRecords()) {
Map<String, Object> temp = new HashMap<String, Object>();
// 创建临时Map存储单个社团类型的信息
Map<String, Object> temp = new HashMap<>();
temp.put("id", teamTypes.getId());
temp.put("name", teamTypes.getName());
temp.put("createTime", teamTypes.getCreateTime());
// 将临时Map添加到结果列表
resl.add(temp);
}
// 创建PageData对象封装分页信息和结果列表
PageData pageData = new PageData(p.getCurrent(), p.getSize(), p.getTotal(), resl);
return pageData;

@ -1,114 +1,139 @@
// 定义包名,指定服务实现类所在的包
package com.rabbiter.association.service.impl;
// 导入MyBatis Plus查询构造器
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
// 导入MyBatis Plus分页插件
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
// 导入服务接口
import com.rabbiter.association.service.UsersService;
// 导入Spring的注解用于定义服务和自动注入
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
// 导入Spring事务注解
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
// 导入数据访问对象DAO
import com.rabbiter.association.dao.MembersDao;
import com.rabbiter.association.entity.Members;
import com.rabbiter.association.msg.PageData;
import com.rabbiter.association.entity.Users;
import com.rabbiter.association.dao.UsersDao;
// 导入工具类
import com.rabbiter.association.utils.StringUtils;
// 导入Java的集合类
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
// 使用@Service注解定义这是一个Spring管理的服务
@Service("usersService")
public class UsersServiceImpl implements UsersService {
// 使用@Autowired注解自动注入MembersDao
@Autowired
private MembersDao membersDao;
// 使用@Autowired注解自动注入UsersDao
@Autowired
private UsersDao usersDao;
// 事务管理,添加系统用户信息
@Override
@Transactional
public void add(Users users) {
// 调用DAO层方法插入系统用户信息
usersDao.insert(users);
}
// 事务管理,更新系统用户信息
@Override
@Transactional
public void update(Users users) {
// 调用DAO层方法更新系统用户信息
usersDao.updateById(users);
}
// 事务管理,删除系统用户信息
@Override
@Transactional
public void delete(Users users) {
// 调用DAO层方法根据ID删除系统用户信息
usersDao.deleteById(users);
}
// 事务管理,检查是否可以删除系统用户
@Override
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public Boolean isRemove(String userId){
QueryWrapper<Members> qw = new QueryWrapper<Members>();
// 创建查询条件构造器
QueryWrapper<Members> qw = new QueryWrapper<>();
// 条件用户ID等于传入的userId
qw.eq("user_id", userId);
// 调用DAO层方法查询关联的成员数量
Integer total = membersDao.selectCount(qw);
// 返回是否可以删除(没有关联的成员时可以删除)
return total <= 0;
}
// 事务管理根据ID获取系统用户信息
@Override
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public Users getOne(String id) {
// 调用DAO层方法根据ID查询系统用户信息
Users users = usersDao.selectById(id);
return users;
}
// 事务管理,根据用户名获取系统用户信息
@Override
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public Users getUserByUserName(String userName) {
QueryWrapper<Users> qw = new QueryWrapper<Users>();
// 创建查询条件构造器
QueryWrapper<Users> qw = new QueryWrapper<>();
// 条件用户名等于传入的userName
qw.eq("user_name", userName);
// 调用DAO层方法查询系统用户信息
Users user = usersDao.selectOne(qw);
return user;
}
// 事务管理,分页查询系统用户信息
@Override
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public PageData getPageInfo(Long pageIndex, Long pageSize, Users users) {
// 创建查询条件构造器
QueryWrapper<Users> qw = new QueryWrapper<>();
QueryWrapper<Users> qw = new QueryWrapper<Users>();
// 如果用户名不为空,则添加模糊查询条件
if (StringUtils.isNotNullOrEmpty(users.getUserName())) {
qw.like("user_name", users.getUserName());
}
// 如果姓名不为空,则添加模糊查询条件
if (StringUtils.isNotNullOrEmpty(users.getName())) {
qw.like("name", users.getName());
}
// 如果电话不为空,则添加模糊查询条件
if (StringUtils.isNotNullOrEmpty(users.getPhone())) {
qw.like("phone", users.getPhone());
}
// 按创建时间降序排列
qw.orderByDesc("create_time");
// 调用DAO层方法进行分页查询
Page<Users> page =
usersDao.selectPage(new Page<Users>(pageIndex, pageSize), qw);
usersDao.selectPage(new Page<>(pageIndex, pageSize), qw);
// 转换分页查询结果
return parsePage(page);
}
@ -116,12 +141,13 @@ public class UsersServiceImpl implements UsersService {
*
*/
public PageData parsePage(Page<Users> p) {
// 创建结果列表
List<Map<String, Object>> resl = new ArrayList<>();
List<Map<String, Object>> resl = new ArrayList<Map<String, Object>>();
// 遍历分页查询结果
for (Users users : p.getRecords()) {
Map<String, Object> temp = new HashMap<String, Object>();
// 创建临时Map存储单个系统用户的信息
Map<String, Object> temp = new HashMap<>();
temp.put("id", users.getId());
temp.put("userName", users.getUserName());
temp.put("passWord", users.getPassWord());
@ -133,9 +159,11 @@ public class UsersServiceImpl implements UsersService {
temp.put("status", users.getStatus());
temp.put("createTime", users.getCreateTime());
temp.put("type", users.getType());
// 将临时Map添加到结果列表
resl.add(temp);
}
// 创建PageData对象封装分页信息和结果列表
PageData pageData = new PageData(p.getCurrent(), p.getSize(), p.getTotal(), resl);
return pageData;

@ -0,0 +1,8 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
</profile>
</component>

@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="node_modules">
<CLASSES>
<root url="jar://$PROJECT_DIR$/node_modules.zip!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_23" default="true" project-jdk-name="23" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/AssociationManagerVue.iml" filepath="$PROJECT_DIR$/.idea/AssociationManagerVue.iml" />
</modules>
</component>
</project>

@ -1,15 +1,25 @@
// 导入Vue核心库
import Vue from 'vue'
// 导入Vue Router插件
import VueRouter from 'vue-router'
// 使用Vue.use方法安装Vue Router插件使其成为Vue的插件
Vue.use(VueRouter)
// 创建一个新的VueRouter实例并导出
export default new VueRouter({
// 定义路由配置
routes: [
// 定义一个路由对象
{
// 路由的路径,当访问根目录'/'时匹配此路由
path: '/',
// 给路由命名,方便在代码中引用
name: 'login',
// 指定路由匹配到时加载的组件使用require动态导入login.vue文件并取其default属性
component: require("../views/login.vue").default
}
// 这里可以继续添加更多的路由对象
]
});
});

@ -1,37 +1,50 @@
// 导入Vue核心库
import Vue from 'vue'
// 导入Vuex库
import Vuex from 'vuex'
// 使用Vue.use方法安装Vuex插件使其成为Vue的插件
Vue.use(Vuex)
// 创建一个新的Vuex.Store实例并导出
export default new Vuex.Store({
state:{
token: null,
menus: null,
user: null,
// 定义state它是Vuex的状态管理对象用于存储应用的状态
state: {
token: null, // 用于存储用户token
menus: null, // 用于存储用户菜单数据
user: null, // 用于存储用户信息
},
// 定义getters它是Vuex的计算属性用于对state进行计算处理
getters: {
// 获取token的getter
getToken: state => {
return state.token
},
// 获取menus的getter
getMenus: state => {
return state.menus
},
},
// 定义mutations它是同步函数用于修改state中的状态
mutations: {
setToken: (state, newToken) =>{
// 设置token的mutation
setToken: (state, newToken) => {
state.token = newToken;
},
clearToken: (state) =>{
// 清除token的mutation
clearToken: (state) => {
state.token = null;
},
setMenus: (state, menus) =>{
// 设置menus的mutation
setMenus: (state, menus) => {
state.menus = menus;
},
clearMenus: (state) =>{
// 清除menus的mutation
clearMenus: (state) => {
state.menus = null;
},
}
})
import '@/utils/initialize'
// 导入initialize模块通常用于初始化Vuex状态或者进行一些配置
import '@/utils/initialize'

@ -1,43 +1,49 @@
/*
* @Description:
* @Description: 该文件定义了一个axios实例用于管理HTTP请求
* @Author: Rabbiter
* @Date: 2022-06-11 13:41:22
*/
// 导入axios库用于发起HTTP请求
import axios from 'axios'
// 导入qs库用于处理URL-encoded格式的数据
import qs from 'qs'
// 从element-ui导入Message组件用于显示操作反馈信息
import {
Message
} from 'element-ui'
// 设置axios默认请求头指定发送的数据格式为application/x-www-form-urlencoded
axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded';
// 创建axios的实例用于配置特定的请求设置
const service = axios.create({
// withCredentials: true,
baseURL: 'http://localhost:9211/association',
timeout: 15000 // 请求超时时间
// withCredentials: true, // 这行代码被注释掉了,如果需要携带凭证可以取消注释
baseURL: 'http://localhost:9211/association', // 设置请求的基础URL
timeout: 15000 // 设置请求超时时间为15000毫秒15秒
})
// 添加请求拦截器,用于在请求发送前对请求进行处理
service.interceptors.request.use(config => {
// 如果请求方法是post则将请求数据转换为URL-encoded格式
if(config.method === "post"){
config.data = qs.stringify(config.data, { indices: false });
}
// 返回处理后的config
return config;
}, error => {
// 如果请求拦截器出现错误返回一个rejected的Promise
Promise.reject(error)
})
// respone拦截器
// 添加响应拦截器,用于在响应返回后对响应进行处理
service.interceptors.response.use(
resp => {
// 如果响应数据的code不等于2则直接返回响应数据
if (resp.data.code != 2) {
return resp.data;
} else {
// 如果响应数据的code等于2则显示错误信息并返回一个rejected的Promise
Message({
message: resp.data.msg,
type: 'error',
@ -47,7 +53,9 @@ service.interceptors.response.use(
}
},
error => {
// 打印错误信息
console.log(error);
// 如果错误响应或错误响应数据未定义,则显示错误信息
if (error.response == undefined ||
error.response.data == undefined) {
Message({
@ -57,6 +65,7 @@ service.interceptors.response.use(
duration: 5000,
});
} else {
// 否则显示错误响应数据
Message({
message: error.response.data,
type: 'error',
@ -64,8 +73,10 @@ service.interceptors.response.use(
duration: 5000,
});
}
// 返回一个rejected的Promise
return Promise.reject(error);
}
)
export default service
// 导出service实例供其他模块使用
export default service

@ -1,50 +1,66 @@
<!--
* @Description:
* @Description: 该组件作为应用的主布局包含导航栏菜单栏和主要内容区域
* @Author: Rabbiter
* @Date: 2022-06-11 13:41:22
-->
<template>
<!-- 使用Element UI的容器组件来布局页面 -->
<el-container>
<!-- 引入Nav组件作为导航栏 -->
<Nav></Nav>
<!-- 再次使用el-container来布局菜单栏和主要内容区域 -->
<el-container>
<Nav></Nav>
<el-container>
<Menu :menuList="this.$store.state.menus.children"></Menu>
<el-main class="fater-body">
<el-breadcrumb
v-if="this.$router.currentRoute.path != '/index'"
class="fater-body-breadcrumb"
>
<el-breadcrumb-item>系统首页</el-breadcrumb-item>
<el-breadcrumb-item>{{
this.$router.currentRoute.name
}}</el-breadcrumb-item>
</el-breadcrumb>
<router-view></router-view>
</el-main>
</el-container>
<!-- 引入Menu组件传入菜单数据 -->
<Menu :menuList="this.$store.state.menus.children"></Menu>
<!-- 使用el-main作为主要内容区域 -->
<el-main class="fater-body">
<!-- 条件渲染el-breadcrumb当当前路由不是'/index'时显示面包屑导航 -->
<el-breadcrumb
v-if="this.$router.currentRoute.path != '/index'"
class="fater-body-breadcrumb"
>
<!-- 面包屑导航的第一项始终是系统首页 -->
<el-breadcrumb-item>系统首页</el-breadcrumb-item>
<!-- 面包屑导航的第二项是当前路由的名称 -->
<el-breadcrumb-item>{{ this.$router.currentRoute.name }}</el-breadcrumb-item>
</el-breadcrumb>
<!-- 使用router-view来渲染匹配的路由组件 -->
<router-view></router-view>
</el-main>
</el-container>
</el-container>
</template>
<style>
<!-- 这里可以添加组件的样式 -->
</style>
<script>
// NavMenu
import Nav from "../components/nav.vue";
import Menu from "../components/menu.vue";
// getLoginUser API
import { getLoginUser } from "../api";
export default {
data() {
return {};
},
methods: {},
mounted() {
getLoginUser(this.$store.state.token).then((resp) => {
this.$store.state.user = resp.data;
});
},
components: {
Nav,
Menu,
},
//
data() {
return {};
},
//
methods: {},
//
mounted() {
// getLoginUsertokenVuexuser
getLoginUser(this.$store.state.token).then((resp) => {
this.$store.state.user = resp.data;
});
},
//
components: {
Nav,
Menu,
},
};
</script>

@ -1,293 +1,350 @@
<template>
<div class="fater-body-show">
<el-card shadow="never">
<div
class="el-card-header"
slot="header"
style="font-size: 26px"
<!-- 外层容器用于包含整个页面内容 -->
<div class="fater-body-show">
<!-- 使用Element UI的卡片组件用于展示信息查询区域 -->
<el-card shadow="never">
<!-- 卡片头部使用slot插槽自定义内容 -->
<div
class="el-card-header"
slot="header"
style="font-size: 26px"
>
<!-- 图标字体用于显示搜索图标 -->
<i class="iconfont icon-r-find" style="font-size: 26px"></i>
<!-- 卡片标题 -->
信息查询
</div>
<!-- 卡片内容区域 -->
<div>
<!-- 表单组件用于输入查询条件设置为内联形式 -->
<el-form :inline="true" :model="qryForm">
<!-- 表单项用于输入社团类型名称 -->
<el-form-item>
<el-input
v-model="qryForm.name"
placeholder="输入社团类型名称…"
autocomplete="off"
></el-input>
</el-form-item>
<!-- 表单项包含搜索按钮 -->
<el-form-item>
<el-button
type="primary"
@click="getPageLikeInfo()"
style="font-size: 18px"
>
<i class="iconfont icon-r-find" style="font-size: 26px"></i>
信息查询
</div>
<div>
<el-form :inline="true" :model="qryForm">
<el-form-item>
<el-input
v-model="qryForm.name"
placeholder="输入社团类型名称…"
autocomplete="off"
></el-input>
</el-form-item>
<el-form-item>
<el-button
type="primary"
@click="getPageLikeInfo()"
style="font-size: 18px"
>
搜索</el-button
>
</el-form-item>
</el-form>
</div>
</el-card>
搜索
</el-button>
</el-form-item>
</el-form>
</div>
</el-card>
<el-card shadow="never">
<div slot="header">
<el-button
type="primary"
style="font-size: 18px"
@click="showAddWin()"
>
新增</el-button
>
</div>
<div>
<el-table
v-loading="loading"
element-loading-text="拼命加载中"
element-loading-spinner="el-icon-loading"
element-loading-background="rgba(124, 124, 124, 0.8)"
:data="pageInfos"
border
>
<el-table-column
align="center"
type="index"
></el-table-column>
<el-table-column
align="center"
prop="name"
label="类型名称"
></el-table-column>
<el-table-column
align="center"
prop="createTime"
label="创建时间"
></el-table-column>
<el-table-column
align="center"
label="操作处理"
fixed="right"
width="250"
>
<template slot-scope="scope">
<el-button
type="primary"
@click="showUpdWin(scope.row)"
style="font-size: 18px"
>
编辑
</el-button>
<el-button
type="danger"
@click="delInfo(scope.row.id)"
style="font-size: 18px"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
v-if="pageTotal >= 0"
style="margin-top: 15px"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="pageIndex"
:page-sizes="[5, 10, 20, 50]"
:page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="totalInfo"
>
</el-pagination>
</div>
</el-card>
<!-- 使用Element UI的卡片组件用于展示用户信息列表区域 -->
<el-card shadow="never">
<!-- 卡片头部包含新增按钮 -->
<div slot="header">
<el-button
type="primary"
style="font-size: 18px"
@click="showAddWin()"
>
新增
</el-button>
</div>
<!-- 卡片内容区域 -->
<div>
<!-- 表格组件用于展示用户信息列表 -->
<el-table
v-loading="loading"
element-loading-text="拼命加载中"
element-loading-spinner="el-icon-loading"
element-loading-background="rgba(124, 124, 124, 0.8)"
:data="pageInfos"
border
>
<!-- 表格列定义包括索引类型名称创建时间 -->
<el-table-column
align="center"
type="index"
></el-table-column>
<el-table-column
align="center"
prop="name"
label="类型名称"
></el-table-column>
<el-table-column
align="center"
prop="createTime"
label="创建时间"
></el-table-column>
<!-- 操作处理列使用插槽自定义内容 -->
<el-table-column
align="center"
label="操作处理"
fixed="right"
width="250"
>
<template slot-scope="scope">
<!-- 编辑按钮 -->
<el-button
type="primary"
@click="showUpdWin(scope.row)"
style="font-size: 18px"
>
编辑
</el-button>
<!-- 删除按钮 -->
<el-button
type="danger"
@click="delInfo(scope.row.id)"
style="font-size: 18px"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页组件用于分页展示用户信息列表 -->
<el-pagination
v-if="pageTotal >= 0"
style="margin-top: 15px"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="pageIndex"
:page-sizes="[5, 10, 20, 50]"
:page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="totalInfo"
>
</el-pagination>
</div>
</el-card>
<el-dialog title="添加信息" width="600px" :visible.sync="showAddFlag">
<el-form label-width="90px" :model="teamTypesForm">
<el-form-item label="类型名称">
<el-input
v-model="teamTypesForm.name"
placeholder="请输入类型名称…"
autocomplete="off"
></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="showAddFlag = false" style="font-size: 18px"
>
</el-button
>
<el-button
type="primary"
@click="addInfo()"
style="font-size: 18px"
>
</el-button
>
</div>
</el-dialog>
<!-- 对话框组件用于添加信息 -->
<el-dialog title="添加信息" width="600px" :visible.sync="showAddFlag">
<!-- 表单组件用于输入新增信息 -->
<el-form label-width="90px" :model="teamTypesForm">
<!-- 表单项用于输入类型名称 -->
<el-form-item label="类型名称">
<el-input
v-model="teamTypesForm.name"
placeholder="请输入类型名称…"
autocomplete="off"
></el-input>
</el-form-item>
</el-form>
<!-- 对话框底部按钮 -->
<div slot="footer" class="dialog-footer">
<el-button @click="showAddFlag = false" style="font-size: 18px">
</el-button>
<el-button
type="primary"
@click="addInfo()"
style="font-size: 18px"
>
</el-button>
</div>
</el-dialog>
<el-dialog title="修改信息" width="600px" :visible.sync="showUpdFlag">
<el-form label-width="90px" :model="teamTypesForm">
<el-form-item label="类型名称">
<el-input
v-model="teamTypesForm.name"
placeholder="请输入类型名称…"
autocomplete="off"
></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="showUpdFlag = false" style="font-size: 18px"
>
</el-button
>
<el-button
type="primary"
@click="updInfo()"
style="font-size: 18px"
>
</el-button
>
</div>
</el-dialog>
</div>
<!-- 对话框组件用于修改信息 -->
<el-dialog title="修改信息" width="600px" :visible.sync="showUpdFlag">
<!-- 表单组件用于输入修改信息 -->
<el-form label-width="90px" :model="teamTypesForm">
<!-- 表单项用于输入类型名称 -->
<el-form-item label="类型名称">
<el-input
v-model="teamTypesForm.name"
placeholder="请输入类型名称…"
autocomplete="off"
></el-input>
</el-form-item>
</el-form>
<!-- 对话框底部按钮 -->
<div slot="footer" class="dialog-footer">
<el-button @click="showUpdFlag = false" style="font-size: 18px">
</el-button>
<el-button
type="primary"
@click="updInfo()"
style="font-size: 18px"
>
</el-button>
</div>
</el-dialog>
</div>
</template>
<!-- 样式标签用于定义组件的CSS样式 -->
<style>
</style>
<script>
// API
import {
getPageTeamTypes,
addTeamTypes,
updTeamTypes,
delTeamTypes,
getPageTeamTypes,
addTeamTypes,
updTeamTypes,
delTeamTypes,
} from "../../api";
export default {
data() {
return {
pageInfos: [],
pageIndex: 1,
pageSize: 10,
pageTotal: 0,
totalInfo: 0,
loading: true,
showAddFlag: false,
showUpdFlag: false,
qryForm: {
name: "",
},
teamTypesForm: {
id: "",
name: "",
},
};
},
methods: {
getPageInfo(pageIndex, pageSize) {
getPageTeamTypes(pageIndex, pageSize).then((resp) => {
this.pageInfos = resp.data.data;
this.pageIndex = resp.data.pageIndex;
this.pageSize = resp.data.pageSize;
this.pageTotal = resp.data.pageTotal;
this.totalInfo = resp.data.count;
this.loading = false;
});
},
getPageLikeInfo() {
getPageTeamTypes(1, this.pageSize, this.qryForm.name).then(
(resp) => {
this.pageInfos = resp.data.data;
this.pageIndex = resp.data.pageIndex;
this.pageSize = resp.data.pageSize;
this.totalInfo = resp.data.count;
this.pageTotal = resp.data.pageTotal;
this.loading = false;
}
);
},
handleSizeChange(pageSize) {
this.getPageInfo(this.pageIndex, pageSize, this.qryForm.name);
},
handleCurrentChange(pageIndex) {
this.getPageInfo(pageIndex, this.pageSize, this.qryForm.name);
},
initForm() {
this.teamTypesForm = {
id: "",
name: "",
};
},
showAddWin() {
this.showAddFlag = true;
},
showUpdWin(row) {
this.teamTypesForm = row;
this.showUpdFlag = true;
},
addInfo() {
addTeamTypes(this.teamTypesForm).then((resp) => {
this.$message({
message: resp.msg,
type: "success",
});
this.getPageInfo(1, this.pageSize);
//
data() {
return {
//
pageInfos: [],
// 1
pageIndex: 1,
// 10
pageSize: 10,
// 0
pageTotal: 0,
// 0
totalInfo: 0,
// true
loading: true,
// false
showAddFlag: false,
// false
showUpdFlag: false,
//
qryForm: {
name: "",
},
//
teamTypesForm: {
id: "",
name: "",
},
};
},
//
methods: {
//
getPageInfo(pageIndex, pageSize) {
getPageTeamTypes(pageIndex, pageSize).then((resp) => {
this.pageInfos = resp.data.data;
this.pageIndex = resp.data.pageIndex;
this.pageSize = resp.data.pageSize;
this.pageTotal = resp.data.pageTotal;
this.totalInfo = resp.data.count;
this.showAddFlag = false;
this.loading = false;
this.initForm();
});
},
updInfo() {
updTeamTypes(this.teamTypesForm).then((resp) => {
this.$message({
message: resp.msg,
type: "success",
});
this.getPageInfo(1, this.pageSize);
this.showUpdFlag = false;
this.initForm();
});
},
delInfo(id) {
this.$confirm("即将删除相关信息, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
});
},
//
getPageLikeInfo() {
getPageTeamTypes(1, this.pageSize, this.qryForm.name).then(
(resp) => {
this.pageInfos = resp.data.data;
this.pageIndex = resp.data.pageIndex;
this.pageSize = resp.data.pageSize;
this.totalInfo = resp.data.count;
this.pageTotal = resp.data.pageTotal;
this.loading = false;
}
);
},
//
handleSizeChange(pageSize) {
this.getPageInfo(this.pageIndex, pageSize, this.qryForm.name);
},
//
handleCurrentChange(pageIndex) {
this.getPageInfo(pageIndex, this.pageSize, this.qryForm.name);
},
//
initForm() {
this.teamTypesForm = {
id: "",
name: "",
};
},
//
showAddWin() {
this.showAddFlag = true;
},
//
showUpdWin(row) {
this.teamTypesForm = row;
this.showUpdFlag = true;
},
//
//
methods: {
// API
addInfo() {
// API
addTeamTypes(this.teamTypesForm).then((resp) => {
//
this.$message({
message: resp.msg,
type: "success",
});
//
this.getPageInfo(1, this.pageSize);
//
this.showAddFlag = false;
//
this.initForm();
});
},
// API
updInfo() {
// API
updTeamTypes(this.teamTypesForm).then((resp) => {
//
this.$message({
message: resp.msg,
type: "success",
});
//
this.getPageInfo(1, this.pageSize);
//
this.showUpdFlag = false;
//
this.initForm();
});
},
// API
delInfo(id) {
//
this.$confirm("即将删除相关信息, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}).then(() => {
// API
delTeamTypes(id).then((resp) => {
// 0
if (resp.code == 0) {
this.$message({
message: resp.msg,
type: "success",
});
//
this.getPageInfo(1, this.pageSize);
} else {
// 0
this.$message({
message: resp.msg,
type: "warning",
}).then(() => {
delTeamTypes(id).then((resp) => {
if (resp.code == 0) {
this.$message({
message: resp.msg,
type: "success",
});
this.getPageInfo(1, this.pageSize);
} else {
this.$message({
message: resp.msg,
type: "warning",
});
}
});
});
},
});
}
});
});
},
},
//
mounted() {
this.getPageInfo(1, this.pageSize);
//
this.getPageInfo(1, this.pageSize);
},
};
},}
</script>
Loading…
Cancel
Save