feat(dictServiceImpl)字典映射
parent
43fec1afd3
commit
50b273c1fc
|
@ -9,6 +9,7 @@ import lombok.Data;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.sql.DataTruncation;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -86,4 +87,39 @@ public class DictController extends BaseController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除字典
|
||||||
|
* @param dictType
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("deleteDictType")
|
||||||
|
public Result deleteDictType(@RequestParam String dictType){
|
||||||
|
Integer id;
|
||||||
|
Integer i1 = service.deleteDictType(dictType);
|
||||||
|
Integer i2 = service.deleteDictDatas(dictType);
|
||||||
|
if (i1>0&&i2>0){
|
||||||
|
id = 1;
|
||||||
|
}else{
|
||||||
|
id = 0;
|
||||||
|
}
|
||||||
|
if (id>0){
|
||||||
|
return success("成功");
|
||||||
|
}else{
|
||||||
|
return error("失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查看详情字典
|
||||||
|
* @param dictType
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("selectDictType")
|
||||||
|
public Result<DictType> selectDictType(@RequestParam String dictType){
|
||||||
|
DictType type = service.selectDictType(dictType);
|
||||||
|
List<DictData> list = service.selDictData(dictType);
|
||||||
|
type.setDictDataList(list);
|
||||||
|
return success(type);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ public class DictData {
|
||||||
/**
|
/**
|
||||||
* 字典编码
|
* 字典编码
|
||||||
*/
|
*/
|
||||||
private Long dictDode;
|
private Long dictCode;
|
||||||
/**
|
/**
|
||||||
* 字典标签
|
* 字典标签
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -20,4 +20,12 @@ public interface DictMapper {
|
||||||
Integer deleteDictData(DictData dictData);
|
Integer deleteDictData(DictData dictData);
|
||||||
|
|
||||||
DictData selectDictData(DictData dictData);
|
DictData selectDictData(DictData dictData);
|
||||||
|
|
||||||
|
Integer updDictData(DictData dictData);
|
||||||
|
|
||||||
|
Integer deleteDictType(@Param("dictType") String dictType);
|
||||||
|
|
||||||
|
Integer deleteDictDatas(@Param("dictType") String dictType);
|
||||||
|
|
||||||
|
DictType selectDictType(@Param("dictType") String dictType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,4 +17,10 @@ public interface DictService {
|
||||||
Integer deleteDictData(DictData dictData);
|
Integer deleteDictData(DictData dictData);
|
||||||
|
|
||||||
DictData selectDictData(DictData dictData);
|
DictData selectDictData(DictData dictData);
|
||||||
|
|
||||||
|
Integer deleteDictType(String dictType);
|
||||||
|
|
||||||
|
Integer deleteDictDatas(String dictType);
|
||||||
|
|
||||||
|
DictType selectDictType(String dictType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,12 @@ public class DictServiceImpl implements DictService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer indexDictData(DictData dictData) {
|
public Integer indexDictData(DictData dictData) {
|
||||||
|
if (dictData.getDictCode() == 0){
|
||||||
return mapper.indexDictData(dictData);
|
return mapper.indexDictData(dictData);
|
||||||
|
}else {
|
||||||
|
return mapper.updDictData(dictData);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -54,4 +59,20 @@ public class DictServiceImpl implements DictService {
|
||||||
public DictData selectDictData(DictData dictData) {
|
public DictData selectDictData(DictData dictData) {
|
||||||
return mapper.selectDictData(dictData);
|
return mapper.selectDictData(dictData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer deleteDictType(String dictType) {
|
||||||
|
return mapper.deleteDictType(dictType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer deleteDictDatas(String dictType) {
|
||||||
|
return mapper.deleteDictDatas(dictType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DictType selectDictType(String dictType) {
|
||||||
|
return mapper.selectDictType(dictType);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,11 +11,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
insert into dict_data (dict_label,dict_value,dict_type)
|
insert into dict_data (dict_label,dict_value,dict_type)
|
||||||
values (#{dictLabel},#{dictValue},#{dictType});
|
values (#{dictLabel},#{dictValue},#{dictType});
|
||||||
</insert>
|
</insert>
|
||||||
|
<update id="updDictData">
|
||||||
|
update dict_data
|
||||||
|
set dict_label = #{dictLabel},dict_value=#{dictValue}
|
||||||
|
where dict_type = #{dictType} and dict_code = #{dictCode};
|
||||||
|
</update>
|
||||||
<delete id="deleteDictData">
|
<delete id="deleteDictData">
|
||||||
delete
|
delete
|
||||||
from dict_data
|
from dict_data
|
||||||
where dict_label = #{dictLabel} and dict_value = #{dictValue} and dict_type=#{dictType};
|
where dict_label = #{dictLabel} and dict_value = #{dictValue} and dict_type=#{dictType};
|
||||||
</delete>
|
</delete>
|
||||||
|
<delete id="deleteDictType">
|
||||||
|
delete
|
||||||
|
from dict_type
|
||||||
|
where dict_type = #{dictType};
|
||||||
|
</delete>
|
||||||
|
<delete id="deleteDictDatas">
|
||||||
|
delete
|
||||||
|
from dict_data
|
||||||
|
where dict_type = #{dictType};
|
||||||
|
</delete>
|
||||||
|
|
||||||
<select id="listDictType" resultType="com.muyu.system.domain.DictType">
|
<select id="listDictType" resultType="com.muyu.system.domain.DictType">
|
||||||
select *
|
select *
|
||||||
|
@ -29,4 +44,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
select *
|
select *
|
||||||
from dict_data where dict_label=#{dictLabel} and dict_value=#{dictValue} and dict_type=#{dictType}
|
from dict_data where dict_label=#{dictLabel} and dict_value=#{dictValue} and dict_type=#{dictType}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectDictType" resultType="com.muyu.system.domain.DictType">
|
||||||
|
select *
|
||||||
|
from dict_type where dict_type = #{dictType}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
Loading…
Reference in New Issue