完成Bean改造
This commit is contained in:
@@ -34,7 +34,7 @@ public class SwaggerConfig {
|
||||
|
||||
private ApiInfo apiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title("Book API")
|
||||
.title("BookVO API")
|
||||
.description("Bill接口")
|
||||
.termsOfServiceUrl("http://fairy8.cn")
|
||||
.contact(new Contact("Alawn","fairy8.cn","alawn.cn@gmail.com"))
|
||||
|
||||
@@ -93,7 +93,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.and()
|
||||
.authorizeRequests()
|
||||
.antMatchers("/").permitAll()
|
||||
.antMatchers("/druid/**").permitAll()
|
||||
.antMatchers("/test/**").permitAll() // 测试用
|
||||
.antMatchers("/druid/**").permitAll() // 阿里Druid
|
||||
.antMatchers("/swagger*").permitAll()
|
||||
.antMatchers( HttpMethod.GET, "/","/*.html", "/favicon.ico", "/**/*.html", "/**/*.css", "/**/*.js").permitAll()
|
||||
// .antMatchers("/resources/**").permitAll()
|
||||
@@ -170,5 +171,4 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
// // 使用自定义身份验证组件
|
||||
// auth.authenticationProvider(new CustomAuthenticationProvider(userDetailsService));
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.alawn.bill.controller;
|
||||
|
||||
import net.alawn.bill.entity.dto.AddUser;
|
||||
import net.alawn.bill.entity.dto.NewUser;
|
||||
import net.alawn.bill.security.JwtAuthenticationRequest;
|
||||
import net.alawn.bill.security.JwtAuthenticationResponse;
|
||||
import net.alawn.bill.service.AuthService;
|
||||
@@ -52,7 +52,7 @@ public class AuthController {
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/auth/register", method = RequestMethod.POST)
|
||||
public AddUser register(@RequestBody AddUser addedUser) throws AuthenticationException, HttpRequestMethodNotSupportedException {
|
||||
public NewUser register(@RequestBody NewUser addedUser) throws AuthenticationException, HttpRequestMethodNotSupportedException {
|
||||
return authService.register(addedUser);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package net.alawn.bill.controller;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.alawn.bill.entity.dto.AddMerchant;
|
||||
import net.alawn.bill.entity.dto.AddPost;
|
||||
import net.alawn.bill.entity.dto.AddTitle;
|
||||
import net.alawn.bill.entity.dto.NewMerchant;
|
||||
import net.alawn.bill.entity.dto.NewPost;
|
||||
import net.alawn.bill.entity.dto.NewTitle;
|
||||
import net.alawn.bill.entity.po.*;
|
||||
import net.alawn.bill.repository.*;
|
||||
import net.alawn.bill.security.AuthUser;
|
||||
@@ -12,7 +12,6 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.security.Principal;
|
||||
import java.util.List;
|
||||
@@ -50,12 +49,12 @@ public class BasicController {
|
||||
|
||||
@RequestMapping(value = "/posts",method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public ResponseEntity<Post> addPost(@RequestBody AddPost addPost, Principal principal) throws URISyntaxException {
|
||||
public ResponseEntity<Post> addPost(@RequestBody NewPost newPost, Principal principal) throws URISyntaxException {
|
||||
AuthUser authUser = (AuthUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
long userId = authUser.getId();
|
||||
|
||||
/** 登记 Post */
|
||||
Post post = addPost.build();
|
||||
Post post = newPost.build();
|
||||
post.setUserId(userId);
|
||||
postRepo.save(post);
|
||||
postRepo.flush();
|
||||
@@ -91,9 +90,9 @@ public class BasicController {
|
||||
|
||||
@RequestMapping(value = "/merchants",method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public ResponseEntity<Merchant> addMerchant(@RequestBody AddMerchant addMerchant) throws URISyntaxException {
|
||||
public ResponseEntity<Merchant> addMerchant(@RequestBody NewMerchant newMerchant) throws URISyntaxException {
|
||||
/** 登记 Post */
|
||||
Merchant merchant = merchantRepo.save(addMerchant.build());
|
||||
Merchant merchant = merchantRepo.save(newMerchant.build());
|
||||
merchantRepo.flush();
|
||||
return ResponseEntity.ok(merchant);
|
||||
}
|
||||
@@ -121,9 +120,9 @@ public class BasicController {
|
||||
|
||||
@RequestMapping(value = "/titles",method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public ResponseEntity<Title> addTitle(@RequestBody AddTitle addTitle) {
|
||||
public ResponseEntity<Title> addTitle(@RequestBody NewTitle newTitle) {
|
||||
/** 登记 Title */
|
||||
Title title = titleRepo.save(addTitle.build());
|
||||
Title title = titleRepo.save(newTitle.build());
|
||||
titleRepo.flush();
|
||||
return ResponseEntity.ok(title);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package net.alawn.bill.controller;
|
||||
|
||||
import net.alawn.bill.entity.dto.AddBill;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.alawn.bill.entity.dto.NewBill;
|
||||
import net.alawn.bill.entity.po.Book;
|
||||
import net.alawn.bill.entity.po.Item;
|
||||
import net.alawn.bill.enums.State;
|
||||
import net.alawn.bill.entity.po.User;
|
||||
import net.alawn.bill.repository.BookRepo;
|
||||
import net.alawn.bill.repository.ItemRepo;
|
||||
import net.alawn.bill.repository.UserRepo;
|
||||
@@ -13,10 +13,7 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.security.Principal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
@@ -26,7 +23,8 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
|
||||
|
||||
@RequestMapping(value = "/bills")
|
||||
@Slf4j
|
||||
@RequestMapping(value = "/bill")
|
||||
@RestController
|
||||
public class BillController {
|
||||
|
||||
@@ -39,24 +37,34 @@ public class BillController {
|
||||
@Autowired
|
||||
UserRepo userRepo;
|
||||
|
||||
@RequestMapping(value = "/",method = RequestMethod.POST)
|
||||
public ResponseEntity<Book> addBook(@RequestBody AddBill addBill, Principal principal){
|
||||
@RequestMapping(value = "/books",method = RequestMethod.POST)
|
||||
public ResponseEntity<Book> newBook(@RequestBody NewBill newBill){
|
||||
AuthUser authUser = (AuthUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
long userId = authUser.getId();
|
||||
|
||||
/** 登记 book */
|
||||
Book book = bookRepo.save(new Book(userId, addBill.getPostId(), State.APPLIED,new Date(),null));
|
||||
log.info("newBill:" + newBill);
|
||||
|
||||
/** DTO -> PO 转换 */
|
||||
List<Item> items = addBill.getBillItems()
|
||||
.stream()
|
||||
.map(bill -> new Item(book.getId(),bill.getDating(),bill.getTitleId(),bill.getMerchantId(),bill.getAmount()))
|
||||
.collect(Collectors.toList());
|
||||
Book book = newBill.toBook();
|
||||
|
||||
/** 登记 item */
|
||||
itemRepo.saveAll(items);
|
||||
book.setUser(new User(userId));
|
||||
log.info("book:" + book);
|
||||
bookRepo.save(book);
|
||||
log.info("book:" + book);
|
||||
bookRepo.flush();
|
||||
itemRepo.flush();
|
||||
|
||||
bookRepo.sumAmount(book.getId());
|
||||
|
||||
return ResponseEntity.ok(book);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/books",method = RequestMethod.GET)
|
||||
public ResponseEntity<List<Book>> fetchBooks(){
|
||||
AuthUser authUser = (AuthUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
long userId = authUser.getId();
|
||||
|
||||
List<Book> books = bookRepo.findByUserId(userId);
|
||||
|
||||
return ResponseEntity.ok(books);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
package net.alawn.bill.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.alawn.bill.entity.po.*;
|
||||
import net.alawn.bill.enums.State;
|
||||
import net.alawn.bill.repository.*;
|
||||
import net.alawn.bill.security.AuthUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 09:59 2019-05-23
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@RequestMapping(value = "/test")
|
||||
@RestController
|
||||
public class TestController {
|
||||
|
||||
@Autowired
|
||||
MainRepo mainRepo;
|
||||
@Autowired
|
||||
DetailRepo detailRepo;
|
||||
@Autowired
|
||||
UserRepo userRepo;
|
||||
@Autowired
|
||||
MerchantRepo merchantRepo;
|
||||
@Autowired
|
||||
TitleRepo titleRepo;
|
||||
@Autowired
|
||||
EntityManager entityManager;
|
||||
|
||||
@RequestMapping(value = "/mains",method = RequestMethod.POST)
|
||||
public ResponseEntity<?> main(){
|
||||
User user = userRepo.findByUsername("alawn");
|
||||
|
||||
log.info("user:" + user);
|
||||
|
||||
|
||||
Merchant merc = Merchant.builder().abbr("商户简称").name("商户名称").build();
|
||||
merc.setId(22l);
|
||||
|
||||
Title title = Title.builder().abbr("北京沐融").name("北京沐融信息科技有限公司").taxNo("2019230901258").build();
|
||||
title.setId(25l);
|
||||
|
||||
Post post = Post.builder().address("世博馆路52号").contact("alawn").mobile("18017581610").userId(user.getId()).build();
|
||||
post.setId(32l);
|
||||
|
||||
Detail detail1 = new Detail();
|
||||
detail1.setAmount(new BigDecimal(3.00));
|
||||
detail1.setMerchant(merc);
|
||||
detail1.setTitle(title);
|
||||
detail1.setDating(new Date());
|
||||
Detail detail2 = new Detail();
|
||||
detail2.setAmount(new BigDecimal(5.00));
|
||||
detail2.setMerchant(merc);
|
||||
detail2.setTitle(title);
|
||||
detail2.setDating(new Date());
|
||||
|
||||
// Set<Detail> details = new HashSet() ;
|
||||
// List<Detail> details = new ArrayList<>() ;
|
||||
// details.add(detail1);
|
||||
// details.add(detail2);
|
||||
// details.add(detail3);
|
||||
|
||||
|
||||
Main main = new Main();
|
||||
|
||||
main.setApplyDate(new Date());
|
||||
main.setAcceptDate(new Date());
|
||||
main.setState(State.APPLIED);
|
||||
main.setUser(user);
|
||||
main.setPost(post);
|
||||
main.addDetail(detail1);
|
||||
main.addDetail(detail2);
|
||||
log.info("main.id:" + main);
|
||||
mainRepo.save(main);
|
||||
mainRepo.flush();
|
||||
main.setAcceptDate(new Date());
|
||||
|
||||
Post post2 = Post.builder().address("世博馆路12号").contact("alawn").mobile("18017581610").userId(user.getId()).build();
|
||||
post2.setId(32l);
|
||||
// post2.setId(33l);
|
||||
|
||||
main.setPost(post2);
|
||||
mainRepo.save(main);
|
||||
mainRepo.flush();
|
||||
|
||||
|
||||
// Long mainId = main.getId();
|
||||
log.info("main:" + main);
|
||||
|
||||
// List<Main> result = mainRepo.findAll();
|
||||
//// log.info("result:" + JSON.toJSONString(result,true));
|
||||
//
|
||||
//
|
||||
// Main rs = entityManager.find(Main.class,mainId);
|
||||
// log.info("rs:" + rs);
|
||||
|
||||
|
||||
// log.info("details:" + details);
|
||||
// detailRepo.saveAll(details);
|
||||
// detailRepo.flush();
|
||||
|
||||
|
||||
// Optional<Main> main1 = mainRepo.findById(mainId);
|
||||
// log.info("is exists:" + mainRepo.existsById(mainId));
|
||||
////
|
||||
// if(main1.isPresent()) {
|
||||
// log.info("main:" + main1.get());
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// log.info("no data");
|
||||
// }
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/mains",method = RequestMethod.GET)
|
||||
public ResponseEntity<List<Main>> mains(){
|
||||
List<Main> result = mainRepo.findAll();
|
||||
log.info("result.size:" + result.size());
|
||||
return ResponseEntity.ok(result);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/details",method = RequestMethod.GET)
|
||||
public ResponseEntity<List<Detail>> details(){
|
||||
List<Detail> result = detailRepo.findAll();
|
||||
log.info("result.size:" + result.size());
|
||||
// log.info("result:" + JSON.toJSONString(result,true));
|
||||
log.info("result:" + result);
|
||||
return ResponseEntity.ok(result);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package net.alawn.bill.entity.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 10:47 2019-05-23
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class AddBill {
|
||||
private long postId;
|
||||
List<BillItem> billItems;
|
||||
}
|
||||
@@ -13,8 +13,8 @@ import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class BillItem {
|
||||
private Date dating;
|
||||
private long titleId;
|
||||
private long merchantId;
|
||||
private BigDecimal amount;
|
||||
private Date dating ;
|
||||
private long titleId ;
|
||||
private long merchantId ;
|
||||
private BigDecimal amount ;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package net.alawn.bill.entity.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import net.alawn.bill.entity.po.*;
|
||||
import net.alawn.bill.enums.State;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 10:47 2019-05-23
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class NewBill {
|
||||
|
||||
private long postId ;
|
||||
private List<BillItem> billItems ;
|
||||
|
||||
public Book toBook() {
|
||||
Book book = new Book();
|
||||
book.setApplyDate(new Date());
|
||||
book.setPost(new Post(postId));
|
||||
book.setState(State.APPLIED);
|
||||
|
||||
// List<Item> items = new ArrayList<>();
|
||||
// for(BillItem rq: itemRQs){
|
||||
// Item item = new Item();
|
||||
// item.setDating(rq.getDating());
|
||||
// item.setAmount(rq.getAmount());
|
||||
// item.setMerchant(new Merchant(rq.getMerchantId()));
|
||||
// item.setTitle(new Title(rq.getTitleId()));
|
||||
// items.add(item);
|
||||
// }
|
||||
|
||||
/** 使用Java8 的stram写法 */
|
||||
List<Item> bookItems = billItems
|
||||
.stream()
|
||||
.map(rq -> new Item(book,new Title(rq.getTitleId()),new Merchant(rq.getMerchantId()),rq.getDating(),rq.getAmount()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
book.setItems(bookItems);
|
||||
return book;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -9,7 +9,7 @@ import net.alawn.bill.entity.po.Merchant;
|
||||
* @Date: Create in 15:21 2019-05-23
|
||||
*/
|
||||
@Data
|
||||
public class AddMerchant {
|
||||
public class NewMerchant {
|
||||
private String abbr;
|
||||
private String name;
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import net.alawn.bill.entity.po.Post;
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class AddPost {
|
||||
public class NewPost {
|
||||
private String address ;
|
||||
private String contact ;
|
||||
private String mobile ;
|
||||
+1
-1
@@ -12,7 +12,7 @@ import java.util.List;
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class AddTitle {
|
||||
public class NewTitle {
|
||||
private String name;
|
||||
private String abbr;
|
||||
private String taxNo;
|
||||
+1
-1
@@ -6,7 +6,7 @@ import net.alawn.bill.entity.po.User;
|
||||
|
||||
@Value
|
||||
@Builder
|
||||
public class AddUser {
|
||||
public class NewUser {
|
||||
|
||||
private String username;
|
||||
private String password;
|
||||
@@ -1,6 +1,8 @@
|
||||
package net.alawn.bill.entity.po;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.*;
|
||||
import org.hibernate.annotations.DynamicUpdate;
|
||||
import org.hibernate.annotations.NotFound;
|
||||
import org.hibernate.annotations.NotFoundAction;
|
||||
|
||||
@@ -14,7 +16,9 @@ import java.io.Serializable;
|
||||
@ToString(exclude = {"user"})
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Authority{
|
||||
@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" },ignoreUnknown = true)
|
||||
@DynamicUpdate
|
||||
public class Authority implements Serializable{
|
||||
|
||||
@EmbeddedId
|
||||
private AuthorityId id;
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
package net.alawn.bill.entity.po;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.*;
|
||||
import net.alawn.bill.enums.State;
|
||||
import org.hibernate.annotations.DynamicUpdate;
|
||||
import org.hibernate.annotations.NotFound;
|
||||
import org.hibernate.annotations.NotFoundAction;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.Table;
|
||||
import java.util.Date;
|
||||
import javax.persistence.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
@@ -22,14 +25,40 @@ import java.util.Date;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class Book extends Base{
|
||||
@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" },ignoreUnknown = true)
|
||||
@DynamicUpdate
|
||||
public class Book extends EntityId {
|
||||
@JsonIgnore
|
||||
@ManyToOne
|
||||
@NotFound(action= NotFoundAction.IGNORE)
|
||||
@JoinColumn(name = "userId",foreignKey = @ForeignKey(name = "none",value = ConstraintMode.NO_CONSTRAINT))
|
||||
private User user;
|
||||
|
||||
private long userId;
|
||||
private long postId;
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "postId",foreignKey = @ForeignKey(name = "none",value = ConstraintMode.NO_CONSTRAINT))
|
||||
@NotFound(action= NotFoundAction.IGNORE)
|
||||
private Post post;
|
||||
|
||||
@OneToMany(cascade=CascadeType.ALL, mappedBy = "book", orphanRemoval = true)
|
||||
@org.hibernate.annotations.ForeignKey(name = "none")
|
||||
@NotFound(action= NotFoundAction.IGNORE)
|
||||
private List<Item> items = new ArrayList<>();
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private State state;
|
||||
|
||||
private Date applyDate;
|
||||
private Date acceptDate;
|
||||
private Date applyDate ;
|
||||
private Date acceptDate ;
|
||||
private BigDecimal totalAmount ;
|
||||
|
||||
public void addItem(Item item) {
|
||||
item.setBook(this);
|
||||
this.items.add(item);
|
||||
}
|
||||
|
||||
public void removeItem(Item item) {
|
||||
item.setBook(null);
|
||||
items.remove(item);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
package net.alawn.bill.entity.po;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.*;
|
||||
import org.hibernate.annotations.DynamicUpdate;
|
||||
import org.hibernate.annotations.NotFound;
|
||||
import org.hibernate.annotations.NotFoundAction;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 10:53 2019-05-23
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "t_bill_detail")
|
||||
@Data
|
||||
@ToString(exclude = {"main"})
|
||||
//@AllArgsConstructor
|
||||
//@NoArgsConstructor
|
||||
//@Builder
|
||||
@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" },ignoreUnknown = true)
|
||||
@DynamicUpdate
|
||||
public class Detail extends EntityId {
|
||||
|
||||
public Detail (Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
public Detail () {
|
||||
}
|
||||
|
||||
// @NotFound(action = NotFoundAction.IGNORE)
|
||||
// @MapsId("id")
|
||||
// @ManyToOne(cascade={CascadeType.MERGE,CascadeType.REFRESH},optional=false) // 可选属性optional=false,表示author不能为空。删除文章,不影响用户
|
||||
// @JoinColumn(name="main_id",)//设置在article表中的关联字段(外键)
|
||||
// @MapsId("id")
|
||||
// @NotFound(action = NotFoundAction.IGNORE)
|
||||
|
||||
|
||||
/** OK */
|
||||
@JsonIgnore
|
||||
// @ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY)
|
||||
@ManyToOne(fetch=FetchType.LAZY,cascade = CascadeType.REFRESH)
|
||||
@JoinColumn(name = "mainId",foreignKey = @ForeignKey(name = "none",value = ConstraintMode.NO_CONSTRAINT))
|
||||
private Main main;
|
||||
|
||||
|
||||
// @ManyToOne(fetch = FetchType.LAZY)
|
||||
// @NotFound(action = NotFoundAction.IGNORE)
|
||||
//// @JoinColumn(name = "userId", referencedColumnName = "id")
|
||||
// @JoinColumn(name = "userId", referencedColumnName = "id")
|
||||
//// @MapsId("username")
|
||||
// @MapsId("id")
|
||||
// private User user;
|
||||
//
|
||||
|
||||
private Date dating;
|
||||
|
||||
// @OneToOne(cascade= CascadeType.REFRESH,fetch=FetchType.LAZY)
|
||||
// @NotFound(action = NotFoundAction.IGNORE)
|
||||
// @MapsId("id")
|
||||
// @ManyToOne(fetch=FetchType.LAZY)
|
||||
@OneToOne(fetch=FetchType.LAZY)
|
||||
@JoinColumn(name="titleId",foreignKey = @ForeignKey(name = "none",value = ConstraintMode.NO_CONSTRAINT))//设置在article表中的关联字段(外键)
|
||||
@NotFound(action = NotFoundAction.IGNORE)
|
||||
private Title title;
|
||||
|
||||
// @OneToOne(cascade= CascadeType.REFRESH,fetch=FetchType.LAZY)
|
||||
// @NotFound(action = NotFoundAction.IGNORE)
|
||||
// @MapsId("id")
|
||||
// @ManyToOne(fetch=FetchType.LAZY)
|
||||
@JsonIgnore
|
||||
@OneToOne(fetch=FetchType.LAZY)
|
||||
@JoinColumn(name="merchantId",foreignKey = @ForeignKey(name = "none",value = ConstraintMode.NO_CONSTRAINT))//设置在article表中的关联字段(外键)
|
||||
@NotFound(action = NotFoundAction.IGNORE)
|
||||
private Merchant merchant;
|
||||
|
||||
private BigDecimal amount;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof Detail )) return false;
|
||||
return id != null && id.equals(((Detail) o).id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 31;
|
||||
}
|
||||
}
|
||||
+18
-11
@@ -1,16 +1,14 @@
|
||||
package net.alawn.bill.entity.po;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import net.alawn.bill.security.AuthUser;
|
||||
import org.springframework.data.annotation.*;
|
||||
import org.springframework.data.annotation.Version;
|
||||
import org.springframework.data.annotation.*;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -20,15 +18,14 @@ import java.util.Date;
|
||||
|
||||
@Data
|
||||
@MappedSuperclass
|
||||
@Accessors(chain = true)
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
public class Base implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" },ignoreUnknown = true)
|
||||
public class EntityId implements Serializable {
|
||||
protected static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private long id;
|
||||
protected Long id;
|
||||
|
||||
// @Temporal(TemporalType.TIMESTAMP)
|
||||
// @CreationTimestamp
|
||||
@@ -61,5 +58,15 @@ public class Base implements Serializable {
|
||||
protected Long version;
|
||||
|
||||
|
||||
|
||||
// @Override
|
||||
// public boolean equals(Object o) {
|
||||
// if (this == o) return true;
|
||||
// if (!(o instanceof Detail )) return false;
|
||||
// return id != null && id.equals(((Detail) o).id);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int hashCode() {
|
||||
// return 31;
|
||||
// }
|
||||
}
|
||||
@@ -1,9 +1,13 @@
|
||||
package net.alawn.bill.entity.po;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.*;
|
||||
import org.hibernate.annotations.DynamicUpdate;
|
||||
import org.hibernate.annotations.NotFound;
|
||||
import org.hibernate.annotations.NotFoundAction;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -15,14 +19,46 @@ import java.util.Date;
|
||||
@Entity
|
||||
@Table(name = "t_bill_items")
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
@ToString(exclude = {"book"})
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class Item extends Base{
|
||||
private long bookId;
|
||||
@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" },ignoreUnknown = true)
|
||||
@DynamicUpdate
|
||||
public class Item extends EntityId {
|
||||
|
||||
public Item(Book book)
|
||||
{ this.book = book; }
|
||||
|
||||
/** OK */
|
||||
@JsonIgnore
|
||||
@ManyToOne(fetch= FetchType.LAZY,cascade = CascadeType.MERGE,optional = false)
|
||||
@JoinColumn(name = "bookId",referencedColumnName = "id",foreignKey = @ForeignKey(name = "none",value = ConstraintMode.NO_CONSTRAINT))
|
||||
private Book book;
|
||||
|
||||
@OneToOne(fetch=FetchType.LAZY)
|
||||
@JoinColumn(name="titleId",foreignKey = @ForeignKey(name = "none",value = ConstraintMode.NO_CONSTRAINT))
|
||||
@NotFound(action = NotFoundAction.IGNORE)
|
||||
private Title title;
|
||||
|
||||
|
||||
@OneToOne(fetch=FetchType.LAZY)
|
||||
@JoinColumn(name="merchantId",foreignKey = @ForeignKey(name = "none",value = ConstraintMode.NO_CONSTRAINT))
|
||||
@NotFound(action = NotFoundAction.IGNORE)
|
||||
private Merchant merchant;
|
||||
|
||||
private Date dating;
|
||||
private long titleId;
|
||||
private long merchantId;
|
||||
private BigDecimal amount;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof Item )) return false;
|
||||
return id != null && id.equals(((Item) o).id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 31;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
package net.alawn.bill.entity.po;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.*;
|
||||
import net.alawn.bill.enums.State;
|
||||
import org.hibernate.annotations.DynamicUpdate;
|
||||
import org.hibernate.annotations.NotFound;
|
||||
import org.hibernate.annotations.NotFoundAction;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 10:06 2019-05-23
|
||||
*/
|
||||
|
||||
@Entity
|
||||
@Table(name="t_bill_main")
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" },ignoreUnknown = true)
|
||||
@DynamicUpdate
|
||||
//@ToString(exclude = {"details"})
|
||||
public class Main extends EntityId {
|
||||
|
||||
// @OneToOne(cascade=CascadeType.ALL,fetch=FetchType.LAZY)
|
||||
// @OneToOne(fetch=FetchType.LAZY)
|
||||
// @NotFound(action = NotFoundAction.IGNORE)
|
||||
// @MapsId("id")
|
||||
@JsonIgnore
|
||||
@ManyToOne
|
||||
@NotFound(action= NotFoundAction.IGNORE)
|
||||
@JoinColumn(name = "userId",foreignKey = @ForeignKey(name = "none",value = ConstraintMode.NO_CONSTRAINT))
|
||||
private User user;
|
||||
|
||||
// @OneToOne(mappedBy="id",cascade=CascadeType.ALL,fetch=FetchType.LAZY)
|
||||
// @OneToOne(cascade=CascadeType.ALL,fetch=FetchType.LAZY)
|
||||
// @NotFound(action = NotFoundAction.IGNORE)
|
||||
// @MapsId("id")
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "postId",foreignKey = @ForeignKey(name = "none",value = ConstraintMode.NO_CONSTRAINT))
|
||||
@NotFound(action= NotFoundAction.IGNORE)
|
||||
private Post post;
|
||||
|
||||
// @OneToMany( mappedBy = "main", cascade=CascadeType.ALL,fetch=FetchType.LAZY)
|
||||
// @NotFound(action = NotFoundAction.IGNORE)
|
||||
// @MapsId("id")
|
||||
|
||||
@OneToMany(cascade=CascadeType.ALL, mappedBy = "main", orphanRemoval = true)
|
||||
// @OneToMany(cascade=CascadeType.ALL, orphanRemoval = true)
|
||||
// @JoinColumn(name = "main_id")
|
||||
@org.hibernate.annotations.ForeignKey(name = "none")
|
||||
@NotFound(action= NotFoundAction.IGNORE)
|
||||
private List<Detail> details = new ArrayList<>();
|
||||
|
||||
// @OneToMany(mappedBy = "user", fetch = FetchType.EAGER)
|
||||
// private Set<Authority> authorities;
|
||||
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private State state;
|
||||
|
||||
private Date applyDate;
|
||||
private Date acceptDate;
|
||||
|
||||
public String toJson() {
|
||||
return JSON.toJSONString(this.toString());
|
||||
// return JSON.toJSONString(this.toString(),true);
|
||||
}
|
||||
|
||||
public void addDetail(Detail detail) {
|
||||
detail.setMain(this);
|
||||
this.details.add(detail);
|
||||
}
|
||||
|
||||
public void removeDetail(Detail detail) {
|
||||
detail.setMain(null);
|
||||
details.remove(detail);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.alawn.bill.entity.po;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.*;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
@@ -17,7 +18,12 @@ import javax.persistence.Table;
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Merchant extends Base{
|
||||
@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" },ignoreUnknown = true)
|
||||
public class Merchant extends EntityId {
|
||||
public Merchant(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
private String abbr;
|
||||
private String name;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package net.alawn.bill.entity.po;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.*;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.annotations.DynamicUpdate;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@@ -17,10 +19,18 @@ import javax.persistence.Table;
|
||||
@Table(name = "t_bill_posts")
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Post extends Base{
|
||||
@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" },ignoreUnknown = true)
|
||||
@DynamicUpdate
|
||||
public class Post extends EntityId {
|
||||
|
||||
public Post(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
private long userId ;
|
||||
private String address ;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package net.alawn.bill.entity.po;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.*;
|
||||
import org.hibernate.annotations.DynamicUpdate;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
@@ -17,10 +19,15 @@ import javax.persistence.*;
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Title extends Base{
|
||||
|
||||
@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" },ignoreUnknown = true)
|
||||
@DynamicUpdate
|
||||
public class Title extends EntityId {
|
||||
private String name;
|
||||
private String abbr;
|
||||
@Column(length = 18)
|
||||
private String taxNo;
|
||||
|
||||
public Title(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
package net.alawn.bill.entity.po;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.*;
|
||||
import lombok.experimental.Accessors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.hibernate.annotations.DynamicUpdate;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Alawn
|
||||
@@ -32,7 +29,13 @@ import java.util.stream.Collectors;
|
||||
@AllArgsConstructor
|
||||
@ToString(exclude = {"authorities"})
|
||||
@Slf4j
|
||||
public class User extends Base {
|
||||
@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" },ignoreUnknown = true)
|
||||
@DynamicUpdate
|
||||
public class User extends EntityId {
|
||||
|
||||
public User(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/** 用户名称 */
|
||||
private String username;
|
||||
@@ -62,6 +65,7 @@ public class User extends Base {
|
||||
@Builder.Default
|
||||
private boolean enabled = true;
|
||||
|
||||
|
||||
// public UserDetails toUserDetails() {
|
||||
// log.info("toUserDetails.authorities:" + authorities);
|
||||
// log.info("toUserDetails.authorities:" + mapToGrantedAuthorities(authorities));
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.alawn.bill.entity.vo;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 10:01 2019-05-29
|
||||
*/
|
||||
public class BookVO {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.alawn.bill.entity.vo;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 10:02 2019-05-29
|
||||
*/
|
||||
public class ItemVO {
|
||||
}
|
||||
@@ -2,7 +2,12 @@ package net.alawn.bill.repository;
|
||||
|
||||
import net.alawn.bill.entity.po.Book;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
@@ -10,7 +15,13 @@ import org.springframework.stereotype.Repository;
|
||||
* @Date: Create in 11:14 2019-05-23
|
||||
*/
|
||||
|
||||
@Transactional
|
||||
@Repository
|
||||
public interface BookRepo extends JpaRepository<Book, Long> {
|
||||
|
||||
List<Book> findByUserId(long userId);
|
||||
|
||||
@Modifying
|
||||
@Query(value = "update t_bill_books set total_amount = (select sum(amount) from t_bill_items where book_id = ?1) where id = ?1",nativeQuery = true)
|
||||
void sumAmount(long bookId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package net.alawn.bill.repository;
|
||||
|
||||
import net.alawn.bill.entity.po.Detail;
|
||||
import net.alawn.bill.entity.po.Main;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 11:14 2019-05-23
|
||||
*/
|
||||
|
||||
@Repository
|
||||
public interface DetailRepo extends JpaRepository<Detail, Long> {
|
||||
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import net.alawn.bill.entity.po.Item;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package net.alawn.bill.repository;
|
||||
|
||||
import net.alawn.bill.entity.po.Main;
|
||||
import net.alawn.bill.entity.po.Post;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 11:14 2019-05-23
|
||||
*/
|
||||
|
||||
@Repository
|
||||
public interface MainRepo extends JpaRepository<Main, Long> {
|
||||
List<Main> findByPost(Post post);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.alawn.bill.security;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.alawn.bill.entity.po.User;
|
||||
import net.alawn.bill.repository.UserRepo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -13,6 +14,7 @@ import org.springframework.stereotype.Service;
|
||||
* @Description:
|
||||
* @Date: Create in 16:46 2019-05-20
|
||||
*/
|
||||
@Slf4j
|
||||
@Service("authUserDetailsService")
|
||||
public class AuthUserDetailsServiceImpl implements UserDetailsService {
|
||||
|
||||
@@ -24,6 +26,8 @@ public class AuthUserDetailsServiceImpl implements UserDetailsService {
|
||||
|
||||
User user = userRepo.findByUsername(name);
|
||||
|
||||
log.info("loadUserByUsername:" + user);
|
||||
|
||||
if (user == null) {
|
||||
throw new UsernameNotFoundException("UsernameNotFoundException");
|
||||
} else {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.alawn.bill.service;
|
||||
|
||||
import net.alawn.bill.entity.dto.AddUser;
|
||||
import net.alawn.bill.entity.dto.NewUser;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
* @Date: Create in 15:58 2019-05-20
|
||||
*/
|
||||
public interface AuthService {
|
||||
AddUser register(AddUser userDTO) throws HttpRequestMethodNotSupportedException, AuthenticationException;
|
||||
NewUser register(NewUser userDTO) throws HttpRequestMethodNotSupportedException, AuthenticationException;
|
||||
String login(String username, String password);
|
||||
String refresh(String oldToken);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.alawn.bill.service.impl;
|
||||
|
||||
import net.alawn.bill.entity.dto.AddUser;
|
||||
import net.alawn.bill.entity.dto.NewUser;
|
||||
import net.alawn.bill.entity.po.Authority;
|
||||
import net.alawn.bill.entity.po.AuthorityId;
|
||||
import net.alawn.bill.entity.po.User;
|
||||
@@ -61,7 +61,7 @@ public class AuthServiceImpl implements AuthService {
|
||||
// }
|
||||
|
||||
@Override
|
||||
public AddUser register(AddUser userDTO) throws AuthenticationException {
|
||||
public NewUser register(NewUser userDTO) throws AuthenticationException {
|
||||
final String username = userDTO.getUsername();
|
||||
|
||||
if(userRepo.findByUsername(username) != null) {
|
||||
@@ -110,7 +110,7 @@ public class AuthServiceImpl implements AuthService {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void authenticateUser(AddUser userDTO) {
|
||||
private void authenticateUser(NewUser userDTO) {
|
||||
UsernamePasswordAuthenticationToken upToken = new UsernamePasswordAuthenticationToken(userDTO.getUsername(), userDTO.getPassword());
|
||||
// 进行安全认证
|
||||
final Authentication authentication = authenticationManager.authenticate(upToken);
|
||||
|
||||
Reference in New Issue
Block a user