parent
09c617c1fb
commit
bba18fbc9f
@ -1,54 +0,0 @@
|
||||
package com.luoo.cms;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.core.env.Environment;
|
||||
import util.IdWorker;
|
||||
import util.JwtUtil;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableEurekaClient
|
||||
@EnableDiscoveryClient
|
||||
@EnableFeignClients
|
||||
public class CmsApplication {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(CmsApplication.class);
|
||||
|
||||
public static void main(String[] args) throws UnknownHostException {
|
||||
ConfigurableApplicationContext application = SpringApplication.run(CmsApplication.class, args);
|
||||
|
||||
Environment env = application.getEnvironment();
|
||||
|
||||
logger.info("\n----------------------------------------------------------\n\t"
|
||||
+ "Application '{}' is running! Access URLs:\n\t" + "Local: \t\thttp://localhost:{}\n\t"
|
||||
+ "External: \thttp://{}:{}\n\t" + "Doc: \thttp://{}:{}/doc.html\n\t"
|
||||
+ "Version: \tversion={},profiles={}\n" + "----------------------------------------------------------",
|
||||
env.getProperty("spring.application.name"), env.getProperty("server.port"),
|
||||
InetAddress.getLocalHost().getHostAddress(), env.getProperty("server.port"),
|
||||
InetAddress.getLocalHost().getHostAddress(), env.getProperty("server.port"),
|
||||
env.getProperty("api.version"),env.getProperty("spring.profiles.active"));
|
||||
|
||||
}
|
||||
|
||||
@Bean
|
||||
public JwtUtil jwtUtil(){
|
||||
return new JwtUtil();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public IdWorker idWorkker(){
|
||||
return new IdWorker(1, 1);
|
||||
}
|
||||
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
package com.luoo.cms.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.service.Contact;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
|
||||
@EnableSwagger2
|
||||
@Configuration
|
||||
public class SwaggerConfig {
|
||||
|
||||
@Autowired
|
||||
private ConfigurableEnvironment configurableEnvironment;
|
||||
|
||||
@Bean
|
||||
public Docket docket() {
|
||||
Docket docket = new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(apiInfo())
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("com.luoo.cms"))
|
||||
.paths(PathSelectors.any())
|
||||
.build().directModelSubstitute(LocalTime.class, String.class)
|
||||
.directModelSubstitute(LocalDate.class, String.class);
|
||||
String appName = configurableEnvironment.getProperty("spring.application.name");
|
||||
if (appName != null){
|
||||
docket.pathMapping(String.format("/%s", appName));
|
||||
}
|
||||
return docket;
|
||||
}
|
||||
|
||||
private ApiInfo apiInfo() {
|
||||
ApiInfo info = new ApiInfoBuilder()
|
||||
.title("通用CMS")
|
||||
.description("通用CMS")
|
||||
.version("0.0.1")
|
||||
.contact(new Contact("通用CMS", "", ""))
|
||||
.build();
|
||||
return info;
|
||||
}
|
||||
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
package com.luoo.cms.controller;
|
||||
|
||||
|
||||
import api.Result;
|
||||
import com.luoo.cms.pojo.Banner;
|
||||
import com.luoo.cms.service.BannerService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
@Api(tags = "banner轮播图")
|
||||
@RestController
|
||||
@RequestMapping("/banner")
|
||||
public class BannerController {
|
||||
|
||||
@Autowired
|
||||
private BannerService bannerService;
|
||||
|
||||
@ApiOperation("通过id查询一个banner")
|
||||
@GetMapping("/{id}")
|
||||
public Result<Banner> findById(@PathVariable String id){
|
||||
return Result.success(bannerService.findById(id));
|
||||
}
|
||||
|
||||
@ApiOperation("banner列表")
|
||||
@GetMapping("/list")
|
||||
public Result<List<Banner>> findById(){
|
||||
return Result.success(bannerService.bannerList());
|
||||
}
|
||||
|
||||
@ApiOperation("添加一个banner")
|
||||
@PostMapping
|
||||
public Result<Void> add(@RequestBody Banner banner){
|
||||
bannerService.add(banner);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@ApiOperation("通过id删除banner")
|
||||
@DeleteMapping("/{id}")
|
||||
public Result<Void> delete(@PathVariable String id ){
|
||||
bannerService.deleteById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package com.luoo.cms.controller;
|
||||
|
||||
|
||||
import api.Result;
|
||||
import com.luoo.cms.pojo.Agreement;
|
||||
import com.luoo.cms.pojo.Banner;
|
||||
import com.luoo.cms.service.AgreementService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@Api(tags = "通用CMS")
|
||||
@RestController
|
||||
@RequestMapping("/cms")
|
||||
public class CmsController {
|
||||
|
||||
@Autowired
|
||||
private AgreementService agreementService;
|
||||
|
||||
@ApiOperation("通过key查询")
|
||||
@GetMapping("/agreement/{key}")
|
||||
public Result<Agreement> findById(@PathVariable String key){
|
||||
return Result.success(agreementService.findByKey(key));
|
||||
}
|
||||
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package com.luoo.cms.dao;
|
||||
|
||||
import com.luoo.cms.pojo.Agreement;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.lang.NonNull;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface AgreementDao extends JpaRepository<Agreement,String> {
|
||||
|
||||
@Query("select a from Agreement a where a.key = ?1")
|
||||
Optional<Agreement> findByKey(String key);
|
||||
|
||||
Optional<Agreement> findByKeyAndState(@NonNull String key, int state);
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package com.luoo.cms.dao;
|
||||
|
||||
import com.luoo.cms.pojo.Banner;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface BannerDao extends JpaRepository<Banner,String> {
|
||||
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
package com.luoo.cms.pojo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "tb_agreement")
|
||||
@ApiModel(value = "协议")
|
||||
public class Agreement implements Serializable {
|
||||
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "url别名")
|
||||
private String key;
|
||||
|
||||
@ApiModelProperty(value = "标题")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "内容")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty(value = "状态")
|
||||
private int state = 0;
|
||||
|
||||
@Column(name = "create_time")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:dd")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
protected LocalDateTime createTime = LocalDateTime.now();
|
||||
|
||||
@Column(name = "update_time")
|
||||
@ApiModelProperty(value = "更新时间", hidden = true)
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
protected LocalDateTime updateTime = LocalDateTime.now();
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
package com.luoo.cms.pojo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "tb_banner")
|
||||
@ApiModel(value = "banner轮播图")
|
||||
public class Banner implements Serializable {
|
||||
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "标题")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "图片地址")
|
||||
private String imgUrl;
|
||||
|
||||
@ApiModelProperty(value = "点击跳转地址")
|
||||
private String url;
|
||||
|
||||
@ApiModelProperty(value = "状态")
|
||||
private int state = 0;
|
||||
|
||||
@Column(name = "create_time")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:dd")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
protected LocalDateTime createTime = LocalDateTime.now();
|
||||
|
||||
@Column(name = "update_time")
|
||||
@ApiModelProperty(value = "更新时间", hidden = true)
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
protected LocalDateTime updateTime = LocalDateTime.now();
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package com.luoo.cms.service;
|
||||
|
||||
import com.luoo.cms.dao.AgreementDao;
|
||||
import com.luoo.cms.pojo.Agreement;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class AgreementService {
|
||||
|
||||
@Autowired
|
||||
private AgreementDao agreementDao;
|
||||
|
||||
public Agreement findByKey1(String key) {
|
||||
Agreement agreement = new Agreement();
|
||||
agreement.setKey(key);
|
||||
Example<Agreement> example = Example.of(agreement);
|
||||
return agreementDao.findOne(example).get();
|
||||
}
|
||||
|
||||
|
||||
public Agreement findByKey(String key) {
|
||||
//agreementDao.findByKeyAndState(key,0);
|
||||
return agreementDao.findByKey(key).get();
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
package com.luoo.cms.service;
|
||||
|
||||
import com.luoo.cms.dao.BannerDao;
|
||||
import com.luoo.cms.pojo.Banner;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import util.IdWorker;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class BannerService {
|
||||
|
||||
@Autowired
|
||||
private BannerDao bannerDao;
|
||||
|
||||
@Autowired
|
||||
private IdWorker idWorker;
|
||||
|
||||
public Banner findById(String id) {
|
||||
return bannerDao.findById(id).get();
|
||||
}
|
||||
|
||||
public void add(Banner banner) {
|
||||
banner.setId(idWorker.nextId()+"");
|
||||
bannerDao.save(banner);
|
||||
}
|
||||
|
||||
public void deleteById(String id) {
|
||||
bannerDao.deleteById(id);
|
||||
}
|
||||
|
||||
public List<Banner> bannerList() {
|
||||
return bannerDao.findAll();
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
server:
|
||||
port: 9013
|
||||
spring:
|
||||
application:
|
||||
name: luoo-tag #指定服务名
|
||||
datasource:
|
||||
driverClassName: com.mysql.jdbc.Driver
|
||||
url: jdbc:mysql://8.134.98.47:3307/indie_tag?characterEncoding=UTF8&useSSL=false
|
||||
username: root
|
||||
password: 47084735abc
|
||||
jpa:
|
||||
database: MySQL
|
||||
show-sql: true
|
||||
redis:
|
||||
host: 8.134.98.47
|
||||
port: 36379
|
||||
eureka:
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://127.0.0.1:6868/eureka/
|
||||
instance:
|
||||
prefer-ip-address: true
|
@ -1,8 +0,0 @@
|
||||
spring:
|
||||
cloud:
|
||||
config:
|
||||
name: cms
|
||||
profile: dev
|
||||
label: master
|
||||
uri: http://116.62.145.60:12000
|
||||
# uri: http://127.0.0.1:12000
|
@ -1,46 +0,0 @@
|
||||
package com.luoo.friend;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
import util.JwtUtil;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableEurekaClient
|
||||
@EnableDiscoveryClient
|
||||
@EnableFeignClients
|
||||
public class FriendApplication {
|
||||
static Logger logger= LoggerFactory.getLogger(FriendApplication.class);
|
||||
public static void main(String[] args) throws UnknownHostException {
|
||||
ConfigurableApplicationContext application=SpringApplication.run(FriendApplication.class, args);
|
||||
Environment env = application.getEnvironment();
|
||||
logger.info("\n----------------------------------------------------------\n\t" +
|
||||
"Application '{}' is running! Access URLs:\n\t" +
|
||||
"Local: \t\thttp://localhost:{}\n\t" +
|
||||
"External: \thttp://{}:{}\n\t"+
|
||||
"Doc: \thttp://{}:{}/doc.html\n"+
|
||||
"----------------------------------------------------------",
|
||||
env.getProperty("spring.application.name"),
|
||||
env.getProperty("server.port"),
|
||||
InetAddress.getLocalHost().getHostAddress(),
|
||||
env.getProperty("server.port"),
|
||||
InetAddress.getLocalHost().getHostAddress(),
|
||||
env.getProperty("server.port"));
|
||||
}
|
||||
|
||||
@Bean
|
||||
public JwtUtil jwtUtil(){
|
||||
return new JwtUtil();
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package com.luoo.friend.client;
|
||||
|
||||
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
|
||||
@FeignClient("luoo-user")
|
||||
public interface UserClient {
|
||||
|
||||
@PutMapping("/user/{userid}/{friendid}/{x}")
|
||||
public void updatefanscountandfollowcount(@PathVariable String userid, @PathVariable String friendid, @PathVariable int x);
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package com.luoo.friend.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
||||
|
||||
import com.luoo.friend.interceptor.JwtInterceptor;
|
||||
|
||||
@Configuration
|
||||
public class InterceptorConfig extends WebMvcConfigurationSupport {
|
||||
|
||||
@Autowired
|
||||
private JwtInterceptor jwtInterceptor;
|
||||
protected void addInterceptors(InterceptorRegistry registry) {
|
||||
String[] excludePathPatterns = { "/user/login/**","/user/appLogin/**","/user/sendsms/**","/user/touristLogin","/doc.html/**","/swagger-resources/**","/webjars/**","/v2/**"};
|
||||
|
||||
registry.addInterceptor(jwtInterceptor).
|
||||
addPathPatterns("/**").
|
||||
excludePathPatterns(excludePathPatterns);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("doc.html")
|
||||
.addResourceLocations("classpath:/META-INF/resources/");
|
||||
registry.addResourceHandler("/webjars/**")
|
||||
.addResourceLocations("classpath:/META-INF/resources/webjars/");
|
||||
super.addResourceHandlers(registry);
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package com.luoo.friend.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI;
|
||||
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
import swagger.BaseSwaggerConfig;
|
||||
import swagger.SwaggerProperties;
|
||||
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
@EnableSwaggerBootstrapUI
|
||||
public class SwaggerConfig extends BaseSwaggerConfig {
|
||||
|
||||
@Override
|
||||
public SwaggerProperties swaggerProperties() {
|
||||
return SwaggerProperties.builder()
|
||||
.apiBasePackage("com.luoo.friend.controller")
|
||||
.title("luoo-friend API")
|
||||
.description("luoo-friend 后端接口文档")
|
||||
.contactName("jeffrey")
|
||||
.version("1.0")
|
||||
.enableSecurity(false)
|
||||
.build();
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package com.luoo.friend.dao;
|
||||
|
||||
import com.luoo.friend.pojo.Friend;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
public interface FriendDao extends JpaRepository<Friend,String> {
|
||||
|
||||
public Friend findByUseridAndFriendid(String userid,String friendid);
|
||||
|
||||
@Modifying
|
||||
@Query(value = "update tb_friend set islike = ? where userid = ? and friendid = ?",nativeQuery = true)
|
||||
public void updateIslike(String islike,String userid,String friendid);
|
||||
|
||||
@Modifying
|
||||
@Query(value = "delete from tb_friend where userid = ? and friendid = ?",nativeQuery = true)
|
||||
void deletefriend(String userid, String friendid);
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package com.luoo.friend.dao;
|
||||
|
||||
import com.luoo.friend.pojo.Friend;
|
||||
import com.luoo.friend.pojo.NoFriend;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
public interface NoFriendDao extends JpaRepository<NoFriend,String> {
|
||||
|
||||
public NoFriend findByUseridAndFriendid(String userid,String friendid);
|
||||
|
||||
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
package com.luoo.friend.interceptor;
|
||||
|
||||
import io.jsonwebtoken.Claims;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import util.JwtUtil;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@Component
|
||||
public class JwtInterceptor implements HandlerInterceptor {
|
||||
|
||||
@Autowired
|
||||
private JwtUtil jwtUtil;
|
||||
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
System.out.println("经过了拦截器");
|
||||
String header = request.getHeader("Authorization");
|
||||
|
||||
if (header!=null && !"".equals(header)) {
|
||||
|
||||
if (header.startsWith("Bearer ")){
|
||||
String token = header.substring(7);
|
||||
try {
|
||||
Claims claims = jwtUtil.parseJWT(token);
|
||||
String roles = (String) claims.get("roles");
|
||||
if (roles != null || !roles.equals("admin")) {
|
||||
request.setAttribute("claims_admin",claims);
|
||||
}
|
||||
if (roles != null || !roles.equals("user")) {
|
||||
request.setAttribute("claims_user",claims);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("令牌不正确!");
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
package com.luoo.friend.pojo;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.IdClass;
|
||||
import javax.persistence.Table;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Entity
|
||||
@Table(name = "tb_friend")
|
||||
@IdClass(Friend.class)
|
||||
public class Friend implements Serializable {
|
||||
|
||||
@Id
|
||||
private String userid;
|
||||
|
||||
@Id
|
||||
private String friendid;
|
||||
|
||||
private String islike;
|
||||
|
||||
public String getUserid() {
|
||||
return userid;
|
||||
}
|
||||
|
||||
public void setUserid(String userid) {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
public String getFriendid() {
|
||||
return friendid;
|
||||
}
|
||||
|
||||
public void setFriendid(String friendid) {
|
||||
this.friendid = friendid;
|
||||
}
|
||||
|
||||
public String getIslike() {
|
||||
return islike;
|
||||
}
|
||||
|
||||
public void setIslike(String islike) {
|
||||
this.islike = islike;
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
package com.luoo.friend.pojo;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.IdClass;
|
||||
import javax.persistence.Table;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Entity
|
||||
@Table(name = "tb_nofriend")
|
||||
@IdClass(NoFriend.class)
|
||||
public class NoFriend implements Serializable {
|
||||
|
||||
@Id
|
||||
private String userid;
|
||||
|
||||
@Id
|
||||
private String friendid;
|
||||
|
||||
|
||||
public String getUserid() {
|
||||
return userid;
|
||||
}
|
||||
|
||||
public void setUserid(String userid) {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
public String getFriendid() {
|
||||
return friendid;
|
||||
}
|
||||
|
||||
public void setFriendid(String friendid) {
|
||||
this.friendid = friendid;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
spring:
|
||||
cloud:
|
||||
config:
|
||||
name: friend
|
||||
profile: dev
|
||||
label: master
|
||||
uri: http://116.62.145.60:12000
|
||||
# uri: http://127.0.0.1:12000
|
@ -1,28 +0,0 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.luoo</groupId>
|
||||
<artifactId>luoo_parent</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>luoo_gathering</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.luoo</groupId>
|
||||
<artifactId>luoo_common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -1,44 +0,0 @@
|
||||
package com.luoo.gathering;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
import util.IdWorker;
|
||||
@SpringBootApplication
|
||||
@EnableCaching
|
||||
@EnableEurekaClient
|
||||
public class GatheringApplication {
|
||||
|
||||
static Logger logger= LoggerFactory.getLogger(GatheringApplication.class);
|
||||
public static void main(String[] args) throws UnknownHostException {
|
||||
ConfigurableApplicationContext application=SpringApplication.run(GatheringApplication.class, args);
|
||||
Environment env = application.getEnvironment();
|
||||
logger.info("\n----------------------------------------------------------\n\t" +
|
||||
"Application '{}' is running! Access URLs:\n\t" +
|
||||
"Local: \t\thttp://localhost:{}\n\t" +
|
||||
"External: \thttp://{}:{}\n\t"+
|
||||
"Doc: \thttp://{}:{}/doc.html\n"+
|
||||
"----------------------------------------------------------",
|
||||
env.getProperty("spring.application.name"),
|
||||
env.getProperty("server.port"),
|
||||
InetAddress.getLocalHost().getHostAddress(),
|
||||
env.getProperty("server.port"),
|
||||
InetAddress.getLocalHost().getHostAddress(),
|
||||
env.getProperty("server.port"));
|
||||
}
|
||||
|
||||
@Bean
|
||||
public IdWorker idWorkker(){
|
||||
return new IdWorker(1, 1);
|
||||
}
|
||||
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package com.luoo.gathering.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI;
|
||||
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
import swagger.BaseSwaggerConfig;
|
||||
import swagger.SwaggerProperties;
|
||||
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
@EnableSwaggerBootstrapUI
|
||||
public class SwaggerConfig extends BaseSwaggerConfig {
|
||||
|
||||
@Override
|
||||
public SwaggerProperties swaggerProperties() {
|
||||
return SwaggerProperties.builder()
|
||||
.apiBasePackage("com.luoo.gathering.controller")
|
||||
.title("luoo-gathering API")
|
||||
.description("luoo-gathering 后端接口文档")
|
||||
.contactName("")
|
||||
.version("1.0")
|
||||
.enableSecurity(false)
|
||||
.build();
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package com.luoo.gathering.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
||||
|
||||
@Configuration
|
||||
public class WebMvcConfig extends WebMvcConfigurationSupport {
|
||||
@Override
|
||||
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");
|
||||
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
|
||||
super.addResourceHandlers(registry);
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
package com.luoo.gathering.controller;
|
||||
import api.Result;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
/**
|
||||
* 统一异常处理类
|
||||
*/
|
||||
@ControllerAdvice
|
||||
public class BaseExceptionHandler {
|
||||
|
||||
@ExceptionHandler(value = Exception.class)
|
||||
@ResponseBody
|
||||
public Result<Void> error(Exception e){
|
||||
e.printStackTrace();
|
||||
return Result.failed();
|
||||
}
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
package com.luoo.gathering.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.luoo.gathering.pojo.Gathering;
|
||||
import com.luoo.gathering.service.GatheringService;
|
||||
|
||||
import api.PageResult;
|
||||
import api.Result;
|
||||
|
||||
/**
|
||||
* 控制器层
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping("/gathering")
|
||||
public class GatheringController {
|
||||
|
||||
@Autowired
|
||||
private GatheringService gatheringService;
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public Result<List<Gathering>> findAll() {
|
||||
return Result.success(gatheringService.findAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param id ID
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
||||
public Result<Gathering> findById(@PathVariable String id) {
|
||||
return Result.success(gatheringService.findById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页+多条件查询
|
||||
*
|
||||
* @param searchMap 查询条件封装
|
||||
* @param page 页码
|
||||
* @param size 页大小
|
||||
* @return 分页结果
|
||||
*/
|
||||
@RequestMapping(value = "/search/{page}/{size}", method = RequestMethod.POST)
|
||||
public Result<PageResult<Gathering>> findSearch(@RequestBody Map searchMap, @PathVariable int page,
|
||||
@PathVariable int size) {
|
||||
Page<Gathering> pageList = gatheringService.findSearch(searchMap, page, size);
|
||||
return Result.success(new PageResult<Gathering>(pageList.getTotalElements(), pageList.getContent()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件查询
|
||||
*
|
||||
* @param searchMap
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/search", method = RequestMethod.POST)
|
||||
public Result findSearch(@RequestBody Map searchMap) {
|
||||
return Result.success(gatheringService.findSearch(searchMap));
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加
|
||||
*
|
||||
* @param gathering
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
public Result<Void> add(@RequestBody Gathering gathering) {
|
||||
gatheringService.add(gathering);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*
|
||||
* @param gathering
|
||||
*/
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
|
||||
public Result<Void> update(@RequestBody Gathering gathering, @PathVariable String id) {
|
||||
gathering.setId(id);
|
||||
gatheringService.update(gathering);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
||||
public Result<Void> delete(@PathVariable String id) {
|
||||
gatheringService.deleteById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package com.luoo.gathering.dao;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
import com.luoo.gathering.pojo.Gathering;
|
||||
/**
|
||||
* 数据访问接口
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
public interface GatheringDao extends JpaRepository<Gathering,String>,JpaSpecificationExecutor<Gathering>{
|
||||
|
||||
}
|
@ -1,120 +0,0 @@
|
||||
package com.luoo.gathering.pojo;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.io.Serializable;
|
||||
/**
|
||||
* 实体类
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="tb_gathering")
|
||||
public class Gathering implements Serializable{
|
||||
|
||||
@Id
|
||||
private String id;//编号
|
||||
|
||||
|
||||
|
||||
private String name;//活动名称
|
||||
private String summary;//大会简介
|
||||
private String detail;//详细说明
|
||||
private String sponsor;//主办方
|
||||
private String image;//活动图片
|
||||
private java.util.Date starttime;//开始时间
|
||||
private java.util.Date endtime;//截止时间
|
||||
private String address;//举办地点
|
||||
private java.util.Date enrolltime;//报名截止
|
||||
private String state;//是否可见
|
||||
private String city;//城市
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getSummary() {
|
||||
return summary;
|
||||
}
|
||||
public void setSummary(String summary) {
|
||||
this.summary = summary;
|
||||
}
|
||||
|
||||
public String getDetail() {
|
||||
return detail;
|
||||
}
|
||||
public void setDetail(String detail) {
|
||||
this.detail = detail;
|
||||
}
|
||||
|
||||
public String getSponsor() {
|
||||
return sponsor;
|
||||
}
|
||||
public void setSponsor(String sponsor) {
|
||||
this.sponsor = sponsor;
|
||||
}
|
||||
|
||||
public String getImage() {
|
||||
return image;
|
||||
}
|
||||
public void setImage(String image) {
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
public java.util.Date getStarttime() {
|
||||
return starttime;
|
||||
}
|
||||
public void setStarttime(java.util.Date starttime) {
|
||||
this.starttime = starttime;
|
||||
}
|
||||
|
||||
public java.util.Date getEndtime() {
|
||||
return endtime;
|
||||
}
|
||||
public void setEndtime(java.util.Date endtime) {
|
||||
this.endtime = endtime;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public java.util.Date getEnrolltime() {
|
||||
return enrolltime;
|
||||
}
|
||||
public void setEnrolltime(java.util.Date enrolltime) {
|
||||
this.enrolltime = enrolltime;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,170 +0,0 @@
|
||||
package com.luoo.gathering.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Expression;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import javax.persistence.criteria.Root;
|
||||
import javax.persistence.criteria.Selection;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import util.IdWorker;
|
||||
|
||||
import com.luoo.gathering.dao.GatheringDao;
|
||||
import com.luoo.gathering.pojo.Gathering;
|
||||
|
||||
/**
|
||||
* 服务层
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
@Service
|
||||
public class GatheringService {
|
||||
|
||||
@Autowired
|
||||
private GatheringDao gatheringDao;
|
||||
|
||||
@Autowired
|
||||
private IdWorker idWorker;
|
||||
|
||||
/**
|
||||
* 查询全部列表
|
||||
* @return
|
||||
*/
|
||||
public List<Gathering> findAll() {
|
||||
return gatheringDao.findAll();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 条件查询+分页
|
||||
* @param whereMap
|
||||
* @param page
|
||||
* @param size
|
||||
* @return
|
||||
*/
|
||||
public Page<Gathering> findSearch(Map whereMap, int page, int size) {
|
||||
Specification<Gathering> specification = createSpecification(whereMap);
|
||||
PageRequest pageRequest = PageRequest.of(page-1, size);
|
||||
return gatheringDao.findAll(specification, pageRequest);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 条件查询
|
||||
* @param whereMap
|
||||
* @return
|
||||
*/
|
||||
public List<Gathering> findSearch(Map whereMap) {
|
||||
Specification<Gathering> specification = createSpecification(whereMap);
|
||||
return gatheringDao.findAll(specification);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询实体
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(value = "gathering",key = "#id")
|
||||
public Gathering findById(String id) {
|
||||
return gatheringDao.findById(id).get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加
|
||||
* @param gathering
|
||||
*/
|
||||
public void add(Gathering gathering) {
|
||||
gathering.setId( idWorker.nextId()+"" );
|
||||
gatheringDao.save(gathering);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @param gathering
|
||||
*/
|
||||
@CacheEvict(value = "gathering",key = "#gathering.id")
|
||||
public void update(Gathering gathering) {
|
||||
gatheringDao.save(gathering);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param id
|
||||
*/
|
||||
@CacheEvict(value = "gathering",key = "#id")
|
||||
public void deleteById(String id) {
|
||||
gatheringDao.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 动态条件构建
|
||||
* @param searchMap
|
||||
* @return
|
||||
*/
|
||||
private Specification<Gathering> createSpecification(Map searchMap) {
|
||||
|
||||
return new Specification<Gathering>() {
|
||||
|
||||
@Override
|
||||
public Predicate toPredicate(Root<Gathering> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
|
||||
List<Predicate> predicateList = new ArrayList<Predicate>();
|
||||
// 编号
|
||||
if (searchMap.get("id")!=null && !"".equals(searchMap.get("id"))) {
|
||||
predicateList.add(cb.like(root.get("id").as(String.class), "%"+(String)searchMap.get("id")+"%"));
|
||||
}
|
||||
// 活动名称
|
||||
if (searchMap.get("name")!=null && !"".equals(searchMap.get("name"))) {
|
||||
predicateList.add(cb.like(root.get("name").as(String.class), "%"+(String)searchMap.get("name")+"%"));
|
||||
}
|
||||
// 大会简介
|
||||
if (searchMap.get("summary")!=null && !"".equals(searchMap.get("summary"))) {
|
||||
predicateList.add(cb.like(root.get("summary").as(String.class), "%"+(String)searchMap.get("summary")+"%"));
|
||||
}
|
||||
// 详细说明
|
||||
if (searchMap.get("detail")!=null && !"".equals(searchMap.get("detail"))) {
|
||||
predicateList.add(cb.like(root.get("detail").as(String.class), "%"+(String)searchMap.get("detail")+"%"));
|
||||
}
|
||||
// 主办方
|
||||
if (searchMap.get("sponsor")!=null && !"".equals(searchMap.get("sponsor"))) {
|
||||
predicateList.add(cb.like(root.get("sponsor").as(String.class), "%"+(String)searchMap.get("sponsor")+"%"));
|
||||
}
|
||||
// 活动图片
|
||||
if (searchMap.get("image")!=null && !"".equals(searchMap.get("image"))) {
|
||||
predicateList.add(cb.like(root.get("image").as(String.class), "%"+(String)searchMap.get("image")+"%"));
|
||||
}
|
||||
// 举办地点
|
||||
if (searchMap.get("address")!=null && !"".equals(searchMap.get("address"))) {
|
||||
predicateList.add(cb.like(root.get("address").as(String.class), "%"+(String)searchMap.get("address")+"%"));
|
||||
}
|
||||
// 是否可见
|
||||
if (searchMap.get("state")!=null && !"".equals(searchMap.get("state"))) {
|
||||
predicateList.add(cb.like(root.get("state").as(String.class), "%"+(String)searchMap.get("state")+"%"));
|
||||
}
|
||||
// 城市
|
||||
if (searchMap.get("city")!=null && !"".equals(searchMap.get("city"))) {
|
||||
predicateList.add(cb.like(root.get("city").as(String.class), "%"+(String)searchMap.get("city")+"%"));
|
||||
}
|
||||
|
||||
return cb.and( predicateList.toArray(new Predicate[predicateList.size()]));
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
server:
|
||||
port: 9005
|
||||
spring:
|
||||
application:
|
||||
name: luoo-gathering #指定服务名
|
||||
datasource:
|
||||
driverClassName: com.mysql.jdbc.Driver
|
||||
url: jdbc:mysql://8.134.98.47:3307/indie_gathering?characterEncoding=UTF8&useSSL=false
|
||||
username: root
|
||||
password: 47084735Abc@
|
||||
jpa:
|
||||
database: MySQL
|
||||
show-sql: true
|
||||
eureka:
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://127.0.0.1:6868/eureka/
|
||||
instance:
|
||||
prefer-ip-address: true
|
@ -1,24 +0,0 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.luoo</groupId>
|
||||
<artifactId>luoo_parent</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>luoo_recruit</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.luoo</groupId>
|
||||
<artifactId>luoo_common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -1,20 +0,0 @@
|
||||
package com.luoo.recruit;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import util.IdWorker;
|
||||
|
||||
//import util.IdWorker;
|
||||
@SpringBootApplication
|
||||
public class RecruitApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(RecruitApplication.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public IdWorker idWorker(){
|
||||
return new IdWorker(1, 1);
|
||||
}
|
||||
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package com.luoo.recruit.controller;
|
||||
import api.Result;
|
||||
import api.StatusCode;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
/**
|
||||
* 统一异常处理类
|
||||
*/
|
||||
@ControllerAdvice
|
||||
public class BaseExceptionHandler {
|
||||
|
||||
@ExceptionHandler(value = Exception.class)
|
||||
@ResponseBody
|
||||
public Result<Void> error(Exception e){
|
||||
e.printStackTrace();
|
||||
return Result.failed(StatusCode.RECRUIT_COMMON_FAILED);
|
||||
}
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
package com.luoo.recruit.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.luoo.recruit.pojo.Enterprise;
|
||||
import com.luoo.recruit.service.EnterpriseService;
|
||||
|
||||
import api.PageResult;
|
||||
import api.Result;
|
||||
|
||||
/**
|
||||
* 控制器层
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping("/enterprise")
|
||||
public class EnterpriseController {
|
||||
|
||||
@Autowired
|
||||
private EnterpriseService enterpriseService;
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public Result<List<Enterprise>> findAll() {
|
||||
return Result.success(enterpriseService.findAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param id ID
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
||||
public Result<Enterprise> findById(@PathVariable String id) {
|
||||
return Result.success(enterpriseService.findById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页+多条件查询
|
||||
*
|
||||
* @param searchMap 查询条件封装
|
||||
* @param page 页码
|
||||
* @param size 页大小
|
||||
* @return 分页结果
|
||||
*/
|
||||
@RequestMapping(value = "/search/{page}/{size}", method = RequestMethod.POST)
|
||||
public Result<PageResult<Enterprise>> findSearch(@RequestBody Map searchMap, @PathVariable int page,
|
||||
@PathVariable int size) {
|
||||
Page<Enterprise> pageList = enterpriseService.findSearch(searchMap, page, size);
|
||||
return Result.success(new PageResult<Enterprise>(pageList.getTotalElements(), pageList.getContent()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件查询
|
||||
*
|
||||
* @param searchMap
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/search", method = RequestMethod.POST)
|
||||
public Result<List<Enterprise>> findSearch(@RequestBody Map searchMap) {
|
||||
return Result.success(enterpriseService.findSearch(searchMap));
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加
|
||||
*
|
||||
* @param enterprise
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
public Result<Void> add(@RequestBody Enterprise enterprise) {
|
||||
enterpriseService.add(enterprise);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*
|
||||
* @param enterprise
|
||||
*/
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
|
||||
public Result<Void> update(@RequestBody Enterprise enterprise, @PathVariable String id) {
|
||||
enterprise.setId(id);
|
||||
enterpriseService.update(enterprise);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
||||
public Result<Void> delete(@PathVariable String id) {
|
||||
enterpriseService.deleteById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
package com.luoo.recruit.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.luoo.recruit.pojo.Recruit;
|
||||
import com.luoo.recruit.service.RecruitService;
|
||||
|
||||
import api.PageResult;
|
||||
import api.Result;
|
||||
|
||||
/**
|
||||
* 控制器层
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping("/recruit")
|
||||
public class RecruitController {
|
||||
|
||||
@Autowired
|
||||
private RecruitService recruitService;
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public Result<List<Recruit>> findAll() {
|
||||
return Result.success(recruitService.findAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param id ID
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
||||
public Result<Recruit> findById(@PathVariable String id) {
|
||||
return Result.success(recruitService.findById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页+多条件查询
|
||||
*
|
||||
* @param searchMap 查询条件封装
|
||||
* @param page 页码
|
||||
* @param size 页大小
|
||||
* @return 分页结果
|
||||
*/
|
||||
@RequestMapping(value = "/search/{page}/{size}", method = RequestMethod.POST)
|
||||
public Result<PageResult<Recruit>> findSearch(@RequestBody Map searchMap, @PathVariable int page,
|
||||
@PathVariable int size) {
|
||||
Page<Recruit> pageList = recruitService.findSearch(searchMap, page, size);
|
||||
return Result.success(new PageResult<Recruit>(pageList.getTotalElements(), pageList.getContent()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件查询
|
||||
*
|
||||
* @param searchMap
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/search", method = RequestMethod.POST)
|
||||
public Result<List<Recruit>> findSearch(@RequestBody Map searchMap) {
|
||||
return Result.success(recruitService.findSearch(searchMap));
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加
|
||||
*
|
||||
* @param recruit
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
public Result<Void> add(@RequestBody Recruit recruit) {
|
||||
recruitService.add(recruit);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*
|
||||
* @param recruit
|
||||
*/
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
|
||||
public Result<Void> update(@RequestBody Recruit recruit, @PathVariable String id) {
|
||||
recruit.setId(id);
|
||||
recruitService.update(recruit);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
||||
public Result<Void> delete(@PathVariable String id) {
|
||||
recruitService.deleteById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package com.luoo.recruit.dao;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
import com.luoo.recruit.pojo.Enterprise;
|
||||
/**
|
||||
* 数据访问接口
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
public interface EnterpriseDao extends JpaRepository<Enterprise,String>,JpaSpecificationExecutor<Enterprise>{
|
||||
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package com.luoo.recruit.dao;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
import com.luoo.recruit.pojo.Recruit;
|
||||
/**
|
||||
* 数据访问接口
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
public interface RecruitDao extends JpaRepository<Recruit,String>,JpaSpecificationExecutor<Recruit>{
|
||||
|
||||
}
|
@ -1,104 +0,0 @@
|
||||
package com.luoo.recruit.pojo;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.io.Serializable;
|
||||
/**
|
||||
* 实体类
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="tb_enterprise")
|
||||
public class Enterprise implements Serializable{
|
||||
|
||||
@Id
|
||||
private String id;//ID
|
||||
|
||||
|
||||
|
||||
private String name;//企业名称
|
||||
private String summary;//企业简介
|
||||
private String address;//企业地址
|
||||
private String labels;//标签列表
|
||||
private String coordinate;//坐标
|
||||
private String ishot;//是否热门
|
||||
private String logo;//LOGO
|
||||
private Integer jobcount;//职位数
|
||||
private String url;//URL
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getSummary() {
|
||||
return summary;
|
||||
}
|
||||
public void setSummary(String summary) {
|
||||
this.summary = summary;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getLabels() {
|
||||
return labels;
|
||||
}
|
||||
public void setLabels(String labels) {
|
||||
this.labels = labels;
|
||||
}
|
||||
|
||||
public String getCoordinate() {
|
||||
return coordinate;
|
||||
}
|
||||
public void setCoordinate(String coordinate) {
|
||||
this.coordinate = coordinate;
|
||||
}
|
||||
|
||||
public String getIshot() {
|
||||
return ishot;
|
||||
}
|
||||
public void setIshot(String ishot) {
|
||||
this.ishot = ishot;
|
||||
}
|
||||
|
||||
public String getLogo() {
|
||||
return logo;
|
||||
}
|
||||
public void setLogo(String logo) {
|
||||
this.logo = logo;
|
||||
}
|
||||
|
||||
public Integer getJobcount() {
|
||||
return jobcount;
|
||||
}
|
||||
public void setJobcount(Integer jobcount) {
|
||||
this.jobcount = jobcount;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,136 +0,0 @@
|
||||
package com.luoo.recruit.pojo;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.io.Serializable;
|
||||
/**
|
||||
* 实体类
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="tb_recruit")
|
||||
public class Recruit implements Serializable{
|
||||
|
||||
@Id
|
||||
private String id;//ID
|
||||
|
||||
|
||||
|
||||
private String jobname;//职位名称
|
||||
private String salary;//薪资范围
|
||||
private String condition;//经验要求
|
||||
private String education;//学历要求
|
||||
private String type;//任职方式
|
||||
private String address;//办公地址
|
||||
private String eid;//企业ID
|
||||
private java.util.Date createtime;//创建日期
|
||||
private String state;//状态
|
||||
private String url;//网址
|
||||
private String label;//标签
|
||||
private String content1;//职位描述
|
||||
private String content2;//职位要求
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getJobname() {
|
||||
return jobname;
|
||||
}
|
||||
public void setJobname(String jobname) {
|
||||
this.jobname = jobname;
|
||||
}
|
||||
|
||||
public String getSalary() {
|
||||
return salary;
|
||||
}
|
||||
public void setSalary(String salary) {
|
||||
this.salary = salary;
|
||||
}
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
public void setCondition(String condition) {
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
public String getEducation() {
|
||||
return education;
|
||||
}
|
||||
public void setEducation(String education) {
|
||||
this.education = education;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getEid() {
|
||||
return eid;
|
||||
}
|
||||
public void setEid(String eid) {
|
||||
this.eid = eid;
|
||||
}
|
||||
|
||||
public java.util.Date getCreatetime() {
|
||||
return createtime;
|
||||
}
|
||||
public void setCreatetime(java.util.Date createtime) {
|
||||
this.createtime = createtime;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getContent1() {
|
||||
return content1;
|
||||
}
|
||||
public void setContent1(String content1) {
|
||||
this.content1 = content1;
|
||||
}
|
||||
|
||||
public String getContent2() {
|
||||
return content2;
|
||||
}
|
||||
public void setContent2(String content2) {
|
||||
this.content2 = content2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,165 +0,0 @@
|
||||
package com.luoo.recruit.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Expression;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import javax.persistence.criteria.Root;
|
||||
import javax.persistence.criteria.Selection;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import util.IdWorker;
|
||||
|
||||
import com.luoo.recruit.dao.EnterpriseDao;
|
||||
import com.luoo.recruit.pojo.Enterprise;
|
||||
|
||||
/**
|
||||
* 服务层
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
@Service
|
||||
public class EnterpriseService {
|
||||
|
||||
@Autowired
|
||||
private EnterpriseDao enterpriseDao;
|
||||
|
||||
@Autowired
|
||||
private IdWorker idWorker;
|
||||
|
||||
/**
|
||||
* 查询全部列表
|
||||
* @return
|
||||
*/
|
||||
public List<Enterprise> findAll() {
|
||||
return enterpriseDao.findAll();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 条件查询+分页
|
||||
* @param whereMap
|
||||
* @param page
|
||||
* @param size
|
||||
* @return
|
||||
*/
|
||||
public Page<Enterprise> findSearch(Map whereMap, int page, int size) {
|
||||
Specification<Enterprise> specification = createSpecification(whereMap);
|
||||
PageRequest pageRequest = PageRequest.of(page-1, size);
|
||||
return enterpriseDao.findAll(specification, pageRequest);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 条件查询
|
||||
* @param whereMap
|
||||
* @return
|
||||
*/
|
||||
public List<Enterprise> findSearch(Map whereMap) {
|
||||
Specification<Enterprise> specification = createSpecification(whereMap);
|
||||
return enterpriseDao.findAll(specification);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询实体
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public Enterprise findById(String id) {
|
||||
return enterpriseDao.findById(id).get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加
|
||||
* @param enterprise
|
||||
*/
|
||||
public void add(Enterprise enterprise) {
|
||||
enterprise.setId( idWorker.nextId()+"" );
|
||||
enterpriseDao.save(enterprise);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @param enterprise
|
||||
*/
|
||||
public void update(Enterprise enterprise) {
|
||||
enterpriseDao.save(enterprise);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param id
|
||||
*/
|
||||
public void deleteById(String id) {
|
||||
enterpriseDao.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 动态条件构建
|
||||
* @param searchMap
|
||||
* @return
|
||||
*/
|
||||
private Specification<Enterprise> createSpecification(Map searchMap) {
|
||||
|
||||
return new Specification<Enterprise>() {
|
||||
|
||||
@Override
|
||||
public Predicate toPredicate(Root<Enterprise> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
|
||||
List<Predicate> predicateList = new ArrayList<Predicate>();
|
||||
// ID
|
||||
if (searchMap.get("id")!=null && !"".equals(searchMap.get("id"))) {
|
||||
predicateList.add(cb.like(root.get("id").as(String.class), "%"+(String)searchMap.get("id")+"%"));
|
||||
}
|
||||
// 企业名称
|
||||
if (searchMap.get("name")!=null && !"".equals(searchMap.get("name"))) {
|
||||
predicateList.add(cb.like(root.get("name").as(String.class), "%"+(String)searchMap.get("name")+"%"));
|
||||
}
|
||||
// 企业简介
|
||||
if (searchMap.get("summary")!=null && !"".equals(searchMap.get("summary"))) {
|
||||
predicateList.add(cb.like(root.get("summary").as(String.class), "%"+(String)searchMap.get("summary")+"%"));
|
||||
}
|
||||
// 企业地址
|
||||
if (searchMap.get("address")!=null && !"".equals(searchMap.get("address"))) {
|
||||
predicateList.add(cb.like(root.get("address").as(String.class), "%"+(String)searchMap.get("address")+"%"));
|
||||
}
|
||||
// 标签列表
|
||||
if (searchMap.get("labels")!=null && !"".equals(searchMap.get("labels"))) {
|
||||
predicateList.add(cb.like(root.get("labels").as(String.class), "%"+(String)searchMap.get("labels")+"%"));
|
||||
}
|
||||
// 坐标
|
||||
if (searchMap.get("coordinate")!=null && !"".equals(searchMap.get("coordinate"))) {
|
||||
predicateList.add(cb.like(root.get("coordinate").as(String.class), "%"+(String)searchMap.get("coordinate")+"%"));
|
||||
}
|
||||
// 是否热门
|
||||
if (searchMap.get("ishot")!=null && !"".equals(searchMap.get("ishot"))) {
|
||||
predicateList.add(cb.like(root.get("ishot").as(String.class), "%"+(String)searchMap.get("ishot")+"%"));
|
||||
}
|
||||
// LOGO
|
||||
if (searchMap.get("logo")!=null && !"".equals(searchMap.get("logo"))) {
|
||||
predicateList.add(cb.like(root.get("logo").as(String.class), "%"+(String)searchMap.get("logo")+"%"));
|
||||
}
|
||||
// URL
|
||||
if (searchMap.get("url")!=null && !"".equals(searchMap.get("url"))) {
|
||||
predicateList.add(cb.like(root.get("url").as(String.class), "%"+(String)searchMap.get("url")+"%"));
|
||||
}
|
||||
|
||||
return cb.and( predicateList.toArray(new Predicate[predicateList.size()]));
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,181 +0,0 @@
|
||||
package com.luoo.recruit.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Expression;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import javax.persistence.criteria.Root;
|
||||
import javax.persistence.criteria.Selection;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import util.IdWorker;
|
||||
|
||||
import com.luoo.recruit.dao.RecruitDao;
|
||||
import com.luoo.recruit.pojo.Recruit;
|
||||
|
||||
/**
|
||||
* 服务层
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
@Service
|
||||
public class RecruitService {
|
||||
|
||||
@Autowired
|
||||
private RecruitDao recruitDao;
|
||||
|
||||
@Autowired
|
||||
private IdWorker idWorker;
|
||||
|
||||
/**
|
||||
* 查询全部列表
|
||||
* @return
|
||||
*/
|
||||
public List<Recruit> findAll() {
|
||||
return recruitDao.findAll();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 条件查询+分页
|
||||
* @param whereMap
|
||||
* @param page
|
||||
* @param size
|
||||
* @return
|
||||
*/
|
||||
public Page<Recruit> findSearch(Map whereMap, int page, int size) {
|
||||
Specification<Recruit> specification = createSpecification(whereMap);
|
||||
PageRequest pageRequest = PageRequest.of(page-1, size);
|
||||
return recruitDao.findAll(specification, pageRequest);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 条件查询
|
||||
* @param whereMap
|
||||
* @return
|
||||
*/
|
||||
public List<Recruit> findSearch(Map whereMap) {
|
||||
Specification<Recruit> specification = createSpecification(whereMap);
|
||||
return recruitDao.findAll(specification);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询实体
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public Recruit findById(String id) {
|
||||
return recruitDao.findById(id).get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加
|
||||
* @param recruit
|
||||
*/
|
||||
public void add(Recruit recruit) {
|
||||
recruit.setId( idWorker.nextId()+"" );
|
||||
recruitDao.save(recruit);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @param recruit
|
||||
*/
|
||||
public void update(Recruit recruit) {
|
||||
recruitDao.save(recruit);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param id
|
||||
*/
|
||||
public void deleteById(String id) {
|
||||
recruitDao.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 动态条件构建
|
||||
* @param searchMap
|
||||
* @return
|
||||
*/
|
||||
private Specification<Recruit> createSpecification(Map searchMap) {
|
||||
|
||||
return new Specification<Recruit>() {
|
||||
|
||||
@Override
|
||||
public Predicate toPredicate(Root<Recruit> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
|
||||
List<Predicate> predicateList = new ArrayList<Predicate>();
|
||||
// ID
|
||||
if (searchMap.get("id")!=null && !"".equals(searchMap.get("id"))) {
|
||||
predicateList.add(cb.like(root.get("id").as(String.class), "%"+(String)searchMap.get("id")+"%"));
|
||||
}
|
||||
// 职位名称
|
||||
if (searchMap.get("jobname")!=null && !"".equals(searchMap.get("jobname"))) {
|
||||
predicateList.add(cb.like(root.get("jobname").as(String.class), "%"+(String)searchMap.get("jobname")+"%"));
|
||||
}
|
||||
// 薪资范围
|
||||
if (searchMap.get("salary")!=null && !"".equals(searchMap.get("salary"))) {
|
||||
predicateList.add(cb.like(root.get("salary").as(String.class), "%"+(String)searchMap.get("salary")+"%"));
|
||||
}
|
||||
// 经验要求
|
||||
if (searchMap.get("condition")!=null && !"".equals(searchMap.get("condition"))) {
|
||||
predicateList.add(cb.like(root.get("condition").as(String.class), "%"+(String)searchMap.get("condition")+"%"));
|
||||
}
|
||||
// 学历要求
|
||||
if (searchMap.get("education")!=null && !"".equals(searchMap.get("education"))) {
|
||||
predicateList.add(cb.like(root.get("education").as(String.class), "%"+(String)searchMap.get("education")+"%"));
|
||||
}
|
||||
// 任职方式
|
||||
if (searchMap.get("type")!=null && !"".equals(searchMap.get("type"))) {
|
||||
predicateList.add(cb.like(root.get("type").as(String.class), "%"+(String)searchMap.get("type")+"%"));
|
||||
}
|
||||
// 办公地址
|
||||
if (searchMap.get("address")!=null && !"".equals(searchMap.get("address"))) {
|
||||
predicateList.add(cb.like(root.get("address").as(String.class), "%"+(String)searchMap.get("address")+"%"));
|
||||
}
|
||||
// 企业ID
|
||||
if (searchMap.get("eid")!=null && !"".equals(searchMap.get("eid"))) {
|
||||
predicateList.add(cb.like(root.get("eid").as(String.class), "%"+(String)searchMap.get("eid")+"%"));
|
||||
}
|
||||
// 状态
|
||||
if (searchMap.get("state")!=null && !"".equals(searchMap.get("state"))) {
|
||||
predicateList.add(cb.like(root.get("state").as(String.class), "%"+(String)searchMap.get("state")+"%"));
|
||||
}
|
||||
// 网址
|
||||
if (searchMap.get("url")!=null && !"".equals(searchMap.get("url"))) {
|
||||
predicateList.add(cb.like(root.get("url").as(String.class), "%"+(String)searchMap.get("url")+"%"));
|
||||
}
|
||||
// 标签
|
||||
if (searchMap.get("label")!=null && !"".equals(searchMap.get("label"))) {
|
||||
predicateList.add(cb.like(root.get("label").as(String.class), "%"+(String)searchMap.get("label")+"%"));
|
||||
}
|
||||
// 职位描述
|
||||
if (searchMap.get("content1")!=null && !"".equals(searchMap.get("content1"))) {
|
||||
predicateList.add(cb.like(root.get("content1").as(String.class), "%"+(String)searchMap.get("content1")+"%"));
|
||||
}
|
||||
// 职位要求
|
||||
if (searchMap.get("content2")!=null && !"".equals(searchMap.get("content2"))) {
|
||||
predicateList.add(cb.like(root.get("content2").as(String.class), "%"+(String)searchMap.get("content2")+"%"));
|
||||
}
|
||||
|
||||
return cb.and( predicateList.toArray(new Predicate[predicateList.size()]));
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
server:
|
||||
port: 9001
|
||||
spring:
|
||||
application:
|
||||
name: luoo-recruit #指定服务名
|
||||
datasource:
|
||||
driverClassName: com.mysql.jdbc.Driver
|
||||
url: jdbc:mysql://116.62.145.60:3306/indie_recruit?characterEncoding=UTF8&useSSL=false
|
||||
username: root
|
||||
password: 47084735Abc@
|
||||
jpa:
|
||||
database: MySQL
|
||||
show-sql: true
|
@ -1,11 +0,0 @@
|
||||
package com.luoo.sms;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SmsApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SmsApplication.class);
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
package com.luoo.sms.listener;
|
||||
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
import com.luoo.sms.util.SmsUtils;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
@RabbitListener(queues = "sms")
|
||||
public class SmsListener {
|
||||
|
||||
@Autowired
|
||||
private SmsUtils smsUtils;
|
||||
|
||||
@Value("${aliyun.sms.template_code}")
|
||||
private String template_code;
|
||||
|
||||
@Value("${aliyun.sms.sign_name}")
|
||||
private String sign_name;
|
||||
|
||||
@RabbitHandler
|
||||
public void executeSms(Map<String,String> map) {
|
||||
String mobile = map.get("mobile");
|
||||
String checkcode= map.get("checkcode");
|
||||
System.out.println("手机号:"+map.get("mobile"));
|
||||
System.out.println("验证码:"+map.get("checkcode"));
|
||||
try {
|
||||
smsUtils.sendSms(mobile,template_code,sign_name,"{\"code\":\""+checkcode+"\"}");
|
||||
} catch (ClientException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
spring:
|
||||
cloud:
|
||||
config:
|
||||
name: sms
|
||||
profile: dev
|
||||
label: master
|
||||
uri: http://116.62.145.60:12000
|
||||
# uri: http://127.0.0.1:12000
|
@ -0,0 +1,14 @@
|
||||
package com.luoo.user.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TotalCommentVo {
|
||||
|
||||
|
||||
private Integer totalThumbup;
|
||||
|
||||
private Integer totalComment;
|
||||
|
||||
private String userId;
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package com.luoo.user.pojo;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@Data
|
||||
public class Comment implements Serializable {
|
||||
|
||||
@Id
|
||||
private String _id;
|
||||
// 评论内容
|
||||
private String content;
|
||||
// 发布时间
|
||||
private Date publishTime;
|
||||
|
||||
private String userId;
|
||||
|
||||
private String nickName;
|
||||
|
||||
// 点赞数
|
||||
private Integer thumbupCount;
|
||||
// 转发数
|
||||
// private Integer share;
|
||||
// 评论数量
|
||||
private Integer commentCount;
|
||||
|
||||
// 状态
|
||||
private Integer state;
|
||||
|
||||
|
||||
private String location; //归属地
|
||||
/**
|
||||
* 父节点 ID
|
||||
*/
|
||||
private String parentId;
|
||||
|
||||
private String journalId;
|
||||
}
|
Loading…
Reference in new issue