Commit d73e9cfc authored by luben's avatar luben

fix

parent 9eefba6c
......@@ -17,6 +17,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -113,4 +114,13 @@ public class LabelsController extends BaseController {
return JSON.toJSONString(AjaxResult.error(500, "服务器内部错误"));
}
}
@ApiOperation("三级返回整个树")
@RequestMapping(value = "/threeToTree", method = RequestMethod.GET)
@ResponseBody
public AjaxResult threeToTree() {
List<String> codes = new ArrayList<String>();
codes.add("company_type_tec");
return commonService.threeToTree(codes);
}
}
......@@ -29,4 +29,6 @@ public interface LabelsMapper {
int updateByExample(@Param("record") Labels record, @Param("example") LabelsExample example);
List<Labels> getWgdxList(String code);
String getDegreeOne(String code);
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.other.Labels;
import com.ruoyi.system.domain.other.LabelsExample;
import com.ruoyi.system.domain.other.vo.LabelsVO;
import com.ruoyi.system.mapper.other.LabelsMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -24,6 +25,9 @@ public class LabelsFacadeService {
@Autowired
private LabelsService bsCommonService;
@Autowired
private LabelsMapper labelsMapper;
public String commit(Labels body, String method) {
try {
AjaxResult result = new AjaxResult();
......@@ -276,4 +280,27 @@ public class LabelsFacadeService {
}
return item.matches("(\\w{8}(-\\w{4}){3}-\\w{12}?)");
}
public AjaxResult threeToTree(List<String> codes){
Set<String> codeSet = new HashSet<>();
List<Labels> bsCommons = new ArrayList<>();
for(String code : codes){
String degree_one = labelsMapper.getDegreeOne(code);
codeSet.add(degree_one);
}
for(String code : codeSet){
LabelsExample bsCommonExample = new LabelsExample();
LabelsExample.Criteria criteria = bsCommonExample.createCriteria();
criteria.andIsValidEqualTo("1");
if(StringUtils.isNotBlank(code)){
criteria.andCodeLike("%"+code+"%");
}
bsCommonExample.setOrderByClause(" sort + 0 ");
List<Labels> bsCommon = bsCommonService.selectByExample(bsCommonExample);
bsCommons.addAll(bsCommon);
}
List<Map<String, Object>> jsTreeModels = convertFrBomsCommon(bsCommons);
return AjaxResult.success(jsTreeModels);
}
}
......@@ -219,6 +219,9 @@
<include refid="Example_Where_Clause" />
</if>
</select>
<select id="getDegreeOne" resultType="java.lang.String">
select code from labels where id = (select parent_id from labels where id = (select parent_id from labels where code = #{code}))
</select>
<update id="updateByExampleSelective" parameterType="map">
update labels
<set>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment