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

Merge branch 'issueThirtyFour' into 'develop'

Issue thirty four

See merge request !94
parents 175d1a44 b0d7fc98
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
Showing
with 132 additions and 7 deletions
......@@ -34,6 +34,7 @@ public class Shops {
private String shopWebsite;
private int shopEarnings;
private String shopImage;
private String shopBanner;
private String shopCountries;
@Convert(converter = TinyIntToBoolean.class)
......@@ -49,13 +50,14 @@ public class Shops {
* @param active - shop active status
*/
public Shops(String name, String website, String description, int earnings,
String image, String countries, boolean active, StampBoards stampBoard,
String image, String banner, String countries, boolean active, StampBoards stampBoard,
Categories categories) {
this.shopName = name;
this.shopDescription = description;
this.shopWebsite = website;
this.shopEarnings = earnings;
this.shopImage = image;
this.shopBanner = banner;
this.shopCountries = countries;
this.shopActive = active;
this.stampBoard = stampBoard;
......
......@@ -24,4 +24,7 @@ public interface TagsRepo extends JpaRepository<Tags, Long> {
@Query("select t from Tags t where t.tagName = ?1")
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;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
@Service
public class BusinessRegisterSaver {
......@@ -71,6 +72,7 @@ public class BusinessRegisterSaver {
business.getBusiness_register_desc(),
business.getEarnings(),
"shopPic.png",
"shopBanner.png",
"UK United Kingdom",
false,
stampBoard,
......@@ -81,17 +83,24 @@ public class BusinessRegisterSaver {
//System.out.println(shop.getStampBoard());
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);
for(String t: business.getBusinessTags()){
if(tagsList.contains(new Tags(t))){
continue;
Tags tag;
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() +
......
package com.example.clientproject.services;
import com.example.clientproject.web.forms.UpdateKeyInfoForm;
import lombok.AllArgsConstructor;
import lombok.Value;
@Value
@AllArgsConstructor
public class KeyInfoDTO {
int shopId;
String shopName;
String shopDescription;
String bannerName;
String logoName;
public KeyInfoDTO(UpdateKeyInfoForm form){
this(
form.getShopId(),
form.getShopName(),
form.getShopDescription(),
form.getBannerName(),
form.getLogoName()
);
}
}
package com.example.clientproject.services;
import com.example.clientproject.data.shops.Shops;
import com.example.clientproject.data.shops.ShopsRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class UpdateKeyInfo {
@Autowired
ShopsRepo shopsRepo;
public void updateInfo(KeyInfoDTO kiDTO){
Shops shop = shopsRepo.getById((long) kiDTO.getShopId());
shop.setShopName(kiDTO.getShopName());
shop.setShopDescription(kiDTO.getShopDescription());
if(!kiDTO.getBannerName().equalsIgnoreCase("")){
shop.setShopBanner(kiDTO.getBannerName());
}
if(!kiDTO.getLogoName().equalsIgnoreCase("")){
shop.setShopImage(kiDTO.getLogoName());
}
shopsRepo.save(shop);
}
}
package com.example.clientproject.web.forms;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UpdateKeyInfoForm {
private int shopId;
private String shopName;
private String shopDescription;
private String bannerName;
private String logoName;
}
package com.example.clientproject.web.restControllers;
import com.example.clientproject.service.Utils.JWTUtils;
import com.example.clientproject.services.KeyInfoDTO;
import com.example.clientproject.services.UpdateKeyInfo;
import com.example.clientproject.web.forms.UpdateKeyInfoForm;
import org.hibernate.sql.Update;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;
@RestController
public class UpdateKeyInformation {
private JWTUtils jwtUtils;
private UpdateKeyInfo updateInfo;
public UpdateKeyInformation(JWTUtils utils, UpdateKeyInfo update){
jwtUtils = utils;
updateInfo = update;
}
@PostMapping("/updateKeyInformation")
public String updateInfo(HttpSession session, UpdateKeyInfoForm keyInformationForm){
if(!jwtUtils.getLoggedInUserId(session).isPresent()){
return "BAD SESSION";
}
try{
updateInfo.updateInfo(new KeyInfoDTO(keyInformationForm));
return "OK";
}catch (Exception e){
e.printStackTrace();
return "ERROR";
}
}
}
src/main/resources/static/imgs/uploaded/012d7d87_1906_4f1d_949c_e8a5814588a2.png

47.1 KiB

src/main/resources/static/imgs/uploaded/12d8340a_95a8_4454_ba7c_464d89f5bed1.png

47.1 KiB

src/main/resources/static/imgs/uploaded/1318622a_7d76_410a_ad6e_035cff865b2c.png

48.1 KiB

src/main/resources/static/imgs/uploaded/3f583233_0231_42ee_b223_3f05c2fe1a3e.png

106 KiB

src/main/resources/static/imgs/uploaded/4d017978_ae1e_4967_a254_740d30fc26df.png

47.1 KiB

src/main/resources/static/imgs/uploaded/54493b56_6026_4106_ab4e_9f6d48970997.png

114 KiB

src/main/resources/static/imgs/uploaded/695dc059_5ff8_465c_84c3_eb67457d5639.png

47.1 KiB

src/main/resources/static/imgs/uploaded/833354f7_3313_4c1e_9d26_1da535b3c330.png

22.1 KiB

src/main/resources/static/imgs/uploaded/926f948f_cda7_4237_9f65_27edf8f80420.png

48.1 KiB

src/main/resources/static/imgs/uploaded/bc4287af_8ade_4aef_858d_1433e903b507.png

48.1 KiB

src/main/resources/static/imgs/uploaded/dc52767c_6f43_452a_a5a1_bc55d20245ad.png

106 KiB

src/main/resources/static/imgs/uploaded/dc9c4698_3b65_41e6_b1cf_e5a8ca282f3b.png

47.1 KiB

src/main/resources/static/imgs/uploaded/edcce7cd_5066_4f74_bbac_b257dc067e79.png

47.1 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment