下拉选公共接口

This commit is contained in:
cwchen 2024-07-15 14:43:57 +08:00
parent 155a9e0afd
commit b002590925
7 changed files with 179 additions and 0 deletions

View File

@ -0,0 +1,41 @@
package com.bonus.system.controller;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.system.api.domain.SysDept;
import com.bonus.system.domain.SysParamsDto;
import com.bonus.system.service.ISelectService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
* @className:SelectController
* @author:cwchen
* @date:2024-07-15-10:24
* @version:1.0
* @description:公共下拉选-controller
*/
@RestController
@RequestMapping("/select/")
@Slf4j
public class SelectController {
@Resource(name = "ISelectService")
private ISelectService service;
/**
* 获取班组下拉选
* @param dto
* @return AjaxResult
* @author cwchen
* @date 2024/7/15 10:35
*/
@GetMapping("/getTeamList")
public AjaxResult getTeamList(SysParamsDto dto) {
return service.getTeamList(dto);
}
}

View File

@ -0,0 +1,16 @@
package com.bonus.system.domain;
import lombok.Data;
/**
* @className:SysParamsDto
* @author:cwchen
* @date:2024-07-15-10:34
* @version:1.0
* @description:前端参数-dto
*/
@Data
public class SysParamsDto {
private String id;
}

View File

@ -0,0 +1,24 @@
package com.bonus.system.domain.vo;
import lombok.Data;
/**
* @className:SysSelectVo
* @author:cwchen
* @date:2024-07-15-10:39
* @version:1.0
* @description:下拉选公共实体类-vo
*/
@Data
public class SysSelectVo {
/**
* id
*/
private String id;
/**
* 名称
*/
private String name;
}

View File

@ -0,0 +1,26 @@
package com.bonus.system.mapper;
import com.bonus.system.domain.SysParamsDto;
import com.bonus.system.domain.vo.SysSelectVo;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @className:SelectMapper
* @author:cwchen
* @date:2024-07-15-10:26
* @version:1.0
* @description:公共下拉选-mapper
*/
@Repository(value = "SelectMapper")
public interface SelectMapper {
/**
* 获取班组下拉选
* @param dto
* @return List<SysSelectVo>
* @author cwchen
* @date 2024/7/15 10:45
*/
List<SysSelectVo> getTeamList(SysParamsDto dto);
}

View File

@ -0,0 +1,22 @@
package com.bonus.system.service;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.system.domain.SysParamsDto;
/**
* @className:SelectService
* @author:cwchen
* @date:2024-07-15-10:25
* @version:1.0
* @description:公共下拉选-service
*/
public interface ISelectService {
/**
* 获取班组下拉选
* @param dto
* @return AjaxResult
* @author cwchen
* @date 2024/7/15 10:35
*/
AjaxResult getTeamList(SysParamsDto dto);
}

View File

@ -0,0 +1,37 @@
package com.bonus.system.service.impl;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.system.domain.SysParamsDto;
import com.bonus.system.domain.vo.SysSelectVo;
import com.bonus.system.mapper.SelectMapper;
import com.bonus.system.service.ISelectService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* @className:SelectServiceImpl
* @author:cwchen
* @date:2024-07-15-10:25
* @version:1.0
* @description:公共下拉选-serviceImpl
*/
@Service(value = "ISelectService")
@Slf4j
public class SelectServiceImpl implements ISelectService {
@Resource(name = "SelectMapper")
private SelectMapper mapper;
@Override
public AjaxResult getTeamList(SysParamsDto dto) {
try {
List<SysSelectVo> list = mapper.getTeamList(dto);
return AjaxResult.success(list);
} catch (Exception e) {
log.error("获取班组下拉选",e);
return AjaxResult.error();
}
}
}

View File

@ -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="com.bonus.system.mapper.SelectMapper">
<!--获取班组下拉选-->
<select id="getTeamList" resultType="com.bonus.system.domain.vo.SysSelectVo">
SELECT team_id AS id,
CONCAT(team_name,'(',team_name,')') AS name
FROM t_work_team WHERE del_flag = 0
</select>
</mapper>