公共下拉选

This commit is contained in:
cwchen 2024-07-19 14:58:43 +08:00
parent e9f4de6a97
commit ec46ddfd26
8 changed files with 207 additions and 2 deletions

View File

@ -13,7 +13,12 @@ public class SelectEntity {
private String id; private String id;
/** /**
*名称 * 名称
*/ */
private String name; private String name;
/**
* 字典值
*/
private String value;
} }

View File

@ -0,0 +1,72 @@
package com.bonus.aqgqj.basis.entity.vo;
import com.bonus.aqgqj.utils.UserUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.Date;
/**
* @className:ExperDeviceVo
* @author:cwchen
* @date:2024-07-19-13:29
* @version:1.0
* @description:试验设备-vo
*/
@Data
public class ExperDeviceVo {
/**
* 设备id
*/
private Long devId;
/**
* 设备名称
*/
private String devName;
/**
* 设备型号
*/
private String devModule;
/**
* 设备编号
*/
private String devCode;
/**
* 合同生效日期
*/
private String contractDate;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Date createTime;
/**
* 修改时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Date updateTime = new Date();
/**
* 创建人
*/
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Long createUser = UserUtil.getLoginUser().getId();
/**
* 修改人
*/
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Long updateUser = UserUtil.getLoginUser().getId();
/**
* 数据来源 0 新增 1 实验配置
*/
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Integer dataSource = 1;
/**
* 删除状态 0正常 1删除
*/
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Integer delFlag = 0;
}

View File

@ -4,6 +4,7 @@ import com.bonus.aqgqj.annotation.DecryptAndVerify;
import com.bonus.aqgqj.base.entity.SelectEntity; import com.bonus.aqgqj.base.entity.SelectEntity;
import com.bonus.aqgqj.system.service.SelectService; import com.bonus.aqgqj.system.service.SelectService;
import com.bonus.aqgqj.system.vo.EncryptedReq; import com.bonus.aqgqj.system.vo.EncryptedReq;
import com.bonus.aqgqj.system.vo.dto.SelectDto;
import com.bonus.aqgqj.utils.ServerResponse; import com.bonus.aqgqj.utils.ServerResponse;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@ -101,4 +102,31 @@ public class SelectController {
public ServerResponse getRoomTypeSelect() { public ServerResponse getRoomTypeSelect() {
return service.getRoomTypeSelect(); return service.getRoomTypeSelect();
} }
/**
* 字典表下拉选-根据父编码查找
*
* @param param
* @return ServerResponse
* @author cwchen
* @date 2024/7/19 13:15
*/
@PostMapping(value = "getDicts")
@DecryptAndVerify(decryptedClass = SelectDto.class)
public ServerResponse getDicts(EncryptedReq<SelectDto> param) {
return service.getDicts(param.getData());
}
/**
* 试验设备-下拉选
* @param param
* @return ServerResponse
* @author cwchen
* @date 2024/7/19 13:23
*/
@PostMapping(value = "getDevices")
@DecryptAndVerify(decryptedClass = SelectDto.class)
public ServerResponse getDevices(EncryptedReq<SelectDto> param) {
return service.getDevices(param.getData());
}
} }

View File

@ -1,6 +1,8 @@
package com.bonus.aqgqj.system.dao; package com.bonus.aqgqj.system.dao;
import com.bonus.aqgqj.base.entity.SelectEntity; import com.bonus.aqgqj.base.entity.SelectEntity;
import com.bonus.aqgqj.basis.entity.vo.ExperDeviceVo;
import com.bonus.aqgqj.system.vo.dto.SelectDto;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
@ -65,4 +67,23 @@ public interface SelectDao {
* @date 2023/11/19 15:14 * @date 2023/11/19 15:14
*/ */
List<SelectEntity> getRoomTypeSelect(); List<SelectEntity> getRoomTypeSelect();
/**
* 字典表下拉选-根据父编码查找
*
* @param dto
* @return List<SelectEntity>
* @author cwchen
* @date 2024/7/19 13:19
*/
List<SelectEntity> getDicts(SelectDto dto);
/**
* 试验设备-下拉选
* @param dto
* @return List<ExperDeviceVo>
* @author cwchen
* @date 2024/7/19 13:26
*/
List<ExperDeviceVo> getDevices(SelectDto dto);
} }

View File

@ -2,6 +2,7 @@ package com.bonus.aqgqj.system.service;
import com.bonus.aqgqj.base.entity.SelectEntity; import com.bonus.aqgqj.base.entity.SelectEntity;
import com.bonus.aqgqj.system.vo.dto.SelectDto;
import com.bonus.aqgqj.utils.ServerResponse; import com.bonus.aqgqj.utils.ServerResponse;
import java.util.List; import java.util.List;
@ -47,7 +48,6 @@ public interface SelectService {
ServerResponse getDeviceChildTypeSelect(); ServerResponse getDeviceChildTypeSelect();
/** /**
* @return ServerResponse * @return ServerResponse
* @description 字典-下拉选 * @description 字典-下拉选
@ -63,4 +63,23 @@ public interface SelectService {
* @date 2023/11/19 15:14 * @date 2023/11/19 15:14
*/ */
ServerResponse getRoomTypeSelect(); ServerResponse getRoomTypeSelect();
/**
* 字典表下拉选-根据父编码查找
*
* @param dto
* @return ServerResponse
* @author cwchen
* @date 2024/7/19 13:16
*/
ServerResponse getDicts(SelectDto dto);
/**
* 试验设备下拉选
* @param data
* @return ServerResponse
* @author cwchen
* @date 2024/7/19 13:24
*/
ServerResponse getDevices(SelectDto data);
} }

View File

@ -4,8 +4,10 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.bonus.aqgqj.base.entity.SelectEntity; import com.bonus.aqgqj.base.entity.SelectEntity;
import com.bonus.aqgqj.basis.entity.vo.ExperDeviceVo;
import com.bonus.aqgqj.system.dao.SelectDao; import com.bonus.aqgqj.system.dao.SelectDao;
import com.bonus.aqgqj.system.service.SelectService; import com.bonus.aqgqj.system.service.SelectService;
import com.bonus.aqgqj.system.vo.dto.SelectDto;
import com.bonus.aqgqj.utils.ServerResponse; import com.bonus.aqgqj.utils.ServerResponse;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -86,4 +88,26 @@ public class SelectServiceImpl implements SelectService {
} }
return ServerResponse.createSuccess("查询成功",list); return ServerResponse.createSuccess("查询成功",list);
} }
@Override
public ServerResponse getDicts(SelectDto dto) {
List<SelectEntity> list = new ArrayList();
try {
list = mapper.getDicts(dto);
} catch (Exception e) {
log.error(e.toString(),e);
}
return ServerResponse.createSuccess("查询成功",list);
}
@Override
public ServerResponse getDevices(SelectDto dto) {
List<ExperDeviceVo> list = new ArrayList();
try {
list = mapper.getDevices(dto);
} catch (Exception e) {
log.error(e.toString(),e);
}
return ServerResponse.createSuccess("查询成功",list);
}
} }

View File

@ -0,0 +1,18 @@
package com.bonus.aqgqj.system.vo.dto;
import lombok.Data;
/**
* @className:SelectDto
* @author:cwchen
* @date:2024-07-19-13:14
* @version:1.0
* @description:下拉选-dto
*/
@Data
public class SelectDto {
/** 字段编码*/
private String code;
}

View File

@ -57,4 +57,22 @@
LEFT JOIN sys_distinct sd2 ON sd.id = sd2.p_id AND sd2.del_flag = 0 LEFT JOIN sys_distinct sd2 ON sd.id = sd2.p_id AND sd2.del_flag = 0
WHERE sd.dict_code = 'room_type' AND sd.del_flag = 0 WHERE sd.dict_code = 'room_type' AND sd.del_flag = 0
</select> </select>
<!--字典表下拉选-根据父编码查找-->
<select id="getDicts" resultType="com.bonus.aqgqj.base.entity.SelectEntity">
SELECT sd2.dict_value AS value,
sd2.dict_name AS name
FROM sys_distinct sd
LEFT JOIN sys_distinct sd2 ON sd.id = sd2.p_id AND sd2.del_flag = 0
WHERE sd.dict_code = #{code} AND sd.del_flag = 0
</select>
<!--试验设备-下拉选-->
<select id="getDevices" resultType="com.bonus.aqgqj.basis.entity.vo.ExperDeviceVo">
SELECT dev_id AS devId,
dev_name AS devName,
dev_code AS devCode,
dev_module AS devModule,
contract_date AS contractDate
FROM tb_exper_device
WHERE del_flag = 0
</select>
</mapper> </mapper>