@@ -62,15 +62,15 @@ public UserController(IUserService userService) {
6262 */
6363 @ GetMapping
6464 @ RequiresPermissions (logical = Logical .AND , value = {"user:view" })
65- public ResponseBean user (@ Validated BaseDto baseDto ){
66- if (baseDto .getPage () == null || baseDto .getRows () == null ){
65+ public ResponseBean user (@ Validated BaseDto baseDto ) {
66+ if (baseDto .getPage () == null || baseDto .getRows () == null ) {
6767 baseDto .setPage (1 );
6868 baseDto .setRows (10 );
6969 }
7070 PageHelper .startPage (baseDto .getPage (), baseDto .getRows ());
7171 List <UserDto > userDtos = userService .selectAll ();
7272 PageInfo <UserDto > selectPage = new PageInfo <UserDto >(userDtos );
73- if (userDtos == null || userDtos .size () <= 0 ){
73+ if (userDtos == null || userDtos .size () <= 0 ) {
7474 throw new CustomException ("查询失败(Query Failure)" );
7575 }
7676 Map <String , Object > result = new HashMap <String , Object >(16 );
@@ -88,12 +88,12 @@ public ResponseBean user(@Validated BaseDto baseDto){
8888 */
8989 @ GetMapping ("/online" )
9090 @ RequiresPermissions (logical = Logical .AND , value = {"user:view" })
91- public ResponseBean online (){
91+ public ResponseBean online () {
9292 List <Object > userDtos = new ArrayList <Object >();
9393 // 查询所有Redis键
9494 Set <String > keys = JedisUtil .keysS (Constant .PREFIX_SHIRO_REFRESH_TOKEN + "*" );
9595 for (String key : keys ) {
96- if (JedisUtil .exists (key )){
96+ if (JedisUtil .exists (key )) {
9797 // 根据:分割key,获取最后一个字符(帐号)
9898 String [] strArray = key .split (":" );
9999 UserDto userDto = new UserDto ();
@@ -104,7 +104,7 @@ public ResponseBean online(){
104104 userDtos .add (userDto );
105105 }
106106 }
107- if (userDtos == null || userDtos .size () <= 0 ){
107+ if (userDtos == null || userDtos .size () <= 0 ) {
108108 throw new CustomException ("查询失败(Query Failure)" );
109109 }
110110 return new ResponseBean (HttpStatus .OK .value (), "查询成功(Query was successful)" , userDtos );
@@ -123,15 +123,15 @@ public ResponseBean login(@Validated(UserLoginValidGroup.class) @RequestBody Use
123123 UserDto userDtoTemp = new UserDto ();
124124 userDtoTemp .setAccount (userDto .getAccount ());
125125 userDtoTemp = userService .selectOne (userDtoTemp );
126- if (userDtoTemp == null ){
126+ if (userDtoTemp == null ) {
127127 throw new CustomUnauthorizedException ("该帐号不存在(The account does not exist.)" );
128128 }
129129 // 密码进行AES解密
130130 String key = AesCipherUtil .deCrypto (userDtoTemp .getPassword ());
131131 // 因为密码加密是以帐号+密码的形式进行加密的,所以解密后的对比是帐号+密码
132132 if (key .equals (userDto .getAccount () + userDto .getPassword ())) {
133133 // 清除可能存在的Shiro权限信息缓存
134- if (JedisUtil .exists (Constant .PREFIX_SHIRO_CACHE + userDto .getAccount ())){
134+ if (JedisUtil .exists (Constant .PREFIX_SHIRO_CACHE + userDto .getAccount ())) {
135135 JedisUtil .delKey (Constant .PREFIX_SHIRO_CACHE + userDto .getAccount ());
136136 }
137137 // 设置RefreshToken,时间戳为当前时间戳,直接设置即可(不用先删后设,会覆盖已有的RefreshToken)
@@ -187,9 +187,9 @@ public ResponseBean requireAuth() {
187187 */
188188 @ GetMapping ("/{id}" )
189189 @ RequiresPermissions (logical = Logical .AND , value = {"user:view" })
190- public ResponseBean findById (@ PathVariable ("id" ) Integer id ){
190+ public ResponseBean findById (@ PathVariable ("id" ) Integer id ) {
191191 UserDto userDto = userService .selectByPrimaryKey (id );
192- if (userDto == null ){
192+ if (userDto == null ) {
193193 throw new CustomException ("查询失败(Query Failure)" );
194194 }
195195 return new ResponseBean (HttpStatus .OK .value (), "查询成功(Query was successful)" , userDto );
@@ -209,18 +209,18 @@ public ResponseBean add(@Validated(UserEditValidGroup.class) @RequestBody UserDt
209209 UserDto userDtoTemp = new UserDto ();
210210 userDtoTemp .setAccount (userDto .getAccount ());
211211 userDtoTemp = userService .selectOne (userDtoTemp );
212- if (userDtoTemp != null && StringUtil .isNotBlank (userDtoTemp .getPassword ())){
212+ if (userDtoTemp != null && StringUtil .isNotBlank (userDtoTemp .getPassword ())) {
213213 throw new CustomUnauthorizedException ("该帐号已存在(Account exist.)" );
214214 }
215215 userDto .setRegTime (new Date ());
216216 // 密码以帐号+密码的形式进行AES加密
217- if (userDto .getPassword ().length () > Constant .PASSWORD_MAX_LEN ){
217+ if (userDto .getPassword ().length () > Constant .PASSWORD_MAX_LEN ) {
218218 throw new CustomException ("密码最多8位(Password up to 8 bits.)" );
219219 }
220220 String key = AesCipherUtil .enCrypto (userDto .getAccount () + userDto .getPassword ());
221221 userDto .setPassword (key );
222222 int count = userService .insert (userDto );
223- if (count <= 0 ){
223+ if (count <= 0 ) {
224224 throw new CustomException ("新增失败(Insert Failure)" );
225225 }
226226 return new ResponseBean (HttpStatus .OK .value (), "新增成功(Insert Success)" , userDto );
@@ -240,22 +240,22 @@ public ResponseBean update(@Validated(UserEditValidGroup.class) @RequestBody Use
240240 UserDto userDtoTemp = new UserDto ();
241241 userDtoTemp .setAccount (userDto .getAccount ());
242242 userDtoTemp = userService .selectOne (userDtoTemp );
243- if (userDtoTemp == null ){
243+ if (userDtoTemp == null ) {
244244 throw new CustomUnauthorizedException ("该帐号不存在(Account not exist.)" );
245- }else {
245+ } else {
246246 userDto .setId (userDtoTemp .getId ());
247247 }
248248 // FIXME: 如果不一样就说明用户修改了密码,重新加密密码(这个处理不太好,但是没有想到好的处理方式)
249- if (!userDtoTemp .getPassword ().equals (userDto .getPassword ())){
249+ if (!userDtoTemp .getPassword ().equals (userDto .getPassword ())) {
250250 // 密码以帐号+密码的形式进行AES加密
251- if (userDto .getPassword ().length () > Constant .PASSWORD_MAX_LEN ){
251+ if (userDto .getPassword ().length () > Constant .PASSWORD_MAX_LEN ) {
252252 throw new CustomException ("密码最多8位(Password up to 8 bits.)" );
253253 }
254254 String key = AesCipherUtil .enCrypto (userDto .getAccount () + userDto .getPassword ());
255255 userDto .setPassword (key );
256256 }
257257 int count = userService .updateByPrimaryKeySelective (userDto );
258- if (count <= 0 ){
258+ if (count <= 0 ) {
259259 throw new CustomException ("更新失败(Update Failure)" );
260260 }
261261 return new ResponseBean (HttpStatus .OK .value (), "更新成功(Update Success)" , userDto );
@@ -270,9 +270,9 @@ public ResponseBean update(@Validated(UserEditValidGroup.class) @RequestBody Use
270270 */
271271 @ DeleteMapping ("/{id}" )
272272 @ RequiresPermissions (logical = Logical .AND , value = {"user:edit" })
273- public ResponseBean delete (@ PathVariable ("id" ) Integer id ){
273+ public ResponseBean delete (@ PathVariable ("id" ) Integer id ) {
274274 int count = userService .deleteByPrimaryKey (id );
275- if (count <= 0 ){
275+ if (count <= 0 ) {
276276 throw new CustomException ("删除失败,ID不存在(Deletion Failed. ID does not exist.)" );
277277 }
278278 return new ResponseBean (HttpStatus .OK .value (), "删除成功(Delete Success)" , null );
@@ -287,10 +287,10 @@ public ResponseBean delete(@PathVariable("id") Integer id){
287287 */
288288 @ DeleteMapping ("/online/{id}" )
289289 @ RequiresPermissions (logical = Logical .AND , value = {"user:edit" })
290- public ResponseBean deleteOnline (@ PathVariable ("id" ) Integer id ){
290+ public ResponseBean deleteOnline (@ PathVariable ("id" ) Integer id ) {
291291 UserDto userDto = userService .selectByPrimaryKey (id );
292- if (JedisUtil .exists (Constant .PREFIX_SHIRO_REFRESH_TOKEN + userDto .getAccount ())){
293- if (JedisUtil .delKey (Constant .PREFIX_SHIRO_REFRESH_TOKEN + userDto .getAccount ()) > 0 ){
292+ if (JedisUtil .exists (Constant .PREFIX_SHIRO_REFRESH_TOKEN + userDto .getAccount ())) {
293+ if (JedisUtil .delKey (Constant .PREFIX_SHIRO_REFRESH_TOKEN + userDto .getAccount ()) > 0 ) {
294294 return new ResponseBean (HttpStatus .OK .value (), "剔除成功(Delete Success)" , null );
295295 }
296296 }
0 commit comments