Commit a1231b2f by Bright Sukumpanumet

Remove .toString

parent 99535670
...@@ -2253,12 +2253,14 @@ ...@@ -2253,12 +2253,14 @@
"balanced-match": { "balanced-match": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"balanced-match": "^1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
...@@ -2273,17 +2275,20 @@ ...@@ -2273,17 +2275,20 @@
"code-point-at": { "code-point-at": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
...@@ -2400,7 +2405,8 @@ ...@@ -2400,7 +2405,8 @@
"inherits": { "inherits": {
"version": "2.0.3", "version": "2.0.3",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"ini": { "ini": {
"version": "1.3.5", "version": "1.3.5",
...@@ -2412,6 +2418,7 @@ ...@@ -2412,6 +2418,7 @@
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"number-is-nan": "^1.0.0" "number-is-nan": "^1.0.0"
} }
...@@ -2426,6 +2433,7 @@ ...@@ -2426,6 +2433,7 @@
"version": "3.0.4", "version": "3.0.4",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }
...@@ -2433,12 +2441,14 @@ ...@@ -2433,12 +2441,14 @@
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"minipass": { "minipass": {
"version": "2.2.4", "version": "2.2.4",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"safe-buffer": "^5.1.1", "safe-buffer": "^5.1.1",
"yallist": "^3.0.0" "yallist": "^3.0.0"
...@@ -2457,6 +2467,7 @@ ...@@ -2457,6 +2467,7 @@
"version": "0.5.1", "version": "0.5.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
} }
...@@ -2537,7 +2548,8 @@ ...@@ -2537,7 +2548,8 @@
"number-is-nan": { "number-is-nan": {
"version": "1.0.1", "version": "1.0.1",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"object-assign": { "object-assign": {
"version": "4.1.1", "version": "4.1.1",
...@@ -2549,6 +2561,7 @@ ...@@ -2549,6 +2561,7 @@
"version": "1.4.0", "version": "1.4.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"wrappy": "1" "wrappy": "1"
} }
...@@ -2670,6 +2683,7 @@ ...@@ -2670,6 +2683,7 @@
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"code-point-at": "^1.0.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",
......
...@@ -37,11 +37,11 @@ public class BidController ...@@ -37,11 +37,11 @@ public class BidController
return bidService.addBid(bid); return bidService.addBid(bid);
} }
@GetMapping("/email") // JUST FOR TESTING // @GetMapping("/email") // JUST FOR TESTING
public void email() throws UnsupportedEncodingException // public void email() throws UnsupportedEncodingException
{ // {
mailService.sendEmailWithoutTemplating(); // mailService.sendEmailWithoutTemplating();
} // }
@GetMapping("/{userId}") @GetMapping("/{userId}")
public List<Bid> getBidsByUser(@PathVariable Long userId) public List<Bid> getBidsByUser(@PathVariable Long userId)
......
...@@ -35,9 +35,9 @@ public class UserController { ...@@ -35,9 +35,9 @@ public class UserController {
@RequestMapping(method = POST, value = "/register") @RequestMapping(method = POST, value = "/register")
public ResponseEntity<?> addUser(@RequestBody User user, UriComponentsBuilder ucBuilder) { public ResponseEntity<?> addUser(@RequestBody User user, UriComponentsBuilder ucBuilder) {
User existUser = this.userService.findByUserId(user.getUserId().toString()) ; User existUser = this.userService.findByUserId(user.getUserId()) ;
if (existUser != null) { if (existUser != null) {
throw new UserAlreadyExistException(user.getUserId().toString(), "Username already exists"); throw new UserAlreadyExistException(user.getUserId(), "Username already exists");
} }
User new_user = this.userService.register(user); User new_user = this.userService.register(user);
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
...@@ -57,7 +57,7 @@ public class UserController { ...@@ -57,7 +57,7 @@ public class UserController {
* Get user. * Get user.
*/ */
@GetMapping("/{userId}") @GetMapping("/{userId}")
public User getUserById(@PathVariable String userId) public User getUserById(@PathVariable Long userId)
{ {
return userRepository.findById(userId).orElse(null); return userRepository.findById(userId).orElse(null);
} }
......
...@@ -8,7 +8,7 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource; ...@@ -8,7 +8,7 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import java.util.List; import java.util.List;
@RepositoryRestResource @RepositoryRestResource
public interface UserDB extends CrudRepository<User, String> { public interface UserDB extends CrudRepository<User, Long> {
User findByEmail(@Param("email") String email); User findByEmail(@Param("email") String email);
User findByUserId(@Param("user_id") Long userId); User findByUserId(@Param("user_id") Long userId);
......
...@@ -6,13 +6,11 @@ import edu.uchicago.mpcs.topics.auction.Status; ...@@ -6,13 +6,11 @@ import edu.uchicago.mpcs.topics.auction.Status;
import edu.uchicago.mpcs.topics.controller.ItemController; import edu.uchicago.mpcs.topics.controller.ItemController;
import edu.uchicago.mpcs.topics.db.BidRepository; import edu.uchicago.mpcs.topics.db.BidRepository;
import edu.uchicago.mpcs.topics.db.ItemRepository; import edu.uchicago.mpcs.topics.db.ItemRepository;
import edu.uchicago.mpcs.topics.db.UserDB;
import edu.uchicago.mpcs.topics.db.UserRepository; import edu.uchicago.mpcs.topics.db.UserRepository;
import edu.uchicago.mpcs.topics.user.User; import edu.uchicago.mpcs.topics.user.User;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.Optional;
/** /**
* Created by Bright on 2018-11-18. * Created by Bright on 2018-11-18.
...@@ -52,14 +50,14 @@ public class BidService ...@@ -52,14 +50,14 @@ public class BidService
if (itemToUpdate.getStatus() != Status.HASBID) if (itemToUpdate.getStatus() != Status.HASBID)
{ {
User seller = userRepository.findById(itemToUpdate.getSellerId()).orElseThrow(NullPointerException::new); User seller = userRepository.findById(itemToUpdate.getSellerId()).orElseThrow(NullPointerException::new);
mailService.sendEmailfirstBid(seller.getEmail()); mailService.sendEmailFirstBid(seller.getEmail());
} }
//send email to previous bidder //send email to previous bidder
User currentBidder = userRepository.findById(itemToUpdate.getCurrentBidderID()).orElseThrow(NullPointerException::new); User currentBidder = userRepository.findById(itemToUpdate.getCurrentBidderID()).orElseThrow(NullPointerException::new);
mailService.sendEmailoutBid(currentBidder.getEmail()); mailService.sendEmailOutBid(currentBidder.getEmail());
//Assign highest bidder and set status //Assign highest bidder and set status
itemToUpdate.setCurrentBidderID(bid.getUserId()); itemToUpdate.setCurrentBidderID(bid.getUserId());
......
...@@ -2,7 +2,6 @@ package edu.uchicago.mpcs.topics.service; ...@@ -2,7 +2,6 @@ package edu.uchicago.mpcs.topics.service;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import edu.uchicago.mpcs.topics.auction.Item;
import it.ozimov.springboot.mail.model.Email; import it.ozimov.springboot.mail.model.Email;
import it.ozimov.springboot.mail.model.defaultimpl.DefaultEmail; import it.ozimov.springboot.mail.model.defaultimpl.DefaultEmail;
import it.ozimov.springboot.mail.service.EmailService; import it.ozimov.springboot.mail.service.EmailService;
...@@ -22,23 +21,23 @@ public class MailService ...@@ -22,23 +21,23 @@ public class MailService
@Autowired @Autowired
public EmailService emailService; public EmailService emailService;
public void sendEmailoutBid(String emailAddress) throws UnsupportedEncodingException public void sendEmailOutBid(String emailAddress) throws UnsupportedEncodingException
{ {
// this.sendEmailWithoutTemplating(); // this.sendEmailWithoutTemplating();
} }
public void sendEmailfirstBid(String emailAddress) throws UnsupportedEncodingException public void sendEmailFirstBid(String emailAddress) throws UnsupportedEncodingException
{ {
// this.sendEmailWithoutTemplating(); // this.sendEmailWithoutTemplating();
} }
public void sendEmailWithoutTemplating() throws UnsupportedEncodingException public void sendEmailWithoutTemplating(String emailAddress, String body) throws UnsupportedEncodingException
{ {
final Email email = DefaultEmail.builder() final Email email = DefaultEmail.builder()
.from(new InternetAddress("topicsauction@gmail.com", "Topics Auction")) .from(new InternetAddress("topicsauction@gmail.com", "Topics Auction"))
.to(Lists.newArrayList(new InternetAddress("topicsauction@gmail.com", "Pomponius Attĭcus"))) .to(Lists.newArrayList(new InternetAddress("topicsauction@gmail.com", "Pomponius Attĭcus")))
.subject("You have been outbid!") .subject("You have been outbid!")
.body("Firmamentum autem stabilitatis constantiaeque eius, quam in amicitia quaerimus, fides est.") .body("Sent to " + emailAddress + body)
.encoding("UTF-8").build(); .encoding("UTF-8").build();
emailService.send(email); emailService.send(email);
......
package edu.uchicago.mpcs.topics.user;
import edu.uchicago.mpcs.topics.auction.Item;
import java.util.List;
//
//public class WatchList {
// private List<Item> items;
//
// public List<Item> getItems() {
// return items;
// }
//
// public void setItems(List<Item> items) {
// this.items = items;
// }
//}
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment