package cn.hnthyy.thmz.mapper.his.mz;

import cn.hnthyy.thmz.entity.his.mz.MzyZdReqtype;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface MzyZdReqtypeMapper {
    /**
     * 查询所有的号别类别
     * @return
     */
    @Select("  SELECT code,name,py_code,d_code wb_code  FROM mzy_zd_reqtype ")
    List<MzyZdReqtype> selectMzyZdReqtype();

    /**
     * 新增号别
     * @param mzyZdReqtype
     * @return
     */
    @Insert("if not exists (select code  from mzy_zd_reqtype where code=#{code}) INSERT INTO mzy_zd_reqtype(code, name, py_code, d_code) VALUES (#{code}, #{name}, #{pyCode}, #{wbCode})")
    int insetMzyZdReqtype(MzyZdReqtype mzyZdReqtype);

    /**
     * 根据编码修改号别类别
     * @param mzyZdReqtype
     * @return
     */
    @Update(" update mzy_zd_reqtype set name=#{name},py_code=#{pyCode},d_code=#{wbCode} where code=#{code}")
    int updateMzyZdReqtype(MzyZdReqtype mzyZdReqtype);

    /**
     * 删除
     * @param code
     * @return
     */
    @Delete("delete  from mzy_zd_reqtype  where code=#{code}")
    int deleteMzyZdReqtype(@Param("code") String code);

    /**
     * 查询新的编码
     * @return
     */
    @Select("select max(code)+1 from mzy_zd_reqtype ")
    String selectNewCode();
}
