97 lines
3.3 KiB
Plaintext
97 lines
3.3 KiB
Plaintext
package com.nationalelectric.greenH5;
|
||
|
||
import java.util.List;
|
||
import java.util.Map;
|
||
|
||
import javax.annotation.Resource;
|
||
|
||
import org.codehaus.jackson.map.ObjectMapper;
|
||
import org.codehaus.jackson.type.TypeReference;
|
||
import org.springframework.beans.factory.annotation.Autowired;
|
||
import org.springframework.stereotype.Controller;
|
||
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.ResponseBody;
|
||
|
||
import com.nationalelectirc.Constant.Constant;
|
||
import com.nationalelectirc.utils.RestResult;
|
||
import com.nationalelectric.greenH5.DTO.GreenMealTicketDTO;
|
||
import com.nationalelectric.greenH5.bizc.IGreenDictionaryInfoBizc;
|
||
import com.nationalelectric.greenH5.po.GreenDictionaryInfo;
|
||
import com.nationalelectric.greenH5.po.UserVo;
|
||
import com.sgcc.uap.persistence.IHibernateDao;
|
||
|
||
|
||
|
||
|
||
/**
|
||
* <b>概述</b>:<br>
|
||
* <p>
|
||
* <b>功能</b>:<br>
|
||
*
|
||
* @author dell
|
||
*/
|
||
@Controller
|
||
@RequestMapping("/greenDictionaryInfo")
|
||
public class GreenDictionaryInfoController {
|
||
/**
|
||
* 字典表service
|
||
*/
|
||
@Resource
|
||
private IGreenDictionaryInfoBizc greendictionaryinfoBizc;
|
||
/**
|
||
* HibernateDao逻辑构件
|
||
*/
|
||
@Autowired
|
||
IHibernateDao hibernateDao;
|
||
|
||
/**
|
||
* 查询字典表数据
|
||
* @param dataType
|
||
* @return
|
||
*/
|
||
@SuppressWarnings("unchecked")
|
||
public List<Map<String, Object>> getDictionaryInfo(String dataType){
|
||
String sql = "SELECT di.data_code as \"data_code\",di.data_value as \"data_value\" FROM GREEN_DICTIONARY_INFO di WHERE di.is_deleted = 'N' AND di.data_type = ? ORDER BY di.data_sort";
|
||
return hibernateDao.queryForListWithSql(sql,new Object[]{dataType});
|
||
}
|
||
@SuppressWarnings("unchecked")
|
||
public List<Map<String, String>> getDictionaryInfo(String dataType,String dataCode){
|
||
String sql = "SELECT di.data_value as \"data_value\" FROM GREEN_DICTIONARY_INFO di WHERE di.is_deleted = 'N' AND di.data_type = ? AND di.data_code = ? ORDER BY di.data_sort";
|
||
return hibernateDao.queryForListWithSql(sql,new Object[]{dataType,dataCode});
|
||
}
|
||
/** 获取字典表 */
|
||
@RequestMapping(value = "/greenTypeInfo", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public RestResult greenTypeInfo(@RequestBody Object requestBody) {
|
||
try {
|
||
GreenDictionaryInfo greenDictionaryInfo = new ObjectMapper().convertValue(requestBody, new TypeReference<GreenDictionaryInfo>() {});
|
||
if(greenDictionaryInfo.getDataType()!=null && !"".equals(greenDictionaryInfo.getDataType())){
|
||
List<Map<String, Object>> list = getDictionaryInfo(greenDictionaryInfo.getDataType());
|
||
return new RestResult(Constant.SUCCESS, "成功", list);
|
||
}
|
||
return new RestResult(Constant.FAILED, "数据类型为空");
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
return new RestResult(Constant.FAILED, "返回异常");
|
||
}
|
||
|
||
|
||
}
|
||
|
||
/**
|
||
* 更新指定字典表的值
|
||
* @param dataValue 更新后的值
|
||
* @param dataType
|
||
* @param dataCode
|
||
* @return
|
||
*/
|
||
@SuppressWarnings("unchecked")
|
||
public void updateDictionaryInfo(int dataValue, String dataType,String dataCode){
|
||
String sql = "update GREEN_DICTIONARY_INFO set data_value=? where data_type=? and data_code = ?";
|
||
hibernateDao.executeSqlUpdate(sql,new Object[]{dataValue,dataType,dataCode});
|
||
}
|
||
|
||
}
|