工作组接口
This commit is contained in:
+51
-3
@@ -1,10 +1,17 @@
|
||||
package com.adc.da.slrs.customWorkGroup.controller;
|
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import com.adc.da.http.ResponseMessage;
|
||||
import com.adc.da.http.Result;
|
||||
import com.adc.da.slrs.customWorkGroup.entity.WorkGroupQueryPage;
|
||||
import com.adc.da.slrs.customWorkGroup.service.IWorkGroupService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.adc.da.slrs.customWorkGroup.entity.WorkGroup;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.adc.da.base.web.BaseController;
|
||||
|
||||
/**
|
||||
@@ -17,7 +24,48 @@ import com.adc.da.base.web.BaseController;
|
||||
*/
|
||||
@RestController
|
||||
@Api(description = "|WorkGroup|")
|
||||
@RequestMapping("/workGroup/work-group")
|
||||
@RequestMapping("/${restPath}/workGroup/work-group")
|
||||
public class WorkGroupController extends BaseController<WorkGroup> {
|
||||
|
||||
|
||||
@Autowired
|
||||
IWorkGroupService iWorkGroupService;
|
||||
|
||||
@ApiModelProperty("新增工作组")
|
||||
@PostMapping
|
||||
public ResponseMessage addWorkGroup(WorkGroup workGroup) {
|
||||
boolean add = iWorkGroupService.add(workGroup);
|
||||
|
||||
return Result.success(add);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ApiModelProperty("删除工作组")
|
||||
@DeleteMapping
|
||||
public ResponseMessage deleteWorkGroup(String id){
|
||||
boolean delete = iWorkGroupService.delete(id);
|
||||
|
||||
return Result.success(delete);
|
||||
}
|
||||
|
||||
@ApiModelProperty("根据组长民或者组名查询工作组")
|
||||
@GetMapping
|
||||
public ResponseMessage<IPage<WorkGroup>> getWorkGroupLists(WorkGroupQueryPage queryPage){
|
||||
IPage<WorkGroup> workGroup = iWorkGroupService.getWorkGroup(queryPage);
|
||||
|
||||
return Result.success(workGroup);
|
||||
}
|
||||
|
||||
|
||||
@ApiModelProperty("修改工作组")
|
||||
@PutMapping
|
||||
public ResponseMessage updateWorkGroup(WorkGroup workGroup){
|
||||
boolean update = iWorkGroupService.update(workGroup);
|
||||
|
||||
return Result.success(update);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
package com.adc.da.slrs.customWorkGroup.dao;
|
||||
|
||||
import com.adc.da.slrs.customWorkGroup.entity.WorkGroup;
|
||||
import com.adc.da.slrs.customWorkGroup.entity.WorkGroupQueryPage;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -13,4 +20,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
*/
|
||||
public interface WorkGroupDao extends BaseMapper<WorkGroup> {
|
||||
|
||||
|
||||
public IPage<WorkGroup> getWorkGroup( @Param("page")IPage<WorkGroup> page,
|
||||
@Param(Constants.WRAPPER) Wrapper<WorkGroupQueryPage> queryWrapper,
|
||||
@Param("queryCondition")WorkGroupQueryPage queryCondition);
|
||||
|
||||
|
||||
public List<String> getUserName(String userId);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,8 @@ public class WorkGroup extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String workGroupName;
|
||||
|
||||
private String workGroup;
|
||||
|
||||
private String workLeader;
|
||||
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.adc.da.slrs.customWorkGroup.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author 22501
|
||||
*/
|
||||
@Data
|
||||
public class WorkGroupQueryPage {
|
||||
|
||||
private Integer page;
|
||||
|
||||
private Integer pageSize;
|
||||
|
||||
private String leaderName;
|
||||
|
||||
private String workGroupName;
|
||||
|
||||
|
||||
public int getPage() {
|
||||
return Optional.ofNullable(this.page)
|
||||
.orElse(1);
|
||||
|
||||
}
|
||||
|
||||
public int getPageSize() {
|
||||
return Optional.ofNullable(this.pageSize)
|
||||
.orElse(20);
|
||||
}
|
||||
}
|
||||
+33
@@ -1,6 +1,8 @@
|
||||
package com.adc.da.slrs.customWorkGroup.service;
|
||||
|
||||
import com.adc.da.slrs.customWorkGroup.entity.WorkGroup;
|
||||
import com.adc.da.slrs.customWorkGroup.entity.WorkGroupQueryPage;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
@@ -13,4 +15,35 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
*/
|
||||
public interface IWorkGroupService extends IService<WorkGroup> {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param workGroup
|
||||
* @return
|
||||
*/
|
||||
public boolean add(WorkGroup workGroup);
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param workGroupId
|
||||
* @return
|
||||
*/
|
||||
public boolean delete(String workGroupId);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @param queryPage
|
||||
* @return
|
||||
*/
|
||||
public IPage<WorkGroup> getWorkGroup(WorkGroupQueryPage queryPage);
|
||||
|
||||
|
||||
/**
|
||||
* 更新
|
||||
* @param workGroup
|
||||
* @return
|
||||
*/
|
||||
public boolean update(WorkGroup workGroup);
|
||||
|
||||
|
||||
}
|
||||
|
||||
+48
@@ -2,8 +2,13 @@ package com.adc.da.slrs.customWorkGroup.service.impl;
|
||||
|
||||
import com.adc.da.slrs.customWorkGroup.entity.WorkGroup;
|
||||
import com.adc.da.slrs.customWorkGroup.dao.WorkGroupDao;
|
||||
import com.adc.da.slrs.customWorkGroup.entity.WorkGroupQueryPage;
|
||||
import com.adc.da.slrs.customWorkGroup.service.IWorkGroupService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
@@ -17,4 +22,47 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class WorkGroupServiceImpl extends ServiceImpl<WorkGroupDao, WorkGroup> implements IWorkGroupService {
|
||||
|
||||
@Autowired
|
||||
WorkGroupDao workGroupDao;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean add(WorkGroup workGroup) {
|
||||
return this.save(workGroup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delete(String workGroupId) {
|
||||
return this.removeById(workGroupId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<WorkGroup> getWorkGroup(WorkGroupQueryPage queryPage) {
|
||||
|
||||
|
||||
QueryWrapper<WorkGroupQueryPage> wrapper = new QueryWrapper<>();
|
||||
if (queryPage.getWorkGroupName()!=null && !"".equals(queryPage.getWorkGroupName())){
|
||||
wrapper.eq("work_group_name",queryPage.getWorkGroupName());
|
||||
}
|
||||
//可以通过组长名称模糊查询
|
||||
IPage<WorkGroup> workGroupList = workGroupDao.getWorkGroup(new Page<>(queryPage.getPage(), queryPage.getPageSize()), wrapper,queryPage);
|
||||
//需要把组长的id和组员的id转换为其名称
|
||||
for (WorkGroup record : workGroupList.getRecords()) {
|
||||
|
||||
record.setWorkLeader( String.join(",",workGroupDao.getUserName(record.getWorkLeaderId())) );
|
||||
record.setWorkPeople( String.join(",",workGroupDao.getUserName(record.getWorkPeopleId())));
|
||||
}
|
||||
|
||||
return workGroupList;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean update(WorkGroup workGroup) {
|
||||
return this.updateById(workGroup);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,4 +2,45 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.adc.da.slrs.customWorkGroup.dao.WorkGroupDao">
|
||||
|
||||
<select id="getWorkGroup" resultType="com.adc.da.slrs.customWorkGroup.entity.WorkGroup">
|
||||
|
||||
SELECT
|
||||
work_group_name AS workGroup,
|
||||
work_leader_id AS workLeaderId,
|
||||
work_people_id AS workPeopleId
|
||||
FROM
|
||||
work_group
|
||||
|
||||
|
||||
<where>
|
||||
<if test="queryCondition.leaderName != null and queryCondition.leaderName != ''">
|
||||
work_leader_id REGEXP (
|
||||
SELECT
|
||||
GROUP_CONCAT(USID SEPARATOR '|')
|
||||
FROM
|
||||
ts_user
|
||||
WHERE
|
||||
UNAME LIKE CONCAT('%', #{queryCondition.leaderName}, '%')
|
||||
)
|
||||
</if>
|
||||
|
||||
<if test="ew != null">
|
||||
<if test="ew.nonEmptyOfWhere">
|
||||
AND
|
||||
</if>
|
||||
${ew.sqlSegment}
|
||||
</if>
|
||||
|
||||
</where>
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
<select id="getUserName" resultType="java.lang.String">
|
||||
SELECT UNAME from ts_user WHERE FIND_IN_SET(USID,#{userId})
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user