教练管理
This commit is contained in:
parent
29212c74ca
commit
3e8480c390
@ -12,7 +12,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@ -50,7 +49,7 @@ public class DlDriveSchoolCoachController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增驾校教练
|
* 保存驾校教练
|
||||||
*
|
*
|
||||||
* @param createReqVO {@link DlDriveSchoolCoachSaveReqVO}
|
* @param createReqVO {@link DlDriveSchoolCoachSaveReqVO}
|
||||||
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<java.lang.String>
|
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<java.lang.String>
|
||||||
@ -59,18 +58,19 @@ public class DlDriveSchoolCoachController {
|
|||||||
**/
|
**/
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建驾校教练")
|
@Operation(summary = "创建驾校教练")
|
||||||
public CommonResult<Boolean> createDlDriveSchoolCoach(@Valid @RequestBody DlDriveSchoolCoachSaveReqVO createReqVO) {
|
public CommonResult<Boolean> saveSchoolCoach(@Valid @RequestBody DlDriveSchoolCoachSaveReqVO createReqVO) {
|
||||||
dlDriveSchoolCoachService.createDlDriveSchoolCoach(createReqVO);
|
dlDriveSchoolCoachService.saveSchoolCoach(createReqVO);
|
||||||
return success(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping("/update")
|
|
||||||
@Operation(summary = "更新驾校教练")
|
|
||||||
public CommonResult<Boolean> updateDlDriveSchoolCoach(@Valid @RequestBody DlDriveSchoolCoachSaveReqVO updateReqVO) {
|
|
||||||
dlDriveSchoolCoachService.updateDlDriveSchoolCoach(updateReqVO);
|
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id删除驾校教练
|
||||||
|
*
|
||||||
|
* @param id 教练id
|
||||||
|
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<java.lang.Boolean>
|
||||||
|
* @author PQZ
|
||||||
|
* @date 21:40 2025/1/16
|
||||||
|
**/
|
||||||
@DeleteMapping("/delete")
|
@DeleteMapping("/delete")
|
||||||
@Operation(summary = "删除驾校教练")
|
@Operation(summary = "删除驾校教练")
|
||||||
@Parameter(name = "id", description = "编号", required = true)
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
@ -79,6 +79,13 @@ public class DlDriveSchoolCoachController {
|
|||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过教练id获取驾校教练
|
||||||
|
* @author PQZ
|
||||||
|
* @date 21:41 2025/1/16
|
||||||
|
* @param id 教练id
|
||||||
|
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<cn.iocoder.yudao.module.base.vo.DlDriveSchoolCoachRespVO>
|
||||||
|
**/
|
||||||
@GetMapping("/get")
|
@GetMapping("/get")
|
||||||
@Operation(summary = "获得驾校教练")
|
@Operation(summary = "获得驾校教练")
|
||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@ -77,7 +77,7 @@ public class DlDriveSchoolCoach extends TenantBaseDO {
|
|||||||
/**
|
/**
|
||||||
* 用户id
|
* 用户id
|
||||||
*/
|
*/
|
||||||
private Integer userId;
|
private Long userId;
|
||||||
/**
|
/**
|
||||||
* 身份证
|
* 身份证
|
||||||
*/
|
*/
|
||||||
|
@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.base.mapper;
|
|||||||
import cn.iocoder.yudao.module.base.entity.DlDriveSchoolCoach;
|
import cn.iocoder.yudao.module.base.entity.DlDriveSchoolCoach;
|
||||||
import cn.iocoder.yudao.module.base.vo.DlDriveSchoolCoachPageReqVO;
|
import cn.iocoder.yudao.module.base.vo.DlDriveSchoolCoachPageReqVO;
|
||||||
import cn.iocoder.yudao.module.base.vo.DlDriveSchoolCoachRespVO;
|
import cn.iocoder.yudao.module.base.vo.DlDriveSchoolCoachRespVO;
|
||||||
import cn.iocoder.yudao.module.member.vo.MemberLevelRespVO;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
@ -29,26 +29,20 @@ public interface DlDriveSchoolCoachService extends IService<DlDriveSchoolCoach>
|
|||||||
IPage<DlDriveSchoolCoachRespVO> queryListPage(DlDriveSchoolCoachPageReqVO pageReqVO, Page<DlDriveSchoolCoachRespVO> page);
|
IPage<DlDriveSchoolCoachRespVO> queryListPage(DlDriveSchoolCoachPageReqVO pageReqVO, Page<DlDriveSchoolCoachRespVO> page);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建驾校教练
|
* 保存驾校教练
|
||||||
*
|
*
|
||||||
* @param createReqVO {@link DlDriveSchoolCoachSaveReqVO}
|
* @param createReqVO {@link DlDriveSchoolCoachSaveReqVO}
|
||||||
* @author PQZ
|
* @author PQZ @date 2025/1/16
|
||||||
* @date 2025/1/16
|
|
||||||
**/
|
**/
|
||||||
void createDlDriveSchoolCoach(@Valid DlDriveSchoolCoachSaveReqVO createReqVO);
|
void saveSchoolCoach(@Valid DlDriveSchoolCoachSaveReqVO createReqVO);
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新驾校教练
|
|
||||||
*
|
|
||||||
* @param updateReqVO 更新信息
|
|
||||||
*/
|
|
||||||
void updateDlDriveSchoolCoach(@Valid DlDriveSchoolCoachSaveReqVO updateReqVO);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除驾校教练
|
* 删除驾校教练
|
||||||
*
|
*
|
||||||
* @param id 编号
|
* @param id 教练id
|
||||||
*/
|
* @author PQZ
|
||||||
|
* @date 21:39 2025/1/16
|
||||||
|
**/
|
||||||
void deleteDlDriveSchoolCoach(String id);
|
void deleteDlDriveSchoolCoach(String id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,7 +51,7 @@ public interface DlDriveSchoolCoachService extends IService<DlDriveSchoolCoach>
|
|||||||
* @param id 编号
|
* @param id 编号
|
||||||
* @return 驾校教练
|
* @return 驾校教练
|
||||||
*/
|
*/
|
||||||
DlDriveSchoolCoach getDlDriveSchoolCoach(String id);
|
DlDriveSchoolCoachRespVO getDlDriveSchoolCoach(String id);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -7,13 +7,24 @@ import cn.iocoder.yudao.module.base.service.DlDriveSchoolCoachService;
|
|||||||
import cn.iocoder.yudao.module.base.vo.DlDriveSchoolCoachPageReqVO;
|
import cn.iocoder.yudao.module.base.vo.DlDriveSchoolCoachPageReqVO;
|
||||||
import cn.iocoder.yudao.module.base.vo.DlDriveSchoolCoachRespVO;
|
import cn.iocoder.yudao.module.base.vo.DlDriveSchoolCoachRespVO;
|
||||||
import cn.iocoder.yudao.module.base.vo.DlDriveSchoolCoachSaveReqVO;
|
import cn.iocoder.yudao.module.base.vo.DlDriveSchoolCoachSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
|
||||||
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||||
|
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.system.api.user.dto.UserDTO;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.common.BaseConstants.PASSWORD_DEFAULT;
|
||||||
|
import static cn.iocoder.yudao.framework.common.config.CommonStr.USER_TYPE_STAFF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 驾校教练 Service 实现类
|
* 驾校教练 Service 实现类
|
||||||
@ -26,6 +37,11 @@ public class DlDriveSchoolCoachServiceImpl extends ServiceImpl<DlDriveSchoolCoac
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private DlDriveSchoolCoachMapper dlDriveSchoolCoachMapper;
|
private DlDriveSchoolCoachMapper dlDriveSchoolCoachMapper;
|
||||||
|
@Resource
|
||||||
|
@Lazy
|
||||||
|
private AdminUserApi adminUserApi;
|
||||||
|
@Resource
|
||||||
|
private PermissionApi permissionApi;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 驾校教练、普通员工列表
|
* 驾校教练、普通员工列表
|
||||||
@ -38,35 +54,80 @@ public class DlDriveSchoolCoachServiceImpl extends ServiceImpl<DlDriveSchoolCoac
|
|||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public IPage<DlDriveSchoolCoachRespVO> queryListPage(DlDriveSchoolCoachPageReqVO pageReqVO, Page<DlDriveSchoolCoachRespVO> page) {
|
public IPage<DlDriveSchoolCoachRespVO> queryListPage(DlDriveSchoolCoachPageReqVO pageReqVO, Page<DlDriveSchoolCoachRespVO> page) {
|
||||||
return dlDriveSchoolCoachMapper.queryListPage(pageReqVO,page);
|
return dlDriveSchoolCoachMapper.queryListPage(pageReqVO, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存驾校教练
|
||||||
|
*
|
||||||
|
* @param createReqVO {@link DlDriveSchoolCoachSaveReqVO}
|
||||||
|
* @author PQZ
|
||||||
|
* @date 21:07 2025/1/16
|
||||||
|
**/
|
||||||
@Override
|
@Override
|
||||||
public void createDlDriveSchoolCoach(DlDriveSchoolCoachSaveReqVO createReqVO) {
|
@Transactional(rollbackFor = Exception.class)
|
||||||
// 插入
|
public void saveSchoolCoach(DlDriveSchoolCoachSaveReqVO createReqVO) {
|
||||||
|
/*1、数据类型转换*/
|
||||||
DlDriveSchoolCoach dlDriveSchoolCoach = BeanUtils.toBean(createReqVO, DlDriveSchoolCoach.class);
|
DlDriveSchoolCoach dlDriveSchoolCoach = BeanUtils.toBean(createReqVO, DlDriveSchoolCoach.class);
|
||||||
dlDriveSchoolCoachMapper.insert(dlDriveSchoolCoach);
|
if (null == createReqVO.getUserId()) {
|
||||||
|
/*2、新增教练或编辑教练无用户id时,同时插入一条用户数据*/
|
||||||
}
|
//通过手机号查询用户
|
||||||
|
AdminUserRespDTO userDTO = adminUserApi.getUserByUsername(createReqVO.getPhone());
|
||||||
@Override
|
Long userId;
|
||||||
public void updateDlDriveSchoolCoach(DlDriveSchoolCoachSaveReqVO updateReqVO) {
|
//存在两种情况,1、用户存在,2、用户不存在
|
||||||
// 校验存在
|
if (null == userDTO) {
|
||||||
DlDriveSchoolCoach updateObj = BeanUtils.toBean(updateReqVO, DlDriveSchoolCoach.class);
|
UserDTO user = new UserDTO();
|
||||||
dlDriveSchoolCoachMapper.updateById(updateObj);
|
//如果不存在创建用户;
|
||||||
|
user.setUsername(createReqVO.getPhone());
|
||||||
|
user.setNickname(createReqVO.getName());
|
||||||
|
//默认密码
|
||||||
|
user.setPassword(PASSWORD_DEFAULT);
|
||||||
|
user.setMobile(createReqVO.getPhone());
|
||||||
|
//用户类型员工
|
||||||
|
user.setUserType(USER_TYPE_STAFF);
|
||||||
|
//创建客户
|
||||||
|
userId = adminUserApi.createUser(user);
|
||||||
|
//创建客户后为客户绑定角色
|
||||||
|
Set<String> roleCodes = new HashSet<>();
|
||||||
|
// TODO: 2025/1/16 枚举值问老马(保存角色方法不对)
|
||||||
|
permissionApi.assignUserRole(userId, roleCodes);
|
||||||
|
} else {
|
||||||
|
userId = userDTO.getId();
|
||||||
|
}
|
||||||
|
dlDriveSchoolCoach.setUserId(userId);
|
||||||
|
}
|
||||||
|
/*3、保存教练信息*/
|
||||||
|
saveOrUpdate(dlDriveSchoolCoach);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除驾校教练
|
||||||
|
*
|
||||||
|
* @param id 教练id
|
||||||
|
* @author PQZ
|
||||||
|
* @date 21:39 2025/1/16
|
||||||
|
**/
|
||||||
@Override
|
@Override
|
||||||
public void deleteDlDriveSchoolCoach(String id) {
|
public void deleteDlDriveSchoolCoach(String id) {
|
||||||
// 删除
|
removeById(id);
|
||||||
dlDriveSchoolCoachMapper.deleteById(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id查询教练信息
|
||||||
|
*
|
||||||
|
* @param id 教练id
|
||||||
|
* @return cn.iocoder.yudao.module.base.vo.DlDriveSchoolCoachRespVO
|
||||||
|
* @author PQZ
|
||||||
|
* @date 21:43 2025/1/16
|
||||||
|
**/
|
||||||
@Override
|
@Override
|
||||||
public DlDriveSchoolCoach getDlDriveSchoolCoach(String id) {
|
public DlDriveSchoolCoachRespVO getDlDriveSchoolCoach(String id) {
|
||||||
return dlDriveSchoolCoachMapper.selectById(id);
|
//通过id查询教练信息
|
||||||
|
DlDriveSchoolCoach schoolCoach = getById(id);
|
||||||
|
//数据类型转换
|
||||||
|
DlDriveSchoolCoachRespVO result = BeanUtils.toBean(schoolCoach, DlDriveSchoolCoachRespVO.class);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user