fix bugs
This commit is contained in:
		
							parent
							
								
									3f72e65969
								
							
						
					
					
						commit
						f77f9af17a
					
				@ -5,7 +5,7 @@ import com.example.survey.dto.project.CreateProjectDTO;
 | 
				
			|||||||
import com.example.survey.dto.project.DeleteRecordDTO;
 | 
					import com.example.survey.dto.project.DeleteRecordDTO;
 | 
				
			||||||
import com.example.survey.dto.project.ModifyProjectDTO;
 | 
					import com.example.survey.dto.project.ModifyProjectDTO;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.example.survey.enumeration.RespondentStateEnum;
 | 
					// import com.example.survey.enumeration.RespondentStateEnum;
 | 
				
			||||||
import com.example.survey.enumeration.ResultEnum;
 | 
					import com.example.survey.enumeration.ResultEnum;
 | 
				
			||||||
import com.example.survey.service.ProjectService;
 | 
					import com.example.survey.service.ProjectService;
 | 
				
			||||||
import com.example.survey.vo.ResultVO;
 | 
					import com.example.survey.vo.ResultVO;
 | 
				
			||||||
 | 
				
			|||||||
@ -35,8 +35,7 @@ public class RecordController {
 | 
				
			|||||||
            @RequestParam(value = "submitTimeLt", required = false, defaultValue = "0") long submitTimeLt,
 | 
					            @RequestParam(value = "submitTimeLt", required = false, defaultValue = "0") long submitTimeLt,
 | 
				
			||||||
            @RequestParam(value = "projectName", required = false) String projectName,
 | 
					            @RequestParam(value = "projectName", required = false) String projectName,
 | 
				
			||||||
            @RequestParam(value = "currentPage", defaultValue = "0") Integer currentPage,
 | 
					            @RequestParam(value = "currentPage", defaultValue = "0") Integer currentPage,
 | 
				
			||||||
                              @RequestParam(value = "pageSize", defaultValue = "30") Integer pageSize
 | 
					            @RequestParam(value = "pageSize", defaultValue = "30") Integer pageSize) {
 | 
				
			||||||
    ) {
 | 
					 | 
				
			||||||
        Map<String, Object> resultMap = new HashMap<>(16, 0.75F);
 | 
					        Map<String, Object> resultMap = new HashMap<>(16, 0.75F);
 | 
				
			||||||
        resultMap.put("totalCount", recordService.countRecord(idNumber, state, uuid, templateName, templateType,
 | 
					        resultMap.put("totalCount", recordService.countRecord(idNumber, state, uuid, templateName, templateType,
 | 
				
			||||||
                submitTimeGt, submitTimeLt, projectName));
 | 
					                submitTimeGt, submitTimeLt, projectName));
 | 
				
			||||||
@ -51,21 +50,24 @@ public class RecordController {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @GetMapping("/recordValues")
 | 
					    @GetMapping("/recordValues")
 | 
				
			||||||
    public ResultVO getRecordValue(@RequestParam("uuid") String uuid
 | 
					    public ResultVO getRecordValue(@RequestParam("uuid") String uuid) {
 | 
				
			||||||
                                  ) {
 | 
					 | 
				
			||||||
        ResultVO resultVO = new ResultVO(ResultEnum.SUCCESS);
 | 
					        ResultVO resultVO = new ResultVO(ResultEnum.SUCCESS);
 | 
				
			||||||
        resultVO.setData(recordService.getRecordValues(uuid));
 | 
					        resultVO.setData(recordService.getRecordValues(uuid));
 | 
				
			||||||
        return resultVO;
 | 
					        return resultVO;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @PutMapping("/review")
 | 
					    @PutMapping("/review")
 | 
				
			||||||
    public ResultVO reviewRecord(@RequestBody ReviewRecordDTO reviewRecordDTO) {
 | 
					    public ResultVO reviewRecord(@RequestBody ReviewRecordDTO reviewRecordDTO,
 | 
				
			||||||
 | 
					            @RequestHeader("Authorization") String token) {
 | 
				
			||||||
 | 
					        reviewRecordDTO.setReviewerPhone((String) TokenUtil.get(token + " : USER_PHONE"));
 | 
				
			||||||
        recordService.reviewRecord(reviewRecordDTO);
 | 
					        recordService.reviewRecord(reviewRecordDTO);
 | 
				
			||||||
        return new ResultVO(ResultEnum.SUCCESS);
 | 
					        return new ResultVO(ResultEnum.SUCCESS);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @PutMapping("/record")
 | 
					    @PutMapping("/record")
 | 
				
			||||||
    public ResultVO modifyRecord(@RequestBody ModifyRecordDTO modifyRecordDTO) {
 | 
					    public ResultVO modifyRecord(@RequestBody ModifyRecordDTO modifyRecordDTO,
 | 
				
			||||||
 | 
					            @RequestHeader("Authorization") String token) {
 | 
				
			||||||
 | 
					        modifyRecordDTO.setUserPhone((String) TokenUtil.get(token + " : USER_PHONE"));
 | 
				
			||||||
        recordService.modifyRecord(modifyRecordDTO);
 | 
					        recordService.modifyRecord(modifyRecordDTO);
 | 
				
			||||||
        return new ResultVO(ResultEnum.SUCCESS);
 | 
					        return new ResultVO(ResultEnum.SUCCESS);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -95,14 +97,14 @@ public class RecordController {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @GetMapping("/record2word")
 | 
					    @GetMapping("/record2word")
 | 
				
			||||||
    public void record2word(@RequestParam("uuid")String uuid,
 | 
					    public void record2word(@RequestParam("uuid") String uuid, HttpServletResponse response) {
 | 
				
			||||||
                            HttpServletResponse response){
 | 
					 | 
				
			||||||
        recordService.record2word(uuid, response);
 | 
					        recordService.record2word(uuid, response);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    @PutMapping("/metaData")
 | 
					    @PutMapping("/metaData")
 | 
				
			||||||
    public ResultVO modifyMetaData(@RequestBody ModifyMetaDataDTO modifyMetaDataDTO){
 | 
					    public ResultVO modifyMetaData(@RequestBody ModifyMetaDataDTO modifyMetaDataDTO,
 | 
				
			||||||
 | 
					                                    @RequestHeader("Authorization") String token) {
 | 
				
			||||||
 | 
					        modifyMetaDataDTO.setPhone((String) TokenUtil.get(token + " : USER_PHONE"));
 | 
				
			||||||
        recordService.modifyMetaData(modifyMetaDataDTO);
 | 
					        recordService.modifyMetaData(modifyMetaDataDTO);
 | 
				
			||||||
        return new ResultVO(ResultEnum.SUCCESS);
 | 
					        return new ResultVO(ResultEnum.SUCCESS);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +1,7 @@
 | 
				
			|||||||
package com.example.survey.dao;
 | 
					package com.example.survey.dao;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.example.survey.entity.Record;
 | 
					import com.example.survey.entity.Record;
 | 
				
			||||||
import com.example.survey.entity.Respondent;
 | 
					// import com.example.survey.entity.Respondent;
 | 
				
			||||||
import com.example.survey.entity.User;
 | 
					import com.example.survey.entity.User;
 | 
				
			||||||
import com.example.survey.enumeration.MetaDataTypeEnum;
 | 
					import com.example.survey.enumeration.MetaDataTypeEnum;
 | 
				
			||||||
import com.example.survey.enumeration.RecordStateEnum;
 | 
					import com.example.survey.enumeration.RecordStateEnum;
 | 
				
			||||||
 | 
				
			|||||||
@ -9,4 +9,5 @@ import lombok.Data;
 | 
				
			|||||||
public class ModifyMetaDataDTO {
 | 
					public class ModifyMetaDataDTO {
 | 
				
			||||||
    private String uuid;
 | 
					    private String uuid;
 | 
				
			||||||
    private String metaDataName;
 | 
					    private String metaDataName;
 | 
				
			||||||
 | 
					    private String phone;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -1,73 +0,0 @@
 | 
				
			|||||||
package com.example.survey.entity;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import com.example.survey.entity.inner.AdministrativeArea;
 | 
					 | 
				
			||||||
import com.example.survey.entity.inner.ProjectPart;
 | 
					 | 
				
			||||||
import lombok.*;
 | 
					 | 
				
			||||||
import org.bson.types.ObjectId;
 | 
					 | 
				
			||||||
import org.springframework.data.annotation.Id;
 | 
					 | 
				
			||||||
import org.springframework.data.mongodb.core.index.CompoundIndex;
 | 
					 | 
				
			||||||
import org.springframework.data.mongodb.core.index.CompoundIndexes;
 | 
					 | 
				
			||||||
import org.springframework.data.mongodb.core.index.Indexed;
 | 
					 | 
				
			||||||
import org.springframework.data.mongodb.core.mapping.DBRef;
 | 
					 | 
				
			||||||
import org.springframework.data.mongodb.core.mapping.Document;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import java.util.Set;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * @author Pope
 | 
					 | 
				
			||||||
 * 调查对象表
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
@Data
 | 
					 | 
				
			||||||
@Document(collection = "respondent")
 | 
					 | 
				
			||||||
@CompoundIndexes({
 | 
					 | 
				
			||||||
        @CompoundIndex(name = "unique",def = "{idNumber : 1, project : 1}",unique = true)
 | 
					 | 
				
			||||||
})
 | 
					 | 
				
			||||||
public class Respondent {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * id
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    @Id
 | 
					 | 
				
			||||||
    private ObjectId id;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * 身份证号
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    private String idNumber;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * 电话
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    private String phone;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * 姓名
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    private String name;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * 备注
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    private String msg;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * 性别
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    private String gender;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * 行政区划
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    private AdministrativeArea administrativeArea;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * 分配的人员
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    @DBRef
 | 
					 | 
				
			||||||
    private User user;
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * 调查对象状态
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    private String state;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -61,6 +61,16 @@ public class Operation {
 | 
				
			|||||||
        return modify;
 | 
					        return modify;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static Operation modifyMetaOp(User user, String msg) {
 | 
				
			||||||
 | 
					        Operation modify = new Operation();
 | 
				
			||||||
 | 
					        modify.setType(OpTypeEnum.META.getValue());
 | 
				
			||||||
 | 
					        modify.setTime(new Date());
 | 
				
			||||||
 | 
					        modify.setUser(user);
 | 
				
			||||||
 | 
					        modify.setMsg(msg);
 | 
				
			||||||
 | 
					        modify.setResult("提交修改");
 | 
				
			||||||
 | 
					        return modify;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static Operation deleteOp(User user, String msg) {
 | 
					    public static Operation deleteOp(User user, String msg) {
 | 
				
			||||||
        Operation delete = new Operation();
 | 
					        Operation delete = new Operation();
 | 
				
			||||||
        delete.setType(OpTypeEnum.DELETE.getValue());
 | 
					        delete.setType(OpTypeEnum.DELETE.getValue());
 | 
				
			||||||
 | 
				
			|||||||
@ -28,6 +28,7 @@ public enum OpTypeEnum {
 | 
				
			|||||||
     * 覆盖
 | 
					     * 覆盖
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    COVER("覆盖"),
 | 
					    COVER("覆盖"),
 | 
				
			||||||
 | 
					    META("修改模板"),
 | 
				
			||||||
    ;
 | 
					    ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final String value;
 | 
					    private final String value;
 | 
				
			||||||
 | 
				
			|||||||
@ -1,32 +0,0 @@
 | 
				
			|||||||
package com.example.survey.enumeration;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * @author Pope
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
public enum RespondentStateEnum {
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * 已调查状态
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    INVESTIGATED("已调查"),
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * 未调查状态
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    NOT_INVESTIGATED("未调查"),
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * 已归档
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    FILED("已归档"),
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    ;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private final String value;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    RespondentStateEnum(String value) {
 | 
					 | 
				
			||||||
        this.value = value;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public String getValue() {
 | 
					 | 
				
			||||||
        return value;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -5,7 +5,7 @@ import com.example.survey.dto.record.*;
 | 
				
			|||||||
import com.example.survey.entity.*;
 | 
					import com.example.survey.entity.*;
 | 
				
			||||||
import com.example.survey.entity.inner.Operation;
 | 
					import com.example.survey.entity.inner.Operation;
 | 
				
			||||||
import com.example.survey.enumeration.RecordStateEnum;
 | 
					import com.example.survey.enumeration.RecordStateEnum;
 | 
				
			||||||
import com.example.survey.enumeration.RespondentStateEnum;
 | 
					
 | 
				
			||||||
import com.example.survey.enumeration.ResultEnum;
 | 
					import com.example.survey.enumeration.ResultEnum;
 | 
				
			||||||
import com.example.survey.exception.*;
 | 
					import com.example.survey.exception.*;
 | 
				
			||||||
import com.example.survey.service.RecordService;
 | 
					import com.example.survey.service.RecordService;
 | 
				
			||||||
@ -237,6 +237,21 @@ public class RecordServiceImpl implements RecordService {
 | 
				
			|||||||
        MetaData metaData = metaDataDao.selectMetaData(modifyMetaDataDTO.getMetaDataName());
 | 
					        MetaData metaData = metaDataDao.selectMetaData(modifyMetaDataDTO.getMetaDataName());
 | 
				
			||||||
       
 | 
					       
 | 
				
			||||||
        Record record = recordDao.getRecord(modifyMetaDataDTO.getUuid());
 | 
					        Record record = recordDao.getRecord(modifyMetaDataDTO.getUuid());
 | 
				
			||||||
 | 
					        if(record == null) {
 | 
				
			||||||
 | 
					            throw new RecordException(ResultEnum.NOT_EXIST_RECORD);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (!userDao.existUser(modifyMetaDataDTO.getPhone())) {
 | 
				
			||||||
 | 
					            throw new UserException(ResultEnum.NOT_EXIST_USER);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        User user = userDao.selectUser(modifyMetaDataDTO.getPhone());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        List<Operation> operationList = record.getOperationList();
 | 
				
			||||||
 | 
					        String msg = record.getMetaData().getName() +"->" + modifyMetaDataDTO.getMetaDataName();
 | 
				
			||||||
 | 
					        Operation modifyMetaOp = Operation.modifyMetaOp(user, msg);
 | 
				
			||||||
 | 
					        // modifyMetaOp.setMsg();
 | 
				
			||||||
 | 
					        operationList.add(modifyMetaOp);
 | 
				
			||||||
 | 
					        record.setOperationList(operationList);
 | 
				
			||||||
        record.setMetaData(metaData);
 | 
					        record.setMetaData(metaData);
 | 
				
			||||||
        recordDao.saveRecord(record);
 | 
					        recordDao.saveRecord(record);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +1,7 @@
 | 
				
			|||||||
package com.example.survey.vo;
 | 
					package com.example.survey.vo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.example.survey.entity.MetaData;
 | 
					import com.example.survey.entity.MetaData;
 | 
				
			||||||
import com.example.survey.entity.Respondent;
 | 
					// import com.example.survey.entity.Respondent;
 | 
				
			||||||
import com.fasterxml.jackson.annotation.JsonFormat;
 | 
					import com.fasterxml.jackson.annotation.JsonFormat;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import lombok.Data;
 | 
					import lombok.Data;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user