#MVC

1 messages · Page 1 of 1 (latest)

lost halo
#

Can someone show me a structure in which has a separation in the same project of controllers, services and repositories to final user and to admin use?

I don't like much the idea that I have to create classes like these CategoryAdminRepository, CategoryUserRepository, i would prefer to use the same name CategoryRepository but put in different packages, but apparently it don't work, I don't know if there's another way, how do you guys use to do it?

grizzled graniteBOT
#

<@&987246841693360200> please have a look, thanks.

lost halo
#

I'm doing now like this:

1-
Client

  • controller
    -- admin
    --- ClientAdminController
    -- user
    --- ClientUserController

  • service
    -- admin
    --- ClientAdminService
    -- user
    --- ClientUserService

  • repository
    -- admin
    --- ClientAdminRepository
    -- user
    --- ClientUserRepository

but there is some part of my code that I'm using something like this:

2-
Category (same name but different packages)

  • controller
    -- admin
    --- CategoryController
    -- user
    --- CategoryController

but I'm getting this error: "The bean 'categoriaRepository', defined in br.com.danielschiavo.produto.repository.admin.CategoriaRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration, could not be registered. A bean with that name has already been defined in br.com.danielschiavo.produto.repository.user.CategoriaRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
"

Is the first way I showed the best way to do it ?

hazy crater
#

repositories should be per-entity

#

if those operate on the same entity, they should be merged

#

same for services and controllers

lost halo
#

I don't like the idea

#

I think I will create a separate module for EndUser and AdminUser, and create another one to represent the model

lost halo