springBoot 常用@注解标签

1.  @Service("/orgService")    

2.  @SuppressWarnings("unused")   忽略警告。

3.  @Value("${cloudDir}")    内容注入。

springBoot 常用@注解标签_第1张图片

 2. 接收数据类型为json对象or form表单数据类型时。

  a.  json

   controller层

/**
	 * 创建或修改查验任务
	 * @param task
	 * @return
	 */
	@RequestMapping(value = "/rest", params = "method=ciq.checktask.createtask")
	public ResMsg createTask(@RequestBody CheckTask task) {
		checkTaskService.createTask(this.getUserId(), task);
		return ResMsg.success();
	}

     service层 : 判断有无id,有id修改,无id新增。

    @Autowired
	private CheckTaskMapper checkTaskMapper;
	
	@Autowired
	private CheckTaskDetailMapper checkTaskDetailMapper;
	
	@Autowired
	private CheckTaskStepMapper checkTaskStepMapper;
	
	@Autowired
	private CrossOrderMapper crossOrderMapper;
	
	public int createTask(Long userId, CheckTask task) {
		int result = 0;
		if(task.getId() != null) {
			checkTaskMapper.updateByPrimaryKeySelective(task);
			//删除明细
			checkTaskDetailMapper.deleteByCheckTaskId(task.getId());
			//重新保存明细
			List details = task.getDetails();
			for(int i=0; i details = task.getDetails();
			for(int i=0; i

b.  form表单

     删除操作:

    /**
	 * 删除查验任务
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/rest", params = "method=ciq.checktask.remove")
	public ResMsg remove(Long id) {
		checkTaskService.remove(id);
		return ResMsg.success();
	}
    @Override
	public int remove(Object id) {
		CheckTask task = checkTaskMapper.selectByPrimaryKey(id);
		if(task != null && task.getStatus() != 0) {
			throw new BusinessException("{checkTask.status.cannotRemove}", "任务不允许删除");
		}
		return checkTaskMapper.deleteByPrimaryKey(id);
	}

 分页查询操作 :

    /**
	 * 查验任务处理列表
	 * @param pageIndex
	 * @param pageSize
	 * @param userId
	 * @param status
	 * @param eciqCode
	 * @return
	 */
	@RequestMapping(value = "/rest", params = "method=ciq.checktask.list")
	@ResponseBody
	public ResMsg list(Integer pageIndex, Integer pageSize, Long userId, String status, String eciqCode,
            String writeOffBillCode,String orderCode,String orgName,String createTime,String finishTime,String planTime) {
		
		//报检号eciqCode     核销号writeOffBillCode   订单编号 orderCode
		//申请单位 orgName   创建时间createTime    处理时间  finishTime
		Integer[] arrStatus = {0,1,2,3,4};
		 
		//创建任务、准备好,开始检查,完成检查,关闭任务
		if(hasRole("ciq_yunying")) {
			//看全部的
			PageList page = checkTaskService.page(pageIndex, pageSize, userId, arrStatus, eciqCode,
					writeOffBillCode,orderCode,orgName,createTime,finishTime,planTime);
			return ResMsg.success(page);
		}
		if(hasRole("ciq_jianyiju")) {
			PageList page = checkTaskService.page(pageIndex, pageSize, userId, arrStatus, eciqCode,
					writeOffBillCode,orderCode,orgName,createTime,finishTime,planTime);
			return ResMsg.success(page);
		}
		if (hasRole("ciq_chayanyuan")) {
			PageList page = checkTaskService.page(pageIndex, pageSize, this.getUserId(), arrStatus, eciqCode,
					writeOffBillCode,orderCode,orgName,createTime,finishTime,planTime);
			return ResMsg.success(page);
		}
		return ResMsg.success(new PageList());
	}
	@Override
	public PageList page(Integer pageIndex, Integer pageSize, Long checkPersonelUserId, Integer[] arrStatus, String eciqCode,
			 String writeOffBillCode,String orderCode,String orgName,String createTime,String finishTime,String planTime) {
		
		Example exp = new Example(CheckTask.class);
		Criteria c = exp.createCriteria();
		
		//查验人员是自己
		if(checkPersonelUserId != null) {
			c.andEqualTo("checkPersonelUserId", checkPersonelUserId);
		}
		//状态
		if(arrStatus != null && arrStatus.length > 0) {
			c.andIn("status", Arrays.asList(arrStatus));
		}
		int[] status ={};
		//调用多条件查询的方法
		expBase(c, exp, null, status, eciqCode, writeOffBillCode, orderCode, orgName, createTime, finishTime, planTime);
		
		 
		return this.page(exp, pageIndex, pageSize);
	}

 

你可能感兴趣的:(spring,boot)