// Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/entity/Client.java
// public class Client extends BasicEntity {
//     private static final long serialVersionUID = 1534976572117011533L;
//     private String clientId;
//     private String clientName;
//     private String clientSecret;
// 
//     public String getClientId() {
//         return clientId;
//     }
// 
//     public void setClientId(String clientId) {
//         this.clientId = clientId;
//     }
// 
//     public String getClientName() {
//         return clientName;
//     }
// 
//     public void setClientName(String clientName) {
//         this.clientName = clientName;
//     }
// 
//     public String getClientSecret() {
//         return clientSecret;
//     }
// 
//     public void setClientSecret(String clientSecret) {
//         this.clientSecret = clientSecret;
//     }
// 
//     @Override
//     public String toString() {
//         return "Client [clientId=" + clientId + ", clientName=" + clientName + ", clientSecret=" + clientSecret + "]";
//     }
// }
// 
// Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/resource/ClientResource.java
// public class ClientResource extends Resource<Client> {
//     public ClientResource(Client client) {
//         super(client);
//     }
// }
// 
// Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/resource/ClientResourceAssembler.java
// public class ClientResourceAssembler extends ResourceAssemblerSupport<Client, ClientResource> {
// 
//     public ClientResourceAssembler() {
//         super(ClientController.class, ClientResource.class);
//     }
// 
//     @Override
//     public ClientResource toResource(Client entity) {
//         ClientResource resource = createResourceWithId(entity.getId(), entity);
//         return resource;
//     }
// 
//     @Override
//     protected ClientResource instantiateResource(Client entity) {
//         return new ClientResource(entity);
//     }
// }
// 
// Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/service/ClientService.java
// @Service
// public class ClientService {
//     @Autowired
//     private ClientDao clientDao;
// 
//     public int save(Client client) {
//         client.setClientId(UUID.randomUUID().toString());
//         client.setClientSecret(UUID.randomUUID().toString());
//         return clientDao.save(client);
//     }
// 
//     public int update(Client client) {
//         return clientDao.update(client);
//     }
// 
//     public int delete(Long id) {
//         return clientDao.delete(id);
//     }
// 
//     public int deleteBatch(List<Long> ids) {
//         return clientDao.deleteBatch(ids);
//     }
// 
//     public Client findOne(Long id) {
//         return clientDao.findOne(id);
//     }
// 
//     public List<Client> findAll() {
//         return clientDao.findAll();
//     }
// 
//     public Page<Client> findPageBy(Pageable pageable, Client client) {
//         List<Client> clients = (List<Client>) clientDao.findPageBy(pageable, client);
//         long count = clientDao.countBy(client);
//         return new PageImpl<Client>(clients, pageable, count);
//     }
// 
//     public Client findByClientName(String clientName) {
//         return clientDao.findByClientName(clientName);
//     }
// 
//     public Client findByClientId(String clientId) {
//         return clientDao.findByClientId(clientId);
//     }
// 
//     public Client findByClientSecret(String clientSecret) {
//         return clientDao.findByClientSecret(clientSecret);
//     }
// }


import io.github.howiefh.jeews.modules.oauth2.entity.Client;
import io.github.howiefh.jeews.modules.oauth2.resource.ClientResource;
import io.github.howiefh.jeews.modules.oauth2.resource.ClientResourceAssembler;
import io.github.howiefh.jeews.modules.oauth2.service.ClientService;
import java.net.URISyntaxException;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.web.PageableDefault;
import org.springframework.data.web.PagedResourcesAssembler;
import org.springframework.hateoas.EntityLinks;
import org.springframework.hateoas.ExposesResourceFor;
import org.springframework.hateoas.PagedResources;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
    }

    @RequiresPermissions("clients:view")
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    public ClientResource get(@PathVariable long id) {
        return new ClientResourceAssembler().toResource(clientService.findOne(id));
    }

    @RequiresPermissions("clients:create")
    @RequestMapping(value = "", method = RequestMethod.POST)
    public ResponseEntity<ClientResource> create(HttpEntity<Client> entity, HttpServletRequest request)
            throws URISyntaxException {
        Client Client = entity.getBody();
        clientService.save(Client);
        HttpHeaders headers = new HttpHeaders();
        ClientResource ClientResource = new ClientResourceAssembler().toResource(Client);
        headers.setLocation(entityLinks.linkForSingleResource(Client.class, Client.getId()).toUri());
        ResponseEntity<ClientResource> responseEntity = new ResponseEntity<ClientResource>(ClientResource, headers,
                HttpStatus.CREATED);
        return responseEntity;
    }

    @RequiresPermissions("clients:update")
    @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
    public ClientResource update(@RequestBody Client client) {
        clientService.update(client);
        return new ClientResourceAssembler().toResource(client);
    }

    @RequiresPermissions("clients:delete")
// Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/entity/Client.java
// public class Client extends BasicEntity {
//     private static final long serialVersionUID = 1534976572117011533L;
//     private String clientId;
//     private String clientName;
//     private String clientSecret;
// 
//     public String getClientId() {
//         return clientId;
//     }
// 
//     public void setClientId(String clientId) {
//         this.clientId = clientId;
//     }
// 
//     public String getClientName() {
//         return clientName;
//     }
// 
//     public void setClientName(String clientName) {
//         this.clientName = clientName;
//     }
// 
//     public String getClientSecret() {
//         return clientSecret;
//     }
// 
//     public void setClientSecret(String clientSecret) {
//         this.clientSecret = clientSecret;
//     }
// 
//     @Override
//     public String toString() {
//         return "Client [clientId=" + clientId + ", clientName=" + clientName + ", clientSecret=" + clientSecret + "]";
//     }
// }
// 
// Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/resource/ClientResource.java
// public class ClientResource extends Resource<Client> {
//     public ClientResource(Client client) {
//         super(client);
//     }
// }
// 
// Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/resource/ClientResourceAssembler.java
// public class ClientResourceAssembler extends ResourceAssemblerSupport<Client, ClientResource> {
// 
//     public ClientResourceAssembler() {
//         super(ClientController.class, ClientResource.class);
//     }
// 
//     @Override
//     public ClientResource toResource(Client entity) {
//         ClientResource resource = createResourceWithId(entity.getId(), entity);
//         return resource;
//     }
// 
//     @Override
//     protected ClientResource instantiateResource(Client entity) {
//         return new ClientResource(entity);
//     }
// }
// 
// Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/service/ClientService.java
// @Service
// public class ClientService {
//     @Autowired
//     private ClientDao clientDao;
// 
//     public int save(Client client) {
//         client.setClientId(UUID.randomUUID().toString());
//         client.setClientSecret(UUID.randomUUID().toString());
//         return clientDao.save(client);
//     }
// 
//     public int update(Client client) {
//         return clientDao.update(client);
//     }
// 
//     public int delete(Long id) {
//         return clientDao.delete(id);
//     }
// 
//     public int deleteBatch(List<Long> ids) {
//         return clientDao.deleteBatch(ids);
//     }
// 
//     public Client findOne(Long id) {
//         return clientDao.findOne(id);
//     }
// 
//     public List<Client> findAll() {
//         return clientDao.findAll();
//     }
// 
//     public Page<Client> findPageBy(Pageable pageable, Client client) {
//         List<Client> clients = (List<Client>) clientDao.findPageBy(pageable, client);
//         long count = clientDao.countBy(client);
//         return new PageImpl<Client>(clients, pageable, count);
//     }
// 
//     public Client findByClientName(String clientName) {
//         return clientDao.findByClientName(clientName);
//     }
// 
//     public Client findByClientId(String clientId) {
//         return clientDao.findByClientId(clientId);
//     }
// 
//     public Client findByClientSecret(String clientSecret) {
//         return clientDao.findByClientSecret(clientSecret);
//     }
// }


// Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/controller/ClientController.java
import io.github.howiefh.jeews.modules.oauth2.entity.Client;
import io.github.howiefh.jeews.modules.oauth2.resource.ClientResource;
import io.github.howiefh.jeews.modules.oauth2.resource.ClientResourceAssembler;
import io.github.howiefh.jeews.modules.oauth2.service.ClientService;
import java.net.URISyntaxException;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.web.PageableDefault;
import org.springframework.data.web.PagedResourcesAssembler;
import org.springframework.hateoas.EntityLinks;
import org.springframework.hateoas.ExposesResourceFor;
import org.springframework.hateoas.PagedResources;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

    }

    @RequiresPermissions("clients:view")
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    public ClientResource get(@PathVariable long id) {
        return new ClientResourceAssembler().toResource(clientService.findOne(id));
    }

    @RequiresPermissions("clients:create")
    @RequestMapping(value = "", method = RequestMethod.POST)
    public ResponseEntity<ClientResource> create(HttpEntity<Client> entity, HttpServletRequest request)
            throws URISyntaxException {
        Client Client = entity.getBody();
        clientService.save(Client);
        HttpHeaders headers = new HttpHeaders();
        ClientResource ClientResource = new ClientResourceAssembler().toResource(Client);
        headers.setLocation(entityLinks.linkForSingleResource(Client.class, Client.getId()).toUri());
        ResponseEntity<ClientResource> responseEntity = new ResponseEntity<ClientResource>(ClientResource, headers,
                HttpStatus.CREATED);
        return responseEntity;
    }

    @RequiresPermissions("clients:update")
    @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
    public ClientResource update(@RequestBody Client client) {
        clientService.update(client);
        return new ClientResourceAssembler().toResource(client);
    }

    @RequiresPermissions("clients:delete")
    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)