All Downloads are FREE. Search and download functionalities are using the official Maven repository.

br.com.anteros.commons.services.rest.resource.v1.UserResource Maven / Gradle / Ivy

There is a newer version: 1.0.86
Show newest version
package br.com.anteros.commons.services.rest.resource.v1;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.HttpStatus;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import br.com.anteros.security.store.sql.domain.User;
import br.com.anteros.commons.services.rest.service.UserService;
import br.com.anteros.persistence.session.service.SQLService;
import br.com.anteros.security.spring.AnterosSecurityManager;
import br.com.anteros.spring.web.resource.AbstractSQLResourceRest;
import br.com.anteros.persistence.session.repository.Page;
import br.com.anteros.persistence.session.repository.PageRequest;
import br.com.anteros.persistence.session.repository.Pageable;
import br.com.anteros.persistence.session.repository.impl.PageImpl;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
*  Generated by Anteros Generator Maven Plugin at 29/12/2019 08:16:42
**/

@RestController
@RequestMapping(value = "/v1/user")
public class UserResource extends AbstractSQLResourceRest {

	@Autowired
	@Lazy
	private UserService userService;

	@Autowired
	@Lazy
	protected AnterosSecurityManager anterosSecurityManager;

	@Override
	public SQLService getService() {
		return userService;
	}
	
	@Override
	protected Page createConcretePage(List content, PageRequest pageRequest,
			long totalElements) {
		return new PageUser(content, pageRequest, totalElements);
	}

	class PageUser extends PageImpl {
		public PageUser(List content) {
			super(content);
		}

		public PageUser(List content, Pageable pageable, long total) {
			super(content, pageable, total);
		}
	}
	
	@Override
	protected List createConcreteList(List result) {
		return new ListUser(result);
	}
	
	class ListUser extends ArrayList{
		public ListUser(Collection c) {
			super(c);
		}
	}
	

	/**
	 * Busca um objeto pelo seu ID.
	 * 
	 * @param id
	 *            Identificador do objeto.
	 * @return Objeto encontrado.
	 * @throws Exception
	 */
	@RequestMapping(value = "/getUserByLogin/{login}", method = RequestMethod.GET)
	@ResponseStatus(HttpStatus.OK)
	@ResponseBody
	@Transactional(rollbackFor = Throwable.class, propagation = Propagation.REQUIRED, readOnly = true, transactionManager="transactionManagerSQL")
	public User getUserByLogin(@PathVariable(value = "login") String login) throws Exception {
		return userService.getUserByLoginName(login);
	}
	
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy