Browse Source

获取字段作为选项

lwx_v1
liwenxuan 1 year ago
parent
commit
c41f0fa88d
  1. 21
      src/main/java/com/hxgk/lowcode/controller/AssociatedFormsController.java
  2. 2
      src/main/java/com/hxgk/lowcode/mapper/CustomerFormViewMapper.java
  3. 15
      src/main/java/com/hxgk/lowcode/mapper/FieldRecordMapper.java
  4. 27
      src/main/java/com/hxgk/lowcode/model/entity/CustomerFormTableSingleFieldValue.java
  5. 33
      src/main/java/com/hxgk/lowcode/model/entity/Option.java
  6. 5
      src/main/java/com/hxgk/lowcode/service/CustomerFormService.java
  7. 55
      src/main/java/com/hxgk/lowcode/service/impl/CustomerFormServiceImpl.java
  8. 5
      src/main/java/com/hxgk/lowcode/service/impl/UserServiceImpl.java
  9. 6
      src/main/resources/application-dev.yml
  10. 6
      src/main/resources/application-prod.yml
  11. 8
      src/main/resources/mapper/CustomerFormvViewMapper.xml
  12. 12
      src/main/resources/mapper/FieldRecordMapper.xml

21
src/main/java/com/hxgk/lowcode/controller/AssociatedFormsController.java

@ -1,5 +1,6 @@
package com.hxgk.lowcode.controller;
import com.hxgk.lowcode.model.entity.CustomerFormTableSingleFieldValue;
import com.hxgk.lowcode.model.entity.Option;
import com.hxgk.lowcode.model.entity.SystemRole;
import com.hxgk.lowcode.model.entity.Tree;
@ -30,6 +31,9 @@ public class AssociatedFormsController {
public JsonData getCustomerFormList(@RequestHeader(value = "User-Key") String key,
@RequestHeader(value = "User-Token") String token) {
Tree tree = customerFormService.getCustomerFormList(key, token);
if(tree==null){
return JsonData.buildError("登录状态已失效,请退出重新登录");
}
return JsonData.buildSuccess(tree);
}
@ -79,4 +83,21 @@ public class AssociatedFormsController {
return JsonData.buildSuccess(options);
}
/*实现获取选项效果*/
@RequestMapping(value = "AssociatedForms/getFieldRecord")
public JsonData getFieldRecord(@RequestHeader(value = "User-Key") String key,
@RequestHeader(value = "User-Token") String token,
@RequestBody Map<String,String> requestBody) {
String optionsValue3Field = requestBody.get("optionsValue3Field");
String[] optionsValue3FieldArray = optionsValue3Field.split(":");
ArrayList<CustomerFormTableSingleFieldValue> fieldList = customerFormService.getFieldRecord(key,token,optionsValue3FieldArray);
if(null==fieldList){
return JsonData.buildError("非法请求");
}
return JsonData.buildSuccess(fieldList);
}
}

2
src/main/java/com/hxgk/lowcode/mapper/CustomerFormViewMapper.java

@ -12,4 +12,6 @@ public interface CustomerFormViewMapper {
ArrayList<CustomerFormView> getCustomerFormViewListByTablekey(ArrayList<String> tablekeyList);
ArrayList<CustomerFormView> getCustomerFormViewListByGroupid(String groupid);
CustomerFormView getTableNameByCfid(String formId);
}

15
src/main/java/com/hxgk/lowcode/mapper/FieldRecordMapper.java

@ -0,0 +1,15 @@
package com.hxgk.lowcode.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.hxgk.lowcode.model.entity.CustomerFormTableSingleFieldValue;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.ArrayList;
@DS("tidbintranetcustomerform")
@Mapper
public interface FieldRecordMapper {
ArrayList<CustomerFormTableSingleFieldValue> getFieldRecord(@Param("formIdOrTableKey") String formIdOrTableKey, @Param("fieldKey")String fieldKey);
}

27
src/main/java/com/hxgk/lowcode/model/entity/CustomerFormTableSingleFieldValue.java

@ -0,0 +1,27 @@
package com.hxgk.lowcode.model.entity;
import org.springframework.stereotype.Repository;
@Repository
public class CustomerFormTableSingleFieldValue {
private String value;
private String label;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
}

33
src/main/java/com/hxgk/lowcode/model/entity/Option.java

@ -0,0 +1,33 @@
package com.hxgk.lowcode.model.entity;
import org.springframework.stereotype.Repository;
@Repository
public class Option {
private String label;
private String value;
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public Option() {
}
public Option(String label, String value) {
this.label = label;
this.value = value;
}
}

5
src/main/java/com/hxgk/lowcode/service/CustomerFormService.java

@ -1,8 +1,7 @@
package com.hxgk.lowcode.service;
import com.hxgk.lowcode.model.entity.CustomerFormView;
import com.hxgk.lowcode.model.entity.SystemRole;
import com.hxgk.lowcode.model.entity.CustomerFormTableSingleFieldValue;
import com.hxgk.lowcode.model.entity.Tree;
import java.util.ArrayList;
@ -13,4 +12,6 @@ public interface CustomerFormService {
Tree getFieldTree(String key,String token,String cfid);
Tree getRoleList();
ArrayList<CustomerFormTableSingleFieldValue> getFieldRecord(String key, String token, String[] optionsValue3FieldArray);
}

55
src/main/java/com/hxgk/lowcode/service/impl/CustomerFormServiceImpl.java

@ -1,16 +1,14 @@
package com.hxgk.lowcode.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.hxgk.lowcode.mapper.CustomerFormMapper;
import com.hxgk.lowcode.mapper.CustomerFormViewMapper;
import com.hxgk.lowcode.mapper.FieldRecordMapper;
import com.hxgk.lowcode.model.entity.*;
import com.hxgk.lowcode.service.CustomerFormService;
import com.hxgk.lowcode.service.SystemRoleService;
@ -38,6 +36,9 @@ public class CustomerFormServiceImpl implements CustomerFormService {
private SystemRoleService systemRoleService;
@Autowired
private CustomerFormViewMapper customerFormViewMapper;
@Autowired
private FieldRecordMapper fieldRecordMapper;
@Override
//根据用户权限查询表单列表
public Tree getCustomerFormList(String key, String token) {
@ -51,7 +52,9 @@ public class CustomerFormServiceImpl implements CustomerFormService {
keytokenmap.put("userkey",key);
keytokenmap.put("usertoken",token);
UserDetail userDetail = userService.getUserDetailFromRedis(keytokenmap);
if(userDetail==null){
return null;
}else{
//得到所有启用的系统角色(state=1的)
ArrayList<SystemRole> roleList = systemRoleService.getAllRole();
@ -159,7 +162,22 @@ public class CustomerFormServiceImpl implements CustomerFormService {
Tree tree1 = new Tree();
if(item.getClassify()==3){//app
/*String signCode = item.getSignCode();
//调用GO接口获取App结构,过滤掉非表单和目录的数据
//上线修改
String url = "http://172.20.2.87:7777/app/gainAppEditPsge";//本地+内网
//String url = "http://36.133.126.182:39250/app/gainAppEditPsge";//外网
JSONObject param = new JSONObject();
param.put("id", signCode);
String post = null;
try {
post = HttpUtils.send(url, param, HTTP.UTF_8, key, token);
System.out.println("post:"+post.toString());
} catch (IOException e) {
e.printStackTrace();
}*/
tree1.setId(item.getCfid());
tree1.setParentId(tree.getId());
@ -254,6 +272,8 @@ public class CustomerFormServiceImpl implements CustomerFormService {
}
tree.setChildren(treeArrayList1);
return tree;
}
}
@ -490,7 +510,7 @@ public class CustomerFormServiceImpl implements CustomerFormService {
e.printStackTrace();
}
//
}
@ -519,5 +539,30 @@ public class CustomerFormServiceImpl implements CustomerFormService {
return tree;
}
@Override
public ArrayList<CustomerFormTableSingleFieldValue> getFieldRecord(String key, String token, String[] optionsValue3FieldArray) {//CustomerFormTableSingleFieldValueList
ArrayList<CustomerFormTableSingleFieldValue> stringArrayList = new ArrayList<>();
if(!StringUtils.isBlank(key)&&!StringUtils.isBlank(token)){
if(optionsValue3FieldArray.length==3){//formField:102:input1717743396622",不涉及子表
String formId = optionsValue3FieldArray[1];
//根据formId(cfid)查询表名
String formName = customerFormViewMapper.getTableNameByCfid(formId).getTablekey();
String fieldKey = optionsValue3FieldArray[2];
stringArrayList = fieldRecordMapper.getFieldRecord(formName,fieldKey);
}else if(optionsValue3FieldArray.length==4){//formField:5:table1718585442447:zhi2wu4",涉及到子表
String formId = optionsValue3FieldArray[1];
String tableKey = optionsValue3FieldArray[2];
String fieldKey = optionsValue3FieldArray[3];
stringArrayList = fieldRecordMapper.getFieldRecord(tableKey,fieldKey);
}
return stringArrayList;
}else{
System.out.println("非法请求!请先登录!");
return null;
}
}
}

5
src/main/java/com/hxgk/lowcode/service/impl/UserServiceImpl.java

@ -49,6 +49,9 @@ public class UserServiceImpl implements UserService {
String userRedisHashKey = "HXGK_GO_ZhixingCollege:ScanCode:Authentication:LoginApi_dev_" + userkey;
Object value1 = redisTemplate.boundHashOps(userRedisHashKey).get("key");
if(value1==null){
return null;
}else{
//唯一识别码
String key = value1.toString();
@ -90,6 +93,8 @@ public class UserServiceImpl implements UserService {
return userDetail;
}
}
@DS("hrnew")
@Override
public ManCont getManContByKey(String key) {

6
src/main/resources/application-dev.yml

@ -34,6 +34,12 @@ spring:
password: 9z_Bu28r1*DZ3K6@+a
url: jdbc:mysql://172.20.5.33:4000/system_empower?allowPublicKeyRetrieval=true&uuseUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&tinyInt1isBit=false
username: root
tidbintranetcustomerform:
driver-class-name: com.mysql.cj.jdbc.Driver
password: 9z_Bu28r1*DZ3K6@+a
#url: jdbc:mysql://127.0.0.1:3306/hengxingaoke_tes?allowPublicKeyRetrieval=true&uuseUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&tinyInt1isBit=false
url: jdbc:mysql://172.20.5.33:4000/customer_form?allowPublicKeyRetrieval=true&uuseUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&tinyInt1isBit=false
username: root
#数据源基础配置
druid:
# 通过connectProperties属性来打开mergeSql功能;慢SQL记录

6
src/main/resources/application-prod.yml

@ -34,6 +34,12 @@ spring:
password: NTYni4L2mfxk5zZZ
url: jdbc:mysql://127.0.0.1:3306/system_empower?allowPublicKeyRetrieval=true&uuseUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&tinyInt1isBit=false
username: system_empower
tidbintranetcustomerform:
driver-class-name: com.mysql.cj.jdbc.Driver
password: Mjh4msNtADGjiMaC
#url: jdbc:mysql://127.0.0.1:3306/hengxingaoke_tes?allowPublicKeyRetrieval=true&uuseUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&tinyInt1isBit=false
url: jdbc:mysql://127.0.0.1:3306/customer_form?allowPublicKeyRetrieval=true&uuseUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&tinyInt1isBit=false
username: customer_form
#数据源基础配置
druid:
# 通过connectProperties属性来打开mergeSql功能;慢SQL记录

8
src/main/resources/mapper/CustomerFormvViewMapper.xml

@ -26,4 +26,12 @@
order by id
</select>
<select id="getTableNameByCfid" resultType="com.hxgk.lowcode.model.entity.CustomerFormView">
select
id,tablekey,version,status,time,creater,edit_time,table_structure,dict,cfid,name,classify,flowkey,signCode
from customer_form_view
where status = 1 and cfid = #{formId}
</select>
</mapper>

12
src/main/resources/mapper/FieldRecordMapper.xml

@ -0,0 +1,12 @@
<?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.hxgk.lowcode.mapper.FieldRecordMapper">
<select id="getFieldRecord" resultType="com.hxgk.lowcode.model.entity.CustomerFormTableSingleFieldValue" parameterType="java.lang.String" statementType="STATEMENT">
select id as value,${fieldKey} as label from ${formIdOrTableKey} where states = 1
</select>
</mapper>
Loading…
Cancel
Save