56 changed files with 768 additions and 1094 deletions
			
			
		@ -1,25 +0,0 @@ | 
				
			|||
-- 用户表 | 
				
			|||
CREATE TABLE tb_user ( | 
				
			|||
  id bigint NOT NULL COMMENT 'id', | 
				
			|||
  username varchar(50) NOT NULL COMMENT '用户名', | 
				
			|||
  mobile varchar(20) NOT NULL COMMENT '手机号', | 
				
			|||
  password varchar(64) COMMENT '密码', | 
				
			|||
  create_date datetime COMMENT '创建时间', | 
				
			|||
  PRIMARY KEY (id), | 
				
			|||
  UNIQUE INDEX (username) | 
				
			|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户'; | 
				
			|||
 | 
				
			|||
-- 用户Token表 | 
				
			|||
CREATE TABLE tb_token ( | 
				
			|||
  id bigint NOT NULL COMMENT 'id', | 
				
			|||
  user_id bigint NOT NULL COMMENT '用户ID', | 
				
			|||
  token varchar(100) NOT NULL COMMENT 'token', | 
				
			|||
  expire_date datetime COMMENT '过期时间', | 
				
			|||
  update_date datetime COMMENT '更新时间', | 
				
			|||
  PRIMARY KEY (id), | 
				
			|||
  UNIQUE INDEX (user_id), | 
				
			|||
  UNIQUE INDEX (token) | 
				
			|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户Token'; | 
				
			|||
 | 
				
			|||
-- 账号:13612345678  密码:admin | 
				
			|||
INSERT INTO tb_user (id, username, mobile, password, create_date) VALUES (1067246875800000168, 'mark', '13612345678', '8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918', now()); | 
				
			|||
@ -1,24 +0,0 @@ | 
				
			|||
CREATE TABLE tb_user ( | 
				
			|||
  id NUMBER(20, 0) NOT NULL, | 
				
			|||
  username varchar(50) NOT NULL, | 
				
			|||
  mobile varchar(20) NOT NULL, | 
				
			|||
  password varchar(64), | 
				
			|||
  create_date date, | 
				
			|||
  PRIMARY KEY (id) | 
				
			|||
); | 
				
			|||
CREATE UNIQUE INDEX idx_user_username on tb_user(username); | 
				
			|||
 | 
				
			|||
CREATE TABLE tb_token ( | 
				
			|||
  id NUMBER(20, 0) NOT NULL, | 
				
			|||
  user_id NUMBER(20, 0) NOT NULL, | 
				
			|||
  token varchar(100) NOT NULL, | 
				
			|||
  expire_date date, | 
				
			|||
  update_date date, | 
				
			|||
  PRIMARY KEY (id) | 
				
			|||
); | 
				
			|||
CREATE UNIQUE INDEX idx_token_user_id on tb_token(user_id); | 
				
			|||
CREATE UNIQUE INDEX idx_token on tb_token(token); | 
				
			|||
 | 
				
			|||
 | 
				
			|||
-- 账号:13612345678  密码:admin | 
				
			|||
INSERT INTO tb_user (id, username, mobile, password, create_date) VALUES (1067246875800000168, 'mark', '13612345678', '8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918', CURRENT_DATE); | 
				
			|||
@ -1,24 +0,0 @@ | 
				
			|||
CREATE TABLE tb_user ( | 
				
			|||
  id int8 NOT NULL, | 
				
			|||
  username varchar(50) NOT NULL, | 
				
			|||
  mobile varchar(20) NOT NULL, | 
				
			|||
  password varchar(64), | 
				
			|||
  create_date timestamp, | 
				
			|||
  PRIMARY KEY (id), | 
				
			|||
  UNIQUE (username) | 
				
			|||
); | 
				
			|||
 | 
				
			|||
CREATE TABLE tb_token ( | 
				
			|||
  id int8 NOT NULL, | 
				
			|||
  user_id int8 NOT NULL, | 
				
			|||
  token varchar(100) NOT NULL, | 
				
			|||
  expire_date timestamp, | 
				
			|||
  update_date timestamp, | 
				
			|||
  PRIMARY KEY (id), | 
				
			|||
  UNIQUE (user_id), | 
				
			|||
  UNIQUE (token) | 
				
			|||
); | 
				
			|||
 | 
				
			|||
 | 
				
			|||
-- 账号:13612345678  密码:admin | 
				
			|||
INSERT INTO tb_user (id, username, mobile, password, create_date) VALUES (1067246875800000168, 'mark', '13612345678', '8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918', now()); | 
				
			|||
@ -1,24 +0,0 @@ | 
				
			|||
CREATE TABLE tb_user ( | 
				
			|||
  id bigint NOT NULL, | 
				
			|||
  username varchar(50) NOT NULL, | 
				
			|||
  mobile varchar(20) NOT NULL, | 
				
			|||
  password varchar(64), | 
				
			|||
  create_date datetime, | 
				
			|||
  PRIMARY KEY (id), | 
				
			|||
  UNIQUE (username) | 
				
			|||
); | 
				
			|||
 | 
				
			|||
CREATE TABLE tb_token ( | 
				
			|||
  id bigint NOT NULL, | 
				
			|||
  user_id bigint NOT NULL, | 
				
			|||
  token varchar(100) NOT NULL, | 
				
			|||
  expire_date datetime, | 
				
			|||
  update_date datetime, | 
				
			|||
  PRIMARY KEY (id), | 
				
			|||
  UNIQUE (user_id), | 
				
			|||
  UNIQUE (token) | 
				
			|||
); | 
				
			|||
 | 
				
			|||
 | 
				
			|||
-- 账号:13612345678  密码:admin | 
				
			|||
INSERT INTO tb_user (id, username, mobile, password, create_date) VALUES (1067246875800000168, 'mark', '13612345678', '8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918', getdate()); | 
				
			|||
@ -1,34 +0,0 @@ | 
				
			|||
/** | 
				
			|||
 /** | 
				
			|||
 * Copyright (c) 2018 人人开源 All rights reserved. | 
				
			|||
 * | 
				
			|||
 * https://www.renren.io
 | 
				
			|||
 * | 
				
			|||
 * 版权所有,侵权必究! | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
package com.epmet.dto; | 
				
			|||
 | 
				
			|||
import io.swagger.annotations.ApiModel; | 
				
			|||
import io.swagger.annotations.ApiModelProperty; | 
				
			|||
import lombok.Data; | 
				
			|||
 | 
				
			|||
import javax.validation.constraints.NotBlank; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 登录表单 | 
				
			|||
 * | 
				
			|||
 * @author Mark sunlightcs@gmail.com | 
				
			|||
 */ | 
				
			|||
@Data | 
				
			|||
@ApiModel(value = "登录表单") | 
				
			|||
public class LoginDTO { | 
				
			|||
    @ApiModelProperty(value = "手机号") | 
				
			|||
    @NotBlank(message="{api.mobile.require}") | 
				
			|||
    private String mobile; | 
				
			|||
 | 
				
			|||
    @ApiModelProperty(value = "密码") | 
				
			|||
    @NotBlank(message="{api.password.require}") | 
				
			|||
    private String password; | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -1,33 +0,0 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright (c) 2018 人人开源 All rights reserved. | 
				
			|||
 * | 
				
			|||
 * https://www.renren.io
 | 
				
			|||
 * | 
				
			|||
 * 版权所有,侵权必究! | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
package com.epmet.dto; | 
				
			|||
 | 
				
			|||
import io.swagger.annotations.ApiModel; | 
				
			|||
import io.swagger.annotations.ApiModelProperty; | 
				
			|||
import lombok.Data; | 
				
			|||
 | 
				
			|||
import javax.validation.constraints.NotBlank; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 注册表单 | 
				
			|||
 * | 
				
			|||
 * @author Mark sunlightcs@gmail.com | 
				
			|||
 */ | 
				
			|||
@Data | 
				
			|||
@ApiModel(value = "注册表单") | 
				
			|||
public class RegisterDTO { | 
				
			|||
    @ApiModelProperty(value = "手机号") | 
				
			|||
    @NotBlank(message="{api.mobile.require}") | 
				
			|||
    private String mobile; | 
				
			|||
 | 
				
			|||
    @ApiModelProperty(value = "密码") | 
				
			|||
    @NotBlank(message="{api.password.require}") | 
				
			|||
    private String password; | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -1,21 +0,0 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright (c) 2018 人人开源 All rights reserved. | 
				
			|||
 * | 
				
			|||
 * https://www.renren.io
 | 
				
			|||
 * | 
				
			|||
 * 版权所有,侵权必究! | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
package com.epmet.annotation; | 
				
			|||
 | 
				
			|||
import java.lang.annotation.*; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 登录效验 | 
				
			|||
 * @author Mark sunlightcs@gmail.com | 
				
			|||
 */ | 
				
			|||
@Target(ElementType.METHOD) | 
				
			|||
@Retention(RetentionPolicy.RUNTIME) | 
				
			|||
@Documented | 
				
			|||
public @interface Login { | 
				
			|||
} | 
				
			|||
@ -1,25 +0,0 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright (c) 2018 人人开源 All rights reserved. | 
				
			|||
 * | 
				
			|||
 * https://www.renren.io
 | 
				
			|||
 * | 
				
			|||
 * 版权所有,侵权必究! | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
package com.epmet.annotation; | 
				
			|||
 | 
				
			|||
import java.lang.annotation.ElementType; | 
				
			|||
import java.lang.annotation.Retention; | 
				
			|||
import java.lang.annotation.RetentionPolicy; | 
				
			|||
import java.lang.annotation.Target; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 登录用户信息 | 
				
			|||
 * | 
				
			|||
 * @author Mark sunlightcs@gmail.com | 
				
			|||
 */ | 
				
			|||
@Target(ElementType.PARAMETER) | 
				
			|||
@Retention(RetentionPolicy.RUNTIME) | 
				
			|||
public @interface LoginUser { | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -1,35 +0,0 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright (c) 2018 人人开源 All rights reserved. | 
				
			|||
 * | 
				
			|||
 * https://www.renren.io
 | 
				
			|||
 * | 
				
			|||
 * 版权所有,侵权必究! | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
package com.epmet.config; | 
				
			|||
 | 
				
			|||
import com.epmet.commons.tools.xss.XssFilter; | 
				
			|||
import org.springframework.boot.web.servlet.FilterRegistrationBean; | 
				
			|||
import org.springframework.context.annotation.Bean; | 
				
			|||
import org.springframework.context.annotation.Configuration; | 
				
			|||
 | 
				
			|||
import javax.servlet.DispatcherType; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * Filter配置 | 
				
			|||
 * | 
				
			|||
 * @author Mark sunlightcs@gmail.com | 
				
			|||
 */ | 
				
			|||
@Configuration | 
				
			|||
public class FilterConfig { | 
				
			|||
 | 
				
			|||
    @Bean | 
				
			|||
    public FilterRegistrationBean xssFilterRegistration() { | 
				
			|||
        FilterRegistrationBean registration = new FilterRegistrationBean(); | 
				
			|||
        registration.setDispatcherTypes(DispatcherType.REQUEST); | 
				
			|||
        registration.setFilter(new XssFilter()); | 
				
			|||
        registration.addUrlPatterns("/*"); | 
				
			|||
        registration.setName("xssFilter"); | 
				
			|||
        return registration; | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
@ -1,42 +0,0 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright (c) 2018 人人开源 All rights reserved. | 
				
			|||
 * | 
				
			|||
 * https://www.renren.io
 | 
				
			|||
 * | 
				
			|||
 * 版权所有,侵权必究! | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
package com.epmet.config; | 
				
			|||
 | 
				
			|||
import com.epmet.interceptor.AuthorizationInterceptor; | 
				
			|||
import com.epmet.resolver.LoginUserHandlerMethodArgumentResolver; | 
				
			|||
import org.springframework.beans.factory.annotation.Autowired; | 
				
			|||
import org.springframework.context.annotation.Configuration; | 
				
			|||
import org.springframework.web.method.support.HandlerMethodArgumentResolver; | 
				
			|||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; | 
				
			|||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | 
				
			|||
 | 
				
			|||
import java.util.List; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * MVC配置 | 
				
			|||
 * | 
				
			|||
 * @author Mark sunlightcs@gmail.com | 
				
			|||
 */ | 
				
			|||
@Configuration | 
				
			|||
public class WebConfig implements WebMvcConfigurer { | 
				
			|||
    @Autowired | 
				
			|||
    private AuthorizationInterceptor authorizationInterceptor; | 
				
			|||
    @Autowired | 
				
			|||
    private LoginUserHandlerMethodArgumentResolver loginUserHandlerMethodArgumentResolver; | 
				
			|||
 | 
				
			|||
    @Override | 
				
			|||
    public void addInterceptors(InterceptorRegistry registry) { | 
				
			|||
        registry.addInterceptor(authorizationInterceptor).addPathPatterns("/**"); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    @Override | 
				
			|||
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) { | 
				
			|||
        argumentResolvers.add(loginUserHandlerMethodArgumentResolver); | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
@ -1,61 +0,0 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright (c) 2018 人人开源 All rights reserved. | 
				
			|||
 * | 
				
			|||
 * https://www.renren.io
 | 
				
			|||
 * | 
				
			|||
 * 版权所有,侵权必究! | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
package com.epmet.controller; | 
				
			|||
 | 
				
			|||
 | 
				
			|||
import com.epmet.annotation.Login; | 
				
			|||
import com.epmet.commons.tools.utils.Result; | 
				
			|||
import com.epmet.commons.tools.validator.ValidatorUtils; | 
				
			|||
import com.epmet.dto.LoginDTO; | 
				
			|||
import com.epmet.service.TokenService; | 
				
			|||
import com.epmet.service.UserService; | 
				
			|||
import io.swagger.annotations.Api; | 
				
			|||
import io.swagger.annotations.ApiOperation; | 
				
			|||
import org.springframework.beans.factory.annotation.Autowired; | 
				
			|||
import org.springframework.web.bind.annotation.*; | 
				
			|||
import springfox.documentation.annotations.ApiIgnore; | 
				
			|||
 | 
				
			|||
import java.util.Map; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 登录接口 | 
				
			|||
 * | 
				
			|||
 * @author Mark sunlightcs@gmail.com | 
				
			|||
 */ | 
				
			|||
@RestController | 
				
			|||
@RequestMapping("auth") | 
				
			|||
@Api(tags="登录接口") | 
				
			|||
public class ApiLoginController { | 
				
			|||
    @Autowired | 
				
			|||
    private UserService userService; | 
				
			|||
    @Autowired | 
				
			|||
    private TokenService tokenService; | 
				
			|||
 | 
				
			|||
 | 
				
			|||
    @PostMapping("login") | 
				
			|||
    @ApiOperation("登录") | 
				
			|||
    public Result<Map<String, Object>> login(@RequestBody LoginDTO dto){ | 
				
			|||
        //表单校验
 | 
				
			|||
        ValidatorUtils.validateEntity(dto); | 
				
			|||
 | 
				
			|||
        //用户登录
 | 
				
			|||
        Map<String, Object> map = userService.login(dto); | 
				
			|||
 | 
				
			|||
        return new Result().ok(map); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    @Login | 
				
			|||
    @PostMapping("logout") | 
				
			|||
    @ApiOperation("退出") | 
				
			|||
    public Result logout(@ApiIgnore @RequestAttribute("userId") Long userId){ | 
				
			|||
        tokenService.expireToken(userId); | 
				
			|||
        return new Result(); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -1,54 +0,0 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright (c) 2018 人人开源 All rights reserved. | 
				
			|||
 * | 
				
			|||
 * https://www.renren.io
 | 
				
			|||
 * | 
				
			|||
 * 版权所有,侵权必究! | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
package com.epmet.controller; | 
				
			|||
 | 
				
			|||
import com.epmet.commons.tools.utils.Result; | 
				
			|||
import com.epmet.commons.tools.validator.ValidatorUtils; | 
				
			|||
import com.epmet.entity.UserEntity; | 
				
			|||
import com.epmet.dto.RegisterDTO; | 
				
			|||
import com.epmet.service.UserService; | 
				
			|||
import io.swagger.annotations.Api; | 
				
			|||
import io.swagger.annotations.ApiOperation; | 
				
			|||
import org.apache.commons.codec.digest.DigestUtils; | 
				
			|||
import org.springframework.beans.factory.annotation.Autowired; | 
				
			|||
import org.springframework.web.bind.annotation.PostMapping; | 
				
			|||
import org.springframework.web.bind.annotation.RequestBody; | 
				
			|||
import org.springframework.web.bind.annotation.RequestMapping; | 
				
			|||
import org.springframework.web.bind.annotation.RestController; | 
				
			|||
 | 
				
			|||
import java.util.Date; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 注册接口 | 
				
			|||
 * | 
				
			|||
 * @author Mark sunlightcs@gmail.com | 
				
			|||
 */ | 
				
			|||
@RestController | 
				
			|||
@RequestMapping("register") | 
				
			|||
@Api(tags="注册接口") | 
				
			|||
public class ApiRegisterController { | 
				
			|||
    @Autowired | 
				
			|||
    private UserService userService; | 
				
			|||
 | 
				
			|||
    @PostMapping | 
				
			|||
    @ApiOperation("注册") | 
				
			|||
    public Result register(@RequestBody RegisterDTO dto){ | 
				
			|||
        //表单校验
 | 
				
			|||
        ValidatorUtils.validateEntity(dto); | 
				
			|||
 | 
				
			|||
        UserEntity user = new UserEntity(); | 
				
			|||
        user.setMobile(dto.getMobile()); | 
				
			|||
        user.setUsername(dto.getMobile()); | 
				
			|||
        user.setPassword(DigestUtils.sha256Hex(dto.getPassword())); | 
				
			|||
        user.setCreateDate(new Date()); | 
				
			|||
        userService.insert(user); | 
				
			|||
 | 
				
			|||
        return new Result(); | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
@ -1,63 +0,0 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright (c) 2018 人人开源 All rights reserved. | 
				
			|||
 * | 
				
			|||
 * https://www.renren.io
 | 
				
			|||
 * | 
				
			|||
 * 版权所有,侵权必究! | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
package com.epmet.controller; | 
				
			|||
 | 
				
			|||
import com.epmet.annotation.Login; | 
				
			|||
import com.epmet.annotation.LoginUser; | 
				
			|||
import com.epmet.commons.tools.utils.Result; | 
				
			|||
import com.epmet.dto.UploadDTO; | 
				
			|||
import com.epmet.entity.UserEntity; | 
				
			|||
import com.epmet.feign.OssFeignClient; | 
				
			|||
import io.swagger.annotations.Api; | 
				
			|||
import io.swagger.annotations.ApiOperation; | 
				
			|||
import org.springframework.beans.factory.annotation.Autowired; | 
				
			|||
import org.springframework.web.bind.annotation.*; | 
				
			|||
import org.springframework.web.multipart.MultipartFile; | 
				
			|||
import springfox.documentation.annotations.ApiIgnore; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 测试接口 | 
				
			|||
 * | 
				
			|||
 * @author Mark sunlightcs@gmail.com | 
				
			|||
 */ | 
				
			|||
@RestController | 
				
			|||
@RequestMapping("test") | 
				
			|||
@Api(tags="测试接口") | 
				
			|||
public class ApiTestController { | 
				
			|||
    @Autowired | 
				
			|||
    private OssFeignClient ossFeignClient; | 
				
			|||
 | 
				
			|||
    @Login | 
				
			|||
    @GetMapping("userInfo") | 
				
			|||
    @ApiOperation(value="获取用户信息", response=UserEntity.class) | 
				
			|||
    public Result<UserEntity> userInfo(@ApiIgnore @LoginUser UserEntity user){ | 
				
			|||
        return new Result<UserEntity>().ok(user); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    @Login | 
				
			|||
    @GetMapping("userId") | 
				
			|||
    @ApiOperation("获取用户ID") | 
				
			|||
    public Result<Long> userInfo(@ApiIgnore @RequestAttribute("userId") Long userId){ | 
				
			|||
        return new Result<Long>().ok(userId); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    @GetMapping("notToken") | 
				
			|||
    @ApiOperation("忽略Token验证测试") | 
				
			|||
    public Result<String> notToken(){ | 
				
			|||
        return new Result<String>().ok("无需token也能访问。。。"); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    @PostMapping("upload") | 
				
			|||
    @ApiOperation(value = "上传文件") | 
				
			|||
    public Result<UploadDTO> upload(@RequestParam("file") MultipartFile file) { | 
				
			|||
        Result<UploadDTO> dto = ossFeignClient.upload(file); | 
				
			|||
 | 
				
			|||
        return dto; | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
@ -1,25 +0,0 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright (c) 2018 人人开源 All rights reserved. | 
				
			|||
 * | 
				
			|||
 * https://www.renren.io
 | 
				
			|||
 * | 
				
			|||
 * 版权所有,侵权必究! | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
package com.epmet.dao; | 
				
			|||
 | 
				
			|||
import com.epmet.commons.mybatis.dao.BaseDao; | 
				
			|||
import com.epmet.entity.TokenEntity; | 
				
			|||
import org.apache.ibatis.annotations.Mapper; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 用户Token | 
				
			|||
 * | 
				
			|||
 * @author Mark sunlightcs@gmail.com | 
				
			|||
 */ | 
				
			|||
@Mapper | 
				
			|||
public interface TokenDao extends BaseDao<TokenEntity> { | 
				
			|||
    TokenEntity getByToken(String token); | 
				
			|||
 | 
				
			|||
    TokenEntity getByUserId(Long userId); | 
				
			|||
} | 
				
			|||
@ -1,25 +0,0 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright (c) 2018 人人开源 All rights reserved. | 
				
			|||
 * | 
				
			|||
 * https://www.renren.io
 | 
				
			|||
 * | 
				
			|||
 * 版权所有,侵权必究! | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
package com.epmet.dao; | 
				
			|||
 | 
				
			|||
import com.epmet.commons.mybatis.dao.BaseDao; | 
				
			|||
import com.epmet.entity.UserEntity; | 
				
			|||
import org.apache.ibatis.annotations.Mapper; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 用户 | 
				
			|||
 * | 
				
			|||
 * @author Mark sunlightcs@gmail.com | 
				
			|||
 */ | 
				
			|||
@Mapper | 
				
			|||
public interface UserDao extends BaseDao<UserEntity> { | 
				
			|||
    UserEntity getUserByMobile(String mobile); | 
				
			|||
 | 
				
			|||
    UserEntity getUserByUserId(Long userId); | 
				
			|||
} | 
				
			|||
@ -1,47 +0,0 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright (c) 2018 人人开源 All rights reserved. | 
				
			|||
 * | 
				
			|||
 * https://www.renren.io
 | 
				
			|||
 * | 
				
			|||
 * 版权所有,侵权必究! | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
package com.epmet.entity; | 
				
			|||
 | 
				
			|||
import com.baomidou.mybatisplus.annotation.TableId; | 
				
			|||
import com.baomidou.mybatisplus.annotation.TableName; | 
				
			|||
import lombok.Data; | 
				
			|||
 | 
				
			|||
import java.io.Serializable; | 
				
			|||
import java.util.Date; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 用户Token | 
				
			|||
 * | 
				
			|||
 * @author Mark sunlightcs@gmail.com | 
				
			|||
 */ | 
				
			|||
@Data | 
				
			|||
@TableName("tb_token") | 
				
			|||
public class TokenEntity implements Serializable { | 
				
			|||
	private static final long serialVersionUID = 1L; | 
				
			|||
 | 
				
			|||
	@TableId | 
				
			|||
	private Long id; | 
				
			|||
	/** | 
				
			|||
	 * 用户ID | 
				
			|||
	 */ | 
				
			|||
	private Long userId; | 
				
			|||
	/** | 
				
			|||
	 * 用户token | 
				
			|||
	 */ | 
				
			|||
	private String token; | 
				
			|||
	/** | 
				
			|||
	 * 过期时间 | 
				
			|||
	 */ | 
				
			|||
	private Date expireDate; | 
				
			|||
	/** | 
				
			|||
	 * 更新时间 | 
				
			|||
	 */ | 
				
			|||
	private Date updateDate; | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -1,52 +0,0 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright (c) 2018 人人开源 All rights reserved. | 
				
			|||
 * | 
				
			|||
 * https://www.renren.io
 | 
				
			|||
 * | 
				
			|||
 * 版权所有,侵权必究! | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
package com.epmet.entity; | 
				
			|||
 | 
				
			|||
import com.alibaba.fastjson.annotation.JSONField; | 
				
			|||
import com.baomidou.mybatisplus.annotation.TableId; | 
				
			|||
import com.baomidou.mybatisplus.annotation.TableName; | 
				
			|||
import lombok.Data; | 
				
			|||
 | 
				
			|||
import java.io.Serializable; | 
				
			|||
import java.util.Date; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 用户 | 
				
			|||
 * | 
				
			|||
 * @author Mark sunlightcs@gmail.com | 
				
			|||
 */ | 
				
			|||
@Data | 
				
			|||
@TableName("tb_user") | 
				
			|||
public class UserEntity implements Serializable { | 
				
			|||
	private static final long serialVersionUID = 1L; | 
				
			|||
 | 
				
			|||
	/** | 
				
			|||
	 * 用户ID | 
				
			|||
	 */ | 
				
			|||
	@TableId | 
				
			|||
	private Long id; | 
				
			|||
	/** | 
				
			|||
	 * 用户名 | 
				
			|||
	 */ | 
				
			|||
	private String username; | 
				
			|||
	/** | 
				
			|||
	 * 手机号 | 
				
			|||
	 */ | 
				
			|||
	private String mobile; | 
				
			|||
	/** | 
				
			|||
	 * 密码 | 
				
			|||
	 */ | 
				
			|||
	@JSONField(serialize=false) | 
				
			|||
	private String password; | 
				
			|||
	/** | 
				
			|||
	 * 创建时间 | 
				
			|||
	 */ | 
				
			|||
	private Date createDate; | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -1,25 +0,0 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright (c) 2018 人人开源 All rights reserved. | 
				
			|||
 * | 
				
			|||
 * https://www.renren.io
 | 
				
			|||
 * | 
				
			|||
 * 版权所有,侵权必究! | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
package com.epmet.exception; | 
				
			|||
 | 
				
			|||
import com.epmet.commons.tools.exception.ErrorCode; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 模块错误编码,由9位数字组成,前6位为模块编码,后3位为业务编码 | 
				
			|||
 * <p> | 
				
			|||
 * 如:100001001(100001代表模块,001代表业务代码) | 
				
			|||
 * </p> | 
				
			|||
 * | 
				
			|||
 * @author Mark sunlightcs@gmail.com | 
				
			|||
 * @since 1.0.0 | 
				
			|||
 */ | 
				
			|||
public interface ModuleErrorCode extends ErrorCode { | 
				
			|||
    int TOKEN_NOT_EMPTY = 100005001; | 
				
			|||
    int TOKEN_INVALID = 100005002; | 
				
			|||
} | 
				
			|||
@ -1,73 +0,0 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright (c) 2018 人人开源 All rights reserved. | 
				
			|||
 * | 
				
			|||
 * https://www.renren.io
 | 
				
			|||
 * | 
				
			|||
 * 版权所有,侵权必究! | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
package com.epmet.interceptor; | 
				
			|||
 | 
				
			|||
import com.epmet.annotation.Login; | 
				
			|||
import com.epmet.commons.tools.exception.RenException; | 
				
			|||
import com.epmet.entity.TokenEntity; | 
				
			|||
import com.epmet.exception.ModuleErrorCode; | 
				
			|||
import com.epmet.service.TokenService; | 
				
			|||
import org.apache.commons.lang3.StringUtils; | 
				
			|||
import org.springframework.beans.factory.annotation.Autowired; | 
				
			|||
import org.springframework.stereotype.Component; | 
				
			|||
import org.springframework.web.method.HandlerMethod; | 
				
			|||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; | 
				
			|||
 | 
				
			|||
import javax.servlet.http.HttpServletRequest; | 
				
			|||
import javax.servlet.http.HttpServletResponse; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 权限(Token)验证 | 
				
			|||
 * | 
				
			|||
 * @author Mark sunlightcs@gmail.com | 
				
			|||
 */ | 
				
			|||
@Component | 
				
			|||
public class AuthorizationInterceptor extends HandlerInterceptorAdapter { | 
				
			|||
    @Autowired | 
				
			|||
    private TokenService tokenService; | 
				
			|||
 | 
				
			|||
    public static final String USER_KEY = "userId"; | 
				
			|||
 | 
				
			|||
    @Override | 
				
			|||
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { | 
				
			|||
        Login annotation; | 
				
			|||
        if(handler instanceof HandlerMethod) { | 
				
			|||
            annotation = ((HandlerMethod) handler).getMethodAnnotation(Login.class); | 
				
			|||
        }else{ | 
				
			|||
            return true; | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
        if(annotation == null){ | 
				
			|||
            return true; | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
        //从header中获取token
 | 
				
			|||
        String token = request.getHeader("token"); | 
				
			|||
        //如果header中不存在token,则从参数中获取token
 | 
				
			|||
        if(StringUtils.isBlank(token)){ | 
				
			|||
            token = request.getParameter("token"); | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
        //token为空
 | 
				
			|||
        if(StringUtils.isBlank(token)){ | 
				
			|||
            throw new RenException(ModuleErrorCode.TOKEN_NOT_EMPTY); | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
        //查询token信息
 | 
				
			|||
        TokenEntity tokenEntity = tokenService.getByToken(token); | 
				
			|||
        if(tokenEntity == null || tokenEntity.getExpireDate().getTime() < System.currentTimeMillis()){ | 
				
			|||
            throw new RenException(ModuleErrorCode.TOKEN_INVALID); | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
        //设置userId到request里,后续根据userId,获取用户信息
 | 
				
			|||
        request.setAttribute(USER_KEY, tokenEntity.getUserId()); | 
				
			|||
 | 
				
			|||
        return true; | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
@ -1,53 +0,0 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright (c) 2018 人人开源 All rights reserved. | 
				
			|||
 * | 
				
			|||
 * https://www.renren.io
 | 
				
			|||
 * | 
				
			|||
 * 版权所有,侵权必究! | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
package com.epmet.resolver; | 
				
			|||
 | 
				
			|||
import com.epmet.annotation.LoginUser; | 
				
			|||
import com.epmet.entity.UserEntity; | 
				
			|||
import com.epmet.interceptor.AuthorizationInterceptor; | 
				
			|||
import com.epmet.service.UserService; | 
				
			|||
import org.springframework.beans.factory.annotation.Autowired; | 
				
			|||
import org.springframework.core.MethodParameter; | 
				
			|||
import org.springframework.stereotype.Component; | 
				
			|||
import org.springframework.web.bind.support.WebDataBinderFactory; | 
				
			|||
import org.springframework.web.context.request.NativeWebRequest; | 
				
			|||
import org.springframework.web.context.request.RequestAttributes; | 
				
			|||
import org.springframework.web.method.support.HandlerMethodArgumentResolver; | 
				
			|||
import org.springframework.web.method.support.ModelAndViewContainer; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 有@LoginUser注解的方法参数,注入当前登录用户 | 
				
			|||
 * | 
				
			|||
 * @author Mark sunlightcs@gmail.com | 
				
			|||
 */ | 
				
			|||
@Component | 
				
			|||
public class LoginUserHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver { | 
				
			|||
    @Autowired | 
				
			|||
    private UserService userService; | 
				
			|||
 | 
				
			|||
    @Override | 
				
			|||
    public boolean supportsParameter(MethodParameter parameter) { | 
				
			|||
        return parameter.getParameterType().isAssignableFrom(UserEntity.class) && parameter.hasParameterAnnotation(LoginUser.class); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    @Override | 
				
			|||
    public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer container, | 
				
			|||
                                  NativeWebRequest request, WebDataBinderFactory factory) throws Exception { | 
				
			|||
        //获取用户ID
 | 
				
			|||
        Object object = request.getAttribute(AuthorizationInterceptor.USER_KEY, RequestAttributes.SCOPE_REQUEST); | 
				
			|||
        if(object == null){ | 
				
			|||
            return null; | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
        //获取用户信息
 | 
				
			|||
        UserEntity user = userService.getUserByUserId((Long)object); | 
				
			|||
 | 
				
			|||
        return user; | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
@ -1,36 +0,0 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright (c) 2018 人人开源 All rights reserved. | 
				
			|||
 * | 
				
			|||
 * https://www.renren.io
 | 
				
			|||
 * | 
				
			|||
 * 版权所有,侵权必究! | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
package com.epmet.service; | 
				
			|||
 | 
				
			|||
import com.epmet.commons.mybatis.service.BaseService; | 
				
			|||
import com.epmet.entity.TokenEntity; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 用户Token | 
				
			|||
 * | 
				
			|||
 * @author Mark sunlightcs@gmail.com | 
				
			|||
 */ | 
				
			|||
public interface TokenService extends BaseService<TokenEntity> { | 
				
			|||
 | 
				
			|||
	TokenEntity getByToken(String token); | 
				
			|||
 | 
				
			|||
	/** | 
				
			|||
	 * 生成token | 
				
			|||
	 * @param userId  用户ID | 
				
			|||
	 * @return        返回token信息 | 
				
			|||
	 */ | 
				
			|||
	TokenEntity createToken(Long userId); | 
				
			|||
 | 
				
			|||
	/** | 
				
			|||
	 * 设置token过期 | 
				
			|||
	 * @param userId 用户ID | 
				
			|||
	 */ | 
				
			|||
	void expireToken(Long userId); | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -1,34 +0,0 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright (c) 2018 人人开源 All rights reserved. | 
				
			|||
 * | 
				
			|||
 * https://www.renren.io
 | 
				
			|||
 * | 
				
			|||
 * 版权所有,侵权必究! | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
package com.epmet.service; | 
				
			|||
 | 
				
			|||
import com.epmet.commons.mybatis.service.BaseService; | 
				
			|||
import com.epmet.entity.UserEntity; | 
				
			|||
import com.epmet.dto.LoginDTO; | 
				
			|||
 | 
				
			|||
import java.util.Map; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 用户 | 
				
			|||
 * | 
				
			|||
 * @author Mark sunlightcs@gmail.com | 
				
			|||
 */ | 
				
			|||
public interface UserService extends BaseService<UserEntity> { | 
				
			|||
 | 
				
			|||
	UserEntity getByMobile(String mobile); | 
				
			|||
 | 
				
			|||
	UserEntity getUserByUserId(Long userId); | 
				
			|||
 | 
				
			|||
	/** | 
				
			|||
	 * 用户登录 | 
				
			|||
	 * @param dto    登录表单 | 
				
			|||
	 * @return        返回登录信息 | 
				
			|||
	 */ | 
				
			|||
	Map<String, Object> login(LoginDTO dto); | 
				
			|||
} | 
				
			|||
@ -1,92 +0,0 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright (c) 2018 人人开源 All rights reserved. | 
				
			|||
 * | 
				
			|||
 * https://www.renren.io
 | 
				
			|||
 * | 
				
			|||
 * 版权所有,侵权必究! | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
package com.epmet.service.impl; | 
				
			|||
 | 
				
			|||
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; | 
				
			|||
import com.epmet.dao.TokenDao; | 
				
			|||
import com.epmet.entity.TokenEntity; | 
				
			|||
import com.epmet.service.TokenService; | 
				
			|||
import org.springframework.stereotype.Service; | 
				
			|||
 | 
				
			|||
import java.util.Date; | 
				
			|||
import java.util.UUID; | 
				
			|||
 | 
				
			|||
 | 
				
			|||
@Service | 
				
			|||
public class TokenServiceImpl extends BaseServiceImpl<TokenDao, TokenEntity> implements TokenService { | 
				
			|||
	/** | 
				
			|||
	 * 12小时后过期 | 
				
			|||
	 */ | 
				
			|||
	private final static int EXPIRE = 3600 * 12; | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public TokenEntity getByToken(String token) { | 
				
			|||
		return baseDao.getByToken(token); | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public TokenEntity createToken(Long userId) { | 
				
			|||
		//当前时间
 | 
				
			|||
		Date now = new Date(); | 
				
			|||
		//过期时间
 | 
				
			|||
		Date expireTime = new Date(now.getTime() + EXPIRE * 1000); | 
				
			|||
 | 
				
			|||
		//用户token
 | 
				
			|||
		String token; | 
				
			|||
 | 
				
			|||
		//判断是否生成过token
 | 
				
			|||
		TokenEntity tokenEntity = baseDao.getByUserId(userId); | 
				
			|||
		if(tokenEntity == null){ | 
				
			|||
			//生成一个token
 | 
				
			|||
			token = generateToken(); | 
				
			|||
 | 
				
			|||
			tokenEntity = new TokenEntity(); | 
				
			|||
			tokenEntity.setUserId(userId); | 
				
			|||
			tokenEntity.setToken(token); | 
				
			|||
			tokenEntity.setUpdateDate(now); | 
				
			|||
			tokenEntity.setExpireDate(expireTime); | 
				
			|||
 | 
				
			|||
			//保存token
 | 
				
			|||
			this.insert(tokenEntity); | 
				
			|||
		}else{ | 
				
			|||
			//判断token是否过期
 | 
				
			|||
			if(tokenEntity.getExpireDate().getTime() < System.currentTimeMillis()){ | 
				
			|||
				//token过期,重新生成token
 | 
				
			|||
				token = generateToken(); | 
				
			|||
			}else { | 
				
			|||
				token = tokenEntity.getToken(); | 
				
			|||
			} | 
				
			|||
 | 
				
			|||
			tokenEntity.setToken(token); | 
				
			|||
			tokenEntity.setUpdateDate(now); | 
				
			|||
			tokenEntity.setExpireDate(expireTime); | 
				
			|||
 | 
				
			|||
			//更新token
 | 
				
			|||
			this.updateById(tokenEntity); | 
				
			|||
		} | 
				
			|||
 | 
				
			|||
		return tokenEntity; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public void expireToken(Long userId){ | 
				
			|||
		Date now = new Date(); | 
				
			|||
 | 
				
			|||
		TokenEntity tokenEntity = new TokenEntity(); | 
				
			|||
		tokenEntity.setUserId(userId); | 
				
			|||
		tokenEntity.setUpdateDate(now); | 
				
			|||
		tokenEntity.setExpireDate(now); | 
				
			|||
 | 
				
			|||
		this.updateById(tokenEntity); | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	private String generateToken(){ | 
				
			|||
		return UUID.randomUUID().toString().replace("-", ""); | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -1,63 +0,0 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright (c) 2018 人人开源 All rights reserved. | 
				
			|||
 * | 
				
			|||
 * https://www.renren.io
 | 
				
			|||
 * | 
				
			|||
 * 版权所有,侵权必究! | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
package com.epmet.service.impl; | 
				
			|||
 | 
				
			|||
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; | 
				
			|||
import com.epmet.commons.tools.exception.ErrorCode; | 
				
			|||
import com.epmet.commons.tools.exception.RenException; | 
				
			|||
import com.epmet.commons.tools.validator.AssertUtils; | 
				
			|||
import com.epmet.dao.UserDao; | 
				
			|||
import com.epmet.entity.TokenEntity; | 
				
			|||
import com.epmet.entity.UserEntity; | 
				
			|||
import com.epmet.dto.LoginDTO; | 
				
			|||
import com.epmet.service.TokenService; | 
				
			|||
import com.epmet.service.UserService; | 
				
			|||
import org.apache.commons.codec.digest.DigestUtils; | 
				
			|||
import org.springframework.beans.factory.annotation.Autowired; | 
				
			|||
import org.springframework.stereotype.Service; | 
				
			|||
 | 
				
			|||
import java.util.HashMap; | 
				
			|||
import java.util.Map; | 
				
			|||
 | 
				
			|||
@Service | 
				
			|||
public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implements UserService { | 
				
			|||
	@Autowired | 
				
			|||
	private TokenService tokenService; | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public UserEntity getByMobile(String mobile) { | 
				
			|||
		return baseDao.getUserByMobile(mobile); | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public UserEntity getUserByUserId(Long userId) { | 
				
			|||
		return baseDao.getUserByUserId(userId); | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public Map<String, Object> login(LoginDTO dto) { | 
				
			|||
		UserEntity user = getByMobile(dto.getMobile()); | 
				
			|||
		AssertUtils.isNull(user, ErrorCode.ACCOUNT_PASSWORD_ERROR); | 
				
			|||
 | 
				
			|||
		//密码错误
 | 
				
			|||
		if(!user.getPassword().equals(DigestUtils.sha256Hex(dto.getPassword()))){ | 
				
			|||
			throw new RenException(ErrorCode.ACCOUNT_PASSWORD_ERROR); | 
				
			|||
		} | 
				
			|||
 | 
				
			|||
		//获取登录token
 | 
				
			|||
		TokenEntity tokenEntity = tokenService.createToken(user.getId()); | 
				
			|||
 | 
				
			|||
		Map<String, Object> map = new HashMap<>(2); | 
				
			|||
		map.put("token", tokenEntity.getToken()); | 
				
			|||
		map.put("expire", tokenEntity.getExpireDate().getTime() - System.currentTimeMillis()); | 
				
			|||
 | 
				
			|||
		return map; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -1,3 +0,0 @@ | 
				
			|||
#Default | 
				
			|||
100005001=token\u4E0D\u80FD\u4E3A\u7A7A | 
				
			|||
100005002=token\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55 | 
				
			|||
@ -1,3 +0,0 @@ | 
				
			|||
#English | 
				
			|||
100005001=Token cannot be empty | 
				
			|||
100005002=Token is invalid, please log in again | 
				
			|||
@ -1,3 +0,0 @@ | 
				
			|||
#\u7B80\u4F53\u4E2D\u6587 | 
				
			|||
100005001=token\u4E0D\u80FD\u4E3A\u7A7A | 
				
			|||
100005002=token\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55 | 
				
			|||
@ -1,3 +0,0 @@ | 
				
			|||
#\u7E41\u4F53\u4E2D\u6587 | 
				
			|||
100005001=token\u4E0D\u80FD\u70BA\u7A7A | 
				
			|||
100005002=token\u5931\u6548\uFF0C\u8ACB\u91CD\u65B0\u767B\u9304 | 
				
			|||
@ -1,3 +0,0 @@ | 
				
			|||
#Default | 
				
			|||
api.mobile.require=\u624B\u673A\u53F7\u4E0D\u80FD\u4E3A\u7A7A | 
				
			|||
api.password.require=\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A | 
				
			|||
@ -1,3 +0,0 @@ | 
				
			|||
#English | 
				
			|||
api.mobile.require=The phone number cannot be empty | 
				
			|||
api.password.require=Password cannot be empty | 
				
			|||
@ -1,3 +0,0 @@ | 
				
			|||
#\u7B80\u4F53\u4E2D\u6587 | 
				
			|||
api.mobile.require=\u624B\u673A\u53F7\u4E0D\u80FD\u4E3A\u7A7A | 
				
			|||
api.password.require=\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A | 
				
			|||
@ -1,3 +0,0 @@ | 
				
			|||
#\u7E41\u4F53\u4E2D\u6587 | 
				
			|||
api.mobile.require=\u624B\u6A5F\u865F\u4E0D\u80FD\u70BA\u7A7A | 
				
			|||
api.password.require=\u5BC6\u78BC\u4E0D\u80FD\u70BA\u7A7A | 
				
			|||
@ -1,14 +0,0 @@ | 
				
			|||
<?xml version="1.0" encoding="UTF-8"?> | 
				
			|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | 
				
			|||
 | 
				
			|||
<mapper namespace="com.epmet.dao.TokenDao"> | 
				
			|||
 | 
				
			|||
    <select id="getByToken" resultType="com.epmet.entity.TokenEntity"> | 
				
			|||
        select * from tb_token where token = #{value} | 
				
			|||
    </select> | 
				
			|||
 | 
				
			|||
    <select id="getByUserId" resultType="com.epmet.entity.TokenEntity"> | 
				
			|||
        select * from tb_token where user_id = #{value} | 
				
			|||
    </select> | 
				
			|||
 | 
				
			|||
</mapper> | 
				
			|||
@ -1,13 +0,0 @@ | 
				
			|||
<?xml version="1.0" encoding="UTF-8"?> | 
				
			|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | 
				
			|||
 | 
				
			|||
<mapper namespace="com.epmet.dao.UserDao"> | 
				
			|||
 | 
				
			|||
    <select id="getUserByMobile" resultType="com.epmet.entity.UserEntity"> | 
				
			|||
        select * from tb_user where mobile = #{value} | 
				
			|||
    </select> | 
				
			|||
 | 
				
			|||
    <select id="getUserByUserId" resultType="com.epmet.entity.UserEntity"> | 
				
			|||
        select * from tb_user where id = #{value} | 
				
			|||
    </select> | 
				
			|||
</mapper> | 
				
			|||
@ -0,0 +1,121 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright 2018 人人开源 https://www.renren.io
 | 
				
			|||
 * <p> | 
				
			|||
 * This program is free software: you can redistribute it and/or modify | 
				
			|||
 * it under the terms of the GNU General Public License as published by | 
				
			|||
 * the Free Software Foundation, either version 3 of the License, or | 
				
			|||
 * (at your option) any later version. | 
				
			|||
 * <p> | 
				
			|||
 * This program is distributed in the hope that it will be useful, | 
				
			|||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
				
			|||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
				
			|||
 * GNU General Public License for more details. | 
				
			|||
 * <p> | 
				
			|||
 * You should have received a copy of the GNU General Public License | 
				
			|||
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
package com.epmet.dto; | 
				
			|||
 | 
				
			|||
import java.io.Serializable; | 
				
			|||
import java.util.Date; | 
				
			|||
import lombok.Data; | 
				
			|||
 | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 居民用户信息表 | 
				
			|||
 * | 
				
			|||
 * @author generator generator@elink-cn.com | 
				
			|||
 * @since v1.0.0 2020-03-16 | 
				
			|||
 */ | 
				
			|||
@Data | 
				
			|||
public class CustomerUserDTO implements Serializable { | 
				
			|||
 | 
				
			|||
    private static final long serialVersionUID = 1L; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 唯一标识 | 
				
			|||
     */ | 
				
			|||
	private String id; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 客户Id CUSTOMER.id | 
				
			|||
     */ | 
				
			|||
	private String customerId; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 微信openId | 
				
			|||
     */ | 
				
			|||
	private String wxOpenId; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 手机号 | 
				
			|||
     */ | 
				
			|||
	private String mobile; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 昵称 | 
				
			|||
     */ | 
				
			|||
	private String nickname; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 性别:0.未知 1.男性2女性 | 
				
			|||
     */ | 
				
			|||
	private Integer sex; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 头像 | 
				
			|||
     */ | 
				
			|||
	private String headImgUrl; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 国家 | 
				
			|||
     */ | 
				
			|||
	private String country; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 省份 | 
				
			|||
     */ | 
				
			|||
	private String province; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 城市 | 
				
			|||
     */ | 
				
			|||
	private String city; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 语言 | 
				
			|||
     */ | 
				
			|||
	private String language; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 删除标识:0.未删除 1.已删除 | 
				
			|||
     */ | 
				
			|||
	private String delFlag; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 乐观锁 | 
				
			|||
     */ | 
				
			|||
	private Integer revision; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 创建人 | 
				
			|||
     */ | 
				
			|||
	private String createdBy; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 创建时间 | 
				
			|||
     */ | 
				
			|||
	private Date createdTime; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 更新人 | 
				
			|||
     */ | 
				
			|||
	private String updatedBy; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 更新时间 | 
				
			|||
     */ | 
				
			|||
	private Date updatedTime; | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -0,0 +1,94 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright 2018 人人开源 https://www.renren.io
 | 
				
			|||
 * <p> | 
				
			|||
 * This program is free software: you can redistribute it and/or modify | 
				
			|||
 * it under the terms of the GNU General Public License as published by | 
				
			|||
 * the Free Software Foundation, either version 3 of the License, or | 
				
			|||
 * (at your option) any later version. | 
				
			|||
 * <p> | 
				
			|||
 * This program is distributed in the hope that it will be useful, | 
				
			|||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
				
			|||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
				
			|||
 * GNU General Public License for more details. | 
				
			|||
 * <p> | 
				
			|||
 * You should have received a copy of the GNU General Public License | 
				
			|||
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
package com.epmet.controller; | 
				
			|||
 | 
				
			|||
import com.epmet.commons.tools.page.PageData; | 
				
			|||
import com.epmet.commons.tools.utils.ExcelUtils; | 
				
			|||
import com.epmet.commons.tools.utils.Result; | 
				
			|||
import com.epmet.commons.tools.validator.AssertUtils; | 
				
			|||
import com.epmet.commons.tools.validator.ValidatorUtils; | 
				
			|||
import com.epmet.commons.tools.validator.group.AddGroup; | 
				
			|||
import com.epmet.commons.tools.validator.group.UpdateGroup; | 
				
			|||
import com.epmet.commons.tools.validator.group.DefaultGroup; | 
				
			|||
import com.epmet.dto.CustomerUserDTO; | 
				
			|||
import com.epmet.excel.CustomerUserExcel; | 
				
			|||
import com.epmet.service.CustomerUserService; | 
				
			|||
import org.springframework.beans.factory.annotation.Autowired; | 
				
			|||
import org.springframework.web.bind.annotation.*; | 
				
			|||
 | 
				
			|||
import javax.servlet.http.HttpServletResponse; | 
				
			|||
import java.util.List; | 
				
			|||
import java.util.Map; | 
				
			|||
 | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 居民用户信息表 | 
				
			|||
 * | 
				
			|||
 * @author generator generator@elink-cn.com | 
				
			|||
 * @since v1.0.0 2020-03-16 | 
				
			|||
 */ | 
				
			|||
@RestController | 
				
			|||
@RequestMapping("customeruser") | 
				
			|||
public class CustomerUserController { | 
				
			|||
     | 
				
			|||
    @Autowired | 
				
			|||
    private CustomerUserService customerUserService; | 
				
			|||
 | 
				
			|||
    @GetMapping("page") | 
				
			|||
    public Result<PageData<CustomerUserDTO>> page(@RequestParam Map<String, Object> params){ | 
				
			|||
        PageData<CustomerUserDTO> page = customerUserService.page(params); | 
				
			|||
        return new Result<PageData<CustomerUserDTO>>().ok(page); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    @GetMapping("{id}") | 
				
			|||
    public Result<CustomerUserDTO> get(@PathVariable("id") String id){ | 
				
			|||
        CustomerUserDTO data = customerUserService.get(id); | 
				
			|||
        return new Result<CustomerUserDTO>().ok(data); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    @PostMapping | 
				
			|||
    public Result save(@RequestBody CustomerUserDTO dto){ | 
				
			|||
        //效验数据
 | 
				
			|||
        ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); | 
				
			|||
        customerUserService.save(dto); | 
				
			|||
        return new Result(); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    @PutMapping | 
				
			|||
    public Result update(@RequestBody CustomerUserDTO dto){ | 
				
			|||
        //效验数据
 | 
				
			|||
        ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); | 
				
			|||
        customerUserService.update(dto); | 
				
			|||
        return new Result(); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    @DeleteMapping | 
				
			|||
    public Result delete(@RequestBody String[] ids){ | 
				
			|||
        //效验数据
 | 
				
			|||
        AssertUtils.isArrayEmpty(ids, "id"); | 
				
			|||
        customerUserService.delete(ids); | 
				
			|||
        return new Result(); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    @GetMapping("export") | 
				
			|||
    public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { | 
				
			|||
        List<CustomerUserDTO> list = customerUserService.list(params); | 
				
			|||
        ExcelUtils.exportExcelToTarget(response, null, list, CustomerUserExcel.class); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -0,0 +1,33 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright 2018 人人开源 https://www.renren.io
 | 
				
			|||
 * <p> | 
				
			|||
 * This program is free software: you can redistribute it and/or modify | 
				
			|||
 * it under the terms of the GNU General Public License as published by | 
				
			|||
 * the Free Software Foundation, either version 3 of the License, or | 
				
			|||
 * (at your option) any later version. | 
				
			|||
 * <p> | 
				
			|||
 * This program is distributed in the hope that it will be useful, | 
				
			|||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
				
			|||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
				
			|||
 * GNU General Public License for more details. | 
				
			|||
 * <p> | 
				
			|||
 * You should have received a copy of the GNU General Public License | 
				
			|||
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
package com.epmet.dao; | 
				
			|||
 | 
				
			|||
import com.epmet.commons.mybatis.dao.BaseDao; | 
				
			|||
import com.epmet.entity.CustomerUserEntity; | 
				
			|||
import org.apache.ibatis.annotations.Mapper; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 居民用户信息表 | 
				
			|||
 * | 
				
			|||
 * @author generator generator@elink-cn.com | 
				
			|||
 * @since v1.0.0 2020-03-16 | 
				
			|||
 */ | 
				
			|||
@Mapper | 
				
			|||
public interface CustomerUserDao extends BaseDao<CustomerUserEntity> { | 
				
			|||
	 | 
				
			|||
} | 
				
			|||
@ -0,0 +1,91 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright 2018 人人开源 https://www.renren.io
 | 
				
			|||
 * <p> | 
				
			|||
 * This program is free software: you can redistribute it and/or modify | 
				
			|||
 * it under the terms of the GNU General Public License as published by | 
				
			|||
 * the Free Software Foundation, either version 3 of the License, or | 
				
			|||
 * (at your option) any later version. | 
				
			|||
 * <p> | 
				
			|||
 * This program is distributed in the hope that it will be useful, | 
				
			|||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
				
			|||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
				
			|||
 * GNU General Public License for more details. | 
				
			|||
 * <p> | 
				
			|||
 * You should have received a copy of the GNU General Public License | 
				
			|||
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
package com.epmet.entity; | 
				
			|||
 | 
				
			|||
import com.baomidou.mybatisplus.annotation.TableName; | 
				
			|||
 | 
				
			|||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; | 
				
			|||
import lombok.Data; | 
				
			|||
import lombok.EqualsAndHashCode; | 
				
			|||
 | 
				
			|||
import java.util.Date; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 居民用户信息表 | 
				
			|||
 * | 
				
			|||
 * @author generator generator@elink-cn.com | 
				
			|||
 * @since v1.0.0 2020-03-16 | 
				
			|||
 */ | 
				
			|||
@Data | 
				
			|||
@EqualsAndHashCode(callSuper=false) | 
				
			|||
@TableName("customer_user") | 
				
			|||
public class CustomerUserEntity extends BaseEpmetEntity { | 
				
			|||
 | 
				
			|||
	private static final long serialVersionUID = 1L; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 客户Id CUSTOMER.id | 
				
			|||
     */ | 
				
			|||
	private String customerId; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 微信openId | 
				
			|||
     */ | 
				
			|||
	private String wxOpenId; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 手机号 | 
				
			|||
     */ | 
				
			|||
	private String mobile; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 昵称 | 
				
			|||
     */ | 
				
			|||
	private String nickname; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 性别:0.未知 1.男性2女性 | 
				
			|||
     */ | 
				
			|||
	private Integer sex; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 头像 | 
				
			|||
     */ | 
				
			|||
	private String headImgUrl; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 国家 | 
				
			|||
     */ | 
				
			|||
	private String country; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 省份 | 
				
			|||
     */ | 
				
			|||
	private String province; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 城市 | 
				
			|||
     */ | 
				
			|||
	private String city; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 语言 | 
				
			|||
     */ | 
				
			|||
	private String language; | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -0,0 +1,86 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright 2018 人人开源 https://www.renren.io
 | 
				
			|||
 * <p> | 
				
			|||
 * This program is free software: you can redistribute it and/or modify | 
				
			|||
 * it under the terms of the GNU General Public License as published by | 
				
			|||
 * the Free Software Foundation, either version 3 of the License, or | 
				
			|||
 * (at your option) any later version. | 
				
			|||
 * <p> | 
				
			|||
 * This program is distributed in the hope that it will be useful, | 
				
			|||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
				
			|||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
				
			|||
 * GNU General Public License for more details. | 
				
			|||
 * <p> | 
				
			|||
 * You should have received a copy of the GNU General Public License | 
				
			|||
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
package com.epmet.excel; | 
				
			|||
 | 
				
			|||
import cn.afterturn.easypoi.excel.annotation.Excel; | 
				
			|||
import lombok.Data; | 
				
			|||
 | 
				
			|||
import java.util.Date; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 居民用户信息表 | 
				
			|||
 * | 
				
			|||
 * @author generator generator@elink-cn.com | 
				
			|||
 * @since v1.0.0 2020-03-16 | 
				
			|||
 */ | 
				
			|||
@Data | 
				
			|||
public class CustomerUserExcel { | 
				
			|||
 | 
				
			|||
    @Excel(name = "唯一标识") | 
				
			|||
    private String id; | 
				
			|||
 | 
				
			|||
    @Excel(name = "客户Id CUSTOMER.id") | 
				
			|||
    private String customerId; | 
				
			|||
 | 
				
			|||
    @Excel(name = "微信openId") | 
				
			|||
    private String wxOpenId; | 
				
			|||
 | 
				
			|||
    @Excel(name = "手机号") | 
				
			|||
    private String mobile; | 
				
			|||
 | 
				
			|||
    @Excel(name = "昵称") | 
				
			|||
    private String nickname; | 
				
			|||
 | 
				
			|||
    @Excel(name = "性别:0.未知 1.男性2女性") | 
				
			|||
    private Integer sex; | 
				
			|||
 | 
				
			|||
    @Excel(name = "头像") | 
				
			|||
    private String headImgUrl; | 
				
			|||
 | 
				
			|||
    @Excel(name = "国家") | 
				
			|||
    private String country; | 
				
			|||
 | 
				
			|||
    @Excel(name = "省份") | 
				
			|||
    private String province; | 
				
			|||
 | 
				
			|||
    @Excel(name = "城市") | 
				
			|||
    private String city; | 
				
			|||
 | 
				
			|||
    @Excel(name = "语言") | 
				
			|||
    private String language; | 
				
			|||
 | 
				
			|||
    @Excel(name = "删除标识:0.未删除 1.已删除") | 
				
			|||
    private String delFlag; | 
				
			|||
 | 
				
			|||
    @Excel(name = "乐观锁") | 
				
			|||
    private Integer revision; | 
				
			|||
 | 
				
			|||
    @Excel(name = "创建人") | 
				
			|||
    private String createdBy; | 
				
			|||
 | 
				
			|||
    @Excel(name = "创建时间") | 
				
			|||
    private Date createdTime; | 
				
			|||
 | 
				
			|||
    @Excel(name = "更新人") | 
				
			|||
    private String updatedBy; | 
				
			|||
 | 
				
			|||
    @Excel(name = "更新时间") | 
				
			|||
    private Date updatedTime; | 
				
			|||
 | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -0,0 +1,47 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright 2018 人人开源 https://www.renren.io
 | 
				
			|||
 * <p> | 
				
			|||
 * This program is free software: you can redistribute it and/or modify | 
				
			|||
 * it under the terms of the GNU General Public License as published by | 
				
			|||
 * the Free Software Foundation, either version 3 of the License, or | 
				
			|||
 * (at your option) any later version. | 
				
			|||
 * <p> | 
				
			|||
 * This program is distributed in the hope that it will be useful, | 
				
			|||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
				
			|||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
				
			|||
 * GNU General Public License for more details. | 
				
			|||
 * <p> | 
				
			|||
 * You should have received a copy of the GNU General Public License | 
				
			|||
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
package com.epmet.redis; | 
				
			|||
 | 
				
			|||
import com.epmet.commons.tools.redis.RedisUtils; | 
				
			|||
import org.springframework.beans.factory.annotation.Autowired; | 
				
			|||
import org.springframework.stereotype.Component; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 居民用户信息表 | 
				
			|||
 * | 
				
			|||
 * @author generator generator@elink-cn.com | 
				
			|||
 * @since v1.0.0 2020-03-16 | 
				
			|||
 */ | 
				
			|||
@Component | 
				
			|||
public class CustomerUserRedis { | 
				
			|||
    @Autowired | 
				
			|||
    private RedisUtils redisUtils; | 
				
			|||
 | 
				
			|||
    public void delete(Object[] ids) { | 
				
			|||
 | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public void set(){ | 
				
			|||
 | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public String get(String id){ | 
				
			|||
        return null; | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -0,0 +1,95 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright 2018 人人开源 https://www.renren.io
 | 
				
			|||
 * <p> | 
				
			|||
 * This program is free software: you can redistribute it and/or modify | 
				
			|||
 * it under the terms of the GNU General Public License as published by | 
				
			|||
 * the Free Software Foundation, either version 3 of the License, or | 
				
			|||
 * (at your option) any later version. | 
				
			|||
 * <p> | 
				
			|||
 * This program is distributed in the hope that it will be useful, | 
				
			|||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
				
			|||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
				
			|||
 * GNU General Public License for more details. | 
				
			|||
 * <p> | 
				
			|||
 * You should have received a copy of the GNU General Public License | 
				
			|||
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
package com.epmet.service; | 
				
			|||
 | 
				
			|||
import com.epmet.commons.mybatis.service.BaseService; | 
				
			|||
import com.epmet.commons.tools.page.PageData; | 
				
			|||
import com.epmet.dto.CustomerUserDTO; | 
				
			|||
import com.epmet.entity.CustomerUserEntity; | 
				
			|||
 | 
				
			|||
import java.util.List; | 
				
			|||
import java.util.Map; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 居民用户信息表 | 
				
			|||
 * | 
				
			|||
 * @author generator generator@elink-cn.com | 
				
			|||
 * @since v1.0.0 2020-03-16 | 
				
			|||
 */ | 
				
			|||
public interface CustomerUserService extends BaseService<CustomerUserEntity> { | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 默认分页 | 
				
			|||
     * | 
				
			|||
     * @param params | 
				
			|||
     * @return PageData<CustomerUserDTO> | 
				
			|||
     * @author generator | 
				
			|||
     * @date 2020-03-16 | 
				
			|||
     */ | 
				
			|||
    PageData<CustomerUserDTO> page(Map<String, Object> params); | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 默认查询 | 
				
			|||
     * | 
				
			|||
     * @param params | 
				
			|||
     * @return java.util.List<CustomerUserDTO> | 
				
			|||
     * @author generator | 
				
			|||
     * @date 2020-03-16 | 
				
			|||
     */ | 
				
			|||
    List<CustomerUserDTO> list(Map<String, Object> params); | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 单条查询 | 
				
			|||
     * | 
				
			|||
     * @param id | 
				
			|||
     * @return CustomerUserDTO | 
				
			|||
     * @author generator | 
				
			|||
     * @date 2020-03-16 | 
				
			|||
     */ | 
				
			|||
    CustomerUserDTO get(String id); | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 默认保存 | 
				
			|||
     * | 
				
			|||
     * @param dto | 
				
			|||
     * @return void | 
				
			|||
     * @author generator | 
				
			|||
     * @date 2020-03-16 | 
				
			|||
     */ | 
				
			|||
    void save(CustomerUserDTO dto); | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 默认更新 | 
				
			|||
     * | 
				
			|||
     * @param dto | 
				
			|||
     * @return void | 
				
			|||
     * @author generator | 
				
			|||
     * @date 2020-03-16 | 
				
			|||
     */ | 
				
			|||
    void update(CustomerUserDTO dto); | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 批量删除 | 
				
			|||
     * | 
				
			|||
     * @param ids | 
				
			|||
     * @return void | 
				
			|||
     * @author generator | 
				
			|||
     * @date 2020-03-16 | 
				
			|||
     */ | 
				
			|||
    void delete(String[] ids); | 
				
			|||
} | 
				
			|||
@ -0,0 +1,104 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright 2018 人人开源 https://www.renren.io
 | 
				
			|||
 * <p> | 
				
			|||
 * This program is free software: you can redistribute it and/or modify | 
				
			|||
 * it under the terms of the GNU General Public License as published by | 
				
			|||
 * the Free Software Foundation, either version 3 of the License, or | 
				
			|||
 * (at your option) any later version. | 
				
			|||
 * <p> | 
				
			|||
 * This program is distributed in the hope that it will be useful, | 
				
			|||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
				
			|||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
				
			|||
 * GNU General Public License for more details. | 
				
			|||
 * <p> | 
				
			|||
 * You should have received a copy of the GNU General Public License | 
				
			|||
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
package com.epmet.service.impl; | 
				
			|||
 | 
				
			|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
				
			|||
import com.baomidou.mybatisplus.core.metadata.IPage; | 
				
			|||
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; | 
				
			|||
import com.epmet.commons.tools.page.PageData; | 
				
			|||
import com.epmet.commons.tools.utils.ConvertUtils; | 
				
			|||
import com.epmet.commons.tools.constant.FieldConstant; | 
				
			|||
import com.epmet.dao.CustomerUserDao; | 
				
			|||
import com.epmet.dto.CustomerUserDTO; | 
				
			|||
import com.epmet.entity.CustomerUserEntity; | 
				
			|||
import com.epmet.redis.CustomerUserRedis; | 
				
			|||
import com.epmet.service.CustomerUserService; | 
				
			|||
import org.apache.commons.lang3.StringUtils; | 
				
			|||
import org.springframework.beans.factory.annotation.Autowired; | 
				
			|||
import org.springframework.stereotype.Service; | 
				
			|||
import org.springframework.transaction.annotation.Transactional; | 
				
			|||
 | 
				
			|||
import java.util.Arrays; | 
				
			|||
import java.util.List; | 
				
			|||
import java.util.Map; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 居民用户信息表 | 
				
			|||
 * | 
				
			|||
 * @author generator generator@elink-cn.com | 
				
			|||
 * @since v1.0.0 2020-03-16 | 
				
			|||
 */ | 
				
			|||
@Service | 
				
			|||
public class CustomerUserServiceImpl extends BaseServiceImpl<CustomerUserDao, CustomerUserEntity> implements CustomerUserService { | 
				
			|||
 | 
				
			|||
    @Autowired | 
				
			|||
    private CustomerUserRedis customerUserRedis; | 
				
			|||
 | 
				
			|||
    @Override | 
				
			|||
    public PageData<CustomerUserDTO> page(Map<String, Object> params) { | 
				
			|||
        IPage<CustomerUserEntity> page = baseDao.selectPage( | 
				
			|||
                getPage(params, FieldConstant.CREATED_TIME, false), | 
				
			|||
                getWrapper(params) | 
				
			|||
        ); | 
				
			|||
        return getPageData(page, CustomerUserDTO.class); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    @Override | 
				
			|||
    public List<CustomerUserDTO> list(Map<String, Object> params) { | 
				
			|||
        List<CustomerUserEntity> entityList = baseDao.selectList(getWrapper(params)); | 
				
			|||
 | 
				
			|||
        return ConvertUtils.sourceToTarget(entityList, CustomerUserDTO.class); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    private QueryWrapper<CustomerUserEntity> getWrapper(Map<String, Object> params){ | 
				
			|||
        String id = (String)params.get(FieldConstant.ID_HUMP); | 
				
			|||
 | 
				
			|||
        QueryWrapper<CustomerUserEntity> wrapper = new QueryWrapper<>(); | 
				
			|||
        wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); | 
				
			|||
 | 
				
			|||
        return wrapper; | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    @Override | 
				
			|||
    public CustomerUserDTO get(String id) { | 
				
			|||
        CustomerUserEntity entity = baseDao.selectById(id); | 
				
			|||
        return ConvertUtils.sourceToTarget(entity, CustomerUserDTO.class); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    @Override | 
				
			|||
    @Transactional(rollbackFor = Exception.class) | 
				
			|||
    public void save(CustomerUserDTO dto) { | 
				
			|||
        CustomerUserEntity entity = ConvertUtils.sourceToTarget(dto, CustomerUserEntity.class); | 
				
			|||
        insert(entity); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    @Override | 
				
			|||
    @Transactional(rollbackFor = Exception.class) | 
				
			|||
    public void update(CustomerUserDTO dto) { | 
				
			|||
        CustomerUserEntity entity = ConvertUtils.sourceToTarget(dto, CustomerUserEntity.class); | 
				
			|||
        updateById(entity); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    @Override | 
				
			|||
    @Transactional(rollbackFor = Exception.class) | 
				
			|||
    public void delete(String[] ids) { | 
				
			|||
        // 逻辑删除(@TableLogic 注解)
 | 
				
			|||
        baseDao.deleteBatchIds(Arrays.asList(ids)); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -0,0 +1,27 @@ | 
				
			|||
<?xml version="1.0" encoding="UTF-8"?> | 
				
			|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | 
				
			|||
 | 
				
			|||
<mapper namespace="com.epmet.dao.CustomerUserDao"> | 
				
			|||
 | 
				
			|||
    <resultMap type="com.epmet.entity.CustomerUserEntity" id="customerUserMap"> | 
				
			|||
        <result property="id" column="ID"/> | 
				
			|||
        <result property="customerId" column="CUSTOMER_ID"/> | 
				
			|||
        <result property="wxOpenId" column="WX_OPEN_ID"/> | 
				
			|||
        <result property="mobile" column="MOBILE"/> | 
				
			|||
        <result property="nickname" column="NICKNAME"/> | 
				
			|||
        <result property="sex" column="SEX"/> | 
				
			|||
        <result property="headImgUrl" column="HEAD_IMG_URL"/> | 
				
			|||
        <result property="country" column="COUNTRY"/> | 
				
			|||
        <result property="province" column="PROVINCE"/> | 
				
			|||
        <result property="city" column="CITY"/> | 
				
			|||
        <result property="language" column="LANGUAGE"/> | 
				
			|||
        <result property="delFlag" column="DEL_FLAG"/> | 
				
			|||
        <result property="revision" column="REVISION"/> | 
				
			|||
        <result property="createdBy" column="CREATED_BY"/> | 
				
			|||
        <result property="createdTime" column="CREATED_TIME"/> | 
				
			|||
        <result property="updatedBy" column="UPDATED_BY"/> | 
				
			|||
        <result property="updatedTime" column="UPDATED_TIME"/> | 
				
			|||
    </resultMap> | 
				
			|||
 | 
				
			|||
 | 
				
			|||
</mapper> | 
				
			|||
					Loading…
					
					
				
		Reference in new issue