分组管理
This commit is contained in:
parent
c2a73d4f4d
commit
cd33672694
|
@ -0,0 +1,180 @@
|
||||||
|
package org.jeecg.modules.contoller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||||
|
import org.jeecg.common.system.base.controller.JeecgController;
|
||||||
|
import org.jeecg.common.system.query.QueryGenerator;
|
||||||
|
import org.jeecg.modules.entity.CeesGroup;
|
||||||
|
import org.jeecg.modules.entity.dto.UpdateGroupUserDto;
|
||||||
|
import org.jeecg.modules.service.ICeesGroupService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Xubx
|
||||||
|
* @date 2025/03/06
|
||||||
|
*/
|
||||||
|
@Api(tags = "分组表")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/cees/ceesGroup")
|
||||||
|
@Slf4j
|
||||||
|
public class CeesGroupController extends JeecgController<CeesGroup, ICeesGroupService> {
|
||||||
|
@Autowired
|
||||||
|
private ICeesGroupService ceesGroupService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页列表查询
|
||||||
|
*
|
||||||
|
* @param ceesGroup
|
||||||
|
* @param pageNo
|
||||||
|
* @param pageSize
|
||||||
|
* @param req
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
//@AutoLog(value = "分组表-分页列表查询")
|
||||||
|
@ApiOperation(value = "分组表-分页列表查询", notes = "分组表-分页列表查询")
|
||||||
|
@GetMapping(value = "/list")
|
||||||
|
public Result<IPage<CeesGroup>> queryPageList(CeesGroup ceesGroup,
|
||||||
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||||
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||||
|
HttpServletRequest req) {
|
||||||
|
QueryWrapper<CeesGroup> queryWrapper = QueryGenerator.initQueryWrapper(ceesGroup, req.getParameterMap());
|
||||||
|
Page<CeesGroup> page = new Page<CeesGroup>(pageNo, pageSize);
|
||||||
|
IPage<CeesGroup> pageList = ceesGroupService.page(page, queryWrapper);
|
||||||
|
return Result.OK(pageList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询当前分组的组员
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/getRowUser")
|
||||||
|
public Result<?> getRowUser(@RequestParam(name = "id") String id) {
|
||||||
|
ArrayList<String> list = ceesGroupService.getRowUser(id);
|
||||||
|
return Result.ok(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新分组用户中间表
|
||||||
|
*
|
||||||
|
* @param updateGroupUserDto
|
||||||
|
* @return {@link Result }<{@link ? }>
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/updateGroupUser")
|
||||||
|
public Result<?> updateGroupUser(@RequestBody UpdateGroupUserDto updateGroupUserDto) {
|
||||||
|
ceesGroupService.updateGroupUser(updateGroupUserDto);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加
|
||||||
|
*
|
||||||
|
* @param ceesGroup
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "分组表-添加")
|
||||||
|
@ApiOperation(value = "分组表-添加", notes = "分组表-添加")
|
||||||
|
@PostMapping(value = "/add")
|
||||||
|
public Result<String> add(@RequestBody CeesGroup ceesGroup) {
|
||||||
|
ceesGroupService.save(ceesGroup);
|
||||||
|
return Result.OK("添加成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑
|
||||||
|
*
|
||||||
|
* @param ceesGroup
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "分组表-编辑")
|
||||||
|
@ApiOperation(value = "分组表-编辑", notes = "分组表-编辑")
|
||||||
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||||
|
public Result<String> edit(@RequestBody CeesGroup ceesGroup) {
|
||||||
|
ceesGroupService.updateById(ceesGroup);
|
||||||
|
return Result.OK("编辑成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id删除
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "分组表-通过id删除")
|
||||||
|
@ApiOperation(value = "分组表-通过id删除", notes = "分组表-通过id删除")
|
||||||
|
@DeleteMapping(value = "/delete")
|
||||||
|
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||||
|
ceesGroupService.removeById(id);
|
||||||
|
return Result.OK("删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除
|
||||||
|
*
|
||||||
|
* @param ids
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "分组表-批量删除")
|
||||||
|
@ApiOperation(value = "分组表-批量删除", notes = "分组表-批量删除")
|
||||||
|
@DeleteMapping(value = "/deleteBatch")
|
||||||
|
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||||
|
this.ceesGroupService.removeByIds(Arrays.asList(ids.split(",")));
|
||||||
|
return Result.OK("批量删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id查询
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
//@AutoLog(value = "分组表-通过id查询")
|
||||||
|
@ApiOperation(value = "分组表-通过id查询", notes = "分组表-通过id查询")
|
||||||
|
@GetMapping(value = "/queryById")
|
||||||
|
public Result<CeesGroup> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||||
|
CeesGroup ceesGroup = ceesGroupService.getById(id);
|
||||||
|
if (ceesGroup == null) {
|
||||||
|
return Result.error("未找到对应数据");
|
||||||
|
}
|
||||||
|
return Result.OK(ceesGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出excel
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param ceesGroup
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/exportXls")
|
||||||
|
public ModelAndView exportXls(HttpServletRequest request, CeesGroup ceesGroup) {
|
||||||
|
return super.exportXls(request, ceesGroup, CeesGroup.class, "分组表");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过excel导入数据
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param response
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||||
|
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
return super.importExcel(request, response, CeesGroup.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
package org.jeecg.modules.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 分组表
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2025-03-04
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("cees_group")
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@ApiModel(value="cees_group对象", description="分组表")
|
||||||
|
public class CeesGroup implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**主键*/
|
||||||
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
|
@ApiModelProperty(value = "主键")
|
||||||
|
private String id;
|
||||||
|
/**创建人*/
|
||||||
|
@ApiModelProperty(value = "创建人")
|
||||||
|
private String createBy;
|
||||||
|
/**创建日期*/
|
||||||
|
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||||
|
@ApiModelProperty(value = "创建日期")
|
||||||
|
private Date createTime;
|
||||||
|
/**更新人*/
|
||||||
|
@ApiModelProperty(value = "更新人")
|
||||||
|
private String updateBy;
|
||||||
|
/**更新日期*/
|
||||||
|
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||||
|
@ApiModelProperty(value = "更新日期")
|
||||||
|
private Date updateTime;
|
||||||
|
/**所属部门*/
|
||||||
|
@ApiModelProperty(value = "所属部门")
|
||||||
|
private String sysOrgCode;
|
||||||
|
/**分组名*/
|
||||||
|
@Excel(name = "分组名", width = 15)
|
||||||
|
@ApiModelProperty(value = "分组名")
|
||||||
|
private String name;
|
||||||
|
/**专业id*/
|
||||||
|
@Excel(name = "专业id", width = 15)
|
||||||
|
@ApiModelProperty(value = "专业id")
|
||||||
|
private Integer majorId;
|
||||||
|
}
|
|
@ -85,7 +85,7 @@ public class CeesLocalTeacher implements Serializable {
|
||||||
/**组id*/
|
/**组id*/
|
||||||
@Excel(name = "组id", width = 15)
|
@Excel(name = "组id", width = 15)
|
||||||
@ApiModelProperty(value = "组id")
|
@ApiModelProperty(value = "组id")
|
||||||
private Integer groupId;
|
private String groupId;
|
||||||
/**使用次数*/
|
/**使用次数*/
|
||||||
@Excel(name = "使用次数", width = 15)
|
@Excel(name = "使用次数", width = 15)
|
||||||
@ApiModelProperty(value = "使用次数")
|
@ApiModelProperty(value = "使用次数")
|
||||||
|
|
|
@ -141,7 +141,7 @@ public class CeesWaiTeacher implements Serializable {
|
||||||
/**组id*/
|
/**组id*/
|
||||||
@Excel(name = "组id", width = 15)
|
@Excel(name = "组id", width = 15)
|
||||||
@ApiModelProperty(value = "组id")
|
@ApiModelProperty(value = "组id")
|
||||||
private Integer groupId;
|
private String groupId;
|
||||||
/**使用次数*/
|
/**使用次数*/
|
||||||
@Excel(name = "使用次数", width = 15)
|
@Excel(name = "使用次数", width = 15)
|
||||||
@ApiModelProperty(value = "使用次数")
|
@ApiModelProperty(value = "使用次数")
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class Student implements Serializable {
|
||||||
/**组id*/
|
/**组id*/
|
||||||
@Excel(name = "组id", width = 15)
|
@Excel(name = "组id", width = 15)
|
||||||
@ApiModelProperty(value = "组id")
|
@ApiModelProperty(value = "组id")
|
||||||
private Integer groupId;
|
private String groupId;
|
||||||
/**使用次数*/
|
/**使用次数*/
|
||||||
@Excel(name = "使用次数", width = 15)
|
@Excel(name = "使用次数", width = 15)
|
||||||
@ApiModelProperty(value = "使用次数")
|
@ApiModelProperty(value = "使用次数")
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package org.jeecg.modules.entity.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分组中间表更新入参
|
||||||
|
* @author Xubx
|
||||||
|
* @date 2025/03/06
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UpdateGroupUserDto {
|
||||||
|
private String userId;
|
||||||
|
|
||||||
|
private String groupId;
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package org.jeecg.modules.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.jeecg.modules.entity.CeesGroup;
|
||||||
|
import org.jeecg.modules.entity.dto.UpdateGroupUserDto;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 分组表
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2025-03-04
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
public interface CeesGroupMapper extends BaseMapper<CeesGroup> {
|
||||||
|
|
||||||
|
ArrayList<String> getGroupUser(String id);
|
||||||
|
|
||||||
|
void updateGroupUser(UpdateGroupUserDto updateGroupUserDto);
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?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="org.jeecg.modules.mapper.CeesGroupMapper">
|
||||||
|
<update id="updateGroupUser">
|
||||||
|
INSERT INTO cees_user_group (user_id, group_id)
|
||||||
|
VALUES (#{userId}, #{groupId}) ON DUPLICATE KEY
|
||||||
|
UPDATE group_id = #{groupId};
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<select id="getGroupUser" resultType="java.lang.String">
|
||||||
|
select user_id from cees_user_group where group_id = #{groupId}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
|
@ -0,0 +1,23 @@
|
||||||
|
package org.jeecg.modules.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import org.jeecg.modules.entity.CeesGroup;
|
||||||
|
import org.jeecg.modules.entity.dto.UpdateGroupUserDto;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 分组表
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2025-03-04
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
public interface ICeesGroupService extends IService<CeesGroup> {
|
||||||
|
//TODO 查分组中间表的所有组员
|
||||||
|
//TODO 添加分组,要分别修改信息表和分组中间表
|
||||||
|
|
||||||
|
ArrayList<String> getRowUser(String id);
|
||||||
|
|
||||||
|
void updateGroupUser(UpdateGroupUserDto updateGroupUserDto);
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
package org.jeecg.modules.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.jeecg.modules.entity.CeesGroup;
|
||||||
|
import org.jeecg.modules.entity.dto.UpdateGroupUserDto;
|
||||||
|
import org.jeecg.modules.mapper.CeesGroupMapper;
|
||||||
|
import org.jeecg.modules.service.ICeesGroupService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 分组表
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2025-03-04
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class CeesGroupServiceImpl extends ServiceImpl<CeesGroupMapper, CeesGroup> implements ICeesGroupService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CeesGroupMapper ceesGroupMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param id
|
||||||
|
* @return {@link ArrayList }<{@link String }>
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ArrayList<String> getRowUser(String id) {
|
||||||
|
ArrayList<String> list;
|
||||||
|
list = ceesGroupMapper.getGroupUser(id);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param updateGroupUserDto
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateGroupUser(UpdateGroupUserDto updateGroupUserDto) {
|
||||||
|
//新增或更新分组中间表
|
||||||
|
ceesGroupMapper.updateGroupUser(updateGroupUserDto);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue