Commit a8b516cb by duanhq

新增根据类型获得字典value by duanht 2019/1/23

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@16957 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 46b0405d
......@@ -12,13 +12,11 @@ import com.glsx.usercenter.pojo.GroupA;
import com.glsx.usercenter.pojo.dictionary.DictionaryType;
import com.glsx.usercenter.service.DictionaryTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.glsx.common.constants.ResultObject;
import com.glsx.common.utils.Page;
......@@ -147,4 +145,18 @@ public class DictionaryTypeController extends BaseController{
result.put("items", list);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), result);
}
/**
* @return ResultObject
* @author duanht
* @Title: getServiceItems
* @Description: TODO 根据类型获取数据
*/
@RequestMapping(value = "/getDictDateByType", method = {RequestMethod.GET, RequestMethod.POST})
@ResponseBody
@Transactional(rollbackFor = Exception.class)
public ResultObject getDictDateByType(String dictType) {
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(),dictionaryTypeService.getDictDateByType(dictType));
}
}
package com.glsx.usercenter.mapper;
import com.glsx.usercenter.pojo.dictionary.DictionaryData;
import com.glsx.usercenter.pojo.dictionary.DictionaryType;
import java.util.List;
......@@ -76,4 +77,15 @@ public interface DictionaryTypeMapper {
*/
List<DictionaryType> list(DictionaryType dictionaryType);
/**
*
* @author zhanghj
* @Title: list
* @Description: TODO 根据类型获取数据
* @param dictType
* @return
* List<DictionaryData>
*
*/
List<DictionaryData> getDictDateByType(String dictType);
}
......@@ -3,6 +3,7 @@ package com.glsx.usercenter.service;
import java.util.List;
import com.glsx.common.utils.Page;
import com.glsx.usercenter.pojo.dictionary.DictionaryData;
import com.glsx.usercenter.pojo.dictionary.DictionaryType;
......@@ -79,4 +80,16 @@ public interface DictionaryTypeService {
*/
List<DictionaryType> list(DictionaryType dictionaryType, Page page);
/**
*
* @author zhanghj
* @Title: list
* @Description: TODO 根据类型获取数据
* @param dictType
* @return
* List<DictionaryData>
*
*/
List<DictionaryData> getDictDateByType(String dictType);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.glsx.manager.mapper.DictionaryTypeMapper">
<resultMap id="baseResultMap" type="com.glsx.manager.pojo.dictionary.DictionaryType">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="dict_type" jdbcType="VARCHAR" property="dictType" />
<result column="dict_status" jdbcType="TINYINT" property="dictStatus" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="base_Column">
id, name, dict_type, dict_status, remark, create_by, create_time, update_by, update_time
</sql>
<select id="get" parameterType="java.lang.Integer" resultMap="baseResultMap">
select
<include refid="base_Column" />
from sys_dict_type
where id = #{id,jdbcType=INTEGER}
</select>
<select id="list" parameterType="com.glsx.manager.pojo.dictionary.DictionaryType" resultMap="baseResultMap">
select
<include refid="base_Column" />
from sys_dict_type
<where>
<if test="name != null">
and name = #{name}
</if>
<if test="dictType != null">
and dict_type = #{dictType}
</if>
<if test="dictStatus != null">
and dict_status = #{dictStatus}
</if>
<if test="beginDate != null">
and DATE_FORMAT(create_time, '%Y-%m-%d') &gt;= #{beginDate}
</if>
<if test="endDate != null">
and DATE_FORMAT(create_time, '%Y-%m-%d') &lt;= #{endDate}
</if>
</where>
</select>
<insert id="save" parameterType="com.glsx.manager.pojo.dictionary.DictionaryType" useGeneratedKeys="true">
insert into sys_dict_type
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">
name,
</if>
<if test="dictType != null">
dict_type,
</if>
<if test="dictStatus != null">
dict_status,
</if>
<if test="remark != null">
remark,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateBy != null">
update_by,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="dictType != null">
#{dictType,jdbcType=VARCHAR},
</if>
<if test="dictStatus != null">
#{dictStatus,jdbcType=TINYINT},
</if>
<if test="remark != null">
#{remark,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null">
#{updateBy,jdbcType=VARCHAR},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="update" parameterType="com.glsx.manager.pojo.dictionary.DictionaryType">
update sys_dict_type
set name = #{name,jdbcType=VARCHAR},
dict_type = #{dictType,jdbcType=VARCHAR},
dict_status = #{dictStatus,jdbcType=TINYINT},
remark = #{remark,jdbcType=VARCHAR},
update_by = #{updateBy,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
<delete id="delete" parameterType="java.lang.Integer">
delete from sys_dict_type
where id = #{id,jdbcType=INTEGER}
</delete>
<mapper namespace="com.glsx.usercenter.mapper.DictionaryTypeMapper">
<resultMap id="baseResultMap" type="com.glsx.usercenter.pojo.dictionary.DictionaryType">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="dict_type" jdbcType="VARCHAR" property="dictType"/>
<result column="dict_status" jdbcType="TINYINT" property="dictStatus"/>
<result column="remark" jdbcType="VARCHAR" property="remark"/>
<result column="create_by" jdbcType="VARCHAR" property="createBy"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
</resultMap>
<sql id="base_Column">
id, name, dict_type, dict_status, remark, create_by, create_time, update_by, update_time
</sql>
<select id="get" parameterType="java.lang.Integer" resultMap="baseResultMap">
select
<include refid="base_Column"/>
from sys_dict_type
where id = #{id,jdbcType=INTEGER}
</select>
<select id="list" parameterType="com.glsx.usercenter.pojo.dictionary.DictionaryType" resultMap="baseResultMap">
select
<include refid="base_Column"/>
from sys_dict_type
<where>
<if test="name != null">
and name = #{name}
</if>
<if test="dictType != null">
and dict_type = #{dictType}
</if>
<if test="dictStatus != null">
and dict_status = #{dictStatus}
</if>
<if test="beginDate != null">
and DATE_FORMAT(create_time, '%Y-%m-%d') &gt;= #{beginDate}
</if>
<if test="endDate != null">
and DATE_FORMAT(create_time, '%Y-%m-%d') &lt;= #{endDate}
</if>
</where>
</select>
<insert id="save" parameterType="com.glsx.usercenter.pojo.dictionary.DictionaryType" useGeneratedKeys="true">
insert into sys_dict_type
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">
name,
</if>
<if test="dictType != null">
dict_type,
</if>
<if test="dictStatus != null">
dict_status,
</if>
<if test="remark != null">
remark,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateBy != null">
update_by,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="dictType != null">
#{dictType,jdbcType=VARCHAR},
</if>
<if test="dictStatus != null">
#{dictStatus,jdbcType=TINYINT},
</if>
<if test="remark != null">
#{remark,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null">
#{updateBy,jdbcType=VARCHAR},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="update" parameterType="com.glsx.manager.pojo.dictionary.DictionaryType">
UPDATE sys_dict_type
SET name = #{name,jdbcType=VARCHAR},
dict_type = #{dictType,jdbcType=VARCHAR},
dict_status = #{dictStatus,jdbcType=TINYINT},
remark = #{remark,jdbcType=VARCHAR},
update_by = #{updateBy,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=TIMESTAMP}
WHERE id = #{id,jdbcType=INTEGER}
</update>
<delete id="delete" parameterType="java.lang.Integer">
DELETE FROM sys_dict_type
WHERE id = #{id,jdbcType=INTEGER}
</delete>
<select id="getDictDateByType" parameterType="java.lang.String"
resultType="com.glsx.usercenter.pojo.dictionary.DictionaryData">
SELECT
data_value dataValue,
data_key dataKey,
sort sort
FROM sys_dict_data
WHERE dict_type = #{dictType,jdbcType=VARCHAR}
AND data_status = 1
</select>
</mapper>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!