Commit d6e1b2045298f0340bf2e634bde27f1278574b66

Authored by fangcheng
1 parent 4f17501680
Exists in master

添加系统字典

Showing 6 changed files with 221 additions and 0 deletions

parent/base.common/src/main/java/com/lyms/base/common/dao/sys/SysDictMapper.java View file @ d6e1b20
  1 +package com.lyms.base.common.dao.sys;
  2 +
  3 +import com.lyms.base.common.entity.sys.SysDict;
  4 +import com.baomidou.mybatisplus.mapper.BaseMapper;
  5 +import org.springframework.stereotype.Repository;
  6 +import java.io.Serializable;
  7 +import java.util.List;
  8 +/**
  9 + * <p>
  10 + * Mapper接口
  11 + * </p>
  12 + *
  13 + * @author fangcheng
  14 + * @since 2017-03-31
  15 + */
  16 +@Repository
  17 +public interface SysDictMapper extends BaseMapper<SysDict> {
  18 +
  19 + public Integer deleteLogicById(Serializable id);
  20 +
  21 + public List<SysDict> getDictListByTypeCode(Serializable typeCode);
  22 +
  23 +}
parent/base.common/src/main/java/com/lyms/base/common/dao/sys/SysDictMapper.xml View file @ d6e1b20
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3 +<mapper namespace="com.lyms.base.common.dao.sys.SysDictMapper">
  4 +
  5 + <!-- 通用查询映射结果 -->
  6 + <resultMap id="BaseResultMap" type="com.lyms.base.common.entity.sys.SysDict">
  7 + <id column="ID" property="id" />
  8 + <result column="PID" property="pid" />
  9 + <result column="TYPECODE" property="typecode" />
  10 + <result column="TXT" property="txt" />
  11 + <result column="ENABLE" property="enable" />
  12 + </resultMap>
  13 +
  14 + <!-- 通用查询结果列 -->
  15 + <sql id="Base_Column_List">
  16 + ID AS id, PID AS pid, TYPECODE AS typecode, TXT AS txt, ENABLE AS enable
  17 + </sql>
  18 +
  19 + <!-- 根据uid获取用户的权限列表-->
  20 + <select id="getDictListByTypeCode" resultType="SysDict">
  21 + select <include refid="Base_Column_List"></include> from SYS_DICT t where t.PID in
  22 + (select id from SYS_DICT where TYPECODE = #{typeCode})
  23 + </select>
  24 +</mapper>
parent/base.common/src/main/java/com/lyms/base/common/entity/sys/SysDict.java View file @ d6e1b20
  1 +package com.lyms.base.common.entity.sys;
  2 +
  3 +import com.baomidou.mybatisplus.annotations.TableId;
  4 +import com.baomidou.mybatisplus.annotations.TableField;
  5 +import com.baomidou.mybatisplus.annotations.TableName;
  6 +import java.io.Serializable;
  7 +
  8 +/**
  9 + * <p>
  10 + *
  11 + * </p>
  12 + *
  13 + * @author fangcheng
  14 + * @since 2017-03-31
  15 + */
  16 +@TableName("SYS_DICT")
  17 +public class SysDict implements Serializable {
  18 +
  19 + private static final long serialVersionUID = 1L;
  20 +
  21 + /**
  22 + *
  23 + */
  24 + @TableId(value="ID")
  25 + private String id;
  26 + /**
  27 + * 父级id
  28 + */
  29 + @TableField(value="PID")
  30 + private String pid;
  31 + /**
  32 + * 字典类型编码,如国籍、学历等
  33 + */
  34 + @TableField(value="TYPECODE")
  35 + private String typecode;
  36 + /**
  37 + * 字典项描述
  38 + */
  39 + @TableField(value="TXT")
  40 + private String txt;
  41 + /**
  42 + *
  43 + */
  44 + @TableField(value="ENABLE")
  45 + private Integer enable;
  46 +
  47 +
  48 + public String getId() {
  49 + return id;
  50 + }
  51 +
  52 + public void setId(String id) {
  53 + this.id = id;
  54 + }
  55 +
  56 + public String getPid() {
  57 + return pid;
  58 + }
  59 +
  60 + public void setPid(String pid) {
  61 + this.pid = pid;
  62 + }
  63 +
  64 + public String getTypecode() {
  65 + return typecode;
  66 + }
  67 +
  68 + public void setTypecode(String typecode) {
  69 + this.typecode = typecode;
  70 + }
  71 +
  72 + public String getTxt() {
  73 + return txt;
  74 + }
  75 +
  76 + public void setTxt(String txt) {
  77 + this.txt = txt;
  78 + }
  79 +
  80 + public Integer getEnable() {
  81 + return enable;
  82 + }
  83 +
  84 + public void setEnable(Integer enable) {
  85 + this.enable = enable;
  86 + }
  87 +
  88 +}
parent/base.common/src/main/java/com/lyms/base/common/service/sys/SysDictService.java View file @ d6e1b20
  1 +package com.lyms.base.common.service.sys;
  2 +
  3 +import com.lyms.base.common.entity.sys.SysDict;
  4 +import com.lyms.web.service.BaseService;
  5 +import java.io.Serializable;
  6 +import java.util.List;
  7 +
  8 +/**
  9 + * <p>
  10 + * 服务类
  11 + * </p>
  12 + *
  13 + * @author fangcheng
  14 + * @since 2017-03-31
  15 + */
  16 +public interface SysDictService extends BaseService<SysDict> {
  17 +
  18 + /**
  19 + * <li>@Description:逻辑删除,ifDel = 1 为删除,否则为没有删除
  20 + * <li>@param id 删除主键id
  21 + * <li>@return 大于0修改成功,否则为失败
  22 + */
  23 + public Integer deleteLogicById(Serializable id);
  24 +
  25 + /**
  26 + * <li>@Description:根据typeCode获取字典列表
  27 + * <li>@param typeCode
  28 + * <li>@return
  29 + * <li>创建人:方承
  30 + * <li>创建时间:2017年3月31日
  31 + * <li>修改人:
  32 + * <li>修改时间:
  33 + */
  34 + public List<SysDict> getDictListByTypeCode(Serializable typeCode);
  35 +
  36 +}
parent/base.common/src/main/java/com/lyms/base/common/service/sys/impl/SysDictServiceImpl.java View file @ d6e1b20
  1 +package com.lyms.base.common.service.sys.impl;
  2 +
  3 +import com.lyms.base.common.entity.sys.SysDict;
  4 +import com.lyms.base.common.dao.sys.SysDictMapper;
  5 +import com.lyms.base.common.service.sys.SysDictService;
  6 +import com.baomidou.mybatisplus.service.impl.ServiceImpl;
  7 +import org.springframework.stereotype.Service;
  8 +import java.io.Serializable;
  9 +import java.util.List;
  10 +
  11 +/**
  12 + * <p>
  13 + * 服务实现类
  14 + * </p>
  15 + *
  16 + * @author fangcheng
  17 + * @since 2017-03-31
  18 + */
  19 +@Service
  20 +public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> implements SysDictService {
  21 +
  22 + public Integer deleteLogicById(Serializable id){
  23 + return baseMapper.deleteLogicById(id);
  24 + }
  25 +
  26 + @Override
  27 + public List<SysDict> getDictListByTypeCode(Serializable typeCode) {
  28 + return baseMapper.getDictListByTypeCode(typeCode);
  29 + }
  30 +}
parent/hospital.web/src/test/java/test/hospital/sys/dict/DictTest.java View file @ d6e1b20
  1 +package test.hospital.sys.dict;
  2 +
  3 +import org.junit.Test;
  4 +import org.springframework.beans.factory.annotation.Autowired;
  5 +
  6 +import com.lyms.base.common.service.sys.SysDictService;
  7 +
  8 +import test.hospital.BaseServiceTest;
  9 +
  10 +public class DictTest extends BaseServiceTest{
  11 +
  12 + @Autowired
  13 + private SysDictService sysDictService;
  14 +
  15 + @Test
  16 + public void getDictByTypeCode(){
  17 + outJson(sysDictService.getDictListByTypeCode("nationality"));
  18 + }
  19 +
  20 +}