Untitled
unknown
plain_text
2 years ago
1.5 kB
13
Indexable
package com.ks.fitpass.web.controller;
import com.ks.fitpass.department.entity.Department;
import com.ks.fitpass.department.service.DepartmentService;
import com.ks.fitpass.web.enums.PageEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@Controller
@RequestMapping("/department")
public class DepartmentController {
private DepartmentService departmentService;
@Autowired
public DepartmentController(DepartmentService departmentService){
this.departmentService = departmentService;
}
@GetMapping("/department-detail/{department_id}")
public String getDepartment(@PathVariable("department_id") int departmentId, Model model) {
try {
Department department = departmentService.getOne(departmentId, 1);
model.addAttribute("department", department);
model.addAttribute("page", PageEnum.XXX_FIRST_PAGE.getCode());
//
return "gym-department-details";
} catch (EmptyResultDataAccessException e) {
return "error/no-data";
}
}
}
Editor is loading...