¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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>mom</artifactId> |
| | | <groupId>com.yuanchu.mom</groupId> |
| | | <version>1.0.0</version> |
| | | </parent> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <artifactId>data-server</artifactId> |
| | | <version>0.0.1-SNAPSHOT</version> |
| | | <name>data-server</name> |
| | | <description>data-server</description> |
| | | <packaging>jar</packaging> |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>com.yuanchu.mom</groupId> |
| | | <artifactId>framework</artifactId> |
| | | <version>0.0.1-SNAPSHOT</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | </project> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom; |
| | | |
| | | public class Main { |
| | | public static void main(String[] args) { |
| | | System.out.println("Hello world!"); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.controller; |
| | | |
| | | import cn.hutool.json.JSONObject; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.dto.DataReportingPageDto; |
| | | import com.yuanchu.mom.pojo.DataReporting; |
| | | import com.yuanchu.mom.service.DataReportingService; |
| | | import com.yuanchu.mom.utils.JackSonUtil; |
| | | import com.yuanchu.mom.vo.Result; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Map; |
| | | |
| | | @RequestMapping("/dataReporting") |
| | | @RestController |
| | | @Api(tags = "æ°æ®ä¸æ¥æ¨¡å") |
| | | @AllArgsConstructor |
| | | public class DataReportingController { |
| | | |
| | | private DataReportingService dataReportingService; |
| | | |
| | | @ApiOperation(value = "è·åæ°æ®ä¸æ¥å表") |
| | | @PostMapping("/selectDataReportingList") |
| | | public Result selectDataReportingList(@RequestBody Map<String, Object> data) { |
| | | Page page = JSON.parseObject(JSON.toJSONString(data.get("page")), Page.class); |
| | | DataReportingPageDto dataReportingPageDto = JSON.parseObject(JSON.toJSONString(data.get("entity")), DataReportingPageDto.class); |
| | | return Result.success(dataReportingService.selectUserList(page, dataReportingPageDto)); |
| | | } |
| | | |
| | | @ApiOperation(value = "ä¿®æ¹æ°æ®ä¸æ¥") |
| | | @PostMapping("/upDataReporting") |
| | | public Result upDataReporting(@RequestBody DataReporting dataReporting) { |
| | | return Result.success(dataReportingService.updateDataReporting(dataReporting)); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.dto; |
| | | |
| | | import com.yuanchu.mom.annotation.ValueTableShow; |
| | | import com.yuanchu.mom.pojo.DataReporting; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | @Data |
| | | @AllArgsConstructor |
| | | @NoArgsConstructor |
| | | public class DataReportingPageDto extends DataReporting { |
| | | |
| | | @ValueTableShow(21) |
| | | @ApiModelProperty(value = "åå»ºç¨æ·") |
| | | private String createUserName; |
| | | |
| | | @ValueTableShow(22) |
| | | @ApiModelProperty(value = "æ´æ°ç¨æ·") |
| | | private String updateUserName; |
| | | |
| | | } |
| | |
| | | <groupId>com.auth0</groupId> |
| | | <artifactId>java-jwt</artifactId> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | </project> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.annotation; |
| | | |
| | | import java.lang.annotation.Retention; |
| | | import java.lang.annotation.RetentionPolicy; |
| | | |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | public @interface ValueTableShow { |
| | | |
| | | int value() default 0; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.common; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.yuanchu.mom.annotation.ValueTableShow; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Builder; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Data |
| | | @AllArgsConstructor |
| | | @NoArgsConstructor |
| | | public class OrderBy implements Serializable { |
| | | |
| | | @TableField(select = false, exist = false) |
| | | private Map<String, String> orderBy; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.common; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.yuanchu.mom.annotation.ValueTableShow; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.util.*; |
| | | |
| | | /*ææ |
| | | * éè¿æ³¨è§£å¿«éçætable表头*/ |
| | | |
| | | public class PrintChina { |
| | | |
| | | public static <T> List<Map<String, String>> printChina(Class<T> tClass) { |
| | | //å°å®ä½ç±»ç屿§å注éè½¬æ¢æåæ° |
| | | List<Field> fieldList = new ArrayList<>(); |
| | | while (tClass != null){ |
| | | fieldList.addAll(new ArrayList<>(Arrays.asList(tClass.getDeclaredFields()))); |
| | | tClass = (Class<T>) tClass.getSuperclass(); |
| | | } |
| | | Field[] fields = new Field[fieldList.size()]; |
| | | fieldList.toArray(fields); |
| | | ArrayList<Map<String, String>> list = new ArrayList<>(); |
| | | for (Field field : fields) { |
| | | Map<String, String> soundVo = new HashMap<>(); |
| | | boolean bool = field.isAnnotationPresent(ApiModelProperty.class); |
| | | boolean bool2 = field.isAnnotationPresent(ValueTableShow.class); |
| | | if (bool) { |
| | | int order; |
| | | if (bool2){ |
| | | order = field.getAnnotation(ValueTableShow.class).value(); |
| | | }else{ |
| | | continue; |
| | | } |
| | | String value = field.getAnnotation(ApiModelProperty.class).value(); |
| | | soundVo.put("label", field.getName()); |
| | | soundVo.put("value", value); |
| | | soundVo.put("order", order + ""); |
| | | if(list.size() == 0){ |
| | | list.add(soundVo); |
| | | }else{ |
| | | boolean isAdd = false; |
| | | for (int i = 0; i < list.size(); i++) { |
| | | Map<String, String> map = list.get(i); |
| | | if(order < Integer.parseInt(map.get("order"))){ |
| | | list.add(i, soundVo); |
| | | isAdd = true; |
| | | break; |
| | | } |
| | | } |
| | | if (!isAdd) list.add(soundVo); |
| | | } |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | } |
| | |
| | | @Value("${server.port}") |
| | | private String serverPort; |
| | | |
| | | private static ThreadLocal<String> threadLocal = new ThreadLocal<>(); |
| | | |
| | | @Override |
| | | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { |
| | | if (HttpMethod.OPTIONS.toString().equals(request.getMethod())) { |
| | |
| | | @ExceptionHandler(SQLException.class) |
| | | public Result<?> handlerSQLException(SQLException e) { |
| | | log.error(e.getMessage().toLowerCase(), e); |
| | | response.setStatus(500); |
| | | response.setStatus(201); |
| | | return Result.fail("æ°æ®æä½å¤±è´¥ï¼è¯·è系管çå"); |
| | | } |
| | | |
| | |
| | | log.error(String.valueOf(e)); |
| | | String message = e.getCause().getMessage(); |
| | | String[] split = message.split("'"); |
| | | response.setStatus(500); |
| | | response.setStatus(201); |
| | | return Result.fail("é夿·»å ï¼ã" + split[1] + "ãæä½å¤±è´¥ï¼"); |
| | | } |
| | | |
| | | @ExceptionHandler |
| | | public Result<?> NullPointerException(NullPointerException e) { |
| | | e.printStackTrace(); |
| | | response.setStatus(500); |
| | | response.setStatus(201); |
| | | return Result.fail("é¨ååæ°ä¸ºç©ºï¼è¯·æ£æ¥ï¼"); |
| | | } |
| | | |
| | |
| | | @ExceptionHandler(RuntimeException.class) |
| | | public Result<?> runtimeExceptionHandler(RuntimeException e) { |
| | | e.printStackTrace(); |
| | | response.setStatus(500); |
| | | response.setStatus(201); |
| | | return Result.fail("è¿è¡æ¶å¼å¸¸"); |
| | | } |
| | | |
| | |
| | | @ExceptionHandler(ClassCastException.class) |
| | | public Result<?> classCastExceptionHandler(ClassCastException e) { |
| | | e.printStackTrace(); |
| | | response.setStatus(500); |
| | | response.setStatus(201); |
| | | return Result.fail("ç±»å转æ¢å¼å¸¸"); |
| | | } |
| | | |
| | |
| | | @ExceptionHandler(FileNotFoundException.class) |
| | | public Result<?> FileNotFoundException(FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | response.setStatus(500); |
| | | response.setStatus(201); |
| | | return Result.fail("æä»¶æªæ¾å°å¼å¸¸"); |
| | | } |
| | | |
| | |
| | | @ExceptionHandler(NumberFormatException.class) |
| | | public Result<?> NumberFormatException(NumberFormatException e) { |
| | | e.printStackTrace(); |
| | | response.setStatus(500); |
| | | response.setStatus(201); |
| | | return Result.fail("æ°åæ ¼å¼å¼å¸¸"); |
| | | } |
| | | |
| | |
| | | @ExceptionHandler(SecurityException.class) |
| | | public Result<?> SecurityException(SecurityException e) { |
| | | e.printStackTrace(); |
| | | response.setStatus(500); |
| | | response.setStatus(201); |
| | | return Result.fail("å®å
¨å¼å¸¸"); |
| | | } |
| | | |
| | |
| | | @ExceptionHandler(TypeNotPresentException.class) |
| | | public Result<?> TypeNotPresentException(TypeNotPresentException e) { |
| | | e.printStackTrace(); |
| | | response.setStatus(500); |
| | | response.setStatus(201); |
| | | return Result.fail("ç±»åä¸åå¨å¼å¸¸"); |
| | | } |
| | | |
| | |
| | | @ExceptionHandler(IOException.class) |
| | | public Result<?> iOExceptionHandler(IOException e) { |
| | | e.printStackTrace(); |
| | | response.setStatus(500); |
| | | response.setStatus(201); |
| | | return Result.fail("IOå¼å¸¸"); |
| | | } |
| | | |
| | |
| | | @ExceptionHandler(NoSuchMethodException.class) |
| | | public Result<?> noSuchMethodExceptionHandler(NoSuchMethodException e) { |
| | | e.printStackTrace(); |
| | | response.setStatus(500); |
| | | response.setStatus(201); |
| | | return Result.fail("æªç¥æ¹æ³å¼å¸¸"); |
| | | } |
| | | |
| | |
| | | @ExceptionHandler(IndexOutOfBoundsException.class) |
| | | public Result<?> indexOutOfBoundsExceptionHandler(IndexOutOfBoundsException e) { |
| | | e.printStackTrace(); |
| | | response.setStatus(500); |
| | | response.setStatus(201); |
| | | return Result.fail("æ°ç»è¶çå¼å¸¸"); |
| | | } |
| | | |
| | |
| | | @ExceptionHandler(BadSqlGrammarException.class) |
| | | public Result<?> BadSqlGrammarException(BadSqlGrammarException e) { |
| | | e.printStackTrace(); |
| | | response.setStatus(500); |
| | | response.setStatus(201); |
| | | return Result.fail("sqlè¯æ³é误å¼å¸¸"); |
| | | } |
| | | |
| | |
| | | @ExceptionHandler(NoSuchBeanDefinitionException.class) |
| | | public Result<?> NoSuchBeanDefinitionException(NoSuchBeanDefinitionException e) { |
| | | e.printStackTrace(); |
| | | response.setStatus(500); |
| | | response.setStatus(201); |
| | | return Result.fail("æ æ³æ³¨å
¥bean"); |
| | | } |
| | | |
| | |
| | | @ExceptionHandler({HttpMessageNotReadableException.class}) |
| | | public Result<?> requestNotReadable(HttpMessageNotReadableException e) { |
| | | e.printStackTrace(); |
| | | response.setStatus(500); |
| | | response.setStatus(201); |
| | | return Result.fail("Httpæ¶æ¯ä¸å¯è¯»"); |
| | | } |
| | | |
| | |
| | | @ExceptionHandler({TypeMismatchException.class}) |
| | | public Result<?> requestTypeMismatch(TypeMismatchException e) { |
| | | e.printStackTrace(); |
| | | response.setStatus(500); |
| | | response.setStatus(201); |
| | | return Result.fail("æå¡å¨å¼å¸¸"); |
| | | } |
| | | |
| | | /** |
| | | * 500é误 |
| | | * 201é误 |
| | | */ |
| | | @ExceptionHandler({ConversionNotSupportedException.class, HttpMessageNotWritableException.class}) |
| | | public Result<?> server500(RuntimeException e) { |
| | | public Result<?> server201(RuntimeException e) { |
| | | e.printStackTrace(); |
| | | response.setStatus(500); |
| | | response.setStatus(201); |
| | | return Result.fail("æå¡å¨å¼å¸¸"); |
| | | } |
| | | |
| | |
| | | @ExceptionHandler({StackOverflowError.class}) |
| | | public Result<?> requestStackOverflow(StackOverflowError e) { |
| | | e.printStackTrace(); |
| | | response.setStatus(500); |
| | | response.setStatus(201); |
| | | return Result.fail("æ æº¢åºå¼å¸¸"); |
| | | } |
| | | |
| | |
| | | @ExceptionHandler({ArithmeticException.class}) |
| | | public Result<?> arithmeticException(ArithmeticException e) { |
| | | e.printStackTrace(); |
| | | response.setStatus(500); |
| | | response.setStatus(201); |
| | | return Result.fail("餿°ä¸è½ä¸º0å¼å¸¸"); |
| | | } |
| | | |
| | |
| | | @ExceptionHandler({Exception.class}) |
| | | public Result<?> exception(Exception e) { |
| | | e.printStackTrace(); |
| | | response.setStatus(500); |
| | | response.setStatus(201); |
| | | return Result.fail("ç½ç»è¿æ¥å¤±è´¥ï¼è¯·éåºååè¯"); |
| | | } |
| | | } |
| | |
| | | package com.yuanchu.mom.mybatis_config; |
| | | |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; |
| | | import com.yuanchu.mom.utils.JackSonUtil; |
| | | import com.yuanchu.mom.utils.Jwt; |
| | | import com.yuanchu.mom.utils.ServletUtils; |
| | | import org.apache.ibatis.reflection.MetaObject; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | |
| | | @Component |
| | | public class MyMetaObjectHandler implements MetaObjectHandler { |
| | | |
| | | @Autowired |
| | | Jwt jwt; |
| | | |
| | | @Override |
| | | public void insertFill(MetaObject metaObject) { |
| | | this.strictInsertFill(metaObject, "createTime", Date.class, new Date()); // èµ·å§çæ¬ 3.3.0(æ¨è使ç¨) |
| | | this.strictInsertFill(metaObject, "updateTime", Date.class, new Date()); // èµ·å§çæ¬ 3.3.0(æ¨è使ç¨) |
| | | this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, LocalDateTime.now()); // èµ·å§çæ¬ 3.3.0(æ¨è使ç¨) |
| | | this.strictInsertFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now()); // èµ·å§çæ¬ 3.3.0(æ¨è使ç¨) |
| | | this.strictInsertFill(metaObject, "createUser", Integer.class, Integer.parseInt(JSONUtil.parseObj(jwt.readJWT(ServletUtils.getRequest().getHeader("token")).get("data")).get("id") + "")); |
| | | this.strictInsertFill(metaObject, "updateUser", Integer.class, Integer.parseInt(JSONUtil.parseObj(jwt.readJWT(ServletUtils.getRequest().getHeader("token")).get("data")).get("id") + "")); |
| | | } |
| | | |
| | | @Override |
| | | public void updateFill(MetaObject metaObject) { |
| | | // updateçæ¶å使ç¨ï¼æ´æ°çæ¶å强å¶è¿è¡å¡«å
|
| | | this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date()); // èµ·å§çæ¬ 3.3.0(æ¨è) |
| | | this.strictUpdateFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now()); // èµ·å§çæ¬ 3.3.0(æ¨è) |
| | | this.strictUpdateFill(metaObject, "updateUser", Integer.class, Integer.parseInt(JSONUtil.parseObj(jwt.readJWT(ServletUtils.getRequest().getHeader("token")).get("data")).get("id") + "")); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.utils; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.CustomLog; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.lang.annotation.Annotation; |
| | | import java.lang.reflect.Field; |
| | | import java.lang.reflect.Method; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | |
| | | /* |
| | | * ææ |
| | | * çæSQLè¯å¥*/ |
| | | |
| | | @Component |
| | | @AllArgsConstructor |
| | | public class QueryWrappers<T> { |
| | | |
| | | public static <T> QueryWrapper<T> queryWrappers(T entity) { |
| | | if (ObjectUtil.isEmpty(entity)) return null; |
| | | Class<?> aClass = entity.getClass(); |
| | | QueryWrapper<T> wrapper = Wrappers.<T>query(); |
| | | List<Field> fieldList = new ArrayList<>(); |
| | | while (aClass != null) { |
| | | fieldList.addAll(new ArrayList<>(Arrays.asList(aClass.getDeclaredFields()))); |
| | | aClass = aClass.getSuperclass(); |
| | | } |
| | | for (Field field : fieldList) { |
| | | field.setAccessible(true); |
| | | Object value; |
| | | try { |
| | | value = field.get(entity); |
| | | } catch (IllegalAccessException e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException("æ¥è¯¢æ¡ä»¶çæé误"); |
| | | } |
| | | // System.out.println(field.getName() + "|" + (value == null || value.equals("")) + "|" + value); |
| | | if(value == null || value.equals("")){ |
| | | continue; |
| | | } |
| | | if (!field.getName().equals("orderBy")) { |
| | | if(value.getClass()== LocalDateTime.class){ |
| | | wrapper.like(StrUtil.toUnderlineCase(field.getName()), ((LocalDateTime) value).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
| | | }else{ |
| | | wrapper.like(StrUtil.toUnderlineCase(field.getName()), value); |
| | | } |
| | | } else { |
| | | Map<String, String> map = (Map<String, String>) value; |
| | | if(map.get("order")!=null){ |
| | | wrapper.orderBy(true, map.get("order").equals("asc"), StrUtil.toUnderlineCase(map.get("field"))); |
| | | } |
| | | } |
| | | } |
| | | System.out.println(wrapper.getExpression().getSqlSegment()); |
| | | return wrapper; |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.utils; |
| | | |
| | | |
| | | import cn.hutool.core.convert.Convert; |
| | | import org.springframework.web.context.request.RequestAttributes; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.servlet.http.HttpSession; |
| | | import java.io.IOException; |
| | | |
| | | /** |
| | | * 客æ·ç«¯å·¥å
·ç±» |
| | | * |
| | | * @author å¼ å®¾ |
| | | */ |
| | | public class ServletUtils { |
| | | /** |
| | | * è·åStringåæ° |
| | | */ |
| | | public static String getParameter(String name) |
| | | { |
| | | return getRequest().getParameter(name); |
| | | } |
| | | |
| | | /** |
| | | * è·åStringåæ° |
| | | */ |
| | | public static String getParameter(String name, String defaultValue) |
| | | { |
| | | return Convert.toStr(getRequest().getParameter(name), defaultValue); |
| | | } |
| | | |
| | | /** |
| | | * è·åIntegeråæ° |
| | | */ |
| | | public static Integer getParameterToInt(String name) |
| | | { |
| | | return Convert.toInt(getRequest().getParameter(name)); |
| | | } |
| | | |
| | | /** |
| | | * è·åIntegeråæ° |
| | | */ |
| | | public static Integer getParameterToInt(String name, Integer defaultValue) |
| | | { |
| | | return Convert.toInt(getRequest().getParameter(name), defaultValue); |
| | | } |
| | | |
| | | /** |
| | | * è·årequest |
| | | */ |
| | | public static HttpServletRequest getRequest() |
| | | { |
| | | return getRequestAttributes().getRequest(); |
| | | } |
| | | |
| | | /** |
| | | * è·åresponse |
| | | */ |
| | | public static HttpServletResponse getResponse() |
| | | { |
| | | return getRequestAttributes().getResponse(); |
| | | } |
| | | |
| | | /** |
| | | * è·åsession |
| | | */ |
| | | public static HttpSession getSession() |
| | | { |
| | | return getRequest().getSession(); |
| | | } |
| | | |
| | | public static ServletRequestAttributes getRequestAttributes() |
| | | { |
| | | RequestAttributes attributes = RequestContextHolder.getRequestAttributes(); |
| | | return (ServletRequestAttributes) attributes; |
| | | } |
| | | |
| | | /** |
| | | * å°å符串渲æå°å®¢æ·ç«¯ |
| | | * |
| | | * @param response 渲æå¯¹è±¡ |
| | | * @param string å¾
渲æçå符串 |
| | | * @return null |
| | | */ |
| | | public static String renderString(HttpServletResponse response, String string) |
| | | { |
| | | try |
| | | { |
| | | response.setContentType("application/json"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | response.getWriter().print(string); |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | } |
| | |
| | | <module>framework</module> |
| | | <module>user-server</module> |
| | | <module>system-run</module> |
| | | <module>data-server</module> |
| | | </modules> |
| | | |
| | | <properties> |
| | |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-validation</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.baomidou</groupId> |
| | | <artifactId>mybatis-plus-extension</artifactId> |
| | | <version>${mybatis-plus.version}</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>cn.hutool</groupId> |
| | | <artifactId>hutool-all</artifactId> |
| | | <version>5.8.18</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.alibaba</groupId> |
| | | <artifactId>fastjson</artifactId> |
| | | <version>2.0.23</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <dependencyManagement> |
| | |
| | | <version>0.0.1-SNAPSHOT</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.yuanchu.mom</groupId> |
| | | <artifactId>data-server</artifactId> |
| | | <version>0.0.1-SNAPSHOT</version> |
| | | </dependency> |
| | | |
| | | <!--druid--> |
| | | <dependency> |
| | | <groupId>com.alibaba</groupId> |
| | |
| | | logging: |
| | | config: classpath:logback-spring.xml |
| | | # æ¥å¿åå¨è·¯å¾+++++++++++++++++++++++++++è¿ç»´éè¦é
ç½®+++++++++++++++++++++++++++ |
| | | file-location: |
| | | file-location: D:\é¹éå
¬å¸\frame-after\logs_IS_UNDEFINED |
| | | |
| | | # æ°æ®åºå¤ä»½è·¯å¾ |
| | | backup: |
| | | # æ°æ®åºå¤ä»½è·¯å¾+++++++++++++++++++++++++++è¿ç»´éè¦é
ç½®+++++++++++++++++++++++++++ |
| | | path: E:/webapp/backup |
| | | path: D:\é¹éå
¬å¸\frame-after |
| | | # æ°æ®åºå¤ä»½å¤©æ° |
| | | destiny: 7 |
| | | # æ°æ®åºå¤ä»½å·¥å
·è·¯å¾+++++++++++++++++++++++++++è¿ç»´éè¦é
ç½®+++++++++++++++++++++++++++ |
| | |
| | | type-aliases-package: com.yuanchu.mom.pojo |
| | | mapper-locations: classpath*:/mapper/*.xml |
| | | configuration: |
| | | log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # å¼å¯mybatis-plusæ¥å¿ |
| | | log-impl: #org.apache.ibatis.logging.stdout.StdOutImpl # å¼å¯mybatis-plusæ¥å¿ |
| | | |
| | | |
| | | # æ°æ®æºé
ç½® |
| | |
| | | datasource: |
| | | type: com.alibaba.druid.pool.DruidDataSource |
| | | driverClassName: com.mysql.cj.jdbc.Driver |
| | | url: jdbc:mysql://114.132.189.42:9004/oms?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 |
| | | username: user |
| | | url: jdbc:mysql://127.0.0.1:3306/shengyun?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 |
| | | username: root |
| | | password: 123456 |
| | | druid: |
| | | # Druidæ°æ®æºé
ç½® |
| | |
| | | # redisæ°æ®åºç´¢å¼(é»è®¤ä¸º0)ï¼æä»¬ä½¿ç¨ç´¢å¼ä¸º3çæ°æ®åºï¼é¿å
åå
¶ä»æ°æ®åºå²çª |
| | | database: 0 |
| | | # redisæå¡å¨å°åï¼é»è®¤ä¸ºlocalhostï¼ |
| | | host: 114.132.189.42 |
| | | host: 127.0.0.1 |
| | | # redis端å£ï¼é»è®¤ä¸º6379ï¼ |
| | | port: 9003 |
| | | port: 6379 |
| | | # redis访é®å¯ç ï¼é»è®¤ä¸ºç©ºï¼ |
| | | password: null |
| | | # redisè¿æ¥è¶
æ¶æ¶é´ï¼å使¯«ç§ï¼ |
| | |
| | | spring: |
| | | datasource: |
| | | type: com.alibaba.druid.pool.DruidDataSource |
| | | driverClassName: com.mysql.jdbc.Driver |
| | | driverClassName: com.mysql.cj.jdbc.Driver |
| | | url: jdbc:mysql://localhost:3306/blog_crunchy?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8 |
| | | username: root |
| | | password: 123456 |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.controller; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.dto.UserPageDto; |
| | | import com.yuanchu.mom.pojo.Role; |
| | | import com.yuanchu.mom.pojo.User; |
| | | import com.yuanchu.mom.service.RoleService; |
| | | import com.yuanchu.mom.service.UserService; |
| | | import com.yuanchu.mom.utils.JackSonUtil; |
| | | import com.yuanchu.mom.utils.Jwt; |
| | | import com.yuanchu.mom.utils.RedisUtil; |
| | | import com.yuanchu.mom.vo.Result; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | @RequestMapping("/role") |
| | | @RestController |
| | | @Api(tags = "è§è²æ¨¡å") |
| | | @AllArgsConstructor |
| | | public class RoleController { |
| | | |
| | | private RoleService roleService; |
| | | |
| | | @ApiOperation(value = "è·åè§è²å表æä¸¾") |
| | | @GetMapping("/selectRoleList") |
| | | public Result selectUserList(){ |
| | | return Result.success(roleService.selectList()); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "è·åè§è²å表") |
| | | @PostMapping("/selectRoleLists") |
| | | public Result selectRoleList(@RequestBody Map<String, Object> data) throws Exception { |
| | | Page page = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("page")), Page.class); |
| | | Role role = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("entity")), Role.class); |
| | | return Result.success(roleService.selectUserList(page, role)); |
| | | } |
| | | |
| | | @ApiOperation(value = "å é¤è§è²å表") |
| | | @PostMapping("/delRole") |
| | | public Result delRole(Integer id){ |
| | | return Result.success(roleService.delRole(id)); |
| | | } |
| | | } |
| | |
| | | package com.yuanchu.mom.controller; |
| | | |
| | | import cn.hutool.json.JSON; |
| | | import cn.hutool.json.JSONObject; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.common.PrintChina; |
| | | import com.yuanchu.mom.dto.UserPageDto; |
| | | import com.yuanchu.mom.pojo.User; |
| | | import com.yuanchu.mom.service.UserService; |
| | | import com.yuanchu.mom.utils.JackSonUtil; |
| | |
| | | import com.yuanchu.mom.utils.RedisUtil; |
| | | import com.yuanchu.mom.vo.Result; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.DigestUtils; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.HashMap; |
| | |
| | | @PostMapping("/enter") |
| | | public Result login(String account, String password) { |
| | | User user = userService.selectUserByPwd(account, password); |
| | | if (user==null) return Result.fail("ç»å½å¤±è´¥"); |
| | | if (user == null) return Result.fail("ç»å½å¤±è´¥"); |
| | | String jwtToken = jwt.createJwt(user.getName(), user.getId(), 60); |
| | | String jwtReToken = jwt.createJwt(user.getName(), user.getId(), 24 * 60); |
| | | RedisUtil.set("" + user.getId(), jwtToken, 60); |
| | |
| | | return Result.fail(map.get("info")); |
| | | } |
| | | |
| | | @ApiOperation(value = "è·åç¨æ·å表") |
| | | @PostMapping("/selectUserList") |
| | | public Result selectUserList(@RequestBody Map<String, Object> data) throws Exception { |
| | | Page page = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("page")), Page.class); |
| | | UserPageDto user = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("entity")), UserPageDto.class); |
| | | return Result.success(userService.selectUserList(page, user)); |
| | | } |
| | | |
| | | @ApiOperation(value = "ä¿®æ¹ç¨æ·ä¿¡æ¯") |
| | | @PostMapping("/updateUser") |
| | | public Result<?> updateUser(@RequestBody User user) { |
| | | if ("".equals(user.getPassword())) user.setPassword(null); |
| | | else user.setPassword(DigestUtils.md5DigestAsHex(user.getPassword().getBytes())); |
| | | return Result.success(userService.updateUser(user)); |
| | | } |
| | | |
| | | @ApiOperation(value = "æ·»å ç¨æ·ä¿¡æ¯") |
| | | @PostMapping("/addUser") |
| | | public Result<?> addUser(@RequestBody User user) { |
| | | if ("".equals(user.getPassword())) user.setPassword(null); |
| | | else user.setPassword(DigestUtils.md5DigestAsHex(user.getPassword().getBytes())); |
| | | return Result.success(userService.addUser(user)); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.dto; |
| | | |
| | | import com.yuanchu.mom.annotation.ValueTableShow; |
| | | import com.yuanchu.mom.pojo.User; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | @Data |
| | | @AllArgsConstructor |
| | | @NoArgsConstructor |
| | | public class UserPageDto extends User { |
| | | |
| | | @ValueTableShow(10) |
| | | @ApiModelProperty(value = "åå»ºç¨æ·") |
| | | private String createUserName; |
| | | |
| | | @ValueTableShow(11) |
| | | @ApiModelProperty(value = "æ´æ°ç¨æ·") |
| | | private String updateUserName; |
| | | |
| | | @ValueTableShow(1) |
| | | @ApiModelProperty(value = "è§è²") |
| | | private String roleName; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.yuanchu.mom.pojo.Role; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | public interface RoleMapper extends BaseMapper<Role> { |
| | | |
| | | } |
| | |
| | | package com.yuanchu.mom.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.yuanchu.mom.dto.UserPageDto; |
| | | import com.yuanchu.mom.pojo.User; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | public interface UserMapper extends BaseMapper<User> { |
| | | |
| | | IPage<User> selectUserDtoPageList(IPage<UserPageDto> page, QueryWrapper<UserPageDto> ew); |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.yuanchu.mom.annotation.ValueTableShow; |
| | | import com.yuanchu.mom.common.OrderBy; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | @AllArgsConstructor |
| | | @NoArgsConstructor |
| | | public class Role extends OrderBy implements Serializable { |
| | | |
| | | @ApiModelProperty(value = "主é®") |
| | | private Integer id; |
| | | |
| | | @ValueTableShow(1) |
| | | @ApiModelProperty(value = "è§è²åç§°") |
| | | private String name; |
| | | |
| | | @ValueTableShow(2) |
| | | @ApiModelProperty(value = "åå»ºæ¥æ") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime createTime; |
| | | |
| | | @ValueTableShow(3) |
| | | @ApiModelProperty(value = "æ´æ°æ¥æ") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime updateTime; |
| | | |
| | | @ApiModelProperty(value = "åå»ºç¨æ·") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Integer createUser; |
| | | |
| | | @ApiModelProperty(value = "æ´æ°ç¨æ·") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Integer updateUser; |
| | | |
| | | } |
| | |
| | | package com.yuanchu.mom.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.yuanchu.mom.annotation.ValueTableShow; |
| | | import com.yuanchu.mom.common.OrderBy; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Builder; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | import java.io.Serializable; |
| | | import java.lang.reflect.Field; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | @Data |
| | | @Builder |
| | | @AllArgsConstructor |
| | | @NoArgsConstructor |
| | | public class User { |
| | | @TableName("user") |
| | | public class User extends OrderBy implements Serializable{ |
| | | |
| | | @ApiModelProperty(value = "主é®") |
| | | @TableId(type = IdType.AUTO) |
| | | private Integer id; |
| | | |
| | | @ValueTableShow(1) |
| | | @ApiModelProperty(value = "è´¦å·") |
| | | private String account; |
| | | |
| | | @ApiModelProperty(value = "å¯ç ") |
| | | private String password; |
| | | |
| | | @ValueTableShow(2) |
| | | @ApiModelProperty(value = "客æ·åç§°") |
| | | private String name; |
| | | |
| | | private int state; |
| | | @ValueTableShow(3) |
| | | @ApiModelProperty(value = "ç¶æ") |
| | | private Integer state; |
| | | |
| | | @ValueTableShow(4) |
| | | @ApiModelProperty(value = "å¹´é¾") |
| | | private Integer age; |
| | | |
| | | @ValueTableShow(5) |
| | | @ApiModelProperty(value = "é®ç®±") |
| | | private String email; |
| | | |
| | | @ValueTableShow(6) |
| | | @ApiModelProperty(value = "çµè¯å·ç ") |
| | | private String phone; |
| | | |
| | | @ValueTableShow(7) |
| | | @ApiModelProperty(value = "é¨é¨") |
| | | private String department; |
| | | |
| | | @ValueTableShow(8) |
| | | @ApiModelProperty(value = "å
¬å¸") |
| | | private String company; |
| | | |
| | | @ApiModelProperty(value = "è§è²ä¸»é®") |
| | | private Integer roleId; |
| | | |
| | | @ValueTableShow(9) |
| | | @ApiModelProperty(value = "åå»ºæ¥æ") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Date createTime; |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime createTime; |
| | | |
| | | @ValueTableShow(10) |
| | | @ApiModelProperty(value = "æ´æ°æ¥æ") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Date updateTime; |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime updateTime; |
| | | |
| | | private int version; |
| | | @ApiModelProperty(value = "åå»ºç¨æ·") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Integer createUser; |
| | | |
| | | @ApiModelProperty(value = "æ´æ°ç¨æ·") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Integer updateUser; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.yuanchu.mom.dto.UserPageDto; |
| | | import com.yuanchu.mom.pojo.Role; |
| | | import com.yuanchu.mom.pojo.User; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | public interface RoleService { |
| | | |
| | | List<Role> selectList(); |
| | | |
| | | Map<String, Object> selectUserList(IPage<Role> page, Role role); |
| | | |
| | | int delRole(Integer id); |
| | | |
| | | } |
| | |
| | | package com.yuanchu.mom.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.dto.UserPageDto; |
| | | import com.yuanchu.mom.pojo.User; |
| | | |
| | | import java.util.List; |
| | |
| | | //æ ¹æ®ç¨æ·idæ¥è¯¢ç¨æ·å |
| | | String selectNameById(Integer id); |
| | | |
| | | Map<String, Object> selectUserList(IPage<UserPageDto> page, UserPageDto user); |
| | | |
| | | int updateUser(User user); |
| | | |
| | | int addUser(User user); |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.service.imp; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.yuanchu.mom.common.PrintChina; |
| | | import com.yuanchu.mom.dto.UserPageDto; |
| | | import com.yuanchu.mom.mapper.RoleMapper; |
| | | import com.yuanchu.mom.mapper.UserMapper; |
| | | import com.yuanchu.mom.pojo.Role; |
| | | import com.yuanchu.mom.pojo.User; |
| | | import com.yuanchu.mom.service.RoleService; |
| | | import com.yuanchu.mom.service.UserService; |
| | | import com.yuanchu.mom.utils.Jwt; |
| | | import com.yuanchu.mom.utils.QueryWrappers; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.DigestUtils; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class RoleServiceImp implements RoleService { |
| | | |
| | | private RoleMapper roleMapper; |
| | | |
| | | @Override |
| | | public List<Role> selectList() { |
| | | return roleMapper.selectList(null); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> selectUserList(IPage<Role> page, Role role) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("head", PrintChina.printChina(Role.class)); |
| | | map.put("body", roleMapper.selectPage(page, QueryWrappers.queryWrappers(role))); |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public int delRole(Integer id) { |
| | | return roleMapper.deleteById(id); |
| | | } |
| | | } |
| | |
| | | package com.yuanchu.mom.service.imp; |
| | | |
| | | import cn.hutool.json.JSONUtil; |
| | | 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.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.common.PrintChina; |
| | | import com.yuanchu.mom.dto.UserPageDto; |
| | | import com.yuanchu.mom.mapper.UserMapper; |
| | | import com.yuanchu.mom.pojo.User; |
| | | import com.yuanchu.mom.service.UserService; |
| | | import com.yuanchu.mom.utils.JackSonUtil; |
| | | import com.yuanchu.mom.utils.Jwt; |
| | | import com.yuanchu.mom.utils.QueryWrappers; |
| | | import com.yuanchu.mom.utils.ServletUtils; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.DigestUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class UserServiceImp implements UserService { |
| | | |
| | | @Resource |
| | | UserMapper userMapper; |
| | | |
| | | Jwt jwt; |
| | | |
| | | @Override |
| | | public User selectUserByPwd(String account, String password) { |
| | | QueryWrapper<User> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("account", account).eq("password", DigestUtils.md5DigestAsHex(password.getBytes())); |
| | | wrapper.eq("account", account).eq("password", DigestUtils.md5DigestAsHex(password.getBytes())).eq("state", 1); |
| | | List<User> list = userMapper.selectList(wrapper); |
| | | return list.size()>0?list.get(0):null; |
| | | } |
| | |
| | | return user.getName(); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> selectUserList(IPage<UserPageDto> page, UserPageDto user) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("head", PrintChina.printChina(UserPageDto.class)); |
| | | map.put("body", userMapper.selectUserDtoPageList(page, QueryWrappers.queryWrappers(user))); |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public int updateUser(User user) { |
| | | return userMapper.updateById(user); |
| | | } |
| | | |
| | | @Override |
| | | public int addUser(User user) { |
| | | return userMapper.insert(user); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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.yuanchu.mom.mapper.RoleMapper"> |
| | | |
| | | </mapper> |
| | |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.yuanchu.mom.mapper.UserMapper"> |
| | | |
| | | <select id="selectUserDtoPageList" resultType="com.yuanchu.mom.dto.UserPageDto"> |
| | | select * from ( |
| | | select u1.id, u1.account, u1.name, u1.state, u1.create_time, u1.update_time, u1.create_user, u1.update_user, u1.age, u1.email, u1.phone, u1.department, u1.company, u1.role_id, u2.name create_user_name, u3.name update_user_name, r.name role_name |
| | | from user u1 |
| | | left join user u2 on u2.id = u1.create_user |
| | | left join user u3 on u3.id = u1.update_user |
| | | left join role r on u1.role_id = r.id |
| | | ) a |
| | | <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''"> |
| | | ${ew.customSqlSegment} |
| | | </if> |
| | | </select> |
| | | </mapper> |