Package idv.takeshi.application.service.spring

Source Code of idv.takeshi.application.service.spring.PersonServiceImpl

/**
* Copyright 2011 The Apache Software Foundation
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package idv.takeshi.application.service.spring;

import idv.takeshi.application.service.PersonService;
import idv.takeshi.model.Person;
import idv.takeshi.persistence.dao.PersonDao;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
*
* @author takeshi.miao
*
*/
@Service("personService")
@Transactional
public class PersonServiceImpl implements PersonService {
 
  private static final Logger logger = LoggerFactory.getLogger(PersonServiceImpl.class);
 
  @Autowired
  private PersonDao personDao;

  /* (non-Javadoc)
   * @see idv.takeshi.application.service.PersonService#getPerson(java.lang.Long)
   */
  @Override
  public Person getPerson(Long id) {
    logger.info("get Person by id:" + id);
    return this.personDao.getById(id);
  }


  /* (non-Javadoc)
   * @see idv.takeshi.application.service.PersonService#getAll()
   */
  @Override
  public List<Person> getAll() {
    logger.info("get all Person");
    return this.personDao.getAll();
  }


  /* (non-Javadoc)
   * @see idv.takeshi.application.service.PersonService#update(idv.takeshi.model.Person)
   */
  @Override
  public void update(Person person) {
    logger.info("update a Person, id:" + person.getId());
    this.personDao.update(person);
  }


  /* (non-Javadoc)
   * @see idv.takeshi.application.service.PersonService#validate(java.lang.String, java.lang.String)
   */
  @Override
  public boolean validate(String accountName, String password) {
    Person person = null;
    boolean pass = false;
    person = this.personDao.getByAccountName(accountName);
    if(null != person){
      if(person.getPassword().equals(password))
        pass = true;
    }
    return pass;
  }


  @Override
  public void delete(Long id) {
    this.personDao.deleteById(id);
  }


  @Override
  public void add(Person person) {
    this.personDao.add(person);
  }

}
TOP

Related Classes of idv.takeshi.application.service.spring.PersonServiceImpl

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.