杂文

239 阅读2分钟

1 #{id, jdbcType=INTEGER} 的例子

@ApiOperation(value="删除", notes="根据id删除")
@PostMapping("/remove")
public CommonResult remove(@RequestBody DepartmentAuditRequest jsonRequest){
    schoolAuditService.removeByPrimaryKey(jsonRequest);
    return ResultUtil.success(ResultCode.SUCCESS);
}
@Data
public class DepartmentAuditRequest extends BaseRequest implements Serializable
{
   private static final long serialVersionUID = 1L;

   private Integer id;

   /** 所属院系代码 */
   @ApiModelProperty(value = "所属院系代码")
   private String departCode;
   
   /** 评审人工号 */
   @ApiModelProperty(value = "评审人工号")
   private String userId;
   
int removeByPrimaryKey(DepartmentAuditRequest jsonRequest);
    <!-- 根据主键ID删除 pert 2021-1-15 -->
<update id="removeByPrimaryKey">
   update school_audit set del_flag = 1
   where id = #{id, jdbcType=INTEGER} 
</update>

2如上,通过id进行删除,sql语句通过#{id, jdbcType=INTEGER},可拿到DepartmentAuditRequest封装类里的id,传进来的请求可以是DepartmentAuditRequest,而然其实只传了id,但最后只封装了id,其他属性都空,只要sql语句能取到id就行了。

2.3更新...........................

1.定值引入

2.如上,分页型结果写法优化

3.如下。欲用分页

@Override
public PageInfo<UserVO> findUserByOrg(FindOrgUserPageRequest request) {
    PageHelper.startPage(request.getPage(),request.getPageSize());
    List<UserVO> sysOrgCode = sysOrgUserMapper.findUserByOrgCode(request.getOrgCode());
    PageInfo<UserVO> info = new PageInfo(sysOrgCode);
    info.setTotal(sysOrgCode.size());
    return info;
}

3.2更新...........................

1 JSON.parseObject(String str)是将str转化为相应的JSONObject对象,其中str是“键值对”形式的json字符串,转化为JSONObject对象之后就可以使用其内置的方法,进行各种处理了。

public AlinpayConfig(String payParam) { Assert.notNull(payParam, "init AllinpayConfig config error");//判断传入的payParam值是否为空,为空则直接抛出异常, 该函数的意思是传入的object必须不能为空。如果为空就抛出异常。 JSONObject object = JSONObject.parseObject(payParam);//JSON.parseObject(String str)是将str转化为相应的JSONObject对象,其中str是“键值对”形式的json字符串,转化为JSONObject对象之后就可以使用其内置的方法,进行各种处理了。 this.appId = object.getString("appid"); this.key = object.getString("key"); this.c = object.getString("c"); } ———————————————— 版权声明:本文为CSDN博主「chen3888015」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 原文链接:blog.csdn.net/chen3888015…

2 将string转化为对象

public CommonResult save(@RequestBody String jsonStr ){  
	MatchInfoAndStepVO matchInfoAndStepVO = JSONObject.parseObject(jsonStr, MatchInfoAndStepVO.class);   
	MatchInformationRequest matchInformationRequest=matchInfoAndStepVO.getMatchInformationRequest();
	String msg = matchInformationService.save(matchInformationRequest, matchInfoAndStepVO);

3新特性集合循环操作

 List<MatchStepRequest> matchStepRequests = matchInfoAndStepVO.getMatchStepRequests();
 if (matchStepRequests.size() > 0) {
 //    List<MatchInformation> matchInformations = matchInformationMapper.findByMatchName(matchInformation.getMatchName());
 Integer matchId = matchInformation.getMatchId();
 //更新赛事阶段状态  默认前后阶段按时间排序​
 matchStepRequests.stream().forEach(matchStepRequest -> {
 matchStepRequest.setMatchId(matchId);
 setMatchStepState(matchStepRequest);
 matchStepService.save(matchStepRequest);
 });