parent
eae6bd4aaf
commit
7c3facd75b
@ -0,0 +1,34 @@
|
||||
package com.example.demo.common.util;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ResponseResult {
|
||||
/**
|
||||
* 请求状态
|
||||
*/
|
||||
private boolean success;
|
||||
/**
|
||||
* 返回提示信息
|
||||
*/
|
||||
private String msg;
|
||||
/**
|
||||
* 返回数据
|
||||
*/
|
||||
private Object data;
|
||||
|
||||
public ResponseResult(boolean success, String msg, Object data) {
|
||||
this.success = success;
|
||||
this.msg = msg;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public ResponseResult(boolean code, String msg) {
|
||||
this.success = success;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public ResponseResult(boolean success) {
|
||||
this.success = success;
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.example.demo.config.config;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import com.example.demo.domain.Task;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
|
||||
@Component
|
||||
public class BaseEntityMetaObjectHandler implements MetaObjectHandler {
|
||||
|
||||
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
// 创建时间自动填充
|
||||
if (metaObject.hasSetter(Task.CREATE_TIME) && ObjectUtil.isNull(getFieldValByName(Task.CREATE_TIME, metaObject))) {
|
||||
this.strictInsertFill(metaObject, Task.CREATE_TIME, LocalDateTime.class, LocalDateTime.now());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
//修改时间自动填充
|
||||
if (metaObject.hasSetter(Task.MODIFIED_TIME) && ObjectUtil.isNull(getFieldValByName(Task.MODIFIED_TIME, metaObject))) {
|
||||
this.strictUpdateFill(metaObject, Task.MODIFIED_TIME, LocalDateTime.class, LocalDateTime.now());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.example.demo.config.config;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* MybatisPlus 配置类
|
||||
*
|
||||
* @author huang
|
||||
* @since 2022-03-18
|
||||
*/
|
||||
|
||||
@Configuration
|
||||
public class MybatisPlusConfig {
|
||||
/**
|
||||
* 分页插件
|
||||
*/
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||
return interceptor;
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.example.demo.config.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* Web 配置类
|
||||
*
|
||||
* @author huang
|
||||
* @since 2022-03-18
|
||||
*/
|
||||
@Configuration
|
||||
public class WebConfig implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addViewControllers(ViewControllerRegistry registry) {
|
||||
registry.addViewController("/").setViewName("login/login");
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
package com.example.demo.controller;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.tags.Tags;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@SpringBootApplication
|
||||
@Tag(name ="你的接口",description = "test")
|
||||
public class ControllerText {
|
||||
@Operation(summary = "获取用户列表",description = "test")
|
||||
@RequestMapping("getUser")
|
||||
|
||||
public Map<String, Object> getUser(){
|
||||
System.out.println("微信小程序正在调用。。。");
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
List<String> list = new ArrayList<String>();
|
||||
list.add("zhangsan");
|
||||
list.add("lisi");
|
||||
list.add("wanger");
|
||||
list.add("mazi");
|
||||
map.put("list",list);
|
||||
System.out.println("微信小程序调用完成。。。");
|
||||
return map;
|
||||
}
|
||||
@Operation(summary = "获取用户表",description = "test")
|
||||
@RequestMapping("getWord")
|
||||
public Map<String, Object> getText(String word){
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
String message = "我能力有限,不要为难我";
|
||||
if ("后来".equals(word)) {
|
||||
message="正在热映的后来的我们是刘若英的处女作。";
|
||||
}else if("微信小程序".equals(word)){
|
||||
message= "想获取更多微信小程序相关知识,请更多的阅读微信官方文档,还有其他更多微信开发相关的内容,学无止境。";
|
||||
}else if("cauc".equals(word)){
|
||||
message="yes";
|
||||
}
|
||||
map.put("message", message);
|
||||
return map;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
JdbcTemplate jct;
|
||||
@Operation(summary = "取用户列表",description = "test")
|
||||
@GetMapping("userslist")
|
||||
public List<Map<String, Object>> userlist(){
|
||||
String sql = "select * from user";
|
||||
List<Map<String, Object>> map = jct.queryForList(sql);
|
||||
System.out.println("调用sql");
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package com.example.demo.controller;
|
||||
import com.example.demo.domain.Task;
|
||||
import com.example.demo.service.impl.TaskServiceImpl;
|
||||
import com.example.demo.common.util.FormatResponseUtil;
|
||||
import com.example.demo.common.util.ResponseResult;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@Tag(name = "WXL")
|
||||
@RequestMapping("/task")
|
||||
|
||||
public class taskController {
|
||||
|
||||
@Autowired
|
||||
public TaskServiceImpl taskService;
|
||||
|
||||
@Operation(summary = "获取任务信息")
|
||||
@GetMapping("/taskList")
|
||||
public ResponseResult queryAll() {
|
||||
return FormatResponseUtil.formatResponse(taskService.queryAll());
|
||||
}
|
||||
|
||||
@PostMapping("/addTask")
|
||||
public ResponseResult addTask(@RequestBody Task task) {
|
||||
return FormatResponseUtil.formatResponse(taskService.save(task));
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")//这里执行的是物理删除
|
||||
public ResponseResult delTaskById(Integer id){
|
||||
return FormatResponseUtil.formatResponse(taskService.delTaskById(id));
|
||||
}
|
||||
|
||||
@GetMapping("/one")
|
||||
public ResponseResult queryById(int id){
|
||||
return FormatResponseUtil.formatResponse(taskService.queryTaskById(id));
|
||||
}
|
||||
|
||||
@PostMapping("/taskInfo")
|
||||
public ResponseResult updateArea(@RequestBody Task task){
|
||||
return FormatResponseUtil.formatResponse(taskService.updateById(task));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
package com.example.demo.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.example.demo.domain.Rcode;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface RcodeMapper extends BaseMapper<Rcode> {
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.example.demo.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.example.demo.domain.Task;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author huang
|
||||
* @since 2022-03-27
|
||||
*/
|
||||
@Mapper
|
||||
public interface TaskMapper extends BaseMapper<Task> {
|
||||
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.example.demo.mapper.TaskMapper">
|
||||
|
||||
</mapper>
|
@ -0,0 +1,29 @@
|
||||
package com.example.demo.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.example.demo.domain.Task;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*/
|
||||
public interface ITaskService extends IService<Task> {
|
||||
|
||||
/**
|
||||
* 查询所有Area
|
||||
*/
|
||||
List<Task> queryAll();
|
||||
|
||||
/**
|
||||
* 通过Id查询Task
|
||||
*/
|
||||
Task queryTaskById(int id);
|
||||
|
||||
/**
|
||||
* 通过Id删除Task
|
||||
*/
|
||||
boolean delTaskById(int id);
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.example.demo.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.example.demo.domain.Task;
|
||||
import com.example.demo.mapper.TaskMapper;
|
||||
import com.example.demo.service.ITaskService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
@Service
|
||||
|
||||
public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements ITaskService {
|
||||
|
||||
@Autowired(required = false)
|
||||
TaskMapper taskMapper;
|
||||
|
||||
@Override
|
||||
public List<Task> queryAll() {
|
||||
LambdaQueryWrapper<Task> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.orderByAsc(Task::getId);
|
||||
List<Task> taskList = taskMapper.selectList(wrapper);
|
||||
return taskList;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Task queryTaskById(int id) {
|
||||
Task task = taskMapper.selectById(id);
|
||||
return task;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean delTaskById(int id) {
|
||||
boolean ans;
|
||||
int i = taskMapper.deleteById(id);
|
||||
return ans = i>0 ? true:false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* 网页登录二维码生成
|
||||
* auther:wangh
|
||||
* 2022.11.6
|
||||
*/
|
||||
createCode()
|
||||
{
|
||||
let codeNumber = '';
|
||||
for (var i = 0; i < 0; i++) {
|
||||
codeNumber += Math.floor(Math.random() * 10);
|
||||
}
|
||||
this.codeNumber = codeNumber;
|
||||
this.qrCode = ''
|
||||
}
|
Loading…
Reference in new issue