查询接口对查询出来的字符进行拼接再返回处理(业务:根据查询出来的数据拼接为前端需要的json格式的数据)

一、查询接口对查询出来的字符进行拼接再返回处理(业务:根据查询出来的数据拼接为前端需要的json格式的数据)
操作的实体类:TSocietyProblems
操作的控制类:TSocietyProblemsController
操作的业务实现类:TSocietyProblemsServiceImpl
操作业务接口:ITSocietyProblemsService
dao层:TSocietyProblemsMapper
工具类:CharacterSubstitution
枚举类:OptionEnum
枚举转换接口:BaseEnum
sql:TSocietyProblemsMapper.xml

业务:根据查询出来的数据拼接为前端需要的json格式的数据,
例如:数据库保存的题目选项格式为招标人#投标人#设计单位#施工单位 需要返回给前端的格式是{"A":"招标人","投标人","设计单位","施工单位"} 和数据库保存的题目正确答案是以0,1,2,3 要将其转化为A,B,C,D
数据库存储的数据格式:
在这里插入图片描述

在这里插入图片描述

前端需要展示的数据格式:
在这里插入图片描述
在这里插入图片描述

列表查询接口:
枚举类:OptionEnum

package org.jeecg.enums;

/**
 * @ProjectName: jeecg-boot
 * @Package: org.jeecg.enums
 * @ClassName: BaseEnum
 * @Author: TianLong
 * @Description: 枚举转换接口
 * @Date: 2023/2/15 17:00
 * @Version: 1.0
 */
public interface BaseEnum {
    /***
     * @Title: getCode
     * @Param: []
     * @description: 获取编码
     * @author: TianLong
     * @date: 2023/2/15 14:56
     * @return: short
     * @throws:
     */
    int getCode();
    /***
     * @Title: getInfo
     * @Param: []
     * @description: 获取文本
     * @author: TianLong
     * @date: 2023/2/15 14:56
     * @return: java.lang.String
     * @throws:
     */
    String getInfo();

    /***
     * @Title: getCodeToString
     * @Param: []
     * @description: 获取字符串格式的编码
     * @author: TianLong
     * @date: 2023/2/15 14:56
     * @return: java.lang.String
     * @throws:
     */
    String getCodeToString();
}

枚举类:OptionEnum

package org.jeecg.enums;

/**
 * @ProjectName: jeecg-boot
 * @Package: org.jeecg.enums
 * @ClassName: OptionEnum
 * @Author: TianLong
 * @Description: 选项枚举转换
 * @Date: 2023/2/15 17:02
 * @Version: 1.0
 */
public enum OptionEnum implements BaseEnum {
    OPTION_A(0,"A"),
    OPTION_B(1,"B"),
    OPTION_C(2,"C"),
    OPTION_D(3,"D"),
    OPTION_E(4,"E"),
    OPTION_F(5,"F"),
    OPTION_G(6,"G"),
    OPTION_H(7,"H");


    private final int code;
    private final String info;
    OptionEnum(int code, String info){
        this.code = code;
        this.info = info;
    }

    @Override
    public int getCode() {
        return this.code;
    }


    @Override
    public String getInfo() {
        return this.info;
    }


    @Override
    public String getCodeToString() {
        return String.valueOf(code);
    }
}

操作的实体类:TSocietyProblems

package org.jeecg.modules.management.problems.entity;

import java.io.Serializable;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.persistence.Column;
import javax.persistence.Id;

/**
 * @Description: t_society_problems
 * @Author: jeecg-boot
 * @Date:   2023-02-01
 * @Version: V1.0
 */
@Data
@TableName("t_society_problems")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="t_society_problems对象", description="题目信息对象")
public class TSocietyProblems implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 主键id
     */
	@Excel(name = "uuid", width = 15)
    @ApiModelProperty(value = "uuid")
    @TableId("UUID")
    @Column(name="UUID")
    private Integer uuid;


    /**
     * 1单选 2多选 3判断
     */
	@Excel(name = "答题类型 int", width = 15)
    @ApiModelProperty(value = "答题类型 int")
    @Column(name="PROBLEM_TYPE")
    private  Integer problemType;

    @Excel(name = "答题类型", width = 15)
    @ApiModelProperty(value = "答题类型")
    @TableField(exist = false)
    private  String problemTypeS;


    /**
     * 题干类型
     */
	@Excel(name = "难度", width = 15)
    @ApiModelProperty(value = "难度")
    @Column(name="CONTENT_TYPE")
    private  Integer contentType;


	/**
     * 题干
     */
	@Excel(name = "题干", width = 15)
    @ApiModelProperty(value = "题干")
    @Column(name="PROBLEM_CONTENT")
    private  String problemContent;


    /**
     * 数据库字段选项
     */
	@Excel(name = "选项", width = 15)
    @ApiModelProperty(value = "选项")
    @Column(name="OPTION_ALL")
    private  String optionAll;


    /**  exist是否为该表字段  默认值:true
     * 选项A
     *
     */
    @Excel(name = "选项A", width = 15)
    @ApiModelProperty(value = "选项A")
    @TableField(exist = false)
    private  String optionAllA;

    /**
     * 选项B
     */
    @Excel(name = "选项B", width = 15)
    @ApiModelProperty(value = "选项B")
    @TableField(exist = false)
    private  String optionAllB;

    /**
     * 选项C
     */
    @Excel(name = "选项C", width = 15)
    @ApiModelProperty(value = "选项C")
    @TableField(exist = false)
    private  String optionAllC;

    /**
     * 选项D
     */
    @Excel(name = "选项D", width = 15)
    @ApiModelProperty(value = "选项D")
    @TableField(exist = false)
    private  String optionAllD;


    /**
     * 选项E
     */
    @Excel(name = "选项E", width = 15)
    @ApiModelProperty(value = "选项E")
    @TableField(exist = false)
    private  String optionAllE;

    /**
     * 选项F
     */
    @Excel(name = "选项F", width = 15)
    @ApiModelProperty(value = "选项F")
    @TableField(exist = false)
    private  String optionAllF;

    /**
     * 选项G
     */
    @Excel(name = "选项G", width = 15)
    @ApiModelProperty(value = "选项G")
    @TableField(exist = false)
    private  String optionAllG;



    /**
     * 选项H
     */
    @Excel(name = "选项H", width = 15)
    @ApiModelProperty(value = "选项H")
    @TableField(exist = false)
    private  String optionAllH;


    /**
     * 正确选项
     */
	@Excel(name = "正确选项", width = 15)
    @ApiModelProperty(value = "正确选项")
    @Column(name="OPTION_CORRECT")
    private  String optionCorrect;


    /**
     * 分析
     */
	@Excel(name = "答案分析", width = 15)
    @ApiModelProperty(value = "答案分析")
    @Column(name="ANALYZING")
    private  String analyzing;


    /**
     * 题目资源
     */
	@Excel(name = "题目资源", width = 15)
    @ApiModelProperty(value = "题目资源")
    @Column(name="PROBLEM_SOURCE")
    private  String problemSource;


    /**
     * 更新时间
     */
	@Excel(name = "更新时间", width = 15, format = "yyyy-MM-dd")
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @ApiModelProperty(value = "更新时间")
    @Column(name="UPTIME")
    private java.util.Date uptime;


    /**
     * 作废标志
     */
	@Excel(name = "作废标志", width = 15)
    @Column(name="ZFBZ")
    @ApiModelProperty(value = "作废标志")
    private  String zfbz;

	public  TSocietyProblems(){}
}

控制层 TSocietyProblemsController

/**
	 * 分页列表查询
	 * @Author: TianLong
	 * @param tSocietyProblems
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	@ApiOperation(value="t_society_problems-分页列表查询", notes="t_society_problems-分页列表查询")
	@GetMapping(value = "/list")
	public Result<IPage<TSocietyProblems>> queryPageList(TSocietyProblems tSocietyProblems,
								   Integer problemType,
								   String zfbz,
								   String problemContent,
								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
								   HttpServletRequest req) {

		//列表查询和模糊查询判断
		if (StringUtils.isNotBlank(zfbz) || problemType != null && problemType != 0 || StringUtils.isNotBlank(problemContent)){
			//对通过作废字段是进行非空判断,true:通过作废字段实现模糊查询
			if (StringUtils.isNotBlank(zfbz)){
						Result<IPage<TSocietyProblems>> res = new Result<>();
						Page<TSocietyProblems> pageList = new Page<>(pageNo, pageSize);
						pageList = tSocietyProblemsService.queryForZfbz(pageList,zfbz);
						List<TSocietyProblems> tSocietyProblems1 = pageList.getRecords();
						tSocietyProblems = new CharacterSubstitution().transformationEnum(tSocietyProblems1);
						tSocietyProblems = new CharacterSubstitution().optionSplicing(tSocietyProblems1);
				res.setResult(pageList);
				res.setSuccess(true);
				return Result.OK("QUERY SUCCESS",pageList);
			}

			//对题目类型字段非空判断,true: 通过题目类型搜索列表信息
			if (problemType != null && problemType != 0){
						Result<IPage<TSocietyProblems>> res = new Result<>();
						Page<TSocietyProblems> pageList = new Page<>(pageNo, pageSize);
						pageList = tSocietyProblemsService.queryForProblemType(pageList,problemType);
						List<TSocietyProblems> tSocietyProblems1 = pageList.getRecords();
						tSocietyProblems = new CharacterSubstitution().transformationEnum(tSocietyProblems1);
						tSocietyProblems = new CharacterSubstitution().optionSplicing(tSocietyProblems1);
				res.setResult(pageList);
				res.setSuccess(true);
				return Result.OK("QUERY SUCCESS",pageList);
			}
			//根据题干进行查询
			if (StringUtils.isNotBlank(problemContent)){
						Result<IPage<TSocietyProblems>> res = new Result<>();
						Page<TSocietyProblems> pageList = new Page<>(pageNo, pageSize);
						pageList = tSocietyProblemsService.queryForProblemContent(pageList,problemContent);
						List<TSocietyProblems> tSocietyProblems1 = pageList.getRecords();
						tSocietyProblems = new CharacterSubstitution().transformationEnum(tSocietyProblems1);
						tSocietyProblems = new CharacterSubstitution().optionSplicing(tSocietyProblems1);
				res.setResult(pageList);
				res.setSuccess(true);
				return Result.OK("QUERY SUCCESS",pageList);
			}
		}
				//列表查询  招标人#投标人#设计单位#施工单位    {"A":"招标人","投标人","设计单位","施工单位"}
				Result<IPage<TSocietyProblems>> res= new Result<>();
				Page<TSocietyProblems> pageList = new Page<>(pageNo, pageSize);
				pageList = tSocietyProblemsService.getProblemPageList(pageList, tSocietyProblems);
				List<TSocietyProblems> tSocietyProblems1 = pageList.getRecords();
		        tSocietyProblems = new CharacterSubstitution().transformationEnum(tSocietyProblems1);
				tSocietyProblems = new CharacterSubstitution().optionSplicing(tSocietyProblems1);
		res.setResult(pageList);
		res.setSuccess(true);
		return Result.OK("QUERY SUCCESS",pageList);
	}



	 /**
	  *
	  * @param 题干新增
	  * @param
	  * @param
	  * @param
	  * @Author: TianLong
	  * @return
	  */
	@AutoLog(value = "t_society_problems-添加")
	@ApiOperation(value="t_society_problems-添加", notes="t_society_problems-添加")
	@PostMapping(value = "/add")
	public Result<String> add(@RequestBody TSocietyProblems tSocietyProblems) {
		String optionAll = tSocietyProblems.getOptionAll(); //optionAll
		String optionCorrect = tSocietyProblems.getOptionCorrect();
		//对正确选项小写进行判断,如果输入的字母为小写则返回一个提醒信息,提示必须为大写字母。
		for (int j = 0; j < optionCorrect.length(); j++) {
			if ((optionCorrect.charAt(j) + "").equals("a") || (optionCorrect.charAt(j) + "").equals("b")
					|| (optionCorrect.charAt(j) + "").equals("c")
					|| (optionCorrect.charAt(j) + "").equals("d")
					|| (optionCorrect.charAt(j) + "").equals("e")
					|| (optionCorrect.charAt(j) + "").equals("f")
					|| (optionCorrect.charAt(j) + "").equals("g")) {
				return Result.error("请输入正确格式!  例如:A,B,C",optionCorrect);
			}
//			return Result.error("正确答案必须为大写字母",optionCorrect);
		}
		if (StringUtils.isNotBlank(optionAll) || StringUtils.isNotBlank(optionCorrect)){
			tSocietyProblems.setOptionCorrect(new String(new CharacterSubstitution().transformationEnumCode(optionCorrect)));
			//字符类型并且装进数组中转为字符串
			tSocietyProblems.setOptionAll(new String(new CharacterSubstitution().characterSubstitutionMethood(optionAll)));
			tSocietyProblemsService.save(tSocietyProblems);
			return Result.OK("SUCCESS");
		}
		tSocietyProblemsService.save(tSocietyProblems);
		return Result.OK("SUCCESS");
	}
	
	/**
	 *  编辑
	 * @Author: TianLong
	 * @param tSocietyProblems
	 * @return
	 */
	@AutoLog(value = "t_society_problems-编辑")
	@ApiOperation(value="t_society_problems-编辑", notes="t_society_problems-编辑")
	//@RequiresPermissions("management.problems:t_society_problems:edit")
	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
	public Result<String> edit(@RequestBody TSocietyProblems tSocietyProblems) {
		String optionAll = tSocietyProblems.getOptionAll();
		String optionCorrect = tSocietyProblems.getOptionCorrect();
		//对正确选项小写进行判断,如果输入的字母为小写则返回一个提醒信息,提示必须为大写字母。
		for (int j = 0; j < optionCorrect.length(); j++) {
			if ((optionCorrect.charAt(j) + "").equals("a") || (optionCorrect.charAt(j) + "").equals("b")
					|| (optionCorrect.charAt(j) + "").equals("c")
					|| (optionCorrect.charAt(j) + "").equals("d")
					|| (optionCorrect.charAt(j) + "").equals("e")
					|| (optionCorrect.charAt(j) + "").equals("f")
					|| (optionCorrect.charAt(j) + "").equals("g")) {
				return Result.error("请输入正确格式!  例如:A,B,C",optionCorrect);
			}
		}
		if (StringUtils.isNotBlank(optionAll)  || StringUtils.isNotBlank(optionCorrect)){
			tSocietyProblems.setOptionCorrect(new String(new CharacterSubstitution().transformationEnumCode(optionCorrect)));
			tSocietyProblems.setOptionAll(new String(new CharacterSubstitution().characterSubstitutionMethood(optionAll)));
			tSocietyProblemsService.updateById(tSocietyProblems);
			return Result.OK("编辑成功!");
		}
		tSocietyProblemsService.updateById(tSocietyProblems);
		return Result.OK("编辑成功!");
	}

工具类:CharacterSubstitution

package org.jeecg.config;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.jeecg.enums.OptionEnum;
import org.jeecg.modules.management.problems.entity.TSocietyProblems;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * @ProjectName: jeecg-boot
 * @Package: org.jeecg.config
 * @ClassName: CharacterSubstitution
 * @Author: TianLong
 * @Description: 字符替换公共类
 * @Date: 2023/2/13 17:26
 * @Version: 1.0
 */
@Slf4j
@Configuration
public class CharacterSubstitution {

    public CharacterSubstitution(){}

    /**
     *
     * @param optionAll
     * @return 字符替换公方法
     */
    public char[] characterSubstitutionMethood(String optionAll){
        //{"A":"招标人","B":"投标人","C":"设计单位","D":"施工单位"}  替换jscon对象的双引号和大括号  招标人#投标人#设计单位#施工单位
        String strOptionAll = (optionAll.replaceAll("\"","").substring(0,(optionAll.replaceAll("\"","")).length()-1)).substring(1);
        //替换字符中含有A,B,C,D....字符   {"A":"招标人","B":"投标人","C":"设计单位","D":"施工单位"}  招标人#投标人#设计单位#施工单位
        String strOptionAllT =  strOptionAll.replaceAll("(?i)A:","")
                                            .replaceAll("(?i)B:","")
                                            .replaceAll("(?i)C:","")
                                            .replaceAll("(?i)D:","")
                                            .replaceAll("(?i)E:","")
                                            .replaceAll("(?i)F:","")
                                            .replaceAll("(?i)G:","")
                                            .replaceAll("(?i)H:","")
                                            .replaceAll("(?i)I:","")
                                            .replaceAll("(?i)J:","")
                                            .replaceAll("(?i)K:","")
                                            .replaceAll("(?i)L:","")
                                            .replaceAll("(?i)M:","")
                                            .replaceAll("(?i)N:","");
        //开辟一个数组存储替换之后的字符    A:A#B:B#C:C#D:D#E:E#A1:A1
        char[] charOptionAll = new char[strOptionAllT.length()];
        for (int i = 0; i < strOptionAllT.length(); i++) {
            if ((strOptionAllT.charAt(i)+"").equals(",")){
                charOptionAll[i] ='#';
            }else {
                charOptionAll[i] = strOptionAllT.charAt(i);
            }
        }
        return charOptionAll;
    }


    /**
     *   查询接口的字符拼接
     * @param stringBuilder
     * @return
     */
    public TSocietyProblems optionSplicing(List<TSocietyProblems> tSocietyProblems1){
        TSocietyProblems tSocietyProblems = new TSocietyProblems();
        for (int i = 0; i <tSocietyProblems1.size() ; i++) {
            //对选项进行非空判断
            if (StringUtils.isNotBlank(tSocietyProblems1.get(i).getOptionAll())){
                String OptionAllA = OptionEnum.OPTION_A.getInfo()+":"+tSocietyProblems1.get(i).getOptionAll();
                StringBuilder stringBuilder = new StringBuilder(OptionAllA);
                //字符拼接
                int ij = 0;
                for (int j = 0; j < stringBuilder.length(); j++) {
                    ij++;
                    if ((stringBuilder.charAt(j)+"").equals("#") && j+1==ij){
                        stringBuilder.insert(j+1,"B:");
                        j=j+2;
                    }else if ((stringBuilder.charAt(j)+"").equals("#") && j+1==ij+2){
                        stringBuilder.insert(j+1,"C:");
                        j=j+2;
                    }else if ((stringBuilder.charAt(j)+"").equals("#") && j+1==ij+4){
                        stringBuilder.insert(j+1,"D:");
                        j=j+2;
                    }else if ((stringBuilder.charAt(j)+"").equals("#") && j+1==ij+6){
                        stringBuilder.insert(j+1,"E:");
                        j=j+2;
                    }else if ((stringBuilder.charAt(j)+"").equals("#") && j+1==ij+8){
                        stringBuilder.insert(j+1,"F:");
                        j=j+2;
                    }else if ((stringBuilder.charAt(j)+"").equals("#") && j+1==ij+10){
                        stringBuilder.insert(j+1,"G:");
                        j=j+2;
                    }
                }
                String substitution = stringBuilder.toString().replaceAll("#","\",\"").replaceAll(":","\":\"");
                String optionSplicing = "{\""+substitution+"\"}";
                tSocietyProblems = tSocietyProblems1.get(i).setOptionAll(optionSplicing);
            }
        }
        return tSocietyProblems;
    }

    /**
     *    正确选项的枚举转换
     * @param optionCorrect
     * @return
     */
    public TSocietyProblems transformationEnum(List<TSocietyProblems> tSocietyProblems1){
        TSocietyProblems tSocietyProblems = new TSocietyProblems();
        for (int i = 0; i < tSocietyProblems1.size(); i++) {
            String optionCorrect = tSocietyProblems1.get(i).getOptionCorrect();
            //对正确答案进行枚举转换,如何有个正确答案走这个方法。
            char[] charsOptionCorrect = new char[optionCorrect.length()];
            if (StringUtils.isNotBlank(optionCorrect)){
                for (int j = 0; j <optionCorrect.length(); j++) {
                    if ((optionCorrect.charAt(j)+"").equals("0") ||(optionCorrect.charAt(j)+"").equals("1") || (optionCorrect.charAt(j)+"").equals("2") || (optionCorrect.charAt(j)+"").equals("3") ){
                        if ((optionCorrect.charAt(j)+"").equals("0")){
                            charsOptionCorrect[j] = OptionEnum.OPTION_A.getInfo().charAt(0);
                        }
                        if ((optionCorrect.charAt(j)+"").equals("1")){
                            charsOptionCorrect[j] = OptionEnum.OPTION_B.getInfo().charAt(0);
                        }
                        if ((optionCorrect.charAt(j)+"").equals("2")){
                            charsOptionCorrect[j] = OptionEnum.OPTION_C.getInfo().charAt(0);
                        }
                        if ((optionCorrect.charAt(j)+"").equals("3")){
                            charsOptionCorrect[j] = OptionEnum.OPTION_D.getInfo().charAt(0);
                        }
                        if ((optionCorrect.charAt(j)+"").equals("4")){
                            charsOptionCorrect[j] = OptionEnum.OPTION_E.getInfo().charAt(0);
                        }
                        if ((optionCorrect.charAt(j)+"").equals("5")){
                            charsOptionCorrect[j] = OptionEnum.OPTION_F.getInfo().charAt(0);
                        }
                        if ((optionCorrect.charAt(j)+"").equals("6")){
                            charsOptionCorrect[j] = OptionEnum.OPTION_G.getInfo().charAt(0);
                        }
                    } else {
                        charsOptionCorrect[j] = optionCorrect.charAt(j);
                    }
                }
            }
            tSocietyProblems = tSocietyProblems1.get(i).setOptionCorrect(new String(charsOptionCorrect));
        }
        return tSocietyProblems;
    }

    /**
     *     对正确答案进行枚举转换
     * @param optionCorrect
     * @return
     */
    public char[] transformationEnumCode(String optionCorrect){
        //对正确答案进行枚举转换,如何有个正确答案走这个方法。
        char[] charsOptionCorrect = new char[optionCorrect.length()];
        if (StringUtils.isNotBlank(optionCorrect)){
            for (int j = 0; j <optionCorrect.length(); j++) {
                if ((optionCorrect.charAt(j)+"").equals("A") || (optionCorrect.charAt(j)+"").equals("B")
                                                             || (optionCorrect.charAt(j)+"").equals("C")
                                                             || (optionCorrect.charAt(j)+"").equals("D")
                                                             || (optionCorrect.charAt(j)+"").equals("E")
                                                             || (optionCorrect.charAt(j)+"").equals("F")
                                                             || (optionCorrect.charAt(j)+"").equals("G")){
                    if ((optionCorrect.charAt(j)+"").equals("A")){
                        charsOptionCorrect[j] = (char) (OptionEnum.OPTION_A.getCode()+'0');
                    }
                    if ((optionCorrect.charAt(j)+"").equals("B")){
                        charsOptionCorrect[j] = (char) (OptionEnum.OPTION_B.getCode()+'0');
                    }
                    if ((optionCorrect.charAt(j)+"").equals("C")){
                        charsOptionCorrect[j] = (char) (OptionEnum.OPTION_C.getCode()+'0');
                    }
                    if ((optionCorrect.charAt(j)+"").equals("D")){
                        charsOptionCorrect[j] = (char) (OptionEnum.OPTION_D.getCode()+'0');
                    }
                    if ((optionCorrect.charAt(j)+"").equals("E")){
                        charsOptionCorrect[j] = (char) (OptionEnum.OPTION_E.getCode()+'0');
                    }
                    if ((optionCorrect.charAt(j)+"").equals("F")){
                        charsOptionCorrect[j] = (char) (OptionEnum.OPTION_F.getCode()+'0');
                    }
                    if ((optionCorrect.charAt(j)+"").equals("G")){
                        charsOptionCorrect[j] = (char) (OptionEnum.OPTION_G.getCode()+'0');
                    }
                } else {
                    charsOptionCorrect[j] = optionCorrect.charAt(j);
                }
            }
        }
        return charsOptionCorrect;
    }
}

业务接口:ITSocietyProblemsService

package org.jeecg.modules.management.problems.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.modules.management.problems.entity.TSocietyProblems;
import com.baomidou.mybatisplus.extension.service.IService;

/**
 * @Description: t_society_problems
 * @Author: jeecg-boot
 * @Date:   2023-02-01
 * @Version: V1.0
 */
public interface ITSocietyProblemsService extends IService<TSocietyProblems> {

    Page<TSocietyProblems> getProblemPageList(Page<TSocietyProblems> page, TSocietyProblems tSocietyProblems);

    /**
     *  根据题干类型查询
     * @param page
     * @param problemType
     * @return
     */
    Page<TSocietyProblems> queryForProblemType(Page<TSocietyProblems> page, Integer problemType);

    /**
     *  根据作废标志查询列表信息
     * @param page
     * @param zfbz
     * @return
     */
    Page<TSocietyProblems> queryForZfbz(Page<TSocietyProblems> page, String zfbz);

    /**
     *  根据题干进行查询
     * @param page
     * @param queryForProblemContent
     * @return
     */
    Page<TSocietyProblems> queryForProblemContent(Page<TSocietyProblems> page, String queryForProblemContent);
}

业务实现类:TSocietyProblemsServiceImpl

package org.jeecg.modules.management.problems.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.models.auth.In;
import org.jeecg.modules.management.problems.entity.TSocietyProblems;
import org.jeecg.modules.management.problems.mapper.TSocietyProblemsMapper;
import org.jeecg.modules.management.problems.service.ITSocietyProblemsService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @Description: t_society_problems
 * @Author: jeecg-boot
 * @Date:   2023-02-01
 * @Version: V1.0
 */
@Service
public class TSocietyProblemsServiceImpl extends ServiceImpl<TSocietyProblemsMapper, TSocietyProblems> implements ITSocietyProblemsService {

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Page<TSocietyProblems> getProblemPageList(Page<TSocietyProblems> page, TSocietyProblems tSocietyProblems) {
        return page.setRecords(baseMapper.getProblemPageList(page, tSocietyProblems));
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Page<TSocietyProblems> queryForProblemType(Page<TSocietyProblems> page, Integer problemType) {
        return page.setRecords(baseMapper.queryForProblemType(page,problemType));
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Page<TSocietyProblems> queryForZfbz(Page<TSocietyProblems> page, String zfbz) {
        return page.setRecords(baseMapper.queryForZfbz(page,zfbz));
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Page<TSocietyProblems> queryForProblemContent(Page<TSocietyProblems> page, String queryForProblemContent) {
        return page.setRecords(baseMapper.queryForProblemContent(page,queryForProblemContent));
    }
}

dao层:TSocietyProblemsMapper

package org.jeecg.modules.management.problems.mapper;

import java.util.List;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.management.problems.entity.TSocietyProblems;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

/**
 * @Description: t_society_problems
 * @Author: jeecg-boot
 * @Date:   2023-02-01
 * @Version: V1.0
 */
public interface TSocietyProblemsMapper extends BaseMapper<TSocietyProblems> {

    List<TSocietyProblems> getProblemPageList(Page<TSocietyProblems> page, TSocietyProblems tSocietyProblems);

    /**
     *  @Description: 根据题干类型查询
     * @param: page
     * @Author: TianLong
     * @param:
     * @param: problemType
     * @return
     */
    List<TSocietyProblems> queryForProblemType(Page<TSocietyProblems> page,Integer problemType);

    /**
     *  @Description: 根据作废标志查询
     * @param: page
     * @Author: TianLong
     * @param:
     * @param: zfbz
     * @return
     */
    List<TSocietyProblems> queryForZfbz(Page<TSocietyProblems> page,String zfbz);

    /**
     *  @Description: 根据题干查询
     * @param: page
     * @Author: TianLong
     * @param:
     * @param: problemContent
     * @return
     */
    List<TSocietyProblems> queryForProblemContent(Page<TSocietyProblems> page,String problemContent);

}

sql:TSocietyProblemsMapper.xml

<?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="org.jeecg.modules.management.problems.mapper.TSocietyProblemsMapper">
<!--映射结果集-->
<!--    <resultMap id="BaseResultMap" type="org.jeecg.modules.management.problems.entity.TSocietyProBlemsLike">-->
<!--        <result column="PROBLEM_CONTENT" property="problemContent" />-->
<!--        <result column="CONTENT_TYPE" property="contentType" />-->
<!--        <result column="ZFBZ" property="zfbz" />-->
<!--    </resultMap>-->

<!--    查询列表数据结果集-->
    <select id="getProblemPageList" parameterType="org.jeecg.modules.management.problems.entity.TSocietyProblems"  resultType="org.jeecg.modules.management.problems.entity.TSocietyProblems" >
        select UUID,PROBLEM_TYPE,CONTENT_TYPE,PROBLEM_CONTENT,OPTION_ALL,OPTION_CORRECT,ANALYZING,PROBLEM_SOURCE,UPTIME,ZFBZ
        from t_society_problems p where 1=1

    </select>

    <!--queryForZfbz   分页查询,题干数据查询-->
    <select id="queryForProblemType" parameterType="org.jeecg.modules.management.problems.entity.TSocietyProblems" resultType="org.jeecg.modules.management.problems.entity.TSocietyProblems">
        SELECT UUID,PROBLEM_TYPE,CONTENT_TYPE,PROBLEM_CONTENT,OPTION_ALL,OPTION_CORRECT,ANALYZING,PROBLEM_SOURCE,UPTIME,ZFBZ
        FROM t_society_problems where PROBLEM_TYPE = #{problemType}
    </select>

    <select id="queryForZfbz" parameterType="org.jeecg.modules.management.problems.entity.TSocietyProblems" resultType="org.jeecg.modules.management.problems.entity.TSocietyProblems">
        SELECT UUID,PROBLEM_TYPE,CONTENT_TYPE,PROBLEM_CONTENT,OPTION_ALL,OPTION_CORRECT,ANALYZING,PROBLEM_SOURCE,UPTIME,ZFBZ
        FROM t_society_problems where ZFBZ = #{zfbz}
    </select>
<!--    queryForProblemContent-->
    <select id="queryForProblemContent" parameterType="org.jeecg.modules.management.problems.entity.TSocietyProblems" resultType="org.jeecg.modules.management.problems.entity.TSocietyProblems">
        SELECT UUID,PROBLEM_TYPE,CONTENT_TYPE,PROBLEM_CONTENT,OPTION_ALL,OPTION_CORRECT,ANALYZING,PROBLEM_SOURCE,UPTIME,ZFBZ
        FROM t_society_problems where PROBLEM_CONTENT like concat('%',#{problemContent},'%')
    </select>
</mapper>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值