remove uneffective module(luoo_gathering,luoo_recruit etc.)

main
wangqing 10 months ago
parent 09c617c1fb
commit bba18fbc9f

@ -1,3 +0,0 @@
# luoo_cms
通用CMS BANNER,协议,文章等,意见反馈)

@ -1,62 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<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_cms</artifactId>
<description>通用CMS BANNER,协议,文章等,意见反馈) </description>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</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.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<!--swagger 升级版-->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>2.0.5</version>
</dependency>
</dependencies>
</project>

@ -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

@ -34,16 +34,11 @@
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.16</version>
</dependency>
<dependency>
<groupId>net.renfei</groupId>
<artifactId>ip2location</artifactId>
<version>1.2.1</version>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>

@ -1,88 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<parent>
<artifactId>luoo_parent</artifactId>
<groupId>com.luoo</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>luoo_friend</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<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>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-bus</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
<build>
<finalName>app</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- docker的maven插件官网 https://github.com/spotify/docker-maven-plugin -->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.4.13</version>
<configuration>
<imageName>116.62.145.60:5000/${project.artifactId}:${project.version}</imageName>
<baseImage>jdk1.8</baseImage>
<entryPoint>["java", "-jar","/${project.build.finalName}.jar"]</entryPoint>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
<dockerHost>http://116.62.145.60:2375</dockerHost>
</configuration>
</plugin>
</plugins>
</build>
</project>

@ -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,84 +0,0 @@
package com.luoo.friend.controller;
import com.luoo.friend.client.UserClient;
import com.luoo.friend.service.FriendService;
import api.Result;
import api.StatusCode;
import io.jsonwebtoken.Claims;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
@RestController
@RequestMapping("/friend")
public class FriendController {
@Autowired
private HttpServletRequest request;
@Autowired
private FriendService friendService;
@Autowired
private UserClient userClient;
/**
* 12
*
* @return
*/
@PutMapping("/like/{friendid}/{type}")
public Result<Void> addFriend(@PathVariable String friendid, @PathVariable String type) {
//验证是否登录并且拿到ID
Claims claims = (Claims) request.getAttribute("claims_user");
if (claims == null) {
return Result.unauthorized(null);
}
String userid = claims.getId();
//判断是添加好友还是非好友(判断是关注操作还是拉黑操作)
if (type != null) {
if (type.equals("1")) {
//添加好友
int flag = friendService.addFriend(userid,friendid);
if (flag == 0) {
return Result.failed(StatusCode.FRIEND_CAN_NOT_REPEAT_ADD_FRIEND); // 不能重复添加好友
}
if (flag == 1) {
userClient.updatefanscountandfollowcount(userid,friendid,1);
return Result.success();
}
} else if (type.equals("2")) {
//添加非好友
int flag = friendService.addNoFriend(userid,friendid);
if (flag == 0) {
return Result.failed(StatusCode.FRIEND_CAN_NOT_REPEAT_ADD_NON_FRIEND);
}
if (flag == 1) {
return Result.success();
}
}
return Result.failed(StatusCode.VALIDATE_FAILED);
} else {
return Result.failed(StatusCode.VALIDATE_FAILED);
}
}
@DeleteMapping("/{friendid}")
public Result<Void> deleteFriend(@PathVariable String friendid){
//验证是否登录并且拿到ID
Claims claims = (Claims) request.getAttribute("claims_user");
if (claims == null) {
return Result.unauthorized(null);
}
String userid = claims.getId();
friendService.deleteFriend(userid,friendid);
userClient.updatefanscountandfollowcount(userid,friendid,-1);
return Result.success();
}
}

@ -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,71 +0,0 @@
package com.luoo.friend.service;
import com.luoo.friend.dao.FriendDao;
import com.luoo.friend.dao.NoFriendDao;
import com.luoo.friend.pojo.Friend;
import com.luoo.friend.pojo.NoFriend;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional
public class FriendService {
@Autowired
private FriendDao friendDao;
@Autowired
private NoFriendDao noFriendDao;
public int addFriend(String userid, String friendid) {
// 先判断 userid到friendid是否有数据有就是重复添加好友
Friend friend = friendDao.findByUseridAndFriendid(userid, friendid);
if (friend!=null) {
return 0;
}
// 直接添加好友让好友表中userid到friend方向的type为0
friend = new Friend();
friend.setUserid(userid);
friend.setFriendid(friendid);
friend.setIslike("0");
friendDao.save(friend);
//判断从friendid到userid是否有数据如果有把双方的状态都改为1
if (friendDao.findByUseridAndFriendid(friendid,userid)!=null) {
// 把双方的islike改成1
friendDao.updateIslike("1",userid,friendid);
friendDao.updateIslike("1",friendid,userid);
}
return 1;
}
public int addNoFriend(String userid, String friendid) {
//先判断是否已经是非好友
NoFriend nofriend = noFriendDao.findByUseridAndFriendid(userid, friendid);
if (nofriend !=null) {
return 0;
}
nofriend = new NoFriend();
nofriend.setUserid(userid);
nofriend.setFriendid(friendid);
noFriendDao.save(nofriend);
return 1;
}
public void deleteFriend(String userid, String friendid) {
// 删除好友表中userid到friendid这条数据
friendDao.deletefriend(userid,friendid);
// 更新friendid到userid的islike为0
friendDao.updateIslike("0",friendid,userid);
// 非好友表中添加数据
NoFriend nofriend = new NoFriend();
nofriend.setFriendid(friendid);
nofriend.setUserid(userid);
noFriendDao.save(nofriend);
}
}

@ -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,81 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<parent>
<artifactId>luoo_parent</artifactId>
<groupId>com.luoo</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>luoo_sms</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-bus</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>3.2.5</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<finalName>app</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- docker的maven插件官网 https://github.com/spotify/docker-maven-plugin -->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.4.13</version>
<configuration>
<imageName>116.62.145.60:5000/${project.artifactId}:${project.version}</imageName>
<baseImage>jdk1.8</baseImage>
<entryPoint>["java", "-jar","/${project.build.finalName}.jar"]</entryPoint>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
<dockerHost>http://116.62.145.60:2375</dockerHost>
</configuration>
</plugin>
</plugins>
</build>
</project>

@ -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,101 +0,0 @@
package com.luoo.sms.util;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.dysmsapi.model.v20170525.QuerySendDetailsRequest;
import com.aliyuncs.dysmsapi.model.v20170525.QuerySendDetailsResponse;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
*
* @author Administrator
*
*/
@Component
public class SmsUtils {
//产品名称:云通信短信API产品,开发者无需替换
static final String product = "Dysmsapi";
//产品域名,开发者无需替换
static final String domain = "dysmsapi.aliyuncs.com";
@Autowired
private Environment env;
// TODO 此处需要替换成开发者自己的AK(在阿里云访问控制台寻找)
/**
*
* @param mobile
* @param template_code
* @param sign_name
* @param param
* @return
* @throws ClientException
*/
public SendSmsResponse sendSms(String mobile,String template_code,String sign_name,String param) throws ClientException {
String accessKeyId =env.getProperty("aliyun.sms.accessKeyId");
String accessKeySecret = env.getProperty("aliyun.sms.accessKeySecret");
//可自助调整超时时间
System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
System.setProperty("sun.net.client.defaultReadTimeout", "10000");
//初始化acsClient,暂不支持region化
IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret);
DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product, domain);
IAcsClient acsClient = new DefaultAcsClient(profile);
//组装请求对象-具体描述见控制台-文档部分内容
SendSmsRequest request = new SendSmsRequest();
//必填:待发送手机号
request.setPhoneNumbers(mobile);
//必填:短信签名-可在短信控制台中找到
request.setSignName(sign_name);
//必填:短信模板-可在短信控制台中找到
request.setTemplateCode(template_code);
//可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
request.setTemplateParam(param);
//选填-上行短信扩展码(无特殊需求用户请忽略此字段)
//request.setSmsUpExtendCode("90997");
//可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者
request.setOutId("yourOutId");
//hint 此处可能会抛出异常注意catch
SendSmsResponse sendSmsResponse = acsClient.getAcsResponse(request);
return sendSmsResponse;
}
public QuerySendDetailsResponse querySendDetails(String mobile,String bizId) throws ClientException {
String accessKeyId =env.getProperty("accessKeyId");
String accessKeySecret = env.getProperty("accessKeySecret");
//可自助调整超时时间
System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
System.setProperty("sun.net.client.defaultReadTimeout", "10000");
//初始化acsClient,暂不支持region化
IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret);
DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product, domain);
IAcsClient acsClient = new DefaultAcsClient(profile);
//组装请求对象
QuerySendDetailsRequest request = new QuerySendDetailsRequest();
//必填-号码
request.setPhoneNumber(mobile);
//可选-流水号
request.setBizId(bizId);
//必填-发送日期 支持30天内记录查询格式yyyyMMdd
SimpleDateFormat ft = new SimpleDateFormat("yyyyMMdd");
request.setSendDate(ft.format(new Date()));
//必填-页大小
request.setPageSize(10L);
//必填-当前页码从1开始计数
request.setCurrentPage(1L);
//hint 此处可能会抛出异常注意catch
QuerySendDetailsResponse querySendDetailsResponse = acsClient.getAcsResponse(request);
return querySendDetailsResponse;
}
}

@ -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

@ -9,6 +9,7 @@ import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import com.luoo.user.dto.TotalCommentVo;
import com.luoo.user.pojo.Feedback;
import com.luoo.user.pojo.UserCollect;
import com.luoo.user.service.UserCollectService;
@ -16,6 +17,10 @@ import com.luoo.user.service.UserCollectService;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.aggregation.Aggregation;
import org.springframework.data.mongodb.core.aggregation.AggregationResults;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@ -76,6 +81,9 @@ public class MyController extends BaseController {
@Autowired
private FeedbackService feedbackService;
@Autowired
private MongoTemplate mongoTemplate;
public static String USER_AVATAR_DIRECTORY = "user/avatar/";
public static String USER_FEEDBACK_IMAGE_DIRECTORY = "user/feedback/";
@ -313,7 +321,22 @@ public class MyController extends BaseController {
userRespDTO.setFansCount(userCollect.getFans().size());
userRespDTO.setFollowCount(userCollect.getFollows().size());
}
/**
*
*/
Criteria criteria = Criteria.where("userId").is(userRespDTO.getId());
Aggregation agg = Aggregation.newAggregation(
Aggregation.match(criteria),//匹配条件
Aggregation.group().sum("thumbupCount").as("totalThumbup")
.sum("commentCount").as("totalComment")
);
AggregationResults<TotalCommentVo> results = mongoTemplate.aggregate(agg,"comment", TotalCommentVo.class);
TotalCommentVo totalCommentVo = results.getUniqueMappedResult();
userRespDTO.setThumbUpCount(totalCommentVo.getTotalThumbup());
userRespDTO.setCommentReplyCount(totalCommentVo.getTotalComment());
return userRespDTO;
}
}

@ -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;
}

@ -9,19 +9,19 @@
<version>1.0-SNAPSHOT</version>
<modules>
<module>luoo_common</module>
<module>luoo_recruit</module>
<!-- <module>luoo_recruit</module>-->
<module>luoo_user</module>
<module>luoo_music</module>
<module>luoo_gathering</module>
<!-- <module>luoo_gathering</module>-->
<module>luoo_comment</module>
<module>luoo_eureka</module>
<module>luoo_friend</module>
<!-- <module>luoo_friend</module>-->
<module>luoo_manage</module>
<module>luoo_web</module>
<module>luoo_sms</module>
<!-- <module>luoo_sms</module>-->
<module>luoo_config</module>
<module>luoo_tag</module>
<module>luoo_cms</module>
<!-- <module>luoo_cms</module>-->
</modules>
<packaging>pom</packaging>
<name>luoo_parent</name>

Loading…
Cancel
Save