完善统计

This commit is contained in:
wanggeng888 2021-02-28 12:12:04 +08:00
parent 95897761f2
commit bd8bd728ef
36 changed files with 1375 additions and 19 deletions

View File

@ -101,4 +101,11 @@ public interface IPositionBaseService {
*/
List<PositionPO> listPO(List<String> positionIds);
/**
* 统计
*
* @param params
* @return
*/
Integer count(Map<String, Object> params);
}

View File

@ -91,6 +91,6 @@ public interface IRoleBaseService {
* @param params
* @return
*/
Integer countRole(Map<String, Object> params);
Integer count(Map<String, Object> params);
}

View File

@ -85,4 +85,43 @@ public interface IUserBaseService {
* @return
*/
SuccessResultList<List<UserDTO>> listPageByExcludeIds(List<String> excludeUserIds, ListPage page);
/**
* 用户统计
*
* @param startDate 开始日期yyyy-MM-dd
* @param endDate 结束日期yyyy-MM-dd
* @return
*/
int countDateRange(String startDate, String endDate);
/**
* 用户统计
*
* @return
*/
int count();
/**
* 用户统计
*
* @param userType0系统用户1普通用户
* @return
*/
int countType(int userType);
/**
* 用户统计错误类型
*
* @return
*/
int countErrorType();
/**
* 用户统计
*
* @param userState 0正常用户1冻结
* @return
*/
Integer countState(int userState);
}

View File

@ -50,7 +50,7 @@ public class SystemProperties {
}
public String getSystemTitle() {
return systemTitle == null ? "" : systemTitle.trim();
return systemTitle == null ? "统一用户管理系统" : systemTitle.trim();
}
public void setSystemTitle(String systemTitle) {
@ -58,7 +58,7 @@ public class SystemProperties {
}
public String getSystemSubTitle() {
return systemSubTitle == null ? "" : systemSubTitle.trim();
return systemSubTitle == null ? "山西腾狮科技" : systemSubTitle.trim();
}
public void setSystemSubTitle(String systemSubTitle) {

View File

@ -0,0 +1,117 @@
package ink.wgink.login.base.controller.api.count;
import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.exceptions.ParamsException;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.login.base.service.count.ICountService;
import ink.wgink.pojo.result.ErrorResult;
import ink.wgink.pojo.result.SuccessResultData;
import io.swagger.annotations.*;
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 java.util.List;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: CountController
* @Description: 统计
* @Author: wanggeng
* @Date: 2021/2/28 9:35 上午
* @Version: 1.0
*/
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "统计")
@RestController
@RequestMapping(ISystemConstant.API_PREFIX + "/count")
public class CountController extends DefaultBaseController {
@Autowired
private ICountService countService;
@ApiOperation(value = "统计新增用户数量统计(按周统计)", notes = "统计新增用户数量统计(按周统计)接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("count-new-user-by-week")
public SuccessResultData<Map<String, Object>> countNewUserByWeek() {
Map<String, Object> params = getParams();
return new SuccessResultData<>(countService.countNewUserByWeek(params));
}
@ApiOperation(value = "统计用户数量", notes = "统计用户数量接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("count-user")
public SuccessResultData<Map<String, Object>> countUser() {
Map<String, Object> params = getParams();
return new SuccessResultData<>(countService.countUser(params));
}
@ApiOperation(value = "Oauth客户端统计", notes = "Oauth客户端统计接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("count-oauth-client")
public SuccessResultData<Map<String, Object>> countOauthClient() {
Map<String, Object> params = getParams();
return new SuccessResultData<>(countService.countOauthClient(params));
}
@ApiOperation(value = "系统登录量统计", notes = "系统登录量统计接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("count-login")
public SuccessResultData<Map<String, Object>> countLogin() {
Map<String, Object> params = getParams();
return new SuccessResultData<>(countService.countLogin(params));
}
@ApiOperation(value = "系统登录量统计(按展示天数)", notes = "系统登录量统计(按展示天数)接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "days", value = "展示天数", paramType = "path"),
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("count-login-for-days/{days}")
public SuccessResultData<Map<String, Object>> countLoginForDays(@PathVariable("days") Integer days) {
if (days < 1) {
throw new ParamsException("天数格式错误");
}
return new SuccessResultData<>(countService.countLoginForDays(days));
}
@ApiOperation(value = "统计机构数量", notes = "统计机构数量接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("count-department")
public SuccessResultData<Integer> countDepartment() {
return new SuccessResultData<>(countService.countDepartment());
}
@ApiOperation(value = "统计角色数量", notes = "统计角色数量接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("count-role")
public SuccessResultData<Integer> countRole() {
return new SuccessResultData<>(countService.countRole());
}
@ApiOperation(value = "统计职位数量", notes = "统计职位数量接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("count-position")
public SuccessResultData<Integer> countPosition() {
return new SuccessResultData<>(countService.countPosition());
}
@ApiOperation(value = "统计用户类型比例", notes = "统计用户类型比例接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("count-user-type-proportion")
public SuccessResultData<List<Map<String, Object>>> countUserTypeProportion() {
return new SuccessResultData<>(countService.countUserTypeProportion());
}
@ApiOperation(value = "统计用户状态比例", notes = "统计用户状态比例接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("count-user-state-proportion")
public SuccessResultData<List<Map<String, Object>>> countUserStateProportion() {
return new SuccessResultData<>(countService.countUserStateProportion());
}
}

View File

@ -0,0 +1,113 @@
package ink.wgink.login.base.controller.api.log;
import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.login.base.pojo.dtos.log.LoginLogDTO;
import ink.wgink.login.base.service.log.ILoginLogService;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.result.ErrorResult;
import ink.wgink.pojo.result.SuccessResultList;
import ink.wgink.service.department.pojo.dtos.DepartmentAdjustmentDTO;
import ink.wgink.service.department.pojo.dtos.DepartmentUserAdjustmentDTO;
import ink.wgink.service.department.service.IDepartmentAdjustmentService;
import ink.wgink.service.department.service.IDepartmentUserAdjustmentService;
import ink.wgink.service.user.pojo.dtos.UserLogDTO;
import ink.wgink.service.user.service.IUserAdjustmentService;
import io.swagger.annotations.*;
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;
import java.util.List;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: LoginLogController
* @Description: 登录日志
* @Author: wanggeng
* @Date: 2021/2/28 11:11 上午
* @Version: 1.0
*/
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "日志")
@RestController
@RequestMapping(ISystemConstant.API_PREFIX + "/log")
public class LogController extends DefaultBaseController {
@Autowired
private IUserAdjustmentService userAdjustmentService;
@Autowired
private IDepartmentAdjustmentService departmentAdjustmentService;
@Autowired
private IDepartmentUserAdjustmentService departmentUserAdjustmentService;
@Autowired
private ILoginLogService loginLoggerService;
@ApiOperation(value = "用户调整分页列表", notes = "用户调整分页列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listpage/user-adjustment")
public SuccessResultList<List<UserLogDTO>> listPageUserAdjustment(ListPage page) {
Map<String, Object> params = requestParams();
page.setParams(params);
return userAdjustmentService.listPage(page);
}
@ApiOperation(value = "用户部门调整分页列表", notes = "用户部门调整分页列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listpage/department-user-adjustment")
public SuccessResultList<List<DepartmentUserAdjustmentDTO>> listPageDepartmentUserAdjustment(ListPage page) {
Map<String, Object> params = requestParams();
page.setParams(params);
return departmentUserAdjustmentService.listPage(page);
}
@ApiOperation(value = "部门调整分页列表", notes = "部门调整分页列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listpage/department-adjustment")
public SuccessResultList<List<DepartmentAdjustmentDTO>> listPageDepartmentAdjustment(ListPage page) {
Map<String, Object> params = requestParams();
page.setParams(params);
return departmentAdjustmentService.listPage(page);
}
@ApiOperation(value = "登录日志分页列表", notes = "登录日志列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listpage/login-log")
public SuccessResultList<List<LoginLogDTO>> listPageLoginLogger(ListPage page) {
Map<String, Object> params = requestParams();
page.setParams(params);
return loginLoggerService.listPage(page);
}
}

View File

@ -1,9 +1,9 @@
package ink.wgink.login.base.dao;
package ink.wgink.login.base.dao.config;
import ink.wgink.exceptions.SaveException;
import ink.wgink.exceptions.SearchException;
import ink.wgink.exceptions.UpdateException;
import ink.wgink.login.base.pojo.dtos.ConfigDTO;
import ink.wgink.login.base.pojo.dtos.config.ConfigDTO;
import org.springframework.stereotype.Repository;
import java.util.List;

View File

@ -0,0 +1,55 @@
package ink.wgink.login.base.dao.log;
import ink.wgink.exceptions.SaveException;
import ink.wgink.exceptions.SearchException;
import ink.wgink.exceptions.UpdateException;
import ink.wgink.login.base.pojo.dtos.log.LoginLogDTO;
import java.util.List;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: ILoginLogDao
* @Description: 登录日志
* @Author: wanggeng
* @Date: 2021/2/28 10:50 上午
* @Version: 1.0
*/
public interface ILoginLogDao {
/**
* 建表
*
* @throws UpdateException
*/
void createTable() throws UpdateException;
/**
* 保存登录日志
*
* @param params
* @throws SaveException
*/
void save(Map<String, Object> params) throws SaveException;
/**
* 登录日志统计
*
* @param params
* @return
* @throws SearchException
*/
Integer count(Map<String, Object> params) throws SearchException;
/**
* 登录日志列表
*
* @param params
* @return
* @throws SearchException
*/
List<LoginLogDTO> list(Map<String, Object> params) throws SearchException;
}

View File

@ -2,8 +2,8 @@ package ink.wgink.login.base.manager;
import ink.wgink.exceptions.SearchException;
import ink.wgink.interfaces.manager.ISystemConfigManager;
import ink.wgink.login.base.dao.IConfigDao;
import ink.wgink.login.base.pojo.dtos.ConfigDTO;
import ink.wgink.login.base.dao.config.IConfigDao;
import ink.wgink.login.base.pojo.dtos.config.ConfigDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -1,4 +1,4 @@
package ink.wgink.login.base.pojo.dtos;
package ink.wgink.login.base.pojo.dtos.config;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

View File

@ -0,0 +1,81 @@
package ink.wgink.login.base.pojo.dtos.log;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: LoginLoggerDTO
* @Description: 登录日志
* @Author: WangGeng
* @Date: 2020/7/21 18:43
* @Version: 1.0
**/
@ApiModel
public class LoginLogDTO implements Serializable {
private static final long serialVersionUID = 7035763517567758961L;
@ApiModelProperty(name = "loginAddress", value = "登录地址")
private String loginAddress;
@ApiModelProperty(name = "creatorName", value = "登录用户")
private String creatorName;
@ApiModelProperty(name = "gmtCreate", value = "登录时间")
private String gmtCreate;
@ApiModelProperty(name = "loginType", value = "登陆类型")
private String loginType;
public static long getSerialVersionUID() {
return serialVersionUID;
}
public String getLoginAddress() {
return loginAddress == null ? "" : loginAddress.trim();
}
public void setLoginAddress(String loginAddress) {
this.loginAddress = loginAddress;
}
public String getCreatorName() {
return creatorName == null ? "" : creatorName.trim();
}
public void setCreatorName(String creatorName) {
this.creatorName = creatorName;
}
public String getGmtCreate() {
return gmtCreate == null ? "" : gmtCreate.trim();
}
public void setGmtCreate(String gmtCreate) {
this.gmtCreate = gmtCreate;
}
public String getLoginType() {
return loginType == null ? "" : loginType.trim();
}
public void setLoginType(String loginType) {
this.loginType = loginType;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("{");
sb.append("\"loginAddress\":\"")
.append(loginAddress).append('\"');
sb.append(",\"creatorName\":\"")
.append(creatorName).append('\"');
sb.append(",\"gmtCreate\":\"")
.append(gmtCreate).append('\"');
sb.append(",\"loginType\":\"")
.append(loginType).append('\"');
sb.append('}');
return sb.toString();
}
}

View File

@ -2,9 +2,9 @@ package ink.wgink.login.base.service.config.impl;
import ink.wgink.common.base.DefaultBaseService;
import ink.wgink.login.base.dao.IConfigDao;
import ink.wgink.login.base.dao.config.IConfigDao;
import ink.wgink.login.base.manager.ConfigManager;
import ink.wgink.login.base.pojo.dtos.ConfigDTO;
import ink.wgink.login.base.pojo.dtos.config.ConfigDTO;
import ink.wgink.login.base.pojo.vos.ConfigVO;
import ink.wgink.login.base.service.config.IConfigService;
import ink.wgink.util.map.HashMapUtil;

View File

@ -0,0 +1,93 @@
package ink.wgink.login.base.service.count;
import java.util.List;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: ICountService
* @Description: 统计
* @Author: wanggeng
* @Date: 2021/2/28 9:36 上午
* @Version: 1.0
*/
public interface ICountService {
String DAY_FORMATTER = "yyyy-MM-dd";
/**
* 统计新增用户数量统计按周统计
*
* @param params
* @return
*/
Map<String, Object> countNewUserByWeek(Map<String, Object> params);
/**
* 统计用户数量
*
* @param params
* @return
*/
Map<String, Object> countUser(Map<String, Object> params);
/**
* @param params
* @return
*/
Map<String, Object> countOauthClient(Map<String, Object> params);
/**
* 系统登录量统计
*
* @param params
* @return
*/
Map<String, Object> countLogin(Map<String, Object> params);
/**
* 系统登录量统计按展示天数
*
* @param days
* @return
*/
Map<String, Object> countLoginForDays(Integer days);
/**
* 统计机构数量
*
* @return
*/
Integer countDepartment();
/**
* 统计角色数量
*
* @return
*/
Integer countRole();
/**
* 统计职位数量
*
* @return
*/
Integer countPosition();
/**
* 统计用户类型比例
*
* @return
*/
List<Map<String, Object>> countUserTypeProportion();
/**
* 统计用户状态比例
*
* @return
*/
List<Map<String, Object>> countUserStateProportion();
}

View File

@ -0,0 +1,197 @@
package ink.wgink.login.base.service.count.impl;
import ink.wgink.common.base.DefaultBaseService;
import ink.wgink.interfaces.position.IPositionBaseService;
import ink.wgink.interfaces.role.IRoleBaseService;
import ink.wgink.login.base.service.count.ICountService;
import ink.wgink.login.base.service.log.ILoginLogService;
import ink.wgink.service.department.service.IDepartmentService;
import ink.wgink.service.user.enums.UserStateEnum;
import ink.wgink.service.user.enums.UserTypeEnum;
import ink.wgink.service.user.service.IUserService;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: CountServiceImpl
* @Description: 统计
* @Author: wanggeng
* @Date: 2021/2/28 9:37 上午
* @Version: 1.0
*/
@Service
public class CountServiceImpl extends DefaultBaseService implements ICountService {
@Autowired
private IUserService userService;
@Autowired
private IDepartmentService departmentService;
@Autowired
private ILoginLogService loginLogService;
@Autowired(required = false)
private IRoleBaseService roleBaseService;
@Autowired(required = false)
private IPositionBaseService positionBaseService;
@Override
public Map<String, Object> countNewUserByWeek(Map<String, Object> params) {
DateTime now = DateTime.now();
DateTimeFormatter dayDateTimeFormatter = DateTimeFormat.forPattern(DAY_FORMATTER);
int weekNewUserCount = userService.countDateRange(now.dayOfWeek().withMinimumValue().toString(dayDateTimeFormatter), now.dayOfWeek().withMaximumValue().toString(dayDateTimeFormatter));
int totalUserCount = userService.count();
Map<String, Object> result = getHashMap(4);
result.put("count", weekNewUserCount);
result.put("percentage", new BigDecimal(getPercentage(weekNewUserCount, totalUserCount)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
return result;
}
@Override
public Map<String, Object> countUser(Map<String, Object> params) {
DateTime now = DateTime.now();
DateTimeFormatter dayDateTimeFormatter = DateTimeFormat.forPattern(DAY_FORMATTER);
int monthUserCount = userService.countDateRange(now.dayOfMonth().withMinimumValue().toString(dayDateTimeFormatter), now.dayOfMonth().withMaximumValue().toString(dayDateTimeFormatter));
int totalUserCount = userService.count();
Map<String, Object> result = getHashMap(4);
result.put("count", totalUserCount);
result.put("newCount", monthUserCount);
return result;
}
@Override
public Map<String, Object> countOauthClient(Map<String, Object> params) {
Map<String, Object> result = getHashMap(4);
return null;
}
@Override
public Map<String, Object> countLogin(Map<String, Object> params) {
DateTime now = DateTime.now();
DateTimeFormatter dayDateTimeFormatter = DateTimeFormat.forPattern(DAY_FORMATTER);
int loginLoggerCount = loginLogService.countDay(now.toString(dayDateTimeFormatter));
int yesterdayLoggerCount = loginLogService.countDay(now.minusDays(1).toString(dayDateTimeFormatter));
Map<String, Object> result = getHashMap(4);
result.put("count", loginLoggerCount);
result.put("percentage", new BigDecimal(getPercentage((loginLoggerCount - yesterdayLoggerCount), yesterdayLoggerCount)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
return result;
}
@Override
public Map<String, Object> countLoginForDays(Integer days) {
DateTime now = DateTime.now();
DateTimeFormatter dayDateTimeFormatter = DateTimeFormat.forPattern(DAY_FORMATTER);
String[] dateArray = new String[days];
Integer[] loginCountArray = new Integer[days];
for (int i = days - 1; i >= 0; i--) {
String currentDay = now.minusDays(i).toString(dayDateTimeFormatter);
int index = days - (i + 1);
dateArray[index] = currentDay;
loginCountArray[index] = loginLogService.countDay(currentDay);
}
Map<String, Object> result = new HashMap<>(2);
result.put("dateArray", dateArray);
result.put("loginCountArray", loginCountArray);
return result;
}
@Override
public Integer countDepartment() {
Map<String, Object> params = getHashMap(0);
return departmentService.count(params);
}
@Override
public Integer countRole() {
Map<String, Object> params = getHashMap(0);
if (roleBaseService != null) {
return roleBaseService.count(params);
}
return 0;
}
@Override
public Integer countPosition() {
Map<String, Object> params = getHashMap(0);
if (positionBaseService != null) {
return positionBaseService.count(params);
}
return 0;
}
@Override
public List<Map<String, Object>> countUserTypeProportion() {
Integer systemUserCount = userService.countType(UserTypeEnum.SYSTEM.getValue());
Integer normalUserCount = userService.countType(UserTypeEnum.NORMAL.getValue());
Integer errorLoginTypeCount = userService.countErrorType();
Map<String, Object> systemUserCountResult = getHashMap(6);
systemUserCountResult.put("name", "系统用户");
systemUserCountResult.put("value", systemUserCount);
systemUserCountResult.put("color", "#009688");
Map<String, Object> normalUserCountResult = getHashMap(6);
normalUserCountResult.put("name", "普通用户");
normalUserCountResult.put("value", normalUserCount);
normalUserCountResult.put("color", "#FFB800");
Map<String, Object> errorLoginTypeCountResult = getHashMap(6);
errorLoginTypeCountResult.put("name", "类型错误");
errorLoginTypeCountResult.put("value", errorLoginTypeCount);
errorLoginTypeCountResult.put("color", "#FF5722");
List<Map<String, Object>> result = new ArrayList<>();
result.add(systemUserCountResult);
result.add(normalUserCountResult);
result.add(errorLoginTypeCountResult);
return result;
}
@Override
public List<Map<String, Object>> countUserStateProportion() {
Integer normalUserCount = userService.countState(UserStateEnum.NORMAL.getValue());
Integer lockingUserCount = userService.countState(UserStateEnum.LOCK.getValue());
Map<String, Object> normalUserCountResult = getHashMap(3);
normalUserCountResult.put("name", "正常用户");
normalUserCountResult.put("value", normalUserCount);
normalUserCountResult.put("color", "#1E9FFF");
Map<String, Object> lockingUserCountResult = getHashMap(3);
lockingUserCountResult.put("name", "锁定用户");
lockingUserCountResult.put("value", lockingUserCount);
lockingUserCountResult.put("color", "#009688");
List<Map<String, Object>> result = new ArrayList<>();
result.add(normalUserCountResult);
result.add(lockingUserCountResult);
return result;
}
/**
* 计算占比
*
* @param count
* @param totalCount
* @return
*/
private double getPercentage(int count, int totalCount) {
if (totalCount == 0) {
return 100D;
}
return (count * 1.0) / totalCount * 100;
}
}

View File

@ -0,0 +1,45 @@
package ink.wgink.login.base.service.log;
import ink.wgink.login.base.pojo.dtos.log.LoginLogDTO;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.result.SuccessResultList;
import java.util.List;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: ILoginLogService
* @Description: 登录日志
* @Author: wanggeng
* @Date: 2021/2/28 10:38 上午
* @Version: 1.0
*/
public interface ILoginLogService {
/**
* 添加
*
* @param params
*/
void save(Map<String, Object> params);
/**
* 统计
*
* @param day
* @return
*/
Integer countDay(String day);
/**
* 登录日志分页列表
*
* @param page
* @return
*/
SuccessResultList<List<LoginLogDTO>> listPage(ListPage page);
}

View File

@ -0,0 +1,53 @@
package ink.wgink.login.base.service.log.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import ink.wgink.common.base.DefaultBaseService;
import ink.wgink.login.base.dao.log.ILoginLogDao;
import ink.wgink.login.base.pojo.dtos.log.LoginLogDTO;
import ink.wgink.login.base.service.log.ILoginLogService;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.result.SuccessResultList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: LoginLogServiceImpl
* @Description: 登录日志
* @Author: wanggeng
* @Date: 2021/2/28 10:39 上午
* @Version: 1.0
*/
@Service
public class LoginLogServiceImpl extends DefaultBaseService implements ILoginLogService {
@Autowired
private ILoginLogDao loginLogDao;
@Override
public void save(Map<String, Object> params) {
loginLogDao.save(params);
}
@Override
public Integer countDay(String day) {
Map<String, Object> params = getHashMap(2);
params.put("day", day);
Integer count = loginLogDao.count(params);
return count == null ? 0 : count;
}
@Override
public SuccessResultList<List<LoginLogDTO>> listPage(ListPage page) {
PageHelper.startPage(page.getPage(), page.getRows());
List<LoginLogDTO> loginLoggerDTOs = loginLogDao.list(page.getParams());
PageInfo<LoginLogDTO> pageInfo = new PageInfo<>(loginLoggerDTOs);
return new SuccessResultList<>(loginLoggerDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
}
}

View File

@ -4,6 +4,7 @@ import ink.wgink.common.enums.RoleDataRightEnum;
import ink.wgink.exceptions.SaveException;
import ink.wgink.exceptions.UpdateException;
import ink.wgink.interfaces.role.IRoleDataRightBaseService;
import ink.wgink.login.base.service.log.ILoginLogService;
import ink.wgink.pojo.bos.LoginUser;
import ink.wgink.pojo.pos.RolePO;
import ink.wgink.service.department.service.IDepartmentService;
@ -44,6 +45,8 @@ public class UserLoginService {
private IDepartmentService departmentService;
@Autowired
private IDepartmentUserService departmentUserService;
@Autowired
private ILoginLogService loginLogService;
@Autowired(required = false)
private IRoleDataRightBaseService roleDataRightBaseService;
@ -103,14 +106,14 @@ public class UserLoginService {
* @throws SaveException
*/
private void saveLoginLogger(String userId, String userName, String loginType, String address, String currentTime) throws SaveException {
Map<String, Object> params = new HashMap<>(7);
params.put("loginLoggerId", UUIDUtil.getUUID());
Map<String, Object> params = new HashMap<>(12);
params.put("loginLogId", UUIDUtil.getUUID());
params.put("loginAddress", address);
params.put("loginType", loginType);
params.put("gmtCreate", currentTime);
params.put("creator", userId);
params.put("creatorName", userName);
// loginLoggerService.saveLoginLogger(params);
loginLogService.save(params);
}
/**

View File

@ -1,6 +1,7 @@
package ink.wgink.login.base.startup;
import ink.wgink.login.base.dao.IConfigDao;
import ink.wgink.login.base.dao.config.IConfigDao;
import ink.wgink.login.base.dao.log.ILoginLogDao;
import ink.wgink.login.base.manager.ConfigManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -26,6 +27,8 @@ public class LoginBaseStartUp implements ApplicationRunner {
@Autowired
private IConfigDao configDao;
@Autowired
private ILoginLogDao loginLogDao;
@Override
public void run(ApplicationArguments args) throws Exception {
@ -34,6 +37,7 @@ public class LoginBaseStartUp implements ApplicationRunner {
LOG.debug("初始化配置");
ConfigManager configManager = ConfigManager.getInstance();
configManager.setConfigDao(configDao);
}
/**
@ -42,6 +46,9 @@ public class LoginBaseStartUp implements ApplicationRunner {
private void initTable() {
LOG.debug("创建 sys_config 表");
configDao.createTable();
LOG.debug("创建 log_login 表");
loginLogDao.createTable();
}
}

View File

@ -1,10 +1,10 @@
<?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="ink.wgink.login.base.dao.IConfigDao">
<mapper namespace="ink.wgink.login.base.dao.config.IConfigDao">
<cache flushInterval="3600000"/>
<resultMap id="configDTO" type="ink.wgink.login.base.pojo.dtos.ConfigDTO">
<resultMap id="configDTO" type="ink.wgink.login.base.pojo.dtos.config.ConfigDTO">
<result property="configKey" column="config_key"/>
<result property="configValue" column="config_value"/>
</resultMap>

View File

@ -0,0 +1,92 @@
<?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="ink.wgink.login.base.dao.log.ILoginLogDao">
<cache flushInterval="3600000"/>
<resultMap id="loginLogDTO" type="ink.wgink.login.base.pojo.dtos.log.LoginLogDTO">
<result column="login_address" property="loginAddress"/>
<result column="login_type" property="loginType"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="creator_name" property="creatorName"/>
</resultMap>
<!-- 建表 -->
<update id="createTable">
CREATE TABLE IF NOT EXISTS `log_login_log` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`loginlog_id` char(36) NOT NULL COMMENT '主键',
`login_address` varchar(255) DEFAULT NULL,
`login_type` int(1) DEFAULT '1' COMMENT '登录类型',
`creator` char(36) DEFAULT NULL,
`gmt_create` datetime DEFAULT NULL,
`creator_name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`,`loginlog_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
</update>
<!-- 新增登录日志 -->
<insert id="save" parameterType="map" flushCache="true">
INSERT INTO log_login_log(
loginlog_id,
login_address,
login_type,
creator,
gmt_create,
creator_name
) VALUES(
#{loginLogId},
#{loginAddress},
#{loginType},
#{creator},
#{gmtCreate},
#{creatorName}
)
</insert>
<!-- 登录日志统计 -->
<select id="count" parameterType="map" resultType="Integer" useCache="true">
SELECT
COUNT(*)
FROM
log_login_log
WHERE
1 = 1
<if test="day != null and day != ''">
AND
LEFT(gmt_create, 10) = #{currentDay}
</if>
</select>
<!-- 登录日志列表 -->
<select id="list" parameterType="map" resultMap="loginLogDTO" useCache="true">
SELECT
login_address,
login_type,
LEFT(gmt_create, 19) gmt_create,
creator_name
FROM
log_login_log
WHERE
1 = 1
<if test="loginType != null and loginType != ''">
AND
login_type = #{loginType}
</if>
<if test="keywords != null and keywords != ''">
AND (
creator_name LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
ORDER BY
gmt_create DESC, id DESC
</select>
</mapper>

View File

@ -1,9 +1,12 @@
package ink.wgink.service.department.dao;
import ink.wgink.exceptions.SaveException;
import ink.wgink.exceptions.SearchException;
import ink.wgink.exceptions.UpdateException;
import ink.wgink.service.department.pojo.dtos.DepartmentAdjustmentDTO;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
/**
@ -33,4 +36,13 @@ public interface IDepartmentAdjustmentDao {
* @throws SaveException
*/
void save(Map<String, Object> params) throws SaveException;
/**
* 部门调整列表
*
* @param params
* @return
* @throws SearchException
*/
List<DepartmentAdjustmentDTO> list(Map<String, Object> params) throws SearchException;
}

View File

@ -1,9 +1,12 @@
package ink.wgink.service.department.dao;
import ink.wgink.exceptions.SaveException;
import ink.wgink.exceptions.SearchException;
import ink.wgink.exceptions.UpdateException;
import ink.wgink.service.department.pojo.dtos.DepartmentUserAdjustmentDTO;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
/**
@ -33,4 +36,13 @@ public interface IDepartmentUserAdjustmentDao {
* @throws SaveException
*/
void save(Map<String, Object> params) throws SaveException;
/**
* 部门用户调整列表
*
* @param params
* @return
* @throws SearchException
*/
List<DepartmentUserAdjustmentDTO> list(Map<String, Object> params) throws SearchException;
}

View File

@ -0,0 +1,93 @@
package ink.wgink.service.department.pojo.dtos;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: DepartmentLogDTO
* @Description: 部门调整
* @Author: WangGeng
* @Date: 2020/7/21 17:18
* @Version: 1.0
**/
@ApiModel
public class DepartmentAdjustmentDTO implements Serializable {
private static final long serialVersionUID = 829590971292786101L;
@ApiModelProperty(name = "oldDepartmentName", value = "旧部门名称")
private String oldDepartmentName;
@ApiModelProperty(name = "newDepartmentName", value = "新部门名称")
private String newDepartmentName;
@ApiModelProperty(name = "adjustmentType", value = "操作类型")
private String adjustmentType;
@ApiModelProperty(name = "gmtCreate", value = "创建时间")
private String gmtCreate;
@ApiModelProperty(name = "creatorName", value = "创建人")
private String creatorName;
public static long getSerialVersionUID() {
return serialVersionUID;
}
public String getOldDepartmentName() {
return oldDepartmentName == null ? "" : oldDepartmentName.trim();
}
public void setOldDepartmentName(String oldDepartmentName) {
this.oldDepartmentName = oldDepartmentName;
}
public String getNewDepartmentName() {
return newDepartmentName == null ? "" : newDepartmentName.trim();
}
public void setNewDepartmentName(String newDepartmentName) {
this.newDepartmentName = newDepartmentName;
}
public String getAdjustmentType() {
return adjustmentType == null ? "" : adjustmentType.trim();
}
public void setAdjustmentType(String adjustmentType) {
this.adjustmentType = adjustmentType;
}
public String getGmtCreate() {
return gmtCreate == null ? "" : gmtCreate.trim();
}
public void setGmtCreate(String gmtCreate) {
this.gmtCreate = gmtCreate;
}
public String getCreatorName() {
return creatorName == null ? "" : creatorName.trim();
}
public void setCreatorName(String creatorName) {
this.creatorName = creatorName;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("{");
sb.append("\"oldDepartmentName\":\"")
.append(oldDepartmentName).append('\"');
sb.append(",\"newDepartmentName\":\"")
.append(newDepartmentName).append('\"');
sb.append(",\"adjustmentType\":\"")
.append(adjustmentType).append('\"');
sb.append(",\"gmtCreate\":\"")
.append(gmtCreate).append('\"');
sb.append(",\"creatorName\":\"")
.append(creatorName).append('\"');
sb.append('}');
return sb.toString();
}
}

View File

@ -0,0 +1,89 @@
package ink.wgink.service.department.pojo.dtos;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: UserDepartmentLogDTO
* @Description: 用户部门日志
* @Author: WangGeng
* @Date: 2020/7/22 12:53 下午
* @Version: 1.0
**/
@ApiModel
public class DepartmentUserAdjustmentDTO implements Serializable {
private static final long serialVersionUID = -7519233242842566624L;
@ApiModelProperty(name = "userName", value = "用户名称")
private String userName;
@ApiModelProperty(name = "departmentName", value = "部门名称")
private String departmentName;
@ApiModelProperty(name = "adjustmentType", value = "修改类型")
private String adjustmentType;
@ApiModelProperty(name = "gmtCreate", value = "创建时间")
private String gmtCreate;
@ApiModelProperty(name = "creatorName", value = "创建人")
private String creatorName;
public String getUserName() {
return userName == null ? "" : userName.trim();
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getDepartmentName() {
return departmentName == null ? "" : departmentName.trim();
}
public void setDepartmentName(String departmentName) {
this.departmentName = departmentName;
}
public String getAdjustmentType() {
return adjustmentType == null ? "" : adjustmentType.trim();
}
public void setAdjustmentType(String adjustmentType) {
this.adjustmentType = adjustmentType;
}
public String getGmtCreate() {
return gmtCreate == null ? "" : gmtCreate.trim();
}
public void setGmtCreate(String gmtCreate) {
this.gmtCreate = gmtCreate;
}
public String getCreatorName() {
return creatorName == null ? "" : creatorName.trim();
}
public void setCreatorName(String creatorName) {
this.creatorName = creatorName;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("{");
sb.append("\"userName\":")
.append("\"").append(userName).append("\"");
sb.append(",\"departmentName\":")
.append("\"").append(departmentName).append("\"");
sb.append(",\"adjustmentType\":")
.append("\"").append(adjustmentType).append("\"");
sb.append(",\"gmtCreate\":")
.append("\"").append(gmtCreate).append("\"");
sb.append(",\"creatorName\":")
.append("\"").append(creatorName).append("\"");
sb.append('}');
return sb.toString();
}
}

View File

@ -1,6 +1,9 @@
package ink.wgink.service.department.service;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.result.SuccessResultList;
import ink.wgink.service.department.enmus.DepartmentAdjustmentTypeEnum;
import ink.wgink.service.department.pojo.dtos.DepartmentAdjustmentDTO;
import java.util.List;
@ -36,4 +39,12 @@ public interface IDepartmentAdjustmentService {
* @param userDepartmentType 部门用户类型joinleave
*/
void save(List<String> departmentUserIds, String departmentId, String departmentName, String userDepartmentType);
/**
* 用户部门调整列表
*
* @param page 分页
* @return
*/
SuccessResultList<List<DepartmentAdjustmentDTO>> listPage(ListPage page);
}

View File

@ -2,7 +2,11 @@ package ink.wgink.service.department.service;
import ink.wgink.exceptions.SaveException;
import ink.wgink.exceptions.UpdateException;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.result.SuccessResultList;
import ink.wgink.service.department.pojo.dtos.DepartmentUserAdjustmentDTO;
import java.util.List;
import java.util.Map;
/**
@ -21,7 +25,15 @@ public interface IDepartmentUserAdjustmentService {
* 新增部门用户调整
*
* @param params
* @throws SaveException
*/
void save(Map<String, Object> params) throws SaveException;
void save(Map<String, Object> params);
/**
* 部门用户调整分页列表
*
* @param page 分页
* @return
*/
SuccessResultList<List<DepartmentUserAdjustmentDTO>> listPage(ListPage page);
}

View File

@ -1,9 +1,14 @@
package ink.wgink.service.department.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import ink.wgink.common.base.DefaultBaseService;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.dtos.user.UserDTO;
import ink.wgink.pojo.result.SuccessResultList;
import ink.wgink.service.department.dao.IDepartmentAdjustmentDao;
import ink.wgink.service.department.enmus.DepartmentAdjustmentTypeEnum;
import ink.wgink.service.department.pojo.dtos.DepartmentAdjustmentDTO;
import ink.wgink.service.department.service.IDepartmentAdjustmentService;
import ink.wgink.service.department.service.IDepartmentUserAdjustmentService;
import ink.wgink.service.user.service.IUserService;
@ -66,4 +71,12 @@ public class DepartmentAdjustmentServiceImpl extends DefaultBaseService implemen
}
}
@Override
public SuccessResultList<List<DepartmentAdjustmentDTO>> listPage(ListPage page) {
PageHelper.startPage(page.getPage(), page.getRows());
List<DepartmentAdjustmentDTO> departmentLogDTOs = departmentAdjustmentDao.list(page.getParams());
PageInfo<DepartmentAdjustmentDTO> pageInfo = new PageInfo<>(departmentLogDTOs);
return new SuccessResultList<>(departmentLogDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
}
}

View File

@ -1,11 +1,17 @@
package ink.wgink.service.department.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import ink.wgink.common.base.DefaultBaseService;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.result.SuccessResultList;
import ink.wgink.service.department.dao.IDepartmentUserAdjustmentDao;
import ink.wgink.service.department.pojo.dtos.DepartmentUserAdjustmentDTO;
import ink.wgink.service.department.service.IDepartmentUserAdjustmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
@ -29,4 +35,12 @@ public class DepartmentUserAdjustmentServiceImpl extends DefaultBaseService impl
departmentUserAdjustmentDao.save(params);
}
@Override
public SuccessResultList<List<DepartmentUserAdjustmentDTO>> listPage(ListPage page) {
PageHelper.startPage(page.getPage(), page.getRows());
List<DepartmentUserAdjustmentDTO> userDepartmentLogDTOs = departmentUserAdjustmentDao.list(page.getParams());
PageInfo<DepartmentUserAdjustmentDTO> pageInfo = new PageInfo<>(userDepartmentLogDTOs);
return new SuccessResultList<>(userDepartmentLogDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
}
}

View File

@ -4,6 +4,14 @@
<cache flushInterval="3600000"/>
<resultMap id="departmentAdjustmentDTO" type="ink.wgink.service.department.pojo.dtos.DepartmentAdjustmentDTO">
<result column="old_department_name" property="oldDepartmentName"/>
<result column="new_department_name" property="newDepartmentName"/>
<result column="adjustment_type" property="adjustmentType"/>
<result column="creator_name" property="creatorName"/>
<result column="gmt_create" property="gmtCreate"/>
</resultMap>
<!-- 建表 -->
<update id="createTable">
CREATE TABLE IF NOT EXISTS `sys_department_adjustment` (
@ -43,5 +51,40 @@
)
</insert>
<!-- 部门调整列表 -->
<select id="list" parameterType="map" resultMap="departmentAdjustmentDTO" useCache="true">
SELECT
old_department_name,
new_department_name,
adjustment_type,
LEFT(gmt_create, 19) gmt_create,
creator_name
FROM
sys_department_adjustment
WHERE
1 = 1
<if test="adjustmentType != null and adjustmentType != ''">
AND
adjustment_type = #{adjustmentType}
</if>
<if test="keywords != null and keywords != ''">
AND (
old_department_name LIKE CONCAT('%', #{keywords}, '%')
OR
new_department_name LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
ORDER BY
gmt_create DESC, id DESC
</select>
</mapper>

View File

@ -4,6 +4,14 @@
<cache flushInterval="3600000"/>
<resultMap id="departmentUserAdjustmentDTO" type="ink.wgink.service.department.pojo.dtos.DepartmentUserAdjustmentDTO">
<result column="user_name" property="userName"/>
<result column="department_name" property="departmentName"/>
<result column="adjustment_type" property="adjustmentType"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="creator_name" property="creatorName"/>
</resultMap>
<!-- 建表 -->
<update id="createTable">
CREATE TABLE IF NOT EXISTS `sys_department_user_adjustment` (
@ -43,4 +51,42 @@
)
</insert>
<!-- 用户部门调整分页列表 -->
<select id="list" parameterType="map" resultMap="departmentUserAdjustmentDTO" useCache="true">
SELECT
user_id,
user_name,
department_id,
department_name,
adjustment_type,
creator,
creator_name,
LEFT(gmt_create, 19) gmt_create
FROM
sys_user_department_adjustment
WHERE
1 = 1
<if test="adjustmentType != null and adjustmentType != ''">
AND
adjustment_type = #{adjustmentType}
</if>
<if test="keywords != null and keywords != ''">
AND (
user_name LIKE CONCAT('%', #{keywords}, '%')
OR
department_name LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
ORDER BY
gmt_create DESC, id DESC
</select>
</mapper>

View File

@ -135,6 +135,12 @@ public class PositionServiceImpl extends DefaultBaseService implements IPosition
return listPO(params);
}
@Override
public Integer count(Map<String, Object> params) {
Integer count = positionDao.count(params);
return count == null ? 0 : count;
}
/**
* 递归查询子组
*

View File

@ -146,7 +146,7 @@ public class RoleServiceImpl extends DefaultBaseService implements IRoleService
}
@Override
public Integer countRole(Map<String, Object> params) throws SearchException {
public Integer count(Map<String, Object> params) throws SearchException {
Integer roleCount = roleDao.countRole(params);
return roleCount == null ? 0 : roleCount;
}

View File

@ -0,0 +1,27 @@
package ink.wgink.service.user.enums;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: UserStateEnum
* @Description: 用户状态
* @Author: wanggeng
* @Date: 2021/2/28 11:52 上午
* @Version: 1.0
*/
public enum UserStateEnum {
NORMAL(0),
LOCK(1);
private int value;
UserStateEnum(int value) {
this.value = value;
}
public int getValue() {
return value;
}
}

View File

@ -0,0 +1,27 @@
package ink.wgink.service.user.enums;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: UserTypeEnum
* @Description: 用户类型
* @Author: wanggeng
* @Date: 2021/2/28 11:52 上午
* @Version: 1.0
*/
public enum UserTypeEnum {
SYSTEM(1),
NORMAL(2);
private int value;
UserTypeEnum(int value) {
this.value = value;
}
public int getValue() {
return value;
}
}

View File

@ -110,4 +110,12 @@ public interface IUserService extends IUserBaseService, IUserCheckService {
*/
void updateLoginInfo(Map<String, Object> params);
/**
* 统计
*
* @param params
* @return
*/
Integer count(Map<String, Object> params);
}

View File

@ -289,6 +289,47 @@ public class UserServiceImpl extends DefaultBaseService implements IUserService
return listPage(page);
}
@Override
public Integer count(Map<String, Object> params) {
Integer count = userDao.count(params);
return count == null ? 0 : count;
}
@Override
public int countDateRange(String startDate, String endDate) {
Map<String, Object> params = getHashMap(4);
params.put("startDay", startDate);
params.put("endDay", endDate);
return count(params);
}
@Override
public int count() {
Map<String, Object> params = getHashMap(0);
return count(params);
}
@Override
public int countType(int userType) {
Map<String, Object> params = getHashMap(2);
params.put("userType", userType);
return count(params);
}
@Override
public int countErrorType() {
Map<String, Object> params = getHashMap(2);
params.put("errorLoginType", "errorLoginType");
return count(params);
}
@Override
public Integer countState(int userState) {
Map<String, Object> params = getHashMap(2);
params.put("userState", userState);
return count(params);
}
/**
* Excel导入错误对象
*