Java_Business layer development

The business is the core of the entire project, and the processing of each business is called by the control layer (this time, the control layer is not considered, only the form in which the client directly calls the business layer), so the business layer in the entire code is still a standard, If the control layer wants to obtain the business layer object, it must also rely on the factory class.

 

1. Define business layer development standards

Taking into account the control of things to be added in the future, it is recommended to have some special considerations in the method, please use the normal name. For example: insert() update()

Keep all business layers under the subpackage of service

Example: Defining IEmpService

If the standard definition of the data layer is determined according to the entity table, then the business layer does not correspond one-to-one with the table.

package xxx.service;

import java.util.List;
import java.util.Map;
import java.util.Set;

import xxx.vo.Emp;

public  interface IEmpService {
     /* *
     * To realize the operation of adding employee information, in this operation, you need to use the following methods in the IEmpDAO interface:<br>
     * <li>First use the IEmpDAO.findByID() method to determine whether the employee ID to be added exists. </li>
     * <li>If the employee number does not exist, use the IEmpDAO.doCreate() method to save the employee information</li>
     * @param vo contains the VO class object to add data
     * @return Returns true if the data is added successfully, otherwise returns false
     * @throws Exception throws exception in IEmpDAO interface
     */
    public boolean insert(Emp vo) throws Exception;
    /**
     * To implement the data modification operation, the IEmpDAO.doUpdate() method is called, and this operation belongs to all modifications
     * @param vo contains the data information to be modified
     * @return Returns true if the modification is successful, otherwise returns false
     * @throws Exception throws exception in IEmpDAO interface
     */
    public boolean update(Emp vo) throws Exception;
    /**
     * To realize the batch deletion operation of data, the following calls need to be executed in this operation:<br>
     * <li>Determine whether the content of the collection passed in to delete the data is empty (judging null and size)</li>
     * <li>If it is determined that there is deleted data, call the IEmpDAO.doRemove() method to delete it</li>
     * @param ids contains all ID content of the data to be deleted
     * @return Returns true if the deletion is successful, otherwise returns false
     * @throws Exception throws exception in IEmpDAO interface
     */
    public boolean delete(Set<Integer> ids) throws Exception;
    /**
     * Query the complete information of an employee according to the employee number, and call the IEmpDAO.findById() method to query
     * @param id the employee number information to be queried
     * @return If the employee can be queried, it will be returned in the form of VO, if the query cannot be found, it will return null
     * @throws Exception throws exception in IEmpDAO interface
     */
    public Emp get(int id) throws Exception;
    /**
     * To query all employee data, call the IEmpDAO.findAll() method to query
     * @return all query records, returned as List collection
     * @throws Exception throws exception in IEmpDAO interface
     */
    public List<Emp> list() throws Exception;
    /**
     * Realize data fuzzy query operation, and return the amount of data that meets the query requirements. This operation needs to call the following functions:<br>
     * <li>Call the IEmpDAO.findAllSplit() method to query the data to be displayed by paging</li>
     * <li>Call the IEmpDAO.getAllCount() method to count the number of data</li>
     * @param column fuzzy query field
     * @param keyWord Fuzzy query keyword
     * @param currentPage current page
     * @param lineSize The length of each page to display
     * @return This method needs to return two data, all of which are returned using the Map collection. The content that appears is as follows:<br>
     * <li>key = allEmps、value = IEmpDAO.findAllSplit(),返回的是List<Emp> </li>
     * <li>key = empCount, value = IEmpDAO.getAllCount(), returns an Integer</li>
     * @throws Exception throws exception in IEmpDAO interface
     */
    public Map<String,Object> listSplit(String column,String keyWord,int currentPage,int lineSize) throws Exception;
}

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324684378&siteId=291194637