Salut à tous,

Dans mon projet, tout marche mais quand je fais un post sur mon entité Tier, ça me génère l'erreur 415.

Ci-dessous les entités.




Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
 
package bj.prexed.edasta.entity;
 
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Size;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
 
@Data
@Entity
@NoArgsConstructor
@Table(indexes = {@Index(columnList = "designation")}, uniqueConstraints = {@UniqueConstraint(columnNames = {"designation", "succursale_id"})})
public class Tier extends Basentity {
    @Column(name = "reference",length = 15)
    private String reference;
 
    @NotEmpty @Size(min = 2)
    private String designation;
 
    @NotEmpty @Column(nullable = false)
    private String portable;
 
    @Column(columnDefinition = "text")
    private String adresse;
 
    @Email
    private String email;
 
    @Basic
    private String siteweb, rc, ifu;
 
    @ManyToOne @JsonIgnore
    private Succursale succursale;
 
    @OneToMany(mappedBy = "tier") @JsonIgnore
    private Set<ChallengeCli>challengeClis;
 
    @OneToOne(mappedBy = "tier") @JsonIgnore
    private DetailChallengeGrpe detailChallientGrp;
 
 
 
    @OneToMany(mappedBy = "tier", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    private Set<TClient> tClients = new HashSet<>();
 
 
 
 
    public void settclients(Set<TClient> tClients){
 
 
        for (TClient tClient : tClients) setTclient(tClient);
 
    }
 
 
 
    private void setTclient(TClient tClient) {
        if(!tClients.contains(tClient)) {
            if (tClient.getTier() == this) tClient.setTier(null);
            else {
                tClient.setTier(this);
                tClients.add(tClient);
            }
        } else if (tClient.getTier() != this) tClients.remove(tClient);
    }
 
 
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Tier)) return false;
        if (!super.equals(o)) return false;
        Tier t = (Tier) o;
        return reference.equals(t.reference) &&
                Objects.equals(designation, t.designation) &&
                portable.equals(t.portable) &&
                email.equals(t.email) &&
                Objects.equals(rc, t.rc) &&
                Objects.equals(ifu, t.ifu) &&
                Objects.equals(tClients, t.tClients) &&
                Objects.equals(succursale, t.succursale);
 
    }
 
    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), reference, portable, email, rc,ifu, succursale, tClients);
    }
}

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
 
package bj.prexed.edasta.entity;
 
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.NoArgsConstructor;
 
import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;
 
@Data
@Entity
@NoArgsConstructor
public class TClient implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
 
    @Column
    private String nemoney, nevd;
 
    @Column(nullable = false)
    private String natureTVA;
 
   @ManyToOne
    private Tier tier;
 
    @JsonBackReference
    @ManyToOne(fetch = FetchType.EAGER)
    private Reglemode reglemode;
 
    @JsonBackReference
    @ManyToOne(fetch = FetchType.EAGER)
    private Clientype clientype;
 
    @JsonBackReference
    @ManyToOne(fetch = FetchType.EAGER)
    private Entrepot entrepot;
 
    @ManyToOne @JsonIgnore
    private Personne personne;
 
    @ManyToOne @JsonIgnore
    private Secteur secteur;
 
    @Basic
    private Boolean divers, blocked, facturedTTC, representant,isVM, isAgentPoint, isMomoPoint;
 
    private double creanceAutorise, moyenneCA;
 
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof TClient)) return false;
        TClient t = (TClient) o;
        return
                id.equals(t.id)
                        && nemoney.equals(t.nemoney)
                        && Objects.equals(tier, t.tier)
                        && Objects.equals(reglemode, t.reglemode)
                        && Objects.equals(secteur, t.secteur);
    }
 
    @Override
    public int hashCode() {
        return Objects.hash(id
                , nemoney
                , tier
                , reglemode
                , secteur);
    }
}
Controller Tier
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package bj.prexed.edasta.controller;
 
import bj.prexed.edasta.entity.Personne;
import bj.prexed.edasta.entity.Tier;
import bj.prexed.edasta.exception.ResourceNotFoundException;
import bj.prexed.edasta.service.TierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import javax.validation.Valid;
 
@Validated
@RestController
@RequestMapping("tiers")
public class TierController {
    @Autowired
    private TierService service;
 
    @GetMapping
    public ResponseEntity<Page<Tier>> getAll(@PageableDefault Pageable pageable) {
        return ResponseEntity.ok(service.all(current().getSuccursale(), pageable));
    }
 
    @PostMapping
    public ResponseEntity<Tier> post(@RequestBody @Valid Tier tier) {
        tier.setSuccursale(current().getSuccursale());
        return new ResponseEntity<>(service.add(tier), HttpStatus.CREATED);
    }
 
    @GetMapping("/{id:[\\d]+}")
    public ResponseEntity<Tier> get(@PathVariable Long id) {
        return ResponseEntity.ok(service.one(id).orElseThrow(() -> new ResourceNotFoundException("Tier", id)));
    }
 
    @PutMapping("/{id:[\\d]+}")
    public ResponseEntity<Tier> put(@PathVariable Long id, @RequestBody @Valid Tier tier) {
        return new ResponseEntity<>(service.set(id, tier).orElseThrow(() -> new ResourceNotFoundException("Tier", id)), HttpStatus.ACCEPTED);
    }
 
    @DeleteMapping("/{id:[\\d]+}")
    public ResponseEntity<Tier> delete(@PathVariable Long id) {
        return new ResponseEntity<>(service.del(id).orElseThrow(() -> new ResourceNotFoundException("Tier", id)), HttpStatus.NO_CONTENT);
    }
 
    private Personne current() {
        return (Personne) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    }
}
Controller Tclient

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
 
package bj.prexed.edasta.controller;
 
import bj.prexed.edasta.entity.Personne;
import bj.prexed.edasta.entity.TClient;
import bj.prexed.edasta.exception.ResourceNotFoundException;
import bj.prexed.edasta.service.TClientService;
import bj.prexed.edasta.service.TierService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import javax.validation.Valid;
 
@Validated
@RestController
@RequestMapping("tiers/{tiers:[\\d]+}/tclients")
public class TClientController {
 
    private final TClientService service;
    private final TierService tierService;
 
    public TClientController(TClientService service, TierService tierService) {
        this.service = service;
        this.tierService = tierService;
    }
 
    @GetMapping
    public ResponseEntity<Page<TClient>> getAll(@PageableDefault Pageable pageable) {
        return ResponseEntity.ok(service.all(current().getSuccursale(), pageable));
    }
 
 
    @RequestMapping("tiers/{tiers:[\\d]+}/tclients")
    @PostMapping
    public ResponseEntity<TClient> post(@PathVariable Long tier, @RequestBody @Valid TClient tClient) {
        return tierService.one(tier).map(tiers -> {
            tClient.setTier(tiers);
            return new ResponseEntity<>(service.add(tClient), HttpStatus.CREATED);
        }).orElse(ResponseEntity.notFound().build());//.orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND));
    }
 
 
    @GetMapping("/{id:[\\d]+}")
    public ResponseEntity<TClient> get(@PathVariable Long id) {
        return ResponseEntity.ok(service.one(id).orElseThrow(() -> new ResourceNotFoundException("Famille", id)));
    }
 
 
    @PutMapping("/{id:[\\d]+}")
    public ResponseEntity<TClient> put(@PathVariable Long id, @RequestBody @Valid TClient tClient) {
        return new ResponseEntity<>(service.set(id, tClient).orElseThrow(() -> new ResourceNotFoundException("TCLIENT", id)), HttpStatus.ACCEPTED);
    }
 
 
    @DeleteMapping("/{id:[\\d]+}")
    public ResponseEntity<TClient> delete(@PathVariable Long id) {
        return new ResponseEntity<>(service.del(id).orElseThrow(() -> new ResourceNotFoundException("Tclient", id)), HttpStatus.NO_CONTENT);
    }
 
 
    private Personne current() {
        return (Personne) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    }
}
Pièce jointe 527142

Merci de m'apporter votre aide SVP