小组管理

master
李永杰 2024-04-24 10:13:06 +08:00
parent e8ae7079c8
commit 99a6387497
9 changed files with 464 additions and 0 deletions

View File

@ -0,0 +1,112 @@
package com.ruoyi.web.controller.business;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.*;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.Result;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.TeamInfo;
import com.ruoyi.business.domain.req.TeamInfoQueryReq;
import com.ruoyi.business.domain.req.TeamInfoSaveReq;
import com.ruoyi.business.domain.req.TeamInfoEditReq;
import com.ruoyi.business.service.TeamInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* Controller
*
* @author ruoyi
* @date 2024-04-23
*/
@Api(tags = "小组管理")
@RestController
@RequestMapping("/business/team")
public class TeamInfoController extends BaseController {
@Autowired
private TeamInfoService teamInfoService;
/**
*
*/
@ApiOperation("获取小组列表")
@PreAuthorize("@ss.hasPermi('business:team:list')")
@GetMapping("/list")
public Result<TableDataInfo<TeamInfo>> list(TeamInfoQueryReq teamInfoQueryReq) {
startPage();
List<TeamInfo> list = teamInfoService.list(TeamInfo.queryBuild(teamInfoQueryReq));
return getDataTable(list);
}
/**
*
*/
@ApiOperation("导出小组列表")
@PreAuthorize("@ss.hasPermi('business:team:export')")
@Log(title = "小组", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, TeamInfo teamInfo) {
List<TeamInfo> list = teamInfoService.list(teamInfo);
ExcelUtil<TeamInfo> util = new ExcelUtil<TeamInfo>(TeamInfo.class);
util.exportExcel(response, list, "小组数据");
}
/**
*
*/
@ApiOperation("获取小组详细信息")
@PreAuthorize("@ss.hasPermi('business:team:query')")
@GetMapping(value = "/{teamId}")
@ApiImplicitParam(name = "teamId", value = "teamId", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
public Result<TeamInfo> getInfo(@PathVariable("teamId") Long teamId) {
return Result.success(teamInfoService.getById(teamId));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('business:team:add')")
@Log(title = "小组", businessType = BusinessType.INSERT)
@PostMapping
@ApiOperation("新增小组")
public Result<String> add(@RequestBody TeamInfoSaveReq teamInfoSaveReq) {
return toAjax(teamInfoService.save(TeamInfo.saveBuild(teamInfoSaveReq)));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('business:team:edit')")
@Log(title = "小组", businessType = BusinessType.UPDATE)
@PutMapping("/{teamId}")
@ApiOperation("修改小组")
public Result<String> edit(@PathVariable Long teamId, @RequestBody TeamInfoEditReq teamInfoEditReq) {
return toAjax(teamInfoService.updateById(TeamInfo.editBuild(teamId,teamInfoEditReq)));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('business:team:remove')")
@Log(title = "小组", businessType = BusinessType.DELETE)
@DeleteMapping("/{teamIds}")
@ApiOperation("删除小组")
@ApiImplicitParam(name = "teamId", value = "teamId", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
public Result<String> remove(@PathVariable List<Long> teamIds) {
return toAjax(teamInfoService.removeBatchByIds(teamIds));
}
}

View File

@ -0,0 +1,90 @@
package com.ruoyi.business.domain;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.business.domain.req.TeamInfoQueryReq;
import com.ruoyi.business.domain.req.TeamInfoSaveReq;
import com.ruoyi.business.domain.req.TeamInfoEditReq;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* team_info
*
* @author ruoyi
* @date 2024-04-23
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName("team_info")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "TeamInfo", description = "小组")
public class TeamInfo extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 小组ID */
@Excel(name = "小组ID")
@TableId(value = "team_id",type = IdType.AUTO)
@ApiModelProperty(name = "小组ID", value = "小组ID")
private Long teamId;
/** 小组名称 */
@Excel(name = "小组名称")
@ApiModelProperty(name = "小组名称", value = "小组名称")
private String teamName;
/** 状态 */
@Excel(name = "状态")
@ApiModelProperty(name = "状态", value = "状态")
private String status;
/** 班级 */
@ApiModelProperty(name = "班级", value = "班级")
private Long clazzId;
/** 班级名称 */
@Excel(name = "班级")
@TableField(exist = false)
private String clazzName;
/**
*
*/
public static TeamInfo queryBuild( TeamInfoQueryReq teamInfoQueryReq){
return TeamInfo.builder()
.teamName(teamInfoQueryReq.getTeamName())
.build();
}
/**
*
*/
public static TeamInfo saveBuild(TeamInfoSaveReq teamInfoSaveReq){
return TeamInfo.builder()
.teamName(teamInfoSaveReq.getTeamName())
.status(teamInfoSaveReq.getStatus())
.clazzId(teamInfoSaveReq.getClazzId())
.build();
}
/**
*
*/
public static TeamInfo editBuild(Long teamId, TeamInfoEditReq teamInfoEditReq){
return TeamInfo.builder()
.teamId(teamId)
.teamName(teamInfoEditReq.getTeamName())
.status(teamInfoEditReq.getStatus())
.clazzId(teamInfoEditReq.getClazzId())
.build();
}
}

View File

@ -0,0 +1,41 @@
package com.ruoyi.business.domain.req;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* team_info
*
* @author ruoyi
* @date 2024-04-23
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "TeamInfoEditReq", description = "小组")
public class TeamInfoEditReq extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 小组名称 */
@ApiModelProperty(name = "小组名称", value = "小组名称")
private String teamName;
/** 状态 */
@ApiModelProperty(name = "状态", value = "状态")
private String status;
/** 班级 */
@ApiModelProperty(name = "班级", value = "班级")
private Long clazzId;
}

View File

@ -0,0 +1,33 @@
package com.ruoyi.business.domain.req;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* team_info
*
* @author ruoyi
* @date 2024-04-23
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "TeamInfoQueryReq", description = "小组")
public class TeamInfoQueryReq extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 小组名称 */
@ApiModelProperty(name = "小组名称", value = "小组名称")
private String teamName;
}

View File

@ -0,0 +1,49 @@
package com.ruoyi.business.domain.req;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* team_info
*
* @author ruoyi
* @date 2024-04-23
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "TeamInfoSaveReq", description = "小组")
public class TeamInfoSaveReq extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 小组ID */
@ApiModelProperty(name = "小组ID", value = "小组ID")
private Long teamId;
/** 小组名称 */
@ApiModelProperty(name = "小组名称", value = "小组名称")
private String teamName;
/** 状态 */
@ApiModelProperty(name = "状态", value = "状态")
private String status;
/** 班级 */
@ApiModelProperty(name = "班级", value = "班级")
private Long clazzId;
}

View File

@ -0,0 +1,24 @@
package com.ruoyi.business.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.*;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.business.domain.TeamInfo;
/**
* Mapper
*
* @author ruoyi
* @date 2024-04-23
*/
public interface TeamInfoMapper extends BaseMapper<TeamInfo> {
/**
*
*
* @param queryWrapper
* @return
*/
List<TeamInfo> selectTeamList(LambdaQueryWrapper<TeamInfo> queryWrapper);
}

View File

@ -0,0 +1,22 @@
package com.ruoyi.business.service;
import java.util.List;
import com.ruoyi.business.domain.TeamInfo;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* Service
*
* @author ruoyi
* @date 2024-04-23
*/
public interface TeamInfoService extends IService<TeamInfo> {
/**
*
*
* @param teamInfo
* @return
*/
public List<TeamInfo> list(TeamInfo teamInfo);
}

View File

@ -0,0 +1,45 @@
package com.ruoyi.business.service.impl;
import java.util.List;
import com.ruoyi.common.utils.ObjUtils;
import com.ruoyi.common.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.*;
import org.springframework.stereotype.Service;
import com.ruoyi.business.mapper.TeamInfoMapper;
import com.ruoyi.business.domain.TeamInfo;
import com.ruoyi.business.service.TeamInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
/**
* Service
*
* @author ruoyi
* @date 2024-04-23
*/
@Slf4j
@Service
public class TeamInfoServiceImpl extends ServiceImpl<TeamInfoMapper, TeamInfo> implements TeamInfoService {
@Autowired
private TeamInfoMapper teamInfoMapper;
/**
*
*
* @param teamInfo
* @return
*/
@Override
public List<TeamInfo> list(TeamInfo teamInfo) {
LambdaQueryWrapper<TeamInfo> queryWrapper = new LambdaQueryWrapper<>();
if (ObjUtils.notNull(teamInfo.getTeamName())){
queryWrapper.like(TeamInfo::getTeamName, teamInfo.getTeamName());
}
return teamInfoMapper.selectTeamList(queryWrapper);
}
}

View File

@ -0,0 +1,48 @@
<?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.ruoyi.business.mapper.TeamInfoMapper">
<resultMap type="com.ruoyi.business.domain.TeamInfo" id="TeamInfoResult">
<result property="teamId" column="team_id" />
<result property="teamName" column="team_name" />
<result property="status" column="status" />
<result property="clazzId" column="clazz_id" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<association property="clazz" javaType="com.ruoyi.business.domain.Clazz">
<result property="clazzId" column="clazz_id"/>
<result property="clazzName" column="clazz_name"/>
<result property="status" column="status" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</association>
</resultMap>
<sql id="selectTeamInfoVo">
select
t.team_id,
t.team_name,
t.status,
c.clazz_name,
t.create_by,
t.create_time,
t.update_by,
t.update_time,
t.remark
from
team_info t
left join t_clazz c on c.clazz_id = t.clazz_id
</sql>
<select id="selectTeamList" resultType="com.ruoyi.business.domain.TeamInfo">
<include refid="selectTeamInfoVo"/>
</select>
</mapper>