瀏覽代碼

新增字典接口

chenweida 8 年之前
父節點
當前提交
714dc95548

+ 1 - 0
patient-co-figure/src/main/java/com/yihu/figure/config/SwaggerConfig.java

@ -41,6 +41,7 @@ public class SwaggerConfig extends WebMvcConfigurerAdapter {
                .select()
                .select()
                .paths(or(
                .paths(or(
                        regex("/suggest/.*"),
                        regex("/suggest/.*"),
                        regex("/dict/.*"),
                        regex("/portrait/.*"),
                        regex("/portrait/.*"),
                        regex("/patient/.*"),
                        regex("/patient/.*"),
                        regex("/disease/.*"),
                        regex("/disease/.*"),

+ 54 - 0
patient-co-figure/src/main/java/com/yihu/figure/controller/system/DictController.java

@ -0,0 +1,54 @@
package com.yihu.figure.controller.system;
import com.yihu.figure.controller.BaseController;
import com.yihu.figure.model.dict.SystemDict;
import com.yihu.figure.service.dict.SystemDictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
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 java.util.List;
/**
 * Created by chenweida on 2017/3/14.
 */
@RestController
@RequestMapping(value = "/dict", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "系统字典")
public class DictController extends BaseController {
    @Autowired
    private SystemDictService systemDictService;
    /**
     * 根据字典code获取字典内容
     *
     * @return
     */
    @ApiOperation(value = "根据字典code获取字典内容")
    @RequestMapping(value = "getDictByDictName", method = RequestMethod.GET)
    public String getDictByDictName(
            @ApiParam(name = "name", value = "字典名称", required = true) @RequestParam(value = "name", required = true) String name) {
        try {
            List<SystemDict> systemDicts = systemDictService.getDictByDictName(name);
            JSONArray ja=new JSONArray();
            systemDicts.stream().forEach( dict->{
                JSONObject jo=new JSONObject();
                jo.put("code",dict.getCode());
                jo.put("value",dict.getValue());
                ja.put(jo);
            });
            return write(10000,"成功","dict",ja);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, e.getMessage());
        }
    }
}

二進制
patient-co-figure/文档/接口文档.docx