Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Team 5 - Smart Towns
Manage
Activity
Members
Labels
Plan
Issues
34
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Rhys Evans
Team 5 - Smart Towns
Merge requests
!39
Draft: Towns
Code
Review changes
Check out branch
Download
Patches
Plain diff
Closed
Draft: Towns
towns
into
main
Overview
0
Commits
22
Pipelines
0
Changes
11
Closed
Rhys Nute
requested to merge
towns
into
main
1 year ago
Overview
0
Commits
22
Pipelines
0
Changes
4
Expand
0
0
Merge request reports
Compare
version 4
version 11
9cafb6a5
1 year ago
version 10
22421a65
1 year ago
version 9
7d1935d0
1 year ago
version 8
710bd7e4
1 year ago
version 7
3d4a11fd
1 year ago
version 6
4dc412e1
1 year ago
version 5
e386e204
1 year ago
version 4
c7c99e5e
1 year ago
version 3
0822ee82
1 year ago
version 2
35f736d2
1 year ago
version 1
23893cc1
1 year ago
main (base)
and
version 5
latest version
bf8d24cb
22 commits,
1 year ago
version 11
9cafb6a5
21 commits,
1 year ago
version 10
22421a65
20 commits,
1 year ago
version 9
7d1935d0
19 commits,
1 year ago
version 8
710bd7e4
18 commits,
1 year ago
version 7
3d4a11fd
17 commits,
1 year ago
version 6
4dc412e1
16 commits,
1 year ago
version 5
e386e204
15 commits,
1 year ago
version 4
c7c99e5e
14 commits,
1 year ago
version 3
0822ee82
13 commits,
1 year ago
version 2
35f736d2
12 commits,
1 year ago
version 1
23893cc1
11 commits,
1 year ago
Show latest version
4 files
+
32
−
15
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
Search (e.g. *.vue) (Ctrl+P)
Conflict: This file was modified in the source branch, but removed in the target branch. Ask someone with write access to resolve it.
src/main/java/Team5/SmartTowns/Organisation/organisationControllers.java
+
26
−
12
Options
package
Team5.SmartTowns.Organisation
;
import
Team5.SmartTowns.Data.Location
;
import
Team5.SmartTowns.
Data
.addAddTowns
Repository
;
import
Team5.SmartTowns.
Landmarks.Landmarks
;
import
Team5.SmartTowns.
addTowns
.addAddTowns
;
import
Team5.SmartTowns.
addTowns.addAddTownsRepository
;
import
Team5.SmartTowns.Towns.Towns
;
import
jakarta.validation.Valid
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.servlet.ModelAndView
;
import
org.springframework.stereotype.Controller
;
import
java.util.List
;
@Controller
public
class
organisationControllers
{
@GetMapping
(
"/localauthorities"
)
public
ModelAndView
getLocalAuthoritiesPage
(){
public
ModelAndView
getLocalAuthoritiesPage
()
{
ModelAndView
modelAndView
=
new
ModelAndView
(
"WorkWith/local-authorities.html"
);
return
modelAndView
;
}
@GetMapping
(
"/businesses"
)
public
ModelAndView
getBusinessPage
(){
public
ModelAndView
getBusinessPage
()
{
ModelAndView
modelAndView
=
new
ModelAndView
(
"WorkWith/business.html"
);
return
modelAndView
;
}
@GetMapping
(
"/consumers"
)
public
ModelAndView
getConsumersPage
(){
public
ModelAndView
getConsumersPage
()
{
ModelAndView
modelAndView
=
new
ModelAndView
(
"WorkWith/consumers.html"
);
return
modelAndView
;
}
@GetMapping
(
"/towns"
)
public
ModelAndView
getTownsPage
(){
public
ModelAndView
getTownsPage
()
{
ModelAndView
modelAndView
=
new
ModelAndView
(
"WorkWith/towns.html"
);
List
<
addAddTowns
>
Towns
=
addAddTownsRepository
.
getAllAddTowns
();
modelAndView
.
addObject
(
"towns"
,
Towns
);
return
modelAndView
;
}
@Autowired
private
addAddTownsRepository
addAddTownsRepository
;
@PostMapping
(
"/townssub"
)
public
ModelAndView
townsSent
(
@Valid
@ModelAttribute
(
"towns-data"
)
Towns
towns
,
BindingResult
bindingResult
,
Model
model
)
{
public
ModelAndView
townsSent
(
@Valid
@ModelAttribute
(
"towns-data"
)
addAddTowns
towns
,
BindingResult
bindingResult
,
Model
model
)
{
List
<
addAddTowns
>
addtowns
=
addAddTownsRepository
.
getAllAddTowns
();
if
(
bindingResult
.
hasErrors
())
{
ModelAndView
modelAndView
=
new
ModelAndView
(
"towns-data"
,
model
.
asMap
());
return
modelAndView
;
}
else
{
// converts user input using the organisation constructor into a submittable format to the sql table
Towns
tow
=
new
Towns
(
towns
.
getTownName
(),
towns
.
getAddress1
(),
towns
.
getAddress2
(),
towns
.
getCity
(),
towns
.
getCounty
(),
towns
.
getPostcode
());
System
.
out
.
println
(
bus
);
addAddTownsRepository
.
add
Add
Town
(
tow
);
//add new towns to Add Towns table
addAdd
Towns
tow
=
new
addAdd
Towns
(
towns
.
getTownName
(),
towns
.
getAddress1
(),
towns
.
getAddress2
(),
towns
.
getCity
(),
towns
.
getCounty
(),
towns
.
getPostcode
());
System
.
out
.
println
(
tow
);
addAddTownsRepository
.
addTown
(
tow
);
//add new towns to Add Towns table
ModelAndView
modelAndView
=
new
ModelAndView
(
"redirect:/businesses"
);
return
modelAndView
;
}
}
}
Loading