浏览代码

字典和字典项变更

zdm 6 年之前
父节点
当前提交
c8ba01720f

+ 4 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/saas/SaasEndpoint.java

@ -267,7 +267,10 @@ public class SaasEndpoint extends EnvelopRestEndpoint {
        userDO.setUsername(userDO.getEmail());
        //初始化租户信息
        saasService.save(saasDO);
        saasDO = saasService.saasAudit(saasDO, userDO);
        //审核通过,初始化用户信息
        if("auditPassed".equals(status.name())){
            saasDO = saasService.saasAudit(saasDO, userDO);
        }
        return send(saasDO);
    }

+ 18 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/system/SystemDictEndpoint.java

@ -16,6 +16,7 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -31,6 +32,9 @@ public class SystemDictEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private SystemDictService systemDictService;
    @Value("${configDefault.saasId}")
    private String saasId;
    @PostMapping(value = BaseRequestMapping.SystemDict.DELETE)
    @ApiOperation(value = "删除")
@ -47,6 +51,9 @@ public class SystemDictEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "json", value = "Json数据", required = true)
            @RequestParam String jsonData) throws Exception {
        SystemDictDO systemDictDO = toEntity(jsonData, SystemDictDO.class);
        if(StringUtils.isBlank(systemDictDO.getSaasId())){
            systemDictDO.setSaasId(saasId);
        }
        if (null == systemDictDO.getCode()) {
            return failed("ID不能为空", Envelop.class);
        }
@ -67,7 +74,11 @@ public class SystemDictEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        if (StringUtils.isBlank(filters)) {
            filters = "saasId=" + saasId;
        } else {
            filters = "saasId=" + saasId + ";" + filters;
        }
       JSONObject result =  systemDictService.queryDictPageByType("1",dictType,filters,sorts,page,size);
       if(StringUtils.equalsIgnoreCase(ConstantUtils.FAIL,result.getString("response"))){
           return failed(result.getString("msg"));
@ -84,6 +95,11 @@ public class SystemDictEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        if (StringUtils.isBlank(filters)) {
            filters = "saasId=" + saasId;
        } else {
            filters = "saasId=" + saasId + ";" + filters;
        }
        List<SystemDictDO> systemDictDOS = systemDictService.search(fields, filters, sorts);
        return success(systemDictDOS, SystemDictVO.class);
    }
@ -94,6 +110,7 @@ public class SystemDictEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "jsonData", value = "json数据,系统字典及其值")
            @RequestParam(value = "jsonData", required = true) String jsonData) throws Exception {
        String message = systemDictService.createSystemDict(jsonData);
        if (StringUtils.equalsIgnoreCase(message, ConstantUtils.SUCCESS)) {
            return success(message);
        }

+ 41 - 9
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/system/SystemDictEntryEndpoint.java

@ -14,6 +14,7 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@ -30,18 +31,28 @@ public class SystemDictEntryEndpoint extends EnvelopRestEndpoint {
    
    @Autowired
    private SystemDictEntryService systemDictEntryService;
    @Value("${configDefault.saasId}")
    private String saasId;
    @PostMapping(value = BaseRequestMapping.SystemDict.CREATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping(value = BaseRequestMapping.SystemDictEntry.CREATE)
    @ApiOperation(value = "创建")
    public ObjEnvelop<SystemDictEntryVO> create (
            @ApiParam(name = "json", value = "Json数据", required = true)
            @RequestBody String jsonData) throws Exception {
            @ApiParam(name = "jsonData", value = "Json数据", required = true)
            @RequestParam(value = "jsonData") String jsonData) throws Exception {
        SystemDictEntryDO systemDictEntryDO = toEntity(jsonData, SystemDictEntryDO.class);
        if(StringUtils.isBlank(systemDictEntryDO.getDictCode())){
            return failed("字典编码不能为空!",ObjEnvelop.class);
        }if(StringUtils.isBlank(systemDictEntryDO.getCode())){
            return failed("字典项编码不能为空!",ObjEnvelop.class);
        }
        if(StringUtils.isBlank(systemDictEntryDO.getSaasId())){
            systemDictEntryDO.setSaasId(saasId);
        }
        systemDictEntryDO = systemDictEntryService.save(systemDictEntryDO);
        return success(systemDictEntryDO, SystemDictEntryVO.class);
    }
    @PostMapping(value = BaseRequestMapping.SystemDict.DELETE)
    @PostMapping(value = BaseRequestMapping.SystemDictEntry.DELETE)
    @ApiOperation(value = "删除")
    public Envelop delete(
            @ApiParam(name = "ids", value = "id串,中间用,分隔", required = true)
@ -50,15 +61,18 @@ public class SystemDictEntryEndpoint extends EnvelopRestEndpoint {
        return success("删除成功");
    }
    @PostMapping(value = BaseRequestMapping.SystemDict.UPDATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping(value = BaseRequestMapping.SystemDictEntry.UPDATE)
    @ApiOperation(value = "更新")
    public Envelop update (
            @ApiParam(name = "json", value = "Json数据", required = true)
            @RequestBody String jsonData) throws Exception {
            @ApiParam(name = "jsonData", value = "Json数据", required = true)
            @RequestParam(value = "jsonData") String jsonData) throws Exception {
        SystemDictEntryDO systemDictEntryDO = toEntity(jsonData, SystemDictEntryDO.class);
        if (null == systemDictEntryDO.getId()) {
            return failed("ID不能为空", Envelop.class);
        }
        if(StringUtils.isBlank(systemDictEntryDO.getSaasId())){
            systemDictEntryDO.setSaasId(saasId);
        }
        systemDictEntryDO = systemDictEntryService.save(systemDictEntryDO);
        return success(systemDictEntryDO, SystemDictEntryVO.class);
    }
@ -89,7 +103,7 @@ public class SystemDictEntryEndpoint extends EnvelopRestEndpoint {
        return success(systemDictEntryDOS, count, page, size, SystemDictEntryVO.class);
    }
    @GetMapping(value = BaseRequestMapping.SystemDict.PAGE)
    @GetMapping(value = BaseRequestMapping.SystemDictEntry.PAGE)
    @ApiOperation(value = "获取分页")
    public PageEnvelop<SystemDictEntryVO> page (
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
@ -102,12 +116,17 @@ public class SystemDictEntryEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        if (StringUtils.isBlank(filters)) {
            filters = "saasId=" + saasId;
        } else {
            filters = "saasId=" + saasId + ";" + filters;
        }
        List<SystemDictEntryDO> systemDictEntryDOS = systemDictEntryService.search(fields, filters, sorts, page, size);
        int count = (int)systemDictEntryService.getCount(filters);
        return success(systemDictEntryDOS, count, page, size, SystemDictEntryVO.class);
    }
    @GetMapping(value = BaseRequestMapping.SystemDict.LIST)
    @GetMapping(value = BaseRequestMapping.SystemDictEntry.LIST)
    @ApiOperation(value = "获取列表")
    public ListEnvelop<SystemDictEntryVO> list (
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
@ -116,7 +135,20 @@ public class SystemDictEntryEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        if (StringUtils.isBlank(filters)) {
            filters = "saasId=" + saasId;
        } else {
            filters = "saasId=" + saasId + ";" + filters;
        }
        List<SystemDictEntryDO> systemDictEntryDOS = systemDictEntryService.search(fields, filters, sorts);
        return success(systemDictEntryDOS, SystemDictEntryVO.class);
    }
    @GetMapping(value = BaseRequestMapping.SystemDictEntry.FINDBYID)
    @ApiOperation(value = "根据id获取详情")
    public ObjEnvelop<SystemDictEntryVO> getSystemDictEntryById(@ApiParam(name = "dictEntryId", value = "字典项id")
                                                                @RequestParam(value = "dictEntryId", required = true) String dictEntryId) throws Exception {
        SystemDictEntryDO systemDictEntryDO = systemDictEntryService.findById(dictEntryId);
        return success(systemDictEntryDO, SystemDictEntryVO.class);
    }
}

+ 3 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/system/SystemDictEntryService.java

@ -16,4 +16,7 @@ public class SystemDictEntryService extends BaseJpaService<SystemDictEntryDO, Sy
    @Autowired
    private SystemDictEntryDao systemDictEntryDao;
    public SystemDictEntryDO findById(String id) {
        return systemDictEntryDao.findOne(id);
    }
}

+ 7 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/service/system/SystemDictService.java

@ -12,6 +12,7 @@ import com.yihu.jw.entity.base.system.SystemDictEntryDO;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -55,6 +56,9 @@ public class SystemDictService extends BaseJpaService<SystemDictDO, SystemDictDa
    @Autowired
    private ObjectMapper objectMapper;
    @Value("${configDefault.saasId}")
    private String saasId;
    @Override
    public long getCount(String filters) throws ParseException {
        return super.getCount(filters);
@ -187,7 +191,9 @@ public class SystemDictService extends BaseJpaService<SystemDictDO, SystemDictDa
        }
        JSONObject dictJson = (JSONObject)jsonParam.get("dict");
        SystemDictDO systemDictDO = objectMapper.readValue(dictJson.toString(),SystemDictDO.class);
        if(StringUtils.isBlank(systemDictDO.getSaasId())){
            systemDictDO.setSaasId(saasId);
        }
        if(StringUtils.isEmpty(systemDictDO.getCode()) || StringUtils.isEmpty(systemDictDO.getName())){
            return "code or name of dict is required";
        }