根据用户ID获取项目信息接口开发

This commit is contained in:
ChenQiaoWen 2025-02-26 23:30:35 +08:00
parent 719c9eec2e
commit f0d40c93d0
5 changed files with 82 additions and 0 deletions
server/src/main/java/net/carbon

View File

@ -0,0 +1,25 @@
package net.carbon.controller;
import net.carbon.model.vo.ProjectVO;
import net.carbon.service.ProjectService;
import net.carbon.utils.JsonData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("/api/project/v1")
public class ProjectController {
@Autowired
private ProjectService projectService;
@GetMapping("/info")
public JsonData getUserProject(@RequestParam("id") Integer id){
List<ProjectVO> projectVOList = projectService.userProject(id);
return JsonData.buildSuccess(projectVOList);
}
}

View File

@ -0,0 +1,14 @@
package net.carbon.mapper;
import net.carbon.model.vo.ProjectVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
@Mapper
public interface ProjectMapper {
@Select("select * from project where user_id = #{id}")
List<ProjectVO> userProject(Integer id);
}

View File

@ -0,0 +1,14 @@
package net.carbon.model.vo;
import lombok.Data;
@Data
public class ProjectVO {
private String projectName;
private String projectId;
private String projectImage;
private String projectAddress;
private String projectStatus;
private String userNumber;
private String companydescription;
}

View File

@ -0,0 +1,9 @@
package net.carbon.service;
import net.carbon.model.vo.ProjectVO;
import java.util.List;
public interface ProjectService {
List<ProjectVO> userProject(Integer id);
}

View File

@ -0,0 +1,20 @@
package net.carbon.service.impl;
import net.carbon.mapper.ProjectMapper;
import net.carbon.model.vo.ProjectVO;
import net.carbon.service.ProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ProjectServiceImpl implements ProjectService {
@Autowired
private ProjectMapper projectMapper;
@Override
public List<ProjectVO> userProject(Integer id) {
List<ProjectVO> userProjectList = projectMapper.userProject(id);
return userProjectList;
}
}