-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
391 additions
and
543 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
pastecode-system/src/main/java/com/mewhz/paste/config/CorsConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.mewhz.paste.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.cors.CorsConfiguration; | ||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource; | ||
import org.springframework.web.filter.CorsFilter; | ||
|
||
/** | ||
* @author mewhz | ||
*/ | ||
@Configuration | ||
public class CorsConfig { | ||
|
||
private static final long MAX_AGE = 26 * 60 * 60; | ||
|
||
@Bean | ||
public CorsFilter corsFilter() { | ||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); | ||
|
||
CorsConfiguration corsConfiguration = new CorsConfiguration(); | ||
|
||
corsConfiguration.addAllowedOriginPattern("*"); | ||
corsConfiguration.addAllowedHeader("*"); | ||
corsConfiguration.addAllowedMethod("*"); | ||
corsConfiguration.setMaxAge(MAX_AGE); | ||
|
||
source.registerCorsConfiguration("/**", corsConfiguration); | ||
|
||
return new CorsFilter(source); | ||
|
||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
pastecode-system/src/main/java/com/mewhz/paste/config/MyBatisPlusConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.mewhz.paste.config; | ||
|
||
import com.baomidou.mybatisplus.annotation.DbType; | ||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; | ||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; | ||
import org.mybatis.spring.annotation.MapperScan; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
/** | ||
* @author mewhz | ||
*/ | ||
@Configuration | ||
@MapperScan("com.mewhz.paste.mapper") | ||
public class MyBatisPlusConfig { | ||
|
||
@Bean | ||
public MybatisPlusInterceptor mybatisPlusInterceptor() { | ||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); | ||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); | ||
return interceptor; | ||
} | ||
} |
54 changes: 22 additions & 32 deletions
54
pastecode-system/src/main/java/com/mewhz/paste/controller/CodeController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,40 @@ | ||
package com.mewhz.paste.controller; | ||
|
||
|
||
import cn.hutool.db.Entity; | ||
import cn.hutool.json.JSONObject; | ||
import cn.hutool.json.JSONUtil; | ||
import com.mewhz.paste.utils.CodeSQL; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.servlet.ModelAndView; | ||
import com.mewhz.paste.model.Code; | ||
import com.mewhz.paste.service.CodeService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* @author mewhz | ||
*/ | ||
@RestController | ||
@RequestMapping("/code") | ||
public class CodeController { | ||
|
||
@RequestMapping("/code") | ||
public ModelAndView code(@RequestParam String id){ | ||
ModelAndView mav = new ModelAndView("/code.html"); | ||
return mav; | ||
} | ||
|
||
@RequestMapping("/selectCode") | ||
public JSONObject selectCode(@RequestParam String id){ | ||
@Autowired | ||
private CodeService codeService; | ||
|
||
JSONObject json = JSONUtil.createObj(); | ||
String type = null; | ||
String text = null; | ||
String remark = null; | ||
|
||
CodeSQL codesql = new CodeSQL(); | ||
List<Entity> list = codesql.findCode(id); | ||
@GetMapping("/") | ||
public List<Code> findAll(){ | ||
return codeService.list(); | ||
} | ||
|
||
type = (String) list.get(0).get("type"); | ||
text = (String) list.get(0).get("text"); | ||
remark = (String) list.get(0).get("remark"); | ||
@PostMapping("/") | ||
public Map<String, Object> save(@RequestBody Code code){ | ||
Map<String, Object> result = new HashMap<>(); | ||
codeService.save(code); | ||
|
||
json.append("text", text); | ||
json.append("type", type); | ||
json.append("remark", remark); | ||
System.out.println(code); | ||
|
||
return json; | ||
result.put("status", 200); | ||
result.put("msg", "success"); | ||
result.put("codeId", code.getCodeId()); | ||
return result; | ||
} | ||
} |
24 changes: 0 additions & 24 deletions
24
pastecode-system/src/main/java/com/mewhz/paste/controller/HeartController.java
This file was deleted.
Oops, something went wrong.
51 changes: 0 additions & 51 deletions
51
pastecode-system/src/main/java/com/mewhz/paste/controller/ListController.java
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
pastecode-system/src/main/java/com/mewhz/paste/controller/LoginController.java
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
pastecode-system/src/main/java/com/mewhz/paste/controller/SubmitController.java
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
pastecode-system/src/main/java/com/mewhz/paste/mapper/CodeMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.mewhz.paste.mapper; | ||
|
||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||
import com.mewhz.paste.model.Code; | ||
|
||
/** | ||
* @author mewhz | ||
*/ | ||
public interface CodeMapper extends BaseMapper<Code> { | ||
} |
Oops, something went wrong.