Commit d2ebb240 by zhanghj

V1.0.0--提交字典数据和字典管理相关接口

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@17059 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent c17b5208
......@@ -22,7 +22,7 @@
<groupId>com.glsx</groupId>
<artifactId>car-service</artifactId>
<version>1.0.0</version>
<relativePath>../pom.xml</relativePath> <!--本例中此处是可选的-->
<!-- <relativePath>../pom.xml</relativePath> --> <!--本例中此处是可选的-->
</parent>
<dependencies>
<dependency>
......@@ -35,6 +35,7 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>test</scope>
<optional>true</optional>
</dependency>
<!-- EurekaClient -->
<dependency>
......
......@@ -18,6 +18,12 @@ public enum ResultCodeEnum {
NOT_LOGIN(101, "用户未登录"),
TRY_AGAIN(102, "失败,请重试"),
/*
* 字典管理,字典数据
*/
DICT_TYPE_KEY_EXISTS(1001, "字典类型重复"),
DICT_TYPE_KEY_NOT_EXISTS(1002, "字典类型不存在"),
DATA_KEY_EXISTS(1003, "字典数据键值重复"),
;
/**
......
package com.glsx.manager.controller;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.validation.groups.Default;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
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 com.glsx.common.constants.ResultObject;
import com.glsx.common.utils.Page;
import com.glsx.manager.constants.ResultCodeEnum;
import com.glsx.manager.pojo.GroupA;
import com.glsx.manager.pojo.dictionary.DictionaryData;
import com.glsx.manager.pojo.dictionary.DictionaryType;
import com.glsx.manager.service.DictionaryDataService;
import com.glsx.manager.service.DictionaryTypeService;
/**
*
* @Title DictionaryDataController.java
* @Package com.glsx.manager.controller
* @Description TODO 字典数据管理
* @author zhanghj
* @date 2019年1月22日 下午5:29:32
* @version 1.0.0
*/
@RestController
@RequestMapping(value="/dictionaryData")
public class DictionaryDataController extends BaseController{
@Autowired
private DictionaryDataService dictionaryDataService;
@Autowired
private DictionaryTypeService dictionaryTypeService;
/**
*
* @author zhanghj
* @Title: save
* @Description: TODO 保存
* @param dictionaryData
* @param bindingResult
* @return
* ResultObject
*
*/
@RequestMapping(value="/save", method=RequestMethod.POST)
public ResultObject save(@Validated(value={Default.class}) DictionaryData dictionaryData, BindingResult bindingResult){
if (bindingResult.hasErrors()) {
Map<String, String> errorMap = getErrors(bindingResult);
return new ResultObject(ResultCodeEnum.PARAM_ERROR.getCode(), ResultCodeEnum.PARAM_ERROR.getMsg(), errorMap);
}
DictionaryType dictionaryType = new DictionaryType();
dictionaryType.setDictType(dictionaryData.getDictType());
DictionaryType dictType = dictionaryTypeService.get(dictionaryType);
if (dictType == null) {
return new ResultObject(ResultCodeEnum.DICT_TYPE_KEY_NOT_EXISTS.getCode(), ResultCodeEnum.DICT_TYPE_KEY_NOT_EXISTS.getMsg());
}
DictionaryData dictData = new DictionaryData();
dictData.setDataKey(dictionaryData.getDataKey());
DictionaryData data = dictionaryDataService.get(dictData);
if (data != null) {
return new ResultObject(ResultCodeEnum.DATA_KEY_EXISTS.getCode(), ResultCodeEnum.DATA_KEY_EXISTS.getMsg());
}
//dictionaryData.setCreateBy();
dictionaryData.setCreateTime(new Date());
int num = dictionaryDataService.save(dictionaryData);
if (num > 0) {
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
} else {
return new ResultObject(ResultCodeEnum.FAIL.getCode(), ResultCodeEnum.FAIL.getMsg());
}
}
/**
*
* @author zhanghj
* @Title: update
* @Description: TODO 更新
* @param dictionaryData
* @param bindingResult
* @return
* ResultObject
*
*/
@RequestMapping(value="/update", method=RequestMethod.POST)
public ResultObject update(@Validated(value={GroupA.class}) DictionaryData dictionaryData, BindingResult bindingResult){
if (bindingResult.hasErrors()) {
Map<String, String> errorMap = getErrors(bindingResult);
return new ResultObject(ResultCodeEnum.PARAM_ERROR.getCode(), ResultCodeEnum.PARAM_ERROR.getMsg(), errorMap);
}
Integer id = dictionaryData.getId();
DictionaryData data = new DictionaryData();
data.setId(id);
data = dictionaryDataService.get(data);
DictionaryData dictData = new DictionaryData();
if (data != null) {
dictData.setDataKey(dictionaryData.getDataKey());
dictData = dictionaryDataService.get(dictData);
if (dictData != null && id != dictData.getId()) {
return new ResultObject(ResultCodeEnum.DATA_KEY_EXISTS.getCode(), ResultCodeEnum.DATA_KEY_EXISTS.getMsg());
}
}
//dictionaryData.setUpdateBy();
dictionaryData.setUpdateTime(new Date());
int num = dictionaryDataService.update(dictionaryData);
if (num > 0) {
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
} else {
return new ResultObject(ResultCodeEnum.FAIL.getCode(), ResultCodeEnum.FAIL.getMsg());
}
}
/**
*
* @author zhanghj
* @Title: delete
* @Description: TODO 通过id删除
* @param id
* @return
* ResultObject
*
*/
@RequestMapping(value="/delete", method=RequestMethod.POST)
public ResultObject delete(@RequestBody Integer[] ids) {
if (ids.length == 0) {
return new ResultObject(ResultCodeEnum.PARAM_ERROR.getCode(), ResultCodeEnum.PARAM_ERROR.getMsg());
}
List<DictionaryData> dictionaryDatas = new ArrayList<DictionaryData>();
for (int id : ids) {
DictionaryData dictionaryData = new DictionaryData();
dictionaryData.setId(id);
//dictionaryData.setUpdateBy();
dictionaryData.setUpdateTime(new Date());
dictionaryDatas.add(dictionaryData);
}
dictionaryDataService.delete(dictionaryDatas);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
}
/**
*
* @author zhanghj
* @Title: get
* @Description: TODO 通过id获取字典类型
* @param id
* @return
* ResultObject
*
*/
@RequestMapping(value="/get", method=RequestMethod.GET)
public ResultObject get(Integer id) {
if (StringUtils.isEmpty(id)) {
return new ResultObject(ResultCodeEnum.PARAM_ERROR.getCode(), ResultCodeEnum.PARAM_ERROR.getMsg());
}
DictionaryData dictionaryData = new DictionaryData();
dictionaryData.setId(id);
dictionaryData = dictionaryDataService.get(dictionaryData);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), dictionaryData);
}
@RequestMapping(value="/list", method=RequestMethod.GET)
public ResultObject list(@RequestParam(defaultValue = "1") int pageIndex, @RequestParam(defaultValue = "10") int pageSize, DictionaryData dictionaryData) {
String dictType = dictionaryData.getDictType();
if (StringUtils.isEmpty(dictType)) {
return new ResultObject(ResultCodeEnum.PARAM_ERROR.getCode(), ResultCodeEnum.PARAM_ERROR.getMsg());
}
Map<String, Object> result = new HashMap<String, Object>();
Page page = new Page(pageIndex, pageSize);
List<DictionaryData> list = dictionaryDataService.list(dictionaryData, page);
com.github.pagehelper.Page<DictionaryData> pages = (com.github.pagehelper.Page<DictionaryData>) list;
page.setTotalCount((int)pages.getTotal());
result.put("page", page);
result.put("items", list);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), result);
}
@RequestMapping(value="/getDictDataListByKey", method=RequestMethod.GET)
public ResultObject getDicttDataListByKey(String dictType) {
if (StringUtils.isEmpty(dictType)) {
return new ResultObject(ResultCodeEnum.PARAM_ERROR.getCode(), ResultCodeEnum.PARAM_ERROR.getMsg());
}
DictionaryData dictionaryData = new DictionaryData();
dictionaryData.setDictType(dictType);
Map<String, Object> result = new HashMap<String, Object>();
Page page = null;
List<DictionaryData> list = dictionaryDataService.list(dictionaryData, page);
result.put("items", list);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), result);
}
}
package com.glsx.manager.controller;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.validation.groups.Default;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.util.StringUtils;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
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 com.glsx.common.constants.ResultObject;
import com.glsx.common.utils.Page;
import com.glsx.manager.constants.ResultCodeEnum;
import com.glsx.manager.pojo.GroupA;
import com.glsx.manager.pojo.dictionary.DictionaryType;
import com.glsx.manager.service.DictionaryTypeService;
/**
*
* @Title DictionaryTypeController.java
* @Package com.glsx.manager.controller
* @Description TODO 字典管理控制层
* @author zhanghj
* @date 2019年1月3日 下午6:01:02
* @version 1.0.0
*/
@RestController
@RequestMapping(value="/dictionaryType")
public class DictionaryTypeController extends BaseController{
@Autowired
private DictionaryTypeService dictionaryTypeService;
/**
*
* @author zhanghj
* @Title: save
* @Description: TODO 保存
* @param dictionaryType
* @param bindingResult
* @return
* ResultObject
*
*/
@RequestMapping(value="/save", method=RequestMethod.POST)
public ResultObject save(@Validated(value={Default.class}) DictionaryType dictionaryType, BindingResult bindingResult){
if (bindingResult.hasErrors()) {
Map<String, String> errorMap = getErrors(bindingResult);
return new ResultObject(ResultCodeEnum.PARAM_ERROR.getCode(), ResultCodeEnum.PARAM_ERROR.getMsg(), errorMap);
}
//dictionaryType.setCreateBy();
dictionaryType.setCreateTime(new Date());
int num = dictionaryTypeService.save(dictionaryType);
if (num > 0) {
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
} else {
return new ResultObject(ResultCodeEnum.FAIL.getCode(), ResultCodeEnum.FAIL.getMsg());
}
}
/**
*
* @author zhanghj
* @Title: update
* @Description: TODO 更新
* @param dictionaryType
* @param bindingResult
* @return
* ResultObject
*
*/
@RequestMapping(value="/update", method=RequestMethod.POST)
public ResultObject update(@Validated(value={GroupA.class}) DictionaryType dictionaryType, BindingResult bindingResult){
if (bindingResult.hasErrors()) {
Map<String, String> errorMap = getErrors(bindingResult);
return new ResultObject(ResultCodeEnum.PARAM_ERROR.getCode(), ResultCodeEnum.PARAM_ERROR.getMsg(), errorMap);
}
//dictionaryType.setUpdateBy();
dictionaryType.setUpdateTime(new Date());
int num = dictionaryTypeService.update(dictionaryType);
if (num > 0) {
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
} else {
return new ResultObject(ResultCodeEnum.FAIL.getCode(), ResultCodeEnum.FAIL.getMsg());
}
}
/**
*
* @author zhanghj
* @Title: delete
* @Description: TODO 通过id删除
* @param id
* @return
* ResultObject
*
*/
@RequestMapping(value="/delete", method=RequestMethod.POST)
public ResultObject delete(@RequestBody Integer[] ids) {
if (ids.length == 0) {
return new ResultObject(ResultCodeEnum.PARAM_ERROR.getCode(), ResultCodeEnum.PARAM_ERROR.getMsg());
}
List<DictionaryType> dictionaryTypes = new ArrayList<DictionaryType>();
for (int id : ids) {
DictionaryType dictionaryType = new DictionaryType();
dictionaryType.setId(id);
//dictionaryType.setUpdateBy();
dictionaryType.setUpdateTime(new Date());
dictionaryTypes.add(dictionaryType);
}
dictionaryTypeService.delete(dictionaryTypes);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
}
/**
*
* @author zhanghj
* @Title: get
* @Description: TODO 通过id获取字典类型
* @param id
* @return
* ResultObject
*
*/
@RequestMapping(value="/get", method=RequestMethod.GET)
public ResultObject get(Integer id) {
if (StringUtils.isEmpty(id)) {
return new ResultObject(ResultCodeEnum.PARAM_ERROR.getCode(), ResultCodeEnum.PARAM_ERROR.getMsg());
}
DictionaryType dictionaryType = new DictionaryType();
dictionaryType.setId(id);
dictionaryType = dictionaryTypeService.get(dictionaryType);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), dictionaryType);
}
@RequestMapping(value="/list", method=RequestMethod.GET)
public ResultObject list(@RequestParam(defaultValue = "1") int pageIndex, @RequestParam(defaultValue = "10") int pageSize, DictionaryType dictionaryType) {
Map<String, Object> result = new HashMap<String, Object>();
Page page = new Page(pageIndex, pageSize);
List<DictionaryType> list = dictionaryTypeService.list(dictionaryType, page);
com.github.pagehelper.Page<DictionaryType> pages = (com.github.pagehelper.Page<DictionaryType>) list;
page.setTotalCount((int)pages.getTotal());
result.put("page", page);
result.put("items", list);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), result);
}
}
package com.glsx.manager.mapper;
import java.util.List;
import com.glsx.manager.pojo.dictionary.DictionaryData;
/**
*
* @Title DictionaryDataMapper.java
* @Package com.glsx.manager.mapper
* @Description TODO 字典数据mapper
* @author zhanghj
* @date 2019年1月22日 下午5:48:21
* @version 1.0.0
*/
public interface DictionaryDataMapper {
/**
*
* @author zhanghj
* @Title: save
* @Description: TODO 保存字典数据
* @param dictionaryData
* @return
* int
*
*/
int save(DictionaryData dictionaryData);
/**
*
* @author zhanghj
* @Title: update
* @Description: TODO 更新字典数据
* @param dictionaryData
* @return
* int
*
*/
int update(DictionaryData dictionaryData);
/**
*
* @author zhanghj
* @Title: delete
* @Description: TODO 删除字典数据
* @param dictionaryData
* @return
* int
*
*/
int delete(DictionaryData dictionaryData);
/**
*
* @author zhanghj
* @Title: get
* @Description: TODO 通过id获取字典数据
* @param dictionaryData
* @return
* DictionaryData
*
*/
DictionaryData get(DictionaryData dictionaryData);
/**
*
* @author zhanghj
* @Title: list
* @Description: TODO 获取字典数据列表
* @param dictionaryData
* @return
* List<DictionaryData>
*
*/
List<DictionaryData> list(DictionaryData dictionaryData);
/**
*
* @author zhanghj
* @Title: deleteByDictType 通过字典类型删除字典数据
* @Description: TODO
* @param dictionaryData
* @return
* int
*
*/
int deleteByDictType(DictionaryData dictionaryData);
}
package com.glsx.manager.mapper;
import java.util.List;
import com.glsx.manager.pojo.dictionary.DictionaryType;
/**
*
* @Title DictionaryTypeMapper.java
* @Package com.glsx.manager.mapper
* @Description TODO 字典管理mapper
* @author zhanghj
* @date 2019年1月3日 下午8:27:29
* @version 1.0.0
*/
public interface DictionaryTypeMapper {
/**
*
* @author zhanghj
* @Title: save
* @Description: TODO 保存字典类型
* @param dictionaryType
* @return
* int
*
*/
int save(DictionaryType dictionaryType);
/**
*
* @author zhanghj
* @Title: update
* @Description: TODO 更新字典类型
* @param dictionaryType
* @return
* int
*
*/
int update(DictionaryType dictionaryType);
/**
*
* @author zhanghj
* @Title: delete
* @Description: TODO 通过id删除字典类型
* @param dictionaryType
* @return
* int
*
*/
int delete(DictionaryType dictionaryType);
/**
*
* @author zhanghj
* @Title: get
* @Description: TODO 通过id获取字典类型
* @param dictionaryType
* @return
* DictionaryType
*
*/
DictionaryType get(DictionaryType dictionaryType);
/**
*
* @author zhanghj
* @Title: list
* @Description: TODO 查询字典类型列表
* @param dictionaryType
* @return
* List<DictionaryType>
*
*/
List<DictionaryType> list(DictionaryType dictionaryType);
}
package com.glsx.manager.pojo;
import java.util.Date;
/**
* 基础模型
* @author Louis
* @date Sep 13, 2018
*/
public class BaseModel {
/**
* 创建人
*/
private String createBy;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新人
*/
private String updateBy;
/**
* 更新时间
*/
private Date updateTime;
/**
* 备注
*/
private String remark;
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getUpdateBy() {
return updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}
package com.glsx.manager.pojo;
/**
*
* @Title GroupA.java
* @Package com.glsx.manager.pojo
* @Description TODO Hibernate-validator的分组
* @author zhanghj
* @date 2019年1月3日 下午7:46:57
* @version 1.0.0
*/
public interface GroupA {
}
package com.glsx.manager.pojo.dictionary;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.groups.Default;
import com.glsx.manager.pojo.BaseModel;
import com.glsx.manager.pojo.GroupA;
/**
*
* @Title DictionaryData.java
* @Package com.glsx.manager.pojo.dictionary
* @Description TODO
* @author zhanghj
* @date 2019年1月22日 下午5:34:49
* @version 1.0.0
*/
public class DictionaryData extends BaseModel{
/**
* 主键id
*/
@NotNull(message="{param.not.null}", groups={GroupA.class})
private Integer id;
/**
* 字典类型
*/
@NotBlank(message="{param.not.null}", groups={Default.class, GroupA.class})
private String dictType;
/**
* 字典标签
*/
@NotBlank(message="{param.not.null}", groups={Default.class, GroupA.class})
private String dataValue;
/**
* 字典键值
*/
@NotBlank(message="{param.not.null}", groups={Default.class, GroupA.class})
private String dataKey;
/**
* 状态:1:启用,2:停用,3:删除
*/
@NotNull(message="{param.not.null}", groups={Default.class, GroupA.class})
private Integer dataStatus;
/**
* 顺序
*/
@NotNull(message="{param.not.null}", groups={Default.class, GroupA.class})
private Integer sort;
/**
* 字典名称
*/
private String name;
/**
* 查询:开始时间
*/
private String beginDate;
/**
* 查询:结束时间
*/
private String endDate;
public String getDictType() {
return dictType;
}
public void setDictType(String dictType) {
this.dictType = dictType == null ? null : dictType.trim();
}
public String getDataValue() {
return dataValue;
}
public void setDataValue(String dataValue) {
this.dataValue = dataValue == null ? null : dataValue.trim();
}
public String getDataKey() {
return dataKey;
}
public void setDataKey(String dataKey) {
this.dataKey = dataKey == null ? null : dataKey.trim();
}
public Integer getDataStatus() {
return dataStatus;
}
public void setDataStatus(Integer dataStatus) {
this.dataStatus = dataStatus;
}
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getBeginDate() {
return beginDate;
}
public void setBeginDate(String beginDate) {
this.beginDate = beginDate;
}
public String getEndDate() {
return endDate;
}
public void setEndDate(String endDate) {
this.endDate = endDate;
}
}
\ No newline at end of file
package com.glsx.manager.pojo.dictionary;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.groups.Default;
import com.glsx.manager.pojo.BaseModel;
import com.glsx.manager.pojo.GroupA;
/**
*
* @Title DictionaryType.java
* @Package com.glsx.manager.pojo.dictionary
* @Description TODO
* @author zhanghj
* @date 2019年1月3日 下午4:24:51
* @version 1.0.0
*/
public class DictionaryType extends BaseModel{
/**
* 主键id
*/
@NotNull(message="{param.not.null}", groups={GroupA.class})
private Integer id;
/**
* 字典名称
*/
@NotBlank(message="{param.not.null}", groups={Default.class, GroupA.class})
private String name;
/**
* 字典类型
*/
@NotBlank(message="{param.not.null}", groups={Default.class, GroupA.class})
private String dictType;
/**
* 状态:1:启用,2:停用,3:注销
*/
@NotNull(message="{param.not.null}", groups={Default.class, GroupA.class})
private Integer dictStatus;
/**
* 查询:开始时间
*/
private String beginDate;
/**
* 查询:结束时间
*/
private String endDate;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public String getDictType() {
return dictType;
}
public void setDictType(String dictType) {
this.dictType = dictType == null ? null : dictType.trim();
}
public Integer getDictStatus() {
return dictStatus;
}
public void setDictStatus(Integer dictStatus) {
this.dictStatus = dictStatus;
}
public String getBeginDate() {
return beginDate;
}
public void setBeginDate(String beginDate) {
this.beginDate = beginDate;
}
public String getEndDate() {
return endDate;
}
public void setEndDate(String endDate) {
this.endDate = endDate;
}
}
\ No newline at end of file
package com.glsx.manager.service;
import java.util.List;
import com.glsx.common.utils.Page;
import com.glsx.manager.pojo.dictionary.DictionaryData;
/**
*
* @Title DictionaryDataService.java
* @Package com.glsx.manager.service
* @Description TODO 字典数据service
* @author zhanghj
* @date 2019年1月22日 下午5:47:20
* @version 1.0.0
*/
public interface DictionaryDataService {
/**
*
* @author zhanghj
* @Title: save
* @Description: TODO 保存字典类型
* @param dictionaryData
* @param a
* @return
* int
*
*/
int save(DictionaryData dictionaryData);
/**
*
* @author zhanghj
* @Title: update
* @Description: TODO 更新字典类型
* @param dictionaryData
* @return
* int
*
*/
int update(DictionaryData dictionaryData);
/**
*
* @author zhanghj
* @Title: delete
* @Description: TODO 通过id删除字典类型
* @param dictionaryDatas
* void
*
*/
void delete(List<DictionaryData> dictionaryDatas);
/**
*
* @author zhanghj
* @Title: get 通过id获取字典类型
* @Description: TODO
* @param dictionaryData
* @return
* DictionaryData
*
*/
DictionaryData get(DictionaryData dictionaryData);
/**
*
* @author zhanghj
* @Title: list
* @Description: TODO 分页获取列表
* @param dictionaryData
* @param page
* @return
* List<DictionaryData>
*
*/
List<DictionaryData> list(DictionaryData dictionaryData, Page page);
/**
*
* @author zhanghj
* @Title: deleteByDictType
* @Description: TODO
* @param dictionaryData
* @return
* int
*
*/
int deleteByDictType(DictionaryData dictionaryData);
}
package com.glsx.manager.service;
import java.util.List;
import com.glsx.common.utils.Page;
import com.glsx.manager.pojo.dictionary.DictionaryType;
/**
*
* @Title DictionaryTypeService.java
* @Package com.glsx.manager.service
* @Description TODO 字典管理service
* @author zhanghj
* @date 2019年1月3日 下午7:57:57
* @version 1.0.0
*/
public interface DictionaryTypeService {
/**
*
* @author zhanghj
* @Title: save
* @Description: TODO 保存字典类型
* @param dictionaryType
* @param a
* @return
* int
*
*/
int save(DictionaryType dictionaryType);
/**
*
* @author zhanghj
* @Title: update
* @Description: TODO 更新字典类型
* @param dictionaryType
* @return
* int
*
*/
int update(DictionaryType dictionaryType);
/**
*
* @author zhanghj
* @Title: delete
* @Description: TODO
* @param dictionaryTypes
* void
*
*/
void delete(List<DictionaryType> dictionaryTypes);
/**
*
* @author zhanghj
* @Title: get 通过id获取字典类型
* @Description: TODO
* @param dictionaryType
* @return
* DictionaryType
*
*/
DictionaryType get(DictionaryType dictionaryType);
/**
*
* @author zhanghj
* @Title: list
* @Description: TODO 分页获取列表
* @param dictionaryType
* @param page
* @return
* List<DictionaryType>
*
*/
List<DictionaryType> list(DictionaryType dictionaryType, Page page);
}
package com.glsx.manager.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.page.PageMethod;
import com.glsx.common.utils.Page;
import com.glsx.manager.mapper.DictionaryDataMapper;
import com.glsx.manager.pojo.dictionary.DictionaryData;
import com.glsx.manager.service.DictionaryDataService;
/**
*
* @Title DictionaryDataServiceImpl.java
* @Package com.glsx.manager.service.impl
* @Description TODO
* @author zhanghj
* @date 2019年1月3日 下午7:58:39
* @version 1.0.0
*/
@Service
public class DictionaryDataServiceImpl implements DictionaryDataService {
@Autowired
private DictionaryDataMapper dictionaryDataDao;
@Override
public int save(DictionaryData dictionaryData) {
// TODO Auto-generated method stub
return dictionaryDataDao.save(dictionaryData);
}
@Override
public int update(DictionaryData dictionaryData) {
// TODO Auto-generated method stub
return dictionaryDataDao.update(dictionaryData);
}
@Override
public void delete(List<DictionaryData> dictionaryDatas) {
// TODO Auto-generated method stub
for (DictionaryData dictionaryData : dictionaryDatas) {
dictionaryDataDao.delete(dictionaryData);
}
}
@Override
public DictionaryData get(DictionaryData dictionaryData) {
// TODO Auto-generated method stub
return dictionaryDataDao.get(dictionaryData);
}
@Override
public List<DictionaryData> list(DictionaryData dictionaryData, Page page) {
// TODO Auto-generated method stub
if (page != null) {
PageMethod.startPage(page.getPageIndex(), page.getPageSize(), true);
}
return dictionaryDataDao.list(dictionaryData);
}
@Override
public int deleteByDictType(DictionaryData dictionaryData) {
// TODO Auto-generated method stub
return dictionaryDataDao.deleteByDictType(dictionaryData);
}
}
package com.glsx.manager.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.github.pagehelper.page.PageMethod;
import com.glsx.common.utils.Page;
import com.glsx.manager.mapper.DictionaryTypeMapper;
import com.glsx.manager.pojo.dictionary.DictionaryData;
import com.glsx.manager.pojo.dictionary.DictionaryType;
import com.glsx.manager.service.DictionaryDataService;
import com.glsx.manager.service.DictionaryTypeService;
/**
*
* @Title DictionaryTypeServiceImpl.java
* @Package com.glsx.manager.service.impl
* @Description TODO
* @author zhanghj
* @date 2019年1月3日 下午7:58:39
* @version 1.0.0
*/
@Service
@Transactional
public class DictionaryTypeServiceImpl implements DictionaryTypeService {
@Autowired
private DictionaryTypeMapper dictionaryTypeDao;
@Autowired
private DictionaryDataService dictionaryDataService;
@Override
public int save(DictionaryType dictionaryType) {
// TODO Auto-generated method stub
return dictionaryTypeDao.save(dictionaryType);
}
@Override
public int update(DictionaryType dictionaryType) {
// TODO Auto-generated method stub
return dictionaryTypeDao.update(dictionaryType);
}
@Override
@Transactional
public void delete(List<DictionaryType> dictionaryTypes) {
// TODO Auto-generated method stub
for (DictionaryType dictionaryType : dictionaryTypes) {
DictionaryType dictType = dictionaryTypeDao.get(dictionaryType);
if (dictType != null) {
DictionaryData dictionaryData = new DictionaryData();
dictionaryData.setDictType(dictType.getDictType());
dictionaryData.setUpdateTime(dictionaryType.getUpdateTime());
dictionaryData.setUpdateBy(dictionaryType.getUpdateBy());
dictionaryTypeDao.delete(dictionaryType);
dictionaryDataService.deleteByDictType(dictionaryData);
}
}
}
@Override
public DictionaryType get(DictionaryType dictionaryType) {
// TODO Auto-generated method stub
return dictionaryTypeDao.get(dictionaryType);
}
@Override
public List<DictionaryType> list(DictionaryType dictionaryType, Page page) {
// TODO Auto-generated method stub
PageMethod.startPage(page.getPageIndex(), page.getPageSize(), true);
return dictionaryTypeDao.list(dictionaryType);
}
}
......@@ -5,7 +5,14 @@ spring.application.name=car-service-manager
server.servlet.context-path=/carservice/manager
server.port=8090
spring.devtools.restart.enabled=true
#\u6307\u5b9adate\u8f93\u51fa\u683c\u5f0f\u4e3ayyyy-MM-dd HH:mm:ss
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8
#eurekaClient
eureka.client.enabled=false
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/
#\u5fc3\u8df3
#eureka.instance.lease-renewal-interval-in-seconds=5
......
<?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.DictionaryDataMapper">
<resultMap id="baseResultMap" type="com.glsx.manager.pojo.dictionary.DictionaryData">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="dict_type" jdbcType="VARCHAR" property="dictType" />
<result column="data_value" jdbcType="VARCHAR" property="dataValue" />
<result column="data_key" jdbcType="VARCHAR" property="dataKey" />
<result column="data_status" jdbcType="INTEGER" property="dataStatus" />
<result column="sort" jdbcType="INTEGER" property="sort" />
<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, dict_type, data_value, data_key, data_status, sort, 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_data
<where>
<if test="id != null">
id = #{id,jdbcType=INTEGER}
</if>
<if test="dataKey !=null and dataKey != ''">
and data_key = #{dataKey}
</if>
<if test="dictType != null and dictType != ''">
and dict_type = #{dictType}
</if>
</where>
</select>
<select id="list" parameterType="com.glsx.manager.pojo.dictionary.DictionaryData" resultMap="baseResultMap">
<if test="dataValue != null and dataValue != ''">
<bind name="pattern" value="'%' + dataValue + '%'" />
</if>
select
sdd.id, sdd.dict_type, sdd.data_value, sdd.data_key, sdd.data_status,
sdd.sort, sdd.remark, sdd.create_by, sdd.create_time, sdd.update_by,
sdd.update_time
from sys_dict_data sdd
left join sys_dict_type sdt on sdd.dict_type = sdt.dict_type
<where>
sdd.data_status != 3
<if test="name != null">
and sdt.name = #{name}
</if>
<if test="dictType != null">
and sdd.dict_type = #{dictType}
</if>
<if test="dataValue != null and dataValue != ''">
and sdd.data_value like #{pattern}
</if>
<if test="dataStatus != null">
and sdd.data_status = #{dataStatus}
</if>
<if test="beginDate != null and beginDate!= ''">
and DATE_FORMAT(sdd.create_time, '%Y-%m-%d') &gt;= #{beginDate}
</if>
<if test="endDate != null and endDate != ''">
and DATE_FORMAT(sdd.create_time, '%Y-%m-%d') &lt;= #{endDate}
</if>
order by sdd.sort asc, sdd.create_time asc
</where>
</select>
<insert id="save" parameterType="com.glsx.manager.pojo.dictionary.DictionaryData" useGeneratedKeys="true">
insert into sys_dict_data
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="dictType != null">
dict_type,
</if>
<if test="dataValue != null and dataValue != ''">
data_value,
</if>
<if test="dataKey != null and dataKey != ''">
data_key,
</if>
<if test="dataStatus != null">
data_status,
</if>
<if test="sort != null">
sort,
</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="dictType != null and dictType != ''">
#{dictType},
</if>
<if test="dataValue != null and dataValue!= ''">
#{dataValue},
</if>
<if test="dataKey != null and dataKey != ''">
#{dataKey},
</if>
<if test="dataStatus != null">
#{dataStatus},
</if>
<if test="sort != null">
#{sort},
</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.DictionaryData">
update sys_dict_data
set
data_value = #{dataValue,jdbcType=VARCHAR},
data_status = #{dataStatus,jdbcType=TINYINT},
sort = #{sort},
remark = #{remark,jdbcType=VARCHAR},
update_by = #{updateBy,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
<delete id="delete" parameterType="com.glsx.manager.pojo.dictionary.DictionaryData">
update sys_dict_data
set data_status = 3,
update_by = #{updateBy},
update_time = #{updateTime}
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByDictType" parameterType="com.glsx.manager.pojo.dictionary.DictionaryData">
update sys_dict_data
set data_status = 3,
update_by = #{updateBy},
update_time = #{updateTime}
where dict_type = #{dictType}
</delete>
</mapper>
\ No newline at end of file
<?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="com.glsx.manager.pojo.dictionary.DictionaryType" resultMap="baseResultMap">
select
<include refid="base_Column" />
from sys_dict_type
<where>
<if test="id != null">
id = #{id,jdbcType=INTEGER}
</if>
<if test="dictType != null and dictType != ''">
dict_type = #{dictType}
</if>
</where>
</select>
<select id="list" parameterType="com.glsx.manager.pojo.dictionary.DictionaryType" resultMap="baseResultMap">
<if test="dictType != null and dictType != ''">
<bind name="dictType" value="'%' + dictType + '%'"/>
</if>
<if test="name != null and name != ''">
<bind name="name" value="'%' + name + '%'"/>
</if>
select
<include refid="base_Column" />
from sys_dict_type
<where>
dict_status != 3
<if test="name != null">
and name like #{name}
</if>
<if test="dictType != null">
and dict_type like #{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="com.glsx.manager.pojo.dictionary.DictionaryType">
update sys_dict_type set dict_status = 3,
update_by = #{updateBy},
update_time = #{updateTime}
where id = #{id}
</delete>
</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!