Commit fb31745c authored by nie'hong's avatar nie'hong

代码提交

parent 00aee727
......@@ -19,6 +19,19 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- JSON Parser -->
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<classifier>jdk15</classifier>
<version>2.4</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--undertow容器-->
<dependency>
<groupId>org.springframework.boot</groupId>
......
package cn.wisenergy.common.utils.exception;
import cn.wisenergy.common.enums.RespCodeEnum;
/**
* 接口异常对象
*/
......@@ -30,7 +28,7 @@ public class BaseCustomException extends RuntimeException {
*
* @param baseResponseCodeEnum 基本响应枚举类
*/
public BaseCustomException(RespCodeEnum baseResponseCodeEnum) {
public BaseCustomException(BASE_RESP_CODE_ENUM baseResponseCodeEnum) {
super("errorCode:" + baseResponseCodeEnum.getCode() + " errorMsg:" + baseResponseCodeEnum.getMsg());
this.errorCode = baseResponseCodeEnum.getCode();
this.errorMsg = baseResponseCodeEnum.getMsg();
......
......@@ -2,13 +2,11 @@ package cn.wisenergy.common.utils.exception;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author wyy
* @date 2019-10-11 20:51
*/
@Data
@ApiModel("返回结果")
public class Result<T> {
// 结果标识
......@@ -58,4 +56,35 @@ public class Result<T> {
}
}
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
public String getErrorCode() {
return errorCode;
}
public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}
public String getErrorMsg() {
return errorMsg;
}
public void setErrorMsg(String errorMsg) {
this.errorMsg = errorMsg;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
}
<?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="cn.wisenergy.mapper.AccountUsersMapper">
<select id="getUserList" resultType="cn.wisenergy.model.app.AccountUsers">
select *
from account_users
<where>
<if test="keyword != null and keyword != ''">
and nickname LIKE CONCAT('%', #{keyword}, '%')
</if>
</where>
</select>
<select id="getUserNameList" resultType="cn.wisenergy.model.vo.AccountUserVo">
select id,auto_id,nickname
from account_users
</select>
<select id="getByName" resultType="cn.wisenergy.model.app.AccountUsers" parameterType="java.lang.String">
select *
from account_users
where nickname=#{nickName}
</select>
<select id="getById" resultType="cn.wisenergy.model.app.AccountUsers" parameterType="java.lang.Integer">
select *
from account_users
where id=#{id}
</select>
<select id="getByAutoId" resultType="cn.wisenergy.model.app.AccountUsers" parameterType="java.lang.String">
select *
from account_users
where auto_id=#{autoId}
</select>
<select id="count" resultType="java.lang.Integer">
select count(1)
from account_users
where is_active=1
</select>
<select id="getUserRoles" resultType="cn.wisenergy.model.vo.UserRoleCountVo">
select r.`name` as userRoleName,count(1) as count
from account_users a ,system_roles r
where
a.is_active=1
and r.is_delete=0
and a.role_id=r.id
GROUP BY r.`name`
</select>
<select id="getNameByRoleName" resultType="java.lang.String" parameterType="java.lang.String">
select a.name
from account_users a,system_roles system_roles
where a.is_active=1
and r.is_delete=0
and a.role_id=r.id
and r.name LIKE CONCAT('%', #{role_name}, '%')
</select>
<select id="countByName" resultType="java.lang.Integer"
parameterType="list">
select count(1)
from account_users
<where>
is_delete=0
<if test="list != null ">
and organization_name IN
<foreach collection="list" index="index" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</if>
</where>
</select>
<select id="getByOrgName" resultType="cn.wisenergy.model.vo.UserRoleCountVo" parameterType="list">
select r.`name` as userRoleName,count(1) as count
from account_users a ,system_roles r
<where>
a.is_active=1
and r.is_delete=0
and a.role_id=r.id
<if test="list != null ">
and a.organization_name IN
<foreach collection="list" index="index" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</if>
GROUP BY r.`name`
</where>
</select>
<select id="getRoleByAutoId" resultType="cn.wisenergy.model.vo.UserRoleCountVo"
parameterType="java.lang.String">
select r.`name` as userRoleName,count(1) as count
from account_users a ,system_roles r
<where>
a.is_active=1
and r.is_delete=0
and a.role_id=r.id
and a.auto_id=#{autoId}
</where>
</select>
</mapper>
\ No newline at end of file
......@@ -21,6 +21,40 @@
<version>1.0.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<!--mybatis-plus-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-annotation</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-extension</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.4.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
<!-- MAVEN构建 -->
......
package cn.wisenergy.model.app;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @ Description : 用户
* @ Author : lcc
* @ CreateDate : 2020/11/8 19:59
*/
@Data
@ApiModel(value = "AccountUsers")
public class AccountUsers implements Serializable {
private static final long serialVersionUID = 2525339404301884673L;
private Integer id;
private Date createTime;
private String createUserAutoId;
private Date updateTime;
private String updateUserAutoId;
private Integer isDelete;
private Integer sort;
/**
* 有前后缀的自动编号
*/
private String autoId;
/**
* oa的用户编号
*/
private String oaAutoId;
/**
* 权限编号
*/
private Integer roleId;
/**
* 权限2编号
*/
private Integer role2Id;
/**
* 等级编号
*/
private String lvlId;
/**
* 登录名
*/
private String userName;
/**
* 真实姓名
*/
private String nickName;
/**
* 组织架构部门编号
*/
private String organizationAutoId;
/**
* 组织架构部门
*/
private String organizationName;
/**
* 父级组织架构编号
*/
private String pOrganizationAutoId;
/**
* 邮箱
*/
private String email;
/**
* 电话
*/
private String mobile;
/**
* 超级管理员
*/
private Integer isSupper;
/**
* 激活
*/
private Integer isActive;
/**
* 自助用户
*/
private Integer isSelf;
/**
* 自助用户是否通过审核
*/
private Integer isReview;
private String accessToken;
private Integer tokenExpired;
/**
* 微信openId
*/
private String wxOpenId;
/**
* 微信公众号
*/
private String wxSubOpenId;
}
package cn.wisenergy.model.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel(value = "AccountUserVo")
public class AccountUserVo implements Serializable {
private static final long serialVersionUID = -4424755712677235597L;
/**
* 用户id
*/
@ApiModelProperty(value = "用户id", name = "id")
private Integer id;
/**
* 用户编号
*/
@ApiModelProperty(value = "用户编号", name = "autoId")
private String autoId;
/**
* 用户真实名称
*/
@ApiModelProperty(value = "用户真实名称", name = "nickName")
private String nickName;
}
......@@ -14,8 +14,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@EnableCaching
//排除原有的Multipart配置 spingboot接受不了multipartfile参数
@SpringBootApplication(exclude = {MultipartAutoConfiguration.class})
@MapperScan(
basePackages = "cn.wisenergy.mapper")
@MapperScan(basePackages = "cn.wisenergy.mapper")
@EnableSwagger2
@EnableScheduling
public class Application {
......
package cn.wisenergy.web.admin.controller.app;
import cn.wisenergy.common.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.entity.ContentType;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.util.UUID;
/**
* @author zhangyuelin
*/
@Api(tags = "图片上传")
@RestController
@RequestMapping("/pic")
@Slf4j
public class FileUploadController {
/**
* 请求 url 中的资源映射,不推荐写死在代码中,最好提供可配置,如 /upload_flowChart/**
*/
@Value("${uploadFile.resourceHandler}")
private String resourceHandler;
/**
* 上传文件保存的本地目录,使用@Value获取全局配置文件中配置的属性值,如 D:/java/upload_flowChart/
*/
@Value("${uploadFile.location}")
private String uploadImagesLocation;
// 允许上传的格式
private static final String[] IMAGE_TYPE = new String[]{".bmp", ".jpg", ".jpeg", ".gif", ".png", ".mp4", ".mp3", ".wav"};
@ApiOperation(value = "文件上传", notes = "文件上传")
@PostMapping(value = "/upload", headers = "content-type=multipart/form-data")
public R file(
@ApiParam(required = true, value = "用户头像")
@RequestParam("file") MultipartFile file,
HttpServletRequest request) {
boolean isLegal = true;
if (file.isEmpty()) {
// 上传文件为空
return R.error("上传图片不能为空");
}
for (String type : IMAGE_TYPE) {
if (StringUtils.endsWithIgnoreCase(file.getOriginalFilename(), type)) {
isLegal = false;
break;
}
}
if (isLegal) {
return R.error("图片类型不符合");
}
File folder = new File(uploadImagesLocation);
if (!folder.exists()) {
folder.mkdirs();
}
String oldName = file.getOriginalFilename();
String newName = UUID.randomUUID().toString() + oldName.substring(oldName.lastIndexOf("."));
try {
file.transferTo(new File(folder, newName));
String url = "/upload_flowChart/" + newName;
return R.ok(200, url);
} catch (IOException e) {
e.printStackTrace();
}
return R.error("图片上传失败!");
}
@ApiOperation(value = "截图文件上传", notes = "文件上传", httpMethod = "POST")
@ApiImplicitParam(name = "uploadVo", value = "入参", dataType = "UploadVo")
@PostMapping(value = "/upload/image")
public R filePicture(@RequestBody UploadVo uploadVo) {
log.info("截图文件上传url:" + uploadVo);
if (null == uploadVo || StringUtils.isBlank(uploadVo.getUrl())) {
return R.error("入参为空");
}
//把图片转为base64字符串
String str = ImageUtils.image2Base64(uploadVo.getUrl());
log.info("把图片转为base64字符串:" + str);
//将base64转成字节数
byte[] image = ImageUtils.base64ToByte(str);
log.info("将base64转成字节数byte:" + image.length);
MultipartFile file = new MockMultipartFile("file", "file",
ContentType.IMAGE_JPEG.toString(), image);
boolean isLegal = true;
if (file.isEmpty()) {
// 上传文件为空
return R.error("上传图片不能为空");
}
File folder = new File(uploadImagesLocation);
if (!folder.exists()) {
folder.mkdirs();
}
String oldName = file.getOriginalFilename() + ".jpeg";
String newName = UUID.randomUUID().toString() + oldName.substring(oldName.lastIndexOf("."));
try {
file.transferTo(new File(folder, newName));
String urlImage = "/upload_flowChart/" + newName;
return R.ok(200, urlImage);
} catch (IOException e) {
e.printStackTrace();
}
return R.error("图片上传失败!");
}
}
package cn.wisenergy.web.admin.controller.app;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.service.app.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @ Description : 用户管理控制类
* @ Author : lcc
* @ CreateDate : 2020/11/4 14:39
*/
@RestController
@Api(tags = "用户管理")
@RequestMapping("/user")
@Slf4j
public class UserController {
@Autowired
private UserService userService;
@ApiOperation(value = "获取用户列表", notes = "获取用户列表", httpMethod = "GET")
@ApiImplicitParam(name = "keyword", value = "keyword关键字", dataType = "String")
@GetMapping("/getList")
public R getList(String keyword) {
log.info("ljfl-service[]UserController[]getList[]input.method");
return userService.getUserList(keyword);
}
@ApiOperation(value = "获取用户名称列表", notes = "获取用户名称列表", httpMethod = "GET")
@GetMapping("/getNameList")
public R getNameList() {
log.info("ljfl-service[]UserController[]getList[]input.method");
return userService.getUserNameList();
}
@ApiOperation(value = "获取用户信息", notes = "获取用户信息", httpMethod = "GET")
@ApiImplicitParam(name = "keyword", value = "keyword关键字", dataType = "String")
@GetMapping("/getUser")
public R getUser(String autoId) {
log.info("ljfl-service[]UserController[]getList[]input.method");
return userService.getUserNameList();
}
}
......@@ -3,9 +3,9 @@ spring:
type: com.alibaba.druid.pool.DruidDataSource
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://172.18.1.55:3306/qzhitsm?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=GMT%2B8
url: jdbc:mysql://localhost:3306/work_hours?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=GMT%2B8
username: root
password: adm4HYservice$
password: 123456
initial-size: 10
max-active: 100
min-idle: 10
......
......@@ -3,9 +3,9 @@ spring:
type: com.alibaba.druid.pool.DruidDataSource
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/dydb?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
url: jdbc:mysql://localhost:3306/work_hours?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
username: root
password: root
password: 123456
initial-size: 10
max-active: 100
min-idle: 10
......
......@@ -63,3 +63,5 @@ camera:
appSecret: TDrCbqQXe9XSt7SimYDO
path: /artemis
mybatis:
mapper-locations: classpath:/mapper/*Mapper.xml
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment