Skip to content
Snippets Groups Projects
Commit 59376b5a authored by Seb Barnard's avatar Seb Barnard :speech_balloon:
Browse files

Fixed duplicate tags being saved, feature should now be working

parent 68b9b0ca
No related branches found
No related tags found
2 merge requests!114LoggingService service class, new method to add a log to the "Logs" table when...,!94Issue thirty four
...@@ -24,4 +24,7 @@ public interface TagsRepo extends JpaRepository<Tags, Long> { ...@@ -24,4 +24,7 @@ public interface TagsRepo extends JpaRepository<Tags, Long> {
@Query("select t from Tags t where t.tagName = ?1") @Query("select t from Tags t where t.tagName = ?1")
Optional<Tags> findByTagName(String tagName); Optional<Tags> findByTagName(String tagName);
@Query("select t from Tags t where t.tagName = ?1")
Optional<Tags> findByTagNameIgnoreCase(String tagName);
} }
...@@ -21,6 +21,7 @@ import org.springframework.stereotype.Service; ...@@ -21,6 +21,7 @@ import org.springframework.stereotype.Service;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale;
@Service @Service
public class BusinessRegisterSaver { public class BusinessRegisterSaver {
...@@ -82,17 +83,24 @@ public class BusinessRegisterSaver { ...@@ -82,17 +83,24 @@ public class BusinessRegisterSaver {
//System.out.println(shop.getStampBoard()); //System.out.println(shop.getStampBoard());
shopsRepo.save(shop); shopsRepo.save(shop);
List<Tags> tagsList = tagsRepo.findAll(); List<String> tagsList = new ArrayList<>();
List<String> tagsLowerList = new ArrayList<>();
tagsRepo.findAll().forEach(x -> tagsList.add(x.getTagName()));
tagsRepo.findAll().forEach(x -> tagsLowerList.add(x.getTagName().toLowerCase()));
System.out.println(tagsLowerList);
business.getBusinessTags().forEach(x-> System.out.println(x));
linkShop.linkUserShop(shop.getShopId(), userId, 2L); linkShop.linkUserShop(shop.getShopId(), userId, 2L);
for(String t: business.getBusinessTags()){ for(String t: business.getBusinessTags()){
if(tagsList.contains(new Tags(t))){ Tags tag;
continue; if(tagsLowerList.contains(t.toLowerCase())){
tag = tagsRepo.findByTagNameIgnoreCase(t).get();
}else{
tag = new Tags(t);
tagsRepo.save(tag);
} }
//long id = 0;
Tags tag = new Tags(t);
tagsRepo.save(tag);
query = "INSERT INTO Shop_Tag_Links (Shop_Id, Tag_Id) VALUES ("+ shop.getShopId() + query = "INSERT INTO Shop_Tag_Links (Shop_Id, Tag_Id) VALUES ("+ shop.getShopId() +
......
src/main/resources/static/imgs/uploaded/f0db0585_1c77_4dcb_a014_54be322c735a.jpg

10.1 KiB

...@@ -11,7 +11,7 @@ function submit(shopId, email={"value":""}){ ...@@ -11,7 +11,7 @@ function submit(shopId, email={"value":""}){
`<div id="staffManagement"> `<div id="staffManagement">
<div class="staffManagementContainer"> <div class="staffManagementContainer">
<p class="subtitle is-6" style="width:50%; margin-bottom: 0">${emailValue}</p> <p class="subtitle is-6" style="width:50%; margin-bottom: 0">${emailValue}</p>
<button class="button is-danger is-outlined" style="border-bottom: 1px solid #00b89c" <button class="button is-danger is-outlined" style="border-bottom: 1px solid black"
onclick="submit(${document.getElementById("shopId").value},this);"> onclick="submit(${document.getElementById("shopId").value},this);">
<span class="icon is-small"> <span class="icon is-small">
<i class="fas fa-times is-danger"></i> <i class="fas fa-times is-danger"></i>
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
<p class="subtitle is-6" style="margin-bottom:3px;margin-top: 10px">Description</p> <p class="subtitle is-6" style="margin-bottom:3px;margin-top: 10px">Description</p>
<textarea class="textarea" id="descriptionInput" th:text="${shop.shopDescription}" cols="30" rows="10"></textarea> <textarea class="textarea" id="descriptionInput" th:text="${shop.shopDescription}" cols="30" rows="10"></textarea>
<p class="subtitle is-6" style="margin-bottom:3px;margin-top: 10px">Banner</p>
<img class="mb-3" id="bannerPreview" th:src="${shop.shopBanner}" style="margin-top: 5px; max-height: 100px"> <img class="mb-3" id="bannerPreview" th:src="${shop.shopBanner}" style="margin-top: 5px; max-height: 100px">
<div class="file has-name mb-5"> <div class="file has-name mb-5">
<label class="file-label"> <label class="file-label">
...@@ -29,6 +30,7 @@ ...@@ -29,6 +30,7 @@
</label> </label>
</div> </div>
<p class="subtitle is-6" style="margin-bottom:3px;margin-top: 10px">Logo</p>
<img class="mb-3" id="logoPreview" th:src="${shop.shopImage}" style="margin-top: 5px; max-height: 100px"> <img class="mb-3" id="logoPreview" th:src="${shop.shopImage}" style="margin-top: 5px; max-height: 100px">
<div class="file has-name mb-5"> <div class="file has-name mb-5">
<label class="file-label"> <label class="file-label">
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<div id="staffManagement" th:each="user : ${staffMembers}"> <div id="staffManagement" th:each="user : ${staffMembers}">
<div class="staffManagementContainer"> <div class="staffManagementContainer">
<p class="subtitle is-6" th:text="${user.userEmail}" style="width:50%; margin-bottom: 0"></p> <p class="subtitle is-6" th:text="${user.userEmail}" style="width:50%; margin-bottom: 0"></p>
<button class="button is-danger is-outlined" style="border-bottom: 1px solid #00b89c" th:onclick="'submit('+${shop.shopId}+',this);'"> <button class="button is-danger is-outlined" style="border-bottom: 1px solid black" th:onclick="'submit('+${shop.shopId}+',this);'">
<span class="icon is-small"> <span class="icon is-small">
<i class="fas fa-times is-danger"></i> <i class="fas fa-times is-danger"></i>
</span> </span>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment