inthemoodforcode
inthemoodforcode

Reputation: 1

How to set date & time informations in entity class?

I'm working on a spring boot project nowadays. And I totally love it. I've created my services, entities, repos. Everything seems ok for simple scenarios.

But the thing is , one of my entities has attributes(properties) as follows:

I'm listing my services on swagger ui. When I try to call update service on swagger, lastModifiedDate criteria shouldn't be listed as an input property, I need to handle this property on the back end. Likewise, when I try to add a new user record from swagger, createdDate criteria shouldn't be listed as an input property, I need to handle this property on the back end.

I try to google this, but I couldn't find a relative answer so far. Do you have any recommendations ? Any links, documents. . . Or is it even possible ?

screenshots from swagger-ui :

https://ibb.co/QMWDLjR

https://ibb.co/yqqQWyG

Upvotes: 0

Views: 136

Answers (1)

Sairam Cherupally
Sairam Cherupally

Reputation: 341

It's a good practice to separate entity and api resonse object. That way you can choose what fields to expose to api contract.

So in your case, create a new object without modifedOn and createdOn and use that in your controller

Upvotes: 2

Related Questions