1、@RestController
@RestController
相当于@Controller+@ResponseBody两个注解的结合,返回json数据不需要在方法前面加@ResponseBody注解了,但使用@RestController这个注解,就不能返回jsp,html页面,视图解析器无法解析jsp,html页
@RestController @RequestMapping("/test") public class TestClassController { @GetMapping("/test") private String test(){ System.out.println(hello); String yhz = environment.getProperty("hello"); System.out.println(yhz); return yhz; } }
2、@Anonymous
@Anonymous匿名访问不鉴权注解
3、forEach
public AjaxResult addOrEdit(List<WechatMenu> menus) { menus.forEach(menu -> { if (ObjectUtils.isEmpty(menu.getId())) { menu.setAddTime(System.currentTimeMillis()); menu.setCreateBy(SecurityUtils.getUsername()); menu.setCreateTime(new Date()); this.save(menu); } else { menu.setEditTime(System.currentTimeMillis()); menu.setUpdateBy(SecurityUtils.getUsername()); menu.setUpdateTime(new Date()); this.updateById(menu); } }); return AjaxResult.success(); }
4、逻辑删除
<update id="deleteWechatReplayByReplayIds" parameterType="String"> update wechat_replay set del_flag = 1 where replay_id in <foreach item="replayId" collection="array" open="(" separator="," close=")"> #{replayId} </foreach> </update>
5、是否存在
public boolean isExist(String mobile) { return ObjectUtils.isNotEmpty(this.getOne(new QueryWrapper<MobileBlacklist>().eq("mobile", mobile).or().eq("work_mobile", mobile))); }
6、rollbackFor
@Transactional(rollbackFor = Exception.class)
7、枚举类
import lombok.Getter; @Getter public enum WxEeventType { /** * 关注公众号 */ SUBSCRIBE("subscribe"), /** * 取消关注公众号 */ UNSUBSCRIBE("unsubscribe");
private String code; WxEeventType(String code) { this.code = code; } }
WxEeventType wxEeventType = WxEeventType.SUBSCRIBE.getCode().equals(subEvent) ? WxEeventType.SUBSCRIBE : WxEeventType.UNSUBSCRIBE; if (wxEeventType.getCode().equals("subscribe")){ }
else if (wxEeventType.getCode().equals("unsubscribe")){}
标签:知识点,code,java,String,mobile,menu,WxEeventType,System,整理 From: https://www.cnblogs.com/mions/p/16743934.html