当前位置: 首页 > 知识库问答 >
问题:

spring - 这种怎么解决?

夏经武
2023-04-24

问题:
image.png
impl:
@Service
public class GraduateCollegeServiceImpl extends ServiceImpl<GraduateCollegeMapper, GraduateCollege> implements IGraduateCollegeService {

@Autowired
private GraduateCollegeMapper graduateCollegeMapper;

@Override
public GraduateCollege getGraduateCollege(String dateYear) {
    GraduateCollege graduateCollege = graduateCollegeMapper.selectGraduateCollegeVo(dateYear);
    return graduateCollege;
}

@Override
public List<GraduateCollege> queryCondition(GraduateCollege entity) {
    if (StringUtils.isNull(entity)) {
        throw new _BaseException("查询条件不能为空");
    }
    LambdaQueryWrapper<GraduateCollege> queryWrapper = new LambdaQueryWrapper<>();
    queryWrapper
            .like(isNotBlank(entity.getCollegeName()),GraduateCollege::getCollegeName,entity.getCollegeName())
            .like(isNotBlank(entity.getCollegeNumber()),GraduateCollege::getCollegeNumber,entity.getCollegeNumber())
            .like(isNotBlank(entity.getEmploymentNumber()),GraduateCollege::getEmploymentNumber,entity.getEmploymentNumber())
            .like(isNotBlank(entity.getDateYear()),GraduateCollege::getDateYear,entity.getDateYear());
    List<GraduateCollege> graduateColleges = graduateCollegeMapper.selectList(queryWrapper);
    checkError(graduateColleges, "条件查询档案列表为空");
    return graduateColleges;
}

controller:
@Api(tags="各高校")
@RestController
@RequestMapping("/graduateCollege")
public class GraduateCollegeController extends BaseController {

@Autowired
private IGraduateCollegeService iGraduateCollegeService;
@Autowired
private GraduateCollegeMapper graduateCollegeMapper;

private Logger log = LoggerFactory.getLogger(bi.she.luo.echarts.controller.employment.GraduateCollegeController.class);

@ApiOperation("根据年份查询各高校")
@ApiImplicitParam(name="dateYear",value="年份",required =true,dataType = "String",dataTypeClass = String.class,paramType = "path")
@GetMapping("/selectByDate/{dateYear}")
public AjaxResult selectByDate(@PathVariable("dateYear") String dateYear){
    checkError(dateYear, "dateYear不能为空");
    GraduateCollege graduateCollege = iGraduateCollegeService.getGraduateCollege(dateYear);
    if (isNotNull(graduateCollege)) {
        return AjaxResult.success(graduateCollege);
    } else {
        log.error("各高校信息为空");
        return AjaxResult.error();
    }
}

@ApiOperation("各高校列表查询")
@GetMapping("/graduateCollegeList")
public TableDataInfo list (GraduateCollege entity){
    LambdaQueryWrapper<GraduateCollege> collegeQueryWrapper = new LambdaQueryWrapper<>();
    collegeQueryWrapper
            .like(isNotBlank(entity.getCollegeName()),GraduateCollege::getCollegeName,entity.getCollegeName())
            .like(isNotBlank(entity.getCollegeNumber()),GraduateCollege::getCollegeNumber,entity.getCollegeNumber())
            .like(isNotBlank(entity.getEmploymentNumber()),GraduateCollege::getEmploymentNumber,entity.getEmploymentNumber())
            .like(isNotBlank(entity.getDateYear()),GraduateCollege::getDateYear,entity.getDateYear());
    List<GraduateCollege> graduateColleges = graduateCollegeMapper.selectList(collegeQueryWrapper);
    TableDataInfo res = getDataTable(graduateColleges);
    List<GraduateCollege> GraduateColleges = JSON.parseArray(JSON.toJSONString(graduateColleges),GraduateCollege.class);
    res.setRows(GraduateColleges);
    return res;
}

entiy:
@Data
@AllArgsConstructor
@NoArgsConstructor
public class GraduateCollege extends BusinessBaseEntity {

private static final long serialVersionUID = 1L;

/**
 * 各高校名称
 * */
@Excel(name = "高校名称")
private String collegeName;

/**
 * 各高校毕业人数
 * */
@Excel(name = "高校毕业人数")
private String graduateNumber;

/**
 * 各高校就业人数
 * */
@Excel(name = "高校就业人数")
private String employmentNumber;

/**
 * 年份
 * */
@Excel(name = "年份",width = 30, dateFormat = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd")
@NotNull(message = "年份不能为空")
private Date dateYear;

service:
public interface IGraduateCollegeService extends IService<GraduateCollege> {

/**
 * @return
 */
GraduateCollege getGraduateCollege(String dateYear);
/**
 * 条件查询 --> 可用于接口复用
 *
 * @param entity
 * @return
 */
List<GraduateCollege> queryCondition(GraduateCollege entity);

mapper:
@Mapper
public interface GraduateCollegeMapper extends BaseMapper<GraduateCollege> {
// GraduateCollege getGraduateCollege(String dateYear);

  public GraduateCollege selectGraduateCollegeVo(String dateYear);

}

共有1个答案

傅阳炎
2023-04-24

你的实体类里缺少collegeNumber这个属性,
自然就没有它的get方法和方法引用了
你的这行代码:

.like(isNotBlank(entity.getCollegeNumber()),GraduateCollege::getCollegeNumber,entity.getCollegeNumber())

你实体类里定义的是graduateNumber,是不是写错了?如果是就改成:

.like(isNotBlank(entity.getGraduateNumber()),GraduateCollege::getGraduateNumber,entity.getGraduateNumber())
 类似资料:
  • 如果dev分支里面部分功能要上生产,该怎么做?比如dev里有ACD这四个功能,A还在测试,生产里有CD这几个功能,然后目前要上线B功能,该怎么把B功能合到生产分支里? 首先不能把dev全部合到生产分支,也不能把开发B功能的分支合到生产分支吧?因为开发B功能的分支是由dev拉出来的,也会有A功能的代码。

  • 这是记录用户下载的表,想统计表内每个文章被下载了几次,也就是需要拿到一个文章ID,然后再求下这个ID出现的次数。

  • vue代码如下 在vue3版本使用vue2版本的script,通过点击字样可以弹出不同的内容 使用setup却无法达到这个功能,只有在console中显示

  • 请求各位大哥帮忙解密,祝大哥们发财娶漂亮老婆!! 完整版:【腾讯文档】 https://docs.qq.com/doc/DV2FaZ0J4c1lzYUtB (function(_0x319d23,_0x253eaa){const _0x17f6bd=_0x319d23();function _0x5ef634(_0x4d9bcf,_0x332385,_0x131a87,_0xdb2988){ret

  • 失败:生成失败,出现异常。 > 其中:Script“C:\flutter\packages\flutter_tools\gradle\flutter.gradle”行:900 错误:任务“:app:CompileFlutterBuildDebug”执行失败。 进程“command”C:\flutter\bin\flutter.bat“已完成,退出值为非零%1 生成在%12s中失败异常:Gradle