Commit 3085dabe authored by mengmeng's avatar mengmeng

20210105 hmit_admin V1.0

parent c681a532
...@@ -2,6 +2,7 @@ package io.hmit.modules.area.controller; ...@@ -2,6 +2,7 @@ package io.hmit.modules.area.controller;
import io.hmit.common.annotation.LogOperation; import io.hmit.common.annotation.LogOperation;
import io.hmit.common.constant.Constant; import io.hmit.common.constant.Constant;
import io.hmit.common.exception.ErrorCode;
import io.hmit.common.page.PageData; import io.hmit.common.page.PageData;
import io.hmit.common.utils.ExcelUtils; import io.hmit.common.utils.ExcelUtils;
import io.hmit.common.utils.Result; import io.hmit.common.utils.Result;
...@@ -13,6 +14,8 @@ import io.hmit.common.validator.group.UpdateGroup; ...@@ -13,6 +14,8 @@ import io.hmit.common.validator.group.UpdateGroup;
import io.hmit.modules.area.dto.AreaDTO; import io.hmit.modules.area.dto.AreaDTO;
import io.hmit.modules.area.excel.AreaExcel; import io.hmit.modules.area.excel.AreaExcel;
import io.hmit.modules.area.service.AreaService; import io.hmit.modules.area.service.AreaService;
import io.hmit.modules.user.dto.UserDTO;
import io.hmit.modules.user.service.UserService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
...@@ -23,6 +26,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -23,6 +26,7 @@ import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -40,6 +44,9 @@ public class AreaController { ...@@ -40,6 +44,9 @@ public class AreaController {
@Autowired @Autowired
private AreaService areaService; private AreaService areaService;
@Autowired
private UserService userService;
@GetMapping("page") @GetMapping("page")
@ApiOperation("分页") @ApiOperation("分页")
@ApiImplicitParams({ @ApiImplicitParams({
...@@ -48,16 +55,26 @@ public class AreaController { ...@@ -48,16 +55,26 @@ public class AreaController {
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") , @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") ,
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String") @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String")
}) })
@RequiresPermissions("area:area:page") //@RequiresPermissions("area:area:page")
public Result<PageData<AreaDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){ public Result<PageData<AreaDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
PageData<AreaDTO> page = areaService.page(params); PageData<AreaDTO> page = areaService.page(params);
return new Result<PageData<AreaDTO>>().ok(page); return new Result<PageData<AreaDTO>>().ok(page);
} }
@GetMapping("list")
@ApiOperation("列表")
@ApiImplicitParam(name = "type", value = "菜单类型 0:市级 1:区级 null:全部", paramType = "query", dataType = "int")
public Result<List<AreaDTO>> list(Integer type) {
List<AreaDTO> list = areaService.getAllAreaList(type);
return new Result<List<AreaDTO>>().ok(list);
}
@GetMapping("{id}") @GetMapping("{id}")
@ApiOperation("信息") @ApiOperation("信息")
@RequiresPermissions("area:area:info") //@RequiresPermissions("area:area:info")
public Result<AreaDTO> get(@PathVariable("id") Long id){ public Result<AreaDTO> get(@PathVariable("id") Long id){
AreaDTO data = areaService.get(id); AreaDTO data = areaService.get(id);
...@@ -67,7 +84,7 @@ public class AreaController { ...@@ -67,7 +84,7 @@ public class AreaController {
@PostMapping @PostMapping
@ApiOperation("保存") @ApiOperation("保存")
@LogOperation("保存") @LogOperation("保存")
@RequiresPermissions("area:area:save") //@RequiresPermissions("area:area:save")
public Result save(@RequestBody AreaDTO dto){ public Result save(@RequestBody AreaDTO dto){
//校验数据 //校验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
...@@ -80,7 +97,7 @@ public class AreaController { ...@@ -80,7 +97,7 @@ public class AreaController {
@PutMapping @PutMapping
@ApiOperation("修改") @ApiOperation("修改")
@LogOperation("修改") @LogOperation("修改")
@RequiresPermissions("area:area:update") //@RequiresPermissions("area:area:update")
public Result update(@RequestBody AreaDTO dto){ public Result update(@RequestBody AreaDTO dto){
//校验数据 //校验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
...@@ -90,15 +107,26 @@ public class AreaController { ...@@ -90,15 +107,26 @@ public class AreaController {
return new Result(); return new Result();
} }
@DeleteMapping @DeleteMapping("{id}")
@ApiOperation("删除") @ApiOperation("删除")
@LogOperation("删除") @LogOperation("删除")
@RequiresPermissions("area:area:delete") @RequiresPermissions("area:area:delete")
public Result delete(@RequestBody Long[] ids){ public Result delete(@PathVariable("id") Long id){
//校验数据 //校验数据
AssertUtils.isArrayEmpty(ids, "id"); AssertUtils.isNull(id, "id");
areaService.delete(ids); //判断是否有子菜单或按钮
List<AreaDTO> list = areaService.getListPid(id);
if (list.size() > 0) {
return new Result().error(ErrorCode.SUB_MENU_EXIST);
}
Map<String, Object> params = new HashMap<>();
params.put("area",id);
List<UserDTO> userList = userService.list(params);
if(userList.size()>0){
return new Result().error(500,"当前地区存在会员信息,请核对后再进行删除");
}
areaService.delete(id);
return new Result(); return new Result();
} }
...@@ -106,11 +134,11 @@ public class AreaController { ...@@ -106,11 +134,11 @@ public class AreaController {
@GetMapping("export") @GetMapping("export")
@ApiOperation("导出") @ApiOperation("导出")
@LogOperation("导出") @LogOperation("导出")
@RequiresPermissions("area:area:export") //@RequiresPermissions("area:area:export")
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<AreaDTO> list = areaService.list(params); List<AreaDTO> list = areaService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, AreaExcel.class); ExcelUtils.exportExcelToTarget(response, null, list, AreaExcel.class);
} }
} }
\ No newline at end of file
...@@ -2,7 +2,11 @@ package io.hmit.modules.area.dao; ...@@ -2,7 +2,11 @@ package io.hmit.modules.area.dao;
import io.hmit.common.dao.BaseDao; import io.hmit.common.dao.BaseDao;
import io.hmit.modules.area.entity.AreaEntity; import io.hmit.modules.area.entity.AreaEntity;
import io.hmit.modules.sys.entity.SysMenuEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* 区市管理 * 区市管理
...@@ -12,5 +16,19 @@ import org.apache.ibatis.annotations.Mapper; ...@@ -12,5 +16,19 @@ import org.apache.ibatis.annotations.Mapper;
*/ */
@Mapper @Mapper
public interface AreaDao extends BaseDao<AreaEntity> { public interface AreaDao extends BaseDao<AreaEntity> {
/**
} * 查询所有区市列表
\ No newline at end of file *
* @param type 区市类型
*/
List<AreaEntity> getAreaList(@Param("type") Integer type);
/**
* 根据市级,查询区级
*
* @param pid 市级ID
*/
List<AreaEntity> getListPid(Long pid);
}
package io.hmit.modules.area.dto; package io.hmit.modules.area.dto;
import io.hmit.common.utils.TreeNode;
import io.hmit.modules.user.dto.AreaUserDTO;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
...@@ -16,14 +19,17 @@ import java.util.Date; ...@@ -16,14 +19,17 @@ import java.util.Date;
*/ */
@Data @Data
@ApiModel(value = "区市管理") @ApiModel(value = "区市管理")
public class AreaDTO implements Serializable { public class AreaDTO extends TreeNode<AreaDTO> implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "区市ID") @ApiModelProperty(value = "区市ID")
private Long id; private Long id;
@ApiModelProperty(value = "父类ID") @ApiModelProperty(value = "父类ID")
private Long parentId; private Long pid;
@ApiModelProperty(value = "父类名称")
private String parentName;
@ApiModelProperty(value = "区市名") @ApiModelProperty(value = "区市名")
private String name; private String name;
...@@ -37,5 +43,6 @@ public class AreaDTO implements Serializable { ...@@ -37,5 +43,6 @@ public class AreaDTO implements Serializable {
@ApiModelProperty(value = "创建时间") @ApiModelProperty(value = "创建时间")
private Date createDate; private Date createDate;
@ApiModelProperty(value = "区市级类型 0:市级 1:区级")
} private Integer type;
\ No newline at end of file }
...@@ -22,7 +22,7 @@ public class AreaEntity extends BaseEntity { ...@@ -22,7 +22,7 @@ public class AreaEntity extends BaseEntity {
/** /**
* 父类ID * 父类ID
*/ */
private Long parentId; private Long pid;
/** /**
* 区市名 * 区市名
*/ */
...@@ -31,4 +31,8 @@ public class AreaEntity extends BaseEntity { ...@@ -31,4 +31,8 @@ public class AreaEntity extends BaseEntity {
* 排序 * 排序
*/ */
private Integer sort; private Integer sort;
} /**
\ No newline at end of file * 区市类型
*/
private Integer type;
}
...@@ -4,6 +4,8 @@ import io.hmit.common.service.CrudService; ...@@ -4,6 +4,8 @@ import io.hmit.common.service.CrudService;
import io.hmit.modules.area.dto.AreaDTO; import io.hmit.modules.area.dto.AreaDTO;
import io.hmit.modules.area.entity.AreaEntity; import io.hmit.modules.area.entity.AreaEntity;
import java.util.List;
/** /**
* 区市管理 * 区市管理
* *
...@@ -11,5 +13,26 @@ import io.hmit.modules.area.entity.AreaEntity; ...@@ -11,5 +13,26 @@ import io.hmit.modules.area.entity.AreaEntity;
* @since 1.0.0 2020-12-25 * @since 1.0.0 2020-12-25
*/ */
public interface AreaService extends CrudService<AreaEntity, AreaDTO> { public interface AreaService extends CrudService<AreaEntity, AreaDTO> {
/**
* 市区列表
*
* @param type 市区类型
*/
List<AreaDTO> getAllAreaList(Integer type);
/**
* 根据市级,查询区级
*
* @param pid 市级ID
*/
List<AreaDTO> getListPid(Long pid);
void delete(Long id);
@Override
void save(AreaDTO dto);
@Override
void update(AreaDTO dto);
} }
\ No newline at end of file
package io.hmit.modules.area.service.impl; package io.hmit.modules.area.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.hmit.common.constant.Constant;
import io.hmit.common.exception.ErrorCode;
import io.hmit.common.exception.HmitException;
import io.hmit.common.service.impl.CrudServiceImpl; import io.hmit.common.service.impl.CrudServiceImpl;
import io.hmit.common.utils.ConvertUtils;
import io.hmit.common.utils.HttpContextUtils;
import io.hmit.common.utils.TreeUtils;
import io.hmit.modules.area.dao.AreaDao; import io.hmit.modules.area.dao.AreaDao;
import io.hmit.modules.area.dto.AreaDTO; import io.hmit.modules.area.dto.AreaDTO;
import io.hmit.modules.area.entity.AreaEntity; import io.hmit.modules.area.entity.AreaEntity;
import io.hmit.modules.area.service.AreaService; import io.hmit.modules.area.service.AreaService;
import io.hmit.modules.sys.service.SysLanguageService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -20,6 +30,9 @@ import java.util.Map; ...@@ -20,6 +30,9 @@ import java.util.Map;
@Service @Service
public class AreaServiceImpl extends CrudServiceImpl<AreaDao, AreaEntity, AreaDTO> implements AreaService { public class AreaServiceImpl extends CrudServiceImpl<AreaDao, AreaEntity, AreaDTO> implements AreaService {
@Autowired
private SysLanguageService sysLanguageService;
@Override @Override
public QueryWrapper<AreaEntity> getWrapper(Map<String, Object> params){ public QueryWrapper<AreaEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get("id"); String id = (String)params.get("id");
...@@ -31,4 +44,58 @@ public class AreaServiceImpl extends CrudServiceImpl<AreaDao, AreaEntity, AreaDT ...@@ -31,4 +44,58 @@ public class AreaServiceImpl extends CrudServiceImpl<AreaDao, AreaEntity, AreaDT
} }
} @Override
\ No newline at end of file public List<AreaDTO> getAllAreaList(Integer type) {
List<AreaEntity> areaList = baseDao.getAreaList(type);
List<AreaDTO> dtoList = ConvertUtils.sourceToTarget(areaList, AreaDTO.class);
return TreeUtils.build(dtoList, Constant.AREA_ROOT);
}
@Override
public List<AreaDTO> getListPid(Long pid) {
List<AreaEntity> areaList = baseDao.getListPid(pid);
return ConvertUtils.sourceToTarget(areaList, AreaDTO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(AreaDTO dto) {
AreaEntity entity = ConvertUtils.sourceToTarget(dto, AreaEntity.class);
//保存菜单
insert(entity);
saveLanguage(entity.getId(), "name", entity.getName());
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
deleteById(id);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(AreaDTO dto) {
AreaEntity entity = ConvertUtils.sourceToTarget(dto, AreaEntity.class);
//上级菜单不能为自身
if (entity.getId().equals(entity.getPid())) {
throw new HmitException(ErrorCode.SUPERIOR_MENU_ERROR);
}
//更新菜单
updateById(entity);
saveLanguage(entity.getId(), "name", entity.getName());
}
private void saveLanguage(Long tableId, String fieldName, String fieldValue) {
sysLanguageService.saveOrUpdate("wl_area", tableId, fieldName, fieldValue, HttpContextUtils.getLanguage());
}
}
...@@ -10,9 +10,12 @@ import io.hmit.common.validator.ValidatorUtils; ...@@ -10,9 +10,12 @@ import io.hmit.common.validator.ValidatorUtils;
import io.hmit.common.validator.group.AddGroup; import io.hmit.common.validator.group.AddGroup;
import io.hmit.common.validator.group.DefaultGroup; import io.hmit.common.validator.group.DefaultGroup;
import io.hmit.common.validator.group.UpdateGroup; import io.hmit.common.validator.group.UpdateGroup;
import io.hmit.modules.area.dto.AreaDTO;
import io.hmit.modules.committee.dto.CommitteeDTO; import io.hmit.modules.committee.dto.CommitteeDTO;
import io.hmit.modules.committee.excel.CommitteeExcel; import io.hmit.modules.committee.excel.CommitteeExcel;
import io.hmit.modules.committee.service.CommitteeService; import io.hmit.modules.committee.service.CommitteeService;
import io.hmit.modules.user.dto.UserDTO;
import io.hmit.modules.user.service.UserService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
...@@ -23,6 +26,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -23,6 +26,7 @@ import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -40,6 +44,9 @@ public class CommitteeController { ...@@ -40,6 +44,9 @@ public class CommitteeController {
@Autowired @Autowired
private CommitteeService committeeService; private CommitteeService committeeService;
@Autowired
private UserService userService;
@GetMapping("page") @GetMapping("page")
@ApiOperation("分页") @ApiOperation("分页")
@ApiImplicitParams({ @ApiImplicitParams({
...@@ -48,16 +55,25 @@ public class CommitteeController { ...@@ -48,16 +55,25 @@ public class CommitteeController {
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") , @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") ,
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String") @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String")
}) })
@RequiresPermissions("committee:committee:page") // @RequiresPermissions("committee:committee:page")
public Result<PageData<CommitteeDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){ public Result<PageData<CommitteeDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
PageData<CommitteeDTO> page = committeeService.page(params); PageData<CommitteeDTO> page = committeeService.page(params);
return new Result<PageData<CommitteeDTO>>().ok(page); return new Result<PageData<CommitteeDTO>>().ok(page);
} }
@GetMapping("list")
@ApiOperation("列表")
public Result<List<CommitteeDTO>> list(@ApiIgnore @RequestParam Map<String, Object> params) {
List<CommitteeDTO> list = committeeService.list(params);
return new Result<List<CommitteeDTO>>().ok(list);
}
@GetMapping("{id}") @GetMapping("{id}")
@ApiOperation("信息") @ApiOperation("信息")
@RequiresPermissions("committee:committee:info") // @RequiresPermissions("committee:committee:info")
public Result<CommitteeDTO> get(@PathVariable("id") Long id){ public Result<CommitteeDTO> get(@PathVariable("id") Long id){
CommitteeDTO data = committeeService.get(id); CommitteeDTO data = committeeService.get(id);
...@@ -67,7 +83,7 @@ public class CommitteeController { ...@@ -67,7 +83,7 @@ public class CommitteeController {
@PostMapping @PostMapping
@ApiOperation("保存") @ApiOperation("保存")
@LogOperation("保存") @LogOperation("保存")
@RequiresPermissions("committee:committee:save") // @RequiresPermissions("committee:committee:save")
public Result save(@RequestBody CommitteeDTO dto){ public Result save(@RequestBody CommitteeDTO dto){
//校验数据 //校验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
...@@ -80,7 +96,7 @@ public class CommitteeController { ...@@ -80,7 +96,7 @@ public class CommitteeController {
@PutMapping @PutMapping
@ApiOperation("修改") @ApiOperation("修改")
@LogOperation("修改") @LogOperation("修改")
@RequiresPermissions("committee:committee:update") //@RequiresPermissions("committee:committee:update")
public Result update(@RequestBody CommitteeDTO dto){ public Result update(@RequestBody CommitteeDTO dto){
//校验数据 //校验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
...@@ -93,12 +109,20 @@ public class CommitteeController { ...@@ -93,12 +109,20 @@ public class CommitteeController {
@DeleteMapping @DeleteMapping
@ApiOperation("删除") @ApiOperation("删除")
@LogOperation("删除") @LogOperation("删除")
@RequiresPermissions("committee:committee:delete") //@RequiresPermissions("committee:committee:delete")
public Result delete(@RequestBody Long[] ids){ public Result delete(@RequestBody Long[] ids){
//校验数据 //校验数据
AssertUtils.isArrayEmpty(ids, "id"); AssertUtils.isArrayEmpty(ids, "id");
for (Long id : ids) {
committeeService.delete(ids); Map<String, Object> params = new HashMap<>();
params.put("committee",id);
List<UserDTO> userList = userService.list(params);
if(userList.size()>0){
return new Result().error(500,"委员会 "+committeeService.get(id).getName()+" 存在会员信息,请核对后再进行删除");
}
committeeService.deleteById(id);
}
// committeeService.delete(ids);
return new Result(); return new Result();
} }
...@@ -106,11 +130,11 @@ public class CommitteeController { ...@@ -106,11 +130,11 @@ public class CommitteeController {
@GetMapping("export") @GetMapping("export")
@ApiOperation("导出") @ApiOperation("导出")
@LogOperation("导出") @LogOperation("导出")
@RequiresPermissions("committee:committee:export") //@RequiresPermissions("committee:committee:export")
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<CommitteeDTO> list = committeeService.list(params); List<CommitteeDTO> list = committeeService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, CommitteeExcel.class); ExcelUtils.exportExcelToTarget(response, null, list, CommitteeExcel.class);
} }
} }
\ No newline at end of file
...@@ -11,18 +11,21 @@ import io.hmit.common.validator.group.AddGroup; ...@@ -11,18 +11,21 @@ import io.hmit.common.validator.group.AddGroup;
import io.hmit.common.validator.group.DefaultGroup; import io.hmit.common.validator.group.DefaultGroup;
import io.hmit.common.validator.group.UpdateGroup; import io.hmit.common.validator.group.UpdateGroup;
import io.hmit.modules.meeting.dto.MeetingDTO; import io.hmit.modules.meeting.dto.MeetingDTO;
import io.hmit.modules.meeting.dto.WlMeetingStaffDTO;
import io.hmit.modules.meeting.excel.MeetingExcel; import io.hmit.modules.meeting.excel.MeetingExcel;
import io.hmit.modules.meeting.service.MeetingService; import io.hmit.modules.meeting.service.MeetingService;
import io.hmit.modules.meeting.service.WlMeetingStaffService;
import io.hmit.modules.user.dto.UserDTO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -40,15 +43,19 @@ public class MeetingController { ...@@ -40,15 +43,19 @@ public class MeetingController {
@Autowired @Autowired
private MeetingService meetingService; private MeetingService meetingService;
@Autowired
private WlMeetingStaffService wlMeetingStaffService;
@GetMapping("page") @GetMapping("page")
@ApiOperation("分页") @ApiOperation("分页")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") , @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") , @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") ,
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String") @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String"),
@ApiImplicitParam(name = "name", value = "会议名称", paramType = "query", dataType="String")
}) })
@RequiresPermissions("meeting:meeting:page") //@RequiresPermissions("meeting:meeting:page")
public Result<PageData<MeetingDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){ public Result<PageData<MeetingDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
PageData<MeetingDTO> page = meetingService.page(params); PageData<MeetingDTO> page = meetingService.page(params);
...@@ -57,17 +64,20 @@ public class MeetingController { ...@@ -57,17 +64,20 @@ public class MeetingController {
@GetMapping("{id}") @GetMapping("{id}")
@ApiOperation("信息") @ApiOperation("信息")
@RequiresPermissions("meeting:meeting:info") //@RequiresPermissions("meeting:meeting:info")
public Result<MeetingDTO> get(@PathVariable("id") Long id){ public Result<MeetingDTO> get(@PathVariable("id") Long id){
MeetingDTO data = meetingService.get(id); MeetingDTO data = meetingService.get(id);
List<UserDTO> userNames = wlMeetingStaffService.getInvitedNames(id);
data.setInvitedUserNames(userNames);
return new Result<MeetingDTO>().ok(data); return new Result<MeetingDTO>().ok(data);
} }
@PostMapping @PostMapping
@ApiOperation("保存") @ApiOperation("保存")
@LogOperation("保存") @LogOperation("保存")
@RequiresPermissions("meeting:meeting:save") //@RequiresPermissions("meeting:meeting:save")
public Result save(@RequestBody MeetingDTO dto){ public Result save(@RequestBody MeetingDTO dto){
//校验数据 //校验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
...@@ -80,7 +90,7 @@ public class MeetingController { ...@@ -80,7 +90,7 @@ public class MeetingController {
@PutMapping @PutMapping
@ApiOperation("修改") @ApiOperation("修改")
@LogOperation("修改") @LogOperation("修改")
@RequiresPermissions("meeting:meeting:update") //@RequiresPermissions("meeting:meeting:update")
public Result update(@RequestBody MeetingDTO dto){ public Result update(@RequestBody MeetingDTO dto){
//校验数据 //校验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
...@@ -93,12 +103,21 @@ public class MeetingController { ...@@ -93,12 +103,21 @@ public class MeetingController {
@DeleteMapping @DeleteMapping
@ApiOperation("删除") @ApiOperation("删除")
@LogOperation("删除") @LogOperation("删除")
@RequiresPermissions("meeting:meeting:delete") //@RequiresPermissions("meeting:meeting:delete")
public Result delete(@RequestBody Long[] ids){ public Result delete(@RequestBody Long[] ids){
//校验数据 //校验数据
AssertUtils.isArrayEmpty(ids, "id"); AssertUtils.isArrayEmpty(ids, "id");
meetingService.delete(ids); for (Long id : ids) {
Map<String, Object> params = new HashMap<>();
params.put("meetingId",id);
List<WlMeetingStaffDTO> meetingList = wlMeetingStaffService.list(params);
if(meetingList.size()>0){
return new Result().error(500,"会议 "+meetingService.get(id).getTitle()+" 存在会员信息,请核对后再进行删除");
}
meetingService.deleteById(id);
}
// meetingService.delete(ids);
return new Result(); return new Result();
} }
...@@ -106,11 +125,11 @@ public class MeetingController { ...@@ -106,11 +125,11 @@ public class MeetingController {
@GetMapping("export") @GetMapping("export")
@ApiOperation("导出") @ApiOperation("导出")
@LogOperation("导出") @LogOperation("导出")
@RequiresPermissions("meeting:meeting:export") //@RequiresPermissions("meeting:meeting:export")
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<MeetingDTO> list = meetingService.list(params); List<MeetingDTO> list = meetingService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, MeetingExcel.class); ExcelUtils.exportExcelToTarget(response, null, list, MeetingExcel.class);
} }
} }
\ No newline at end of file
package io.hmit.modules.meeting.controller;
import io.hmit.common.annotation.LogOperation;
import io.hmit.common.constant.Constant;
import io.hmit.common.page.PageData;
import io.hmit.common.utils.ExcelUtils;
import io.hmit.common.utils.Result;
import io.hmit.common.validator.AssertUtils;
import io.hmit.common.validator.ValidatorUtils;
import io.hmit.common.validator.group.AddGroup;
import io.hmit.common.validator.group.DefaultGroup;
import io.hmit.common.validator.group.UpdateGroup;
import io.hmit.modules.area.service.AreaService;
import io.hmit.modules.committee.service.CommitteeService;
import io.hmit.modules.meeting.dto.WlMeetingStaffDTO;
import io.hmit.modules.meeting.excel.WlMeetingStaffExcel;
import io.hmit.modules.meeting.service.WlMeetingStaffService;
import io.hmit.modules.user.dto.UserDTO;
import io.hmit.modules.user.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
* 参会人员
*
* @author zsh 408538940@qq.com
* @since 1.0.0 2020-12-29
*/
@RestController
@RequestMapping("meeting/wlmeetingstaff")
@Api(tags="参会人员")
public class WlMeetingStaffController {
@Autowired
private WlMeetingStaffService wlMeetingStaffService;
@Autowired
private UserService userService;
@Autowired
private CommitteeService committeeService;
@Autowired
private AreaService areaService;
@GetMapping("page")
@ApiOperation("分页")
@ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") ,
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String"),
@ApiImplicitParam(name = "meetingId", value = "会议ID", paramType = "query", dataType="long"),
@ApiImplicitParam(name = "registrationState", value = "是否报名 1:已报名 2:未报名", paramType = "query", dataType="int")
})
// @RequiresPermissions("meeting:wlmeetingstaff:page")
public Result<PageData<WlMeetingStaffDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
PageData<WlMeetingStaffDTO> page = wlMeetingStaffService.page(params);
page.getList().forEach(wlMeetingStaff -> {
UserDTO userDTO= userService.get(wlMeetingStaff.getUserId());
if(userDTO.getCommitteeId()!= null && userDTO.getAreaId() != null){
userDTO.setCommitteeName(committeeService.get(userDTO.getCommitteeId()).getName());
userDTO.setAreaName(areaService.get(userDTO.getAreaId()).getName());
wlMeetingStaff.setUserInfo(userDTO);
return;
}
userDTO.setCommitteeName("暂无所属委员会");
userDTO.setAreaName("暂无所属地区");
wlMeetingStaff.setUserInfo(userDTO);
});
return new Result<PageData<WlMeetingStaffDTO>>().ok(page);
}
@GetMapping("{id}")
@ApiOperation("信息")
// @RequiresPermissions("meeting:wlmeetingstaff:info")
public Result<WlMeetingStaffDTO> get(@PathVariable("id") Long id){
WlMeetingStaffDTO data = wlMeetingStaffService.get(id);
return new Result<WlMeetingStaffDTO>().ok(data);
}
@PostMapping
@ApiOperation("保存")
@LogOperation("保存")
// @RequiresPermissions("meeting:wlmeetingstaff:save")
public Result save(@RequestBody WlMeetingStaffDTO dto){
//校验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
wlMeetingStaffService.save(dto);
return new Result();
}
@PutMapping
@ApiOperation("修改")
@LogOperation("修改")
// @RequiresPermissions("meeting:wlmeetingstaff:update")
public Result update(@RequestBody WlMeetingStaffDTO dto){
//校验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
wlMeetingStaffService.update(dto);
return new Result();
}
@DeleteMapping
@ApiOperation("删除")
@LogOperation("删除")
// @RequiresPermissions("meeting:wlmeetingstaff:delete")
public Result delete(@RequestBody Long[] ids){
//校验数据
AssertUtils.isArrayEmpty(ids, "id");
wlMeetingStaffService.delete(ids);
return new Result();
}
@GetMapping("export")
@ApiOperation("导出")
@LogOperation("导出")
// @RequiresPermissions("meeting:wlmeetingstaff:export")
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<WlMeetingStaffDTO> list = wlMeetingStaffService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, WlMeetingStaffExcel.class);
}
}
package io.hmit.modules.meeting.dao;
import io.hmit.common.dao.BaseDao;
import io.hmit.modules.meeting.entity.WlMeetingStaffEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 参会人员
*
* @author zsh 408538940@qq.com
* @since 1.0.0 2020-12-29
*/
@Mapper
public interface WlMeetingStaffDao extends BaseDao<WlMeetingStaffEntity> {
}
\ No newline at end of file
package io.hmit.modules.meeting.dto; package io.hmit.modules.meeting.dto;
import io.hmit.modules.user.dto.UserDTO;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
...@@ -23,7 +25,13 @@ public class MeetingDTO implements Serializable { ...@@ -23,7 +25,13 @@ public class MeetingDTO implements Serializable {
private Long id; private Long id;
@ApiModelProperty(value = "会议名称") @ApiModelProperty(value = "会议名称")
private String name; private String title;
@ApiModelProperty(value = "邀请参会人员ID列表")
private List<Long> invitedUserIDs;
@ApiModelProperty(value = "邀请参会人员ID列表")
private List<UserDTO> invitedUserNames;
@ApiModelProperty(value = "发布人") @ApiModelProperty(value = "发布人")
private String author; private String author;
...@@ -38,4 +46,4 @@ public class MeetingDTO implements Serializable { ...@@ -38,4 +46,4 @@ public class MeetingDTO implements Serializable {
private Date createDate; private Date createDate;
} }
\ No newline at end of file
package io.hmit.modules.meeting.dto;
import io.hmit.modules.user.dto.UserDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.security.core.userdetails.UserDetails;
import java.io.Serializable;
import java.util.Date;
/**
* 参会人员
*
* @author zsh 408538940@qq.com
* @since 1.0.0 2020-12-29
*/
@Data
@ApiModel(value = "参会人员")
public class WlMeetingStaffDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键id")
private Long id;
@ApiModelProperty(value = "会议id")
private Long meetingId;
@ApiModelProperty(value = "参会人员id")
private Long userId;
@ApiModelProperty(value = "参会人员信息")
private UserDTO userInfo;
@ApiModelProperty(value = "短信发送状态")
private Integer messageState;
@ApiModelProperty(value = "报名状态 1:已报名 2:未报名(默认)")
private Integer registrationState;
@ApiModelProperty(value = "报名时间")
private Date createDate;
@ApiModelProperty(value = "创建时间")
private Date registrationDate;
@ApiModelProperty(value = "更新时间")
private Date updateDate;
}
...@@ -22,7 +22,7 @@ public class MeetingEntity extends BaseEntity { ...@@ -22,7 +22,7 @@ public class MeetingEntity extends BaseEntity {
/** /**
* 会议名称 * 会议名称
*/ */
private String name; private String title;
/** /**
* 发布人 * 发布人
*/ */
...@@ -31,4 +31,5 @@ public class MeetingEntity extends BaseEntity { ...@@ -31,4 +31,5 @@ public class MeetingEntity extends BaseEntity {
* 会议内容 * 会议内容
*/ */
private String content; private String content;
}
\ No newline at end of file }
package io.hmit.modules.meeting.entity;
import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.annotation.TableName;
import io.hmit.common.entity.BaseEntity;
import io.hmit.modules.meeting.dto.MeetingDTO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import java.util.List;
/**
* 参会人员
*
* @author zsh 408538940@qq.com
* @since 1.0.0 2020-12-29
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("wl_meeting_staff")
public class WlMeetingStaffEntity extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 会议id
*/
private Long meetingId;
/**
* 参会人员id
*/
private Long userId;
/**
* 短信发送状态
*/
private Integer messageState;
/**
* 报名状态
*/
private Integer registrationState;
/**
* 报名时间
*/
private Date registrationDate;
/**
* 更新时间
*/
private Date updateDate;
public WlMeetingStaffEntity assembleWlMeetingStaff(Long meetingId,Long userId,Integer registrationState){
WlMeetingStaffEntity wlMeetingStaffEntity = new WlMeetingStaffEntity();
wlMeetingStaffEntity.setMeetingId(meetingId);
wlMeetingStaffEntity.setUserId(userId);
wlMeetingStaffEntity.setRegistrationState(2);
wlMeetingStaffEntity.setUpdateDate(new DateTime());
if (registrationState != null){
wlMeetingStaffEntity.setRegistrationState(registrationState);
wlMeetingStaffEntity.setRegistrationDate(new DateTime());
}
return wlMeetingStaffEntity;
}
}
package io.hmit.modules.meeting.excel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import java.util.Date;
/**
* 参会人员
*
* @author zsh 408538940@qq.com
* @since 1.0.0 2020-12-29
*/
@Data
public class WlMeetingStaffExcel {
@Excel(name = "主键id")
private Long id;
@Excel(name = "会议id")
private Long meetingId;
@Excel(name = "参会人员id")
private Long userId;
@Excel(name = "短信发送状态")
private Integer messageState;
@Excel(name = "报名状态")
private Integer registrationState;
@Excel(name = "报名时间")
private Date createDate;
@Excel(name = "创建时间")
private Date registrationDate;
@Excel(name = "更新时间")
private Date updateDate;
}
\ No newline at end of file
...@@ -12,4 +12,6 @@ import io.hmit.modules.meeting.entity.MeetingEntity; ...@@ -12,4 +12,6 @@ import io.hmit.modules.meeting.entity.MeetingEntity;
*/ */
public interface MeetingService extends CrudService<MeetingEntity, MeetingDTO> { public interface MeetingService extends CrudService<MeetingEntity, MeetingDTO> {
} @Override
\ No newline at end of file void save(MeetingDTO dto);
}
package io.hmit.modules.meeting.service;
import io.hmit.common.service.CrudService;
import io.hmit.modules.meeting.dto.WlMeetingStaffDTO;
import io.hmit.modules.meeting.entity.WlMeetingStaffEntity;
import io.hmit.modules.user.dto.UserDTO;
import java.util.List;
/**
* 参会人员
*
* @author zsh 408538940@qq.com
* @since 1.0.0 2020-12-29
*/
public interface WlMeetingStaffService extends CrudService<WlMeetingStaffEntity, WlMeetingStaffDTO> {
List<UserDTO> getInvitedNames(Long meetingId );
}
...@@ -2,13 +2,22 @@ package io.hmit.modules.meeting.service.impl; ...@@ -2,13 +2,22 @@ package io.hmit.modules.meeting.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.hmit.common.service.impl.CrudServiceImpl; import io.hmit.common.service.impl.CrudServiceImpl;
import io.hmit.common.utils.ConvertUtils;
import io.hmit.modules.meeting.dao.MeetingDao; import io.hmit.modules.meeting.dao.MeetingDao;
import io.hmit.modules.meeting.dto.MeetingDTO; import io.hmit.modules.meeting.dto.MeetingDTO;
import io.hmit.modules.meeting.entity.MeetingEntity; import io.hmit.modules.meeting.entity.MeetingEntity;
import io.hmit.modules.meeting.entity.WlMeetingStaffEntity;
import io.hmit.modules.meeting.service.MeetingService; import io.hmit.modules.meeting.service.MeetingService;
import io.hmit.modules.meeting.service.WlMeetingStaffService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -20,15 +29,40 @@ import java.util.Map; ...@@ -20,15 +29,40 @@ import java.util.Map;
@Service @Service
public class MeetingServiceImpl extends CrudServiceImpl<MeetingDao, MeetingEntity, MeetingDTO> implements MeetingService { public class MeetingServiceImpl extends CrudServiceImpl<MeetingDao, MeetingEntity, MeetingDTO> implements MeetingService {
@Autowired
private WlMeetingStaffService wlMeetingStaffService;
@Override @Override
public QueryWrapper<MeetingEntity> getWrapper(Map<String, Object> params){ public QueryWrapper<MeetingEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get("id"); String id = (String)params.get("id");
String title = (String)params.get("name");
QueryWrapper<MeetingEntity> wrapper = new QueryWrapper<>(); QueryWrapper<MeetingEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), "id", id); wrapper.eq(StringUtils.isNotBlank(id), "id", id)
.like(StringUtils.isNotBlank(title), "title", title);
return wrapper; return wrapper;
} }
@Override
@Transactional(rollbackFor = Exception.class)
public void save(MeetingDTO dto) {
MeetingEntity entity = ConvertUtils.sourceToTarget(dto, currentModelClass());
insert(entity);
//copy主键值到dto
BeanUtils.copyProperties(entity, dto);
//会议人员对应关系保存
List<WlMeetingStaffEntity> wlMeetingStaffList = new ArrayList<>();
dto.getInvitedUserIDs().stream().forEach(userId->{
WlMeetingStaffEntity meetingStaff = new WlMeetingStaffEntity();
meetingStaff = meetingStaff.assembleWlMeetingStaff(dto.getId(),userId,null);
wlMeetingStaffList.add(meetingStaff);
});
wlMeetingStaffService.insertBatch(wlMeetingStaffList);
}
} }
\ No newline at end of file
package io.hmit.modules.meeting.service.impl;
import cn.hutool.system.UserInfo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.hmit.common.service.impl.CrudServiceImpl;
import io.hmit.modules.meeting.dao.WlMeetingStaffDao;
import io.hmit.modules.meeting.dto.WlMeetingStaffDTO;
import io.hmit.modules.meeting.entity.WlMeetingStaffEntity;
import io.hmit.modules.meeting.service.WlMeetingStaffService;
import io.hmit.modules.user.dto.UserDTO;
import io.hmit.modules.user.service.UserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 参会人员
*
* @author zsh 408538940@qq.com
* @since 1.0.0 2020-12-29
*/
@Service
public class WlMeetingStaffServiceImpl extends CrudServiceImpl<WlMeetingStaffDao, WlMeetingStaffEntity, WlMeetingStaffDTO> implements WlMeetingStaffService {
@Autowired
private UserService userService;
@Override
public QueryWrapper<WlMeetingStaffEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get("id");
String userId = "";
if(params.get("userId") !=null){
userId = params.get("userId").toString();
}
String meetingId = "";
if(params.get("meetingId") != null){
meetingId = params.get("meetingId").toString();
}
String registrationState = (String)params.get("registrationState");
QueryWrapper<WlMeetingStaffEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), "id", id)
.eq(StringUtils.isNotBlank(registrationState), "registration_state", registrationState)
.eq(StringUtils.isNotBlank(userId), "user_id", userId)
.eq(StringUtils.isNotBlank(meetingId), "meeting_id", meetingId);
return wrapper;
}
@Override
public List<UserDTO> getInvitedNames(Long meetingId) {
Map<String, Object> params = new HashMap<>();
params.put("meetingId",meetingId);
List<UserDTO> userList=new ArrayList<>();
baseDao.selectList(getWrapper(params)).stream().forEach(meetingStaff->{
userList.add(userService.get(meetingStaff.getUserId()));
});
return userList;
}
}
...@@ -62,7 +62,7 @@ public class SysUserDTO implements Serializable { ...@@ -62,7 +62,7 @@ public class SysUserDTO implements Serializable {
private String mobile; private String mobile;
@ApiModelProperty(value = "部门ID", required = true) @ApiModelProperty(value = "部门ID", required = true)
@NotNull(message = "{sysuser.deptId.require}", groups = DefaultGroup.class) @NotNull(groups = DefaultGroup.class)
private Long deptId; private Long deptId;
@ApiModelProperty(value = "状态 0:停用 1:正常", required = true) @ApiModelProperty(value = "状态 0:停用 1:正常", required = true)
...@@ -83,4 +83,4 @@ public class SysUserDTO implements Serializable { ...@@ -83,4 +83,4 @@ public class SysUserDTO implements Serializable {
@ApiModelProperty(value = "部门名称") @ApiModelProperty(value = "部门名称")
private String deptName; private String deptName;
} }
\ No newline at end of file
...@@ -10,6 +10,11 @@ import io.hmit.common.validator.ValidatorUtils; ...@@ -10,6 +10,11 @@ import io.hmit.common.validator.ValidatorUtils;
import io.hmit.common.validator.group.AddGroup; import io.hmit.common.validator.group.AddGroup;
import io.hmit.common.validator.group.DefaultGroup; import io.hmit.common.validator.group.DefaultGroup;
import io.hmit.common.validator.group.UpdateGroup; import io.hmit.common.validator.group.UpdateGroup;
import io.hmit.modules.area.dto.AreaDTO;
import io.hmit.modules.area.service.AreaService;
import io.hmit.modules.committee.service.CommitteeService;
import io.hmit.modules.user.dto.AreaUserDTO;
import io.hmit.modules.user.dto.CommitteeUserDTO;
import io.hmit.modules.user.dto.UserDTO; import io.hmit.modules.user.dto.UserDTO;
import io.hmit.modules.user.excel.UserExcel; import io.hmit.modules.user.excel.UserExcel;
import io.hmit.modules.user.service.UserService; import io.hmit.modules.user.service.UserService;
...@@ -23,6 +28,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -23,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -40,34 +46,88 @@ public class UserController { ...@@ -40,34 +46,88 @@ public class UserController {
@Autowired @Autowired
private UserService userService; private UserService userService;
@Autowired
private CommitteeService committeeService;
@Autowired
private AreaService areaService;
@GetMapping("page") @GetMapping("page")
@ApiOperation("分页") @ApiOperation("分页")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") , @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") , @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") ,
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String") @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String"),
@ApiImplicitParam(name = "check", value = "是否审核:0,待审核(审核用户列表)", paramType = "query", dataType="int"),
@ApiImplicitParam(name = "company", value = "单位名称", paramType = "query", dataType="String"),
@ApiImplicitParam(name = "area", value = "区市ID", paramType = "query", dataType="long"),
@ApiImplicitParam(name = "mobile", value = "手机号码", paramType = "query", dataType="String"),
@ApiImplicitParam(name = "name", value = "姓名", paramType = "query", dataType="String"),
@ApiImplicitParam(name = "committee", value = "委员会ID", paramType = "query", dataType="long")
}) })
@RequiresPermissions("user:user:page") //@RequiresPermissions("user:user:page")
public Result<PageData<UserDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){ public Result<PageData<UserDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
PageData<UserDTO> page = userService.page(params); PageData<UserDTO> page = userService.page(params);
page.getList().forEach(userDTO -> {
if(userDTO.getCommitteeId()!= null && userDTO.getAreaId() != null){
userDTO.setCommitteeName(committeeService.get(userDTO.getCommitteeId()).getName());
userDTO.setAreaName(areaService.get(userDTO.getAreaId()).getName());
return;
}
userDTO.setCommitteeName("暂无所属委员会");
userDTO.setAreaName("暂无所属地区");
});
return new Result<PageData<UserDTO>>().ok(page); return new Result<PageData<UserDTO>>().ok(page);
} }
@GetMapping("committeeList")
@ApiOperation("根据委员会获取用户信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "committee", value = "委员会Id", paramType = "query", dataType = "long"),
@ApiImplicitParam(name = "name", value = "人员姓名", paramType = "query", dataType = "String")
})
public Result<List<CommitteeUserDTO>> CommitteeUserList(@ApiIgnore @RequestParam Map<String, Object> params) {
List<CommitteeUserDTO> list = userService.getCommitteeUserList(params);
return new Result<List<CommitteeUserDTO>>().ok(list);
}
@GetMapping("areaList")
@ApiOperation("根据区市获取用户信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "area", value = "区市Id", paramType = "query",dataType = "long"),
@ApiImplicitParam(name = "name", value = "人员姓名", paramType = "query", dataType = "String")
})
public Result<List<AreaUserDTO>> AreaUserList(@ApiIgnore @RequestParam Map<String, Object> params) {
List<AreaUserDTO> list = userService.getAreaUserList(params);
return new Result<List<AreaUserDTO>>().ok(list);
}
@GetMapping("{id}") @GetMapping("{id}")
@ApiOperation("信息") @ApiOperation("信息")
@RequiresPermissions("user:user:info") //@RequiresPermissions("user:user:info")
public Result<UserDTO> get(@PathVariable("id") Long id){ public Result<UserDTO> get(@PathVariable("id") Long id){
UserDTO data = userService.get(id); UserDTO data = userService.get(id);
if(data.getCommitteeId()!= null && data.getAreaId() != null){
data.setCommitteeName(committeeService.get(data.getCommitteeId()).getName());
data.setAreaName(areaService.get(data.getAreaId()).getName());
}else {
data.setAreaName("暂无所属地区");
data.setCommitteeName("暂无所属委员会");
}
return new Result<UserDTO>().ok(data); return new Result<UserDTO>().ok(data);
} }
@PostMapping @PostMapping
@ApiOperation("保存") @ApiOperation("保存")
@LogOperation("保存") @LogOperation("保存")
@RequiresPermissions("user:user:save") //@RequiresPermissions("user:user:save")
public Result save(@RequestBody UserDTO dto){ public Result save(@RequestBody UserDTO dto){
//校验数据 //校验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
...@@ -80,7 +140,7 @@ public class UserController { ...@@ -80,7 +140,7 @@ public class UserController {
@PutMapping @PutMapping
@ApiOperation("修改") @ApiOperation("修改")
@LogOperation("修改") @LogOperation("修改")
@RequiresPermissions("user:user:update") //@RequiresPermissions("user:user:update")
public Result update(@RequestBody UserDTO dto){ public Result update(@RequestBody UserDTO dto){
//校验数据 //校验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
...@@ -93,7 +153,7 @@ public class UserController { ...@@ -93,7 +153,7 @@ public class UserController {
@DeleteMapping @DeleteMapping
@ApiOperation("删除") @ApiOperation("删除")
@LogOperation("删除") @LogOperation("删除")
@RequiresPermissions("user:user:delete") //@RequiresPermissions("user:user:delete")
public Result delete(@RequestBody Long[] ids){ public Result delete(@RequestBody Long[] ids){
//校验数据 //校验数据
AssertUtils.isArrayEmpty(ids, "id"); AssertUtils.isArrayEmpty(ids, "id");
...@@ -106,11 +166,11 @@ public class UserController { ...@@ -106,11 +166,11 @@ public class UserController {
@GetMapping("export") @GetMapping("export")
@ApiOperation("导出") @ApiOperation("导出")
@LogOperation("导出") @LogOperation("导出")
@RequiresPermissions("user:user:export") //@RequiresPermissions("user:user:export")
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<UserDTO> list = userService.list(params); List<UserDTO> list = userService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, UserExcel.class); ExcelUtils.exportExcelToTarget(response, null, list, UserExcel.class);
} }
} }
\ No newline at end of file
package io.hmit.modules.user.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 区市用户列表
*
* @author syf syf0412@qq.com
* @since 1.0.0 2020-12-25
*/
@Data
@ApiModel(value = "区市用户列表")
public class AreaUserDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "区市ID")
private Long id;
@ApiModelProperty(value = "区市名")
private String name;
@ApiModelProperty(value = "用户信息")
private List<UserDTO> userInfo;
public AreaUserDTO assembleAreaUser(Long areaId,String areaName,List<UserDTO> userDTO){
AreaUserDTO areaUserDTO = new AreaUserDTO();
areaUserDTO.setId(areaId);
areaUserDTO.setName(areaName);
areaUserDTO.setUserInfo(userDTO);
return areaUserDTO;
}
}
package io.hmit.modules.user.dto;
import io.hmit.common.utils.TreeNode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 委员会用户列表
*
* @author syf syf0412@qq.com
* @since 1.0.0 2020-12-25
*/
@Data
@ApiModel(value = "委员会用户列表")
public class CommitteeUserDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "区市ID")
private Long id;
@ApiModelProperty(value = "区市名")
private String name;
@ApiModelProperty(value = "用户信息")
private List<UserDTO> userInfoList;
public CommitteeUserDTO assembleCommitteeUser(Long committeeId,String committeeName,List<UserDTO> userDTO){
CommitteeUserDTO committeeUserDTO = new CommitteeUserDTO();
committeeUserDTO.setId(committeeId);
committeeUserDTO.setName(committeeName);
committeeUserDTO.setUserInfoList(userDTO);
return committeeUserDTO;
}
}
...@@ -46,9 +46,15 @@ public class UserDTO implements Serializable { ...@@ -46,9 +46,15 @@ public class UserDTO implements Serializable {
@ApiModelProperty(value = "委员会ID") @ApiModelProperty(value = "委员会ID")
private Long committeeId; private Long committeeId;
@ApiModelProperty(value = "委员会名称")
private String committeeName;
@ApiModelProperty(value = "区市ID") @ApiModelProperty(value = "区市ID")
private Long areaId; private Long areaId;
@ApiModelProperty(value = "区市名称")
private String areaName;
@ApiModelProperty(value = "是否审核;0,待审核1,已审核;2,审核未通过") @ApiModelProperty(value = "是否审核;0,待审核1,已审核;2,审核未通过")
private Integer ifCheck; private Integer ifCheck;
...@@ -65,4 +71,4 @@ public class UserDTO implements Serializable { ...@@ -65,4 +71,4 @@ public class UserDTO implements Serializable {
private Date updateDate; private Date updateDate;
} }
\ No newline at end of file
package io.hmit.modules.user.service; package io.hmit.modules.user.service;
import io.hmit.common.service.CrudService; import io.hmit.common.service.CrudService;
import io.hmit.modules.user.dto.AreaUserDTO;
import io.hmit.modules.user.dto.CommitteeUserDTO;
import io.hmit.modules.user.dto.UserDTO; import io.hmit.modules.user.dto.UserDTO;
import io.hmit.modules.user.entity.UserEntity; import io.hmit.modules.user.entity.UserEntity;
import java.util.List;
import java.util.Map;
/** /**
* 用户信息表(关注公众号的用户) * 用户信息表(关注公众号的用户)
* *
...@@ -12,4 +17,8 @@ import io.hmit.modules.user.entity.UserEntity; ...@@ -12,4 +17,8 @@ import io.hmit.modules.user.entity.UserEntity;
*/ */
public interface UserService extends CrudService<UserEntity, UserDTO> { public interface UserService extends CrudService<UserEntity, UserDTO> {
} List<CommitteeUserDTO> getCommitteeUserList(Map<String, Object> params);
\ No newline at end of file
List<AreaUserDTO> getAreaUserList(Map<String, Object> params);
}
...@@ -2,13 +2,27 @@ package io.hmit.modules.user.service.impl; ...@@ -2,13 +2,27 @@ package io.hmit.modules.user.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.hmit.common.service.impl.CrudServiceImpl; import io.hmit.common.service.impl.CrudServiceImpl;
import io.hmit.common.utils.ConvertUtils;
import io.hmit.modules.area.dto.AreaDTO;
import io.hmit.modules.area.service.AreaService;
import io.hmit.modules.committee.dto.CommitteeDTO;
import io.hmit.modules.committee.service.CommitteeService;
import io.hmit.modules.meeting.service.WlMeetingStaffService;
import io.hmit.modules.user.dao.UserDao; import io.hmit.modules.user.dao.UserDao;
import io.hmit.modules.user.dto.AreaUserDTO;
import io.hmit.modules.user.dto.CommitteeUserDTO;
import io.hmit.modules.user.dto.UserDTO; import io.hmit.modules.user.dto.UserDTO;
import io.hmit.modules.user.entity.UserEntity; import io.hmit.modules.user.entity.UserEntity;
import io.hmit.modules.user.service.UserService; import io.hmit.modules.user.service.UserService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -20,15 +34,120 @@ import java.util.Map; ...@@ -20,15 +34,120 @@ import java.util.Map;
@Service @Service
public class UserServiceImpl extends CrudServiceImpl<UserDao, UserEntity, UserDTO> implements UserService { public class UserServiceImpl extends CrudServiceImpl<UserDao, UserEntity, UserDTO> implements UserService {
@Autowired
private CommitteeService committeeService;
@Autowired
private AreaService areaService;
@Autowired
private WlMeetingStaffService wlMeetingStaffService;
@Override @Override
public QueryWrapper<UserEntity> getWrapper(Map<String, Object> params){ public QueryWrapper<UserEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get("id"); String id = (String)params.get("id");
String mobile = (String)params.get("mobile");
String area = "";
if(params.get("area") != null){
area = params.get("area").toString();
}
String committee = "";
if(params.get("committee") != null){
committee = params.get("committee").toString();
}
String company = (String)params.get("company");
String name = (String)params.get("name");
String check = (String)params.get("check");
String groupByCommittee = (String)params.get("groupByCommittee");
String groupByArea = (String)params.get("groupByArea");
String member = (String)params.get("member");
QueryWrapper<UserEntity> wrapper = new QueryWrapper<UserEntity>()
.eq(StringUtils.isNotBlank(id), "id", id)
.like(StringUtils.isNotBlank(mobile), "mobile", mobile)
.eq(StringUtils.isNotBlank(area), "area_id", area)
.like(StringUtils.isNotBlank(company), "company", company)
.like(StringUtils.isNotBlank(name), "name", name)
.eq(StringUtils.isNotBlank(committee), "committee_id", committee)
.eq(StringUtils.isNotBlank(check),"if_check",check)
.eq(StringUtils.isNotBlank(member),"member",member)
.groupBy(StringUtils.isNotBlank(groupByCommittee),"committee_id")
.groupBy(StringUtils.isNotBlank(groupByArea),"area_id");
QueryWrapper<UserEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), "id", id);
return wrapper; return wrapper;
} }
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long[] ids) {
Map<String, Object> params = new HashMap<>();
for (Long id : ids) {
params.put("userId",id);
wlMeetingStaffService.list(params).forEach(wlMeetingStaffDTO -> {
wlMeetingStaffService.deleteById(wlMeetingStaffDTO.getId());
});
}
super.delete(ids);
}
@Override
public List<CommitteeUserDTO> getCommitteeUserList(Map<String, Object> params) {
List<CommitteeUserDTO> committeeUserDTOList = new ArrayList<>();
//根据查询条件查找出部分满足条件的会员信息,并按委员会分组(重点是得到满足条件的会员的委员会ID)
params.put("groupByCommittee","committee_id");
params.put("member","1");
//遍历查询出的会员信息
list(params).forEach(userDTO -> {
String name = (String)params.get("name");
} //构造符合信息的某委员会下的UserInfoList
\ No newline at end of file List<UserDTO> userDTOList = ConvertUtils.sourceToTarget(baseDao.selectList(new QueryWrapper<UserEntity>()
.eq("committee_id", userDTO.getCommitteeId())
.eq("member",1)
.like(StringUtils.isNotBlank(name),"name", name)),UserDTO.class) ;
//根据委员会ID查询出委员会Name 对DTO进行填充
if(userDTO.getCommitteeId()!= null){
userDTO.setCommitteeName(committeeService.get(userDTO.getCommitteeId()).getName());
//调用封装的方法组成会员和委员会的层级关系并返回
committeeUserDTOList.add(new CommitteeUserDTO().assembleCommitteeUser(userDTO.getCommitteeId(),userDTO.getCommitteeName(),userDTOList));
return;
}
});
return committeeUserDTOList;
}
@Override
public List<AreaUserDTO> getAreaUserList(Map<String, Object> params) {
List<AreaUserDTO> areaUserDTO = new ArrayList<>();
//根据查询条件查找出部分满足条件的会员信息,并按地区分组(重点是得到满足条件的会员的地区ID)
params.put("groupByArea","area_id");
params.put("member","1");
//遍历查询出的会员信息
list(params).forEach(userDTO -> {
String name = (String)params.get("name");
//构造符合信息的某地区下的UserInfoList
List<UserDTO> userDTOList = ConvertUtils.sourceToTarget(
baseDao.selectList(new QueryWrapper<UserEntity>()
.eq("area_id", userDTO.getAreaId()).eq("member",1)
.like(StringUtils.isNotBlank(name),"name",name)),UserDTO.class) ;
//根据地区ID查询出地区Name 对DTO进行填充
if(userDTO.getAreaId()!= null){
userDTO.setAreaName(areaService.get(userDTO.getAreaId()).getName());
//调用封装的方法组成会员和地区的层级关系并返回
areaUserDTO.add(new AreaUserDTO().assembleAreaUser(userDTO.getAreaId(),userDTO.getAreaName(),userDTOList));
return;
}
});
return areaUserDTO;
}
}
...@@ -12,5 +12,17 @@ ...@@ -12,5 +12,17 @@
<result property="createDate" column="create_date"/> <result property="createDate" column="create_date"/>
</resultMap> </resultMap>
<select id="getAreaList" resultType="io.hmit.modules.area.entity.AreaEntity">
select t1.* from wl_area t1
<where>
<if test="type != null">
t1.type = #{type}
</if>
</where>
order by t1.sort asc
</select>
</mapper> <select id="getListPid" resultType="io.hmit.modules.area.entity.AreaEntity">
\ No newline at end of file select * from wl_area where pid = #{value}
</select>
</mapper>
<?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="io.hmit.modules.meeting.dao.WlMeetingStaffDao">
<resultMap type="io.hmit.modules.meeting.entity.WlMeetingStaffEntity" id="wlMeetingStaffMap">
<result property="id" column="id"/>
<result property="meetingId" column="meeting_id"/>
<result property="userId" column="user_id"/>
<result property="messageState" column="message_state"/>
<result property="registrationState" column="registration_state"/>
<result property="createDate" column="create_date"/>
<result property="registrationDate" column="registration_date"/>
<result property="updateDate" column="update_date"/>
</resultMap>
</mapper>
\ No newline at end of file
...@@ -27,6 +27,10 @@ public interface Constant { ...@@ -27,6 +27,10 @@ public interface Constant {
* 菜单根节点标识 * 菜单根节点标识
*/ */
Long MENU_ROOT = 0L; Long MENU_ROOT = 0L;
/**
* 地区根节点标识
*/
Long AREA_ROOT = 0L;
/** /**
* 部门根节点标识 * 部门根节点标识
*/ */
...@@ -178,4 +182,4 @@ public interface Constant { ...@@ -178,4 +182,4 @@ public interface Constant {
return value; return value;
} }
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment