|
|
|
@ -49,334 +49,275 @@ import com.utils.CommonUtil;
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/yonghu")
|
|
|
|
|
public class YonghuController {
|
|
|
|
|
|
|
|
|
|
// 自动注入用户服务类,用于处理与用户相关的业务逻辑
|
|
|
|
|
@Autowired
|
|
|
|
|
private YonghuService yonghuService;
|
|
|
|
|
|
|
|
|
|
// 自动注入令牌服务类,用于生成和管理用户令牌
|
|
|
|
|
@Autowired
|
|
|
|
|
private TokenService tokenService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 用户登录方法
|
|
|
|
|
* @param username 用户名
|
|
|
|
|
* @param password 密码
|
|
|
|
|
* @param captcha 验证码(此处未在代码中看到对验证码的实际验证逻辑)
|
|
|
|
|
* @param request Http请求对象
|
|
|
|
|
* @return 返回包含登录结果信息的R对象,若登录成功则包含生成的令牌
|
|
|
|
|
*/
|
|
|
|
|
@IgnoreAuth
|
|
|
|
|
@RequestMapping(value = "/login")
|
|
|
|
|
public R login(String username, String password, String captcha, HttpServletRequest request) {
|
|
|
|
|
// 根据用户名查询用户实体
|
|
|
|
|
YonghuEntity u = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("zhanghao", username));
|
|
|
|
|
if (u == null ||!u.getMima().equals(password)) {
|
|
|
|
|
// 若用户不存在或密码不匹配,返回错误信息
|
|
|
|
|
return R.error("账号或密码不正确");
|
|
|
|
|
}
|
|
|
|
|
// 生成用户令牌
|
|
|
|
|
String token = tokenService.generateToken(u.getId(), username, "yonghu", "用户");
|
|
|
|
|
return R.ok().put("token", token);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 用户注册方法
|
|
|
|
|
* @param yonghu 包含用户注册信息的YonghuEntity对象
|
|
|
|
|
* @return 返回包含注册结果信息的R对象
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private TokenService tokenService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 登录
|
|
|
|
|
*/
|
|
|
|
|
@IgnoreAuth
|
|
|
|
|
@RequestMapping(value = "/login")
|
|
|
|
|
public R login(String username, String password, String captcha, HttpServletRequest request) {
|
|
|
|
|
YonghuEntity u = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("zhanghao", username));
|
|
|
|
|
if(u==null || !u.getMima().equals(password)) {
|
|
|
|
|
return R.error("账号或密码不正确");
|
|
|
|
|
}
|
|
|
|
|
String token = tokenService.generateToken(u.getId(), username,"yonghu", "用户" );
|
|
|
|
|
return R.ok().put("token", token);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 注册
|
|
|
|
|
*/
|
|
|
|
|
@IgnoreAuth
|
|
|
|
|
@IgnoreAuth
|
|
|
|
|
@RequestMapping("/register")
|
|
|
|
|
public R register(@RequestBody YonghuEntity yonghu) {
|
|
|
|
|
// 此处原本应有对用户实体的验证逻辑,但被注释掉了
|
|
|
|
|
//ValidatorUtils.validateEntity(yonghu);
|
|
|
|
|
// 根据用户名查询是否已存在该用户
|
|
|
|
|
YonghuEntity u = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("zhanghao", yonghu.getZhanghao()));
|
|
|
|
|
if (u!= null) {
|
|
|
|
|
// 若用户已存在,返回错误信息
|
|
|
|
|
return R.error("注册用户已存在");
|
|
|
|
|
}
|
|
|
|
|
// 设置用户ID为当前时间戳
|
|
|
|
|
Long uId = new Date().getTime();
|
|
|
|
|
yonghu.setId(uId);
|
|
|
|
|
// 插入新用户信息到数据库
|
|
|
|
|
public R register(@RequestBody YonghuEntity yonghu){
|
|
|
|
|
//ValidatorUtils.validateEntity(yonghu);
|
|
|
|
|
YonghuEntity u = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("zhanghao", yonghu.getZhanghao()));
|
|
|
|
|
if(u!=null) {
|
|
|
|
|
return R.error("注册用户已存在");
|
|
|
|
|
}
|
|
|
|
|
Long uId = new Date().getTime();
|
|
|
|
|
yonghu.setId(uId);
|
|
|
|
|
yonghuService.insert(yonghu);
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 用户退出方法
|
|
|
|
|
* @param request Http请求对象
|
|
|
|
|
* @return 返回包含退出成功信息的R对象
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/logout")
|
|
|
|
|
public R logout(HttpServletRequest request) {
|
|
|
|
|
// 使当前会话失效,实现用户退出
|
|
|
|
|
request.getSession().invalidate();
|
|
|
|
|
return R.ok("退出成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取当前用户的会话信息方法
|
|
|
|
|
* @param request Http请求对象
|
|
|
|
|
* @return 返回包含当前用户信息的R对象
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 退出
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/logout")
|
|
|
|
|
public R logout(HttpServletRequest request) {
|
|
|
|
|
request.getSession().invalidate();
|
|
|
|
|
return R.ok("退出成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取用户的session用户信息
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/session")
|
|
|
|
|
public R getCurrUser(HttpServletRequest request) {
|
|
|
|
|
// 从会话中获取用户ID
|
|
|
|
|
Long id = (Long) request.getSession().getAttribute("userId");
|
|
|
|
|
// 根据用户ID查询用户实体
|
|
|
|
|
public R getCurrUser(HttpServletRequest request){
|
|
|
|
|
Long id = (Long)request.getSession().getAttribute("userId");
|
|
|
|
|
YonghuEntity u = yonghuService.selectById(id);
|
|
|
|
|
return R.ok().put("data", u);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 用户密码重置方法
|
|
|
|
|
* @param username 用户名
|
|
|
|
|
* @param request Http请求对象
|
|
|
|
|
* @return 返回包含密码重置结果信息的R对象
|
|
|
|
|
* 密码重置
|
|
|
|
|
*/
|
|
|
|
|
@IgnoreAuth
|
|
|
|
|
@RequestMapping(value = "/resetPass")
|
|
|
|
|
public R resetPass(String username, HttpServletRequest request) {
|
|
|
|
|
// 根据用户名查询用户实体
|
|
|
|
|
YonghuEntity u = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("zhanghao", username));
|
|
|
|
|
if (u == null) {
|
|
|
|
|
// 若用户不存在,返回错误信息
|
|
|
|
|
return R.error("账号不存在");
|
|
|
|
|
}
|
|
|
|
|
// 将用户密码重置为"123456"
|
|
|
|
|
@RequestMapping(value = "/resetPass")
|
|
|
|
|
public R resetPass(String username, HttpServletRequest request){
|
|
|
|
|
YonghuEntity u = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("zhanghao", username));
|
|
|
|
|
if(u==null) {
|
|
|
|
|
return R.error("账号不存在");
|
|
|
|
|
}
|
|
|
|
|
u.setMima("123456");
|
|
|
|
|
// 更新用户信息到数据库
|
|
|
|
|
yonghuService.updateById(u);
|
|
|
|
|
return R.ok("密码已重置为:123456");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取用户列表(后端)方法
|
|
|
|
|
* @param params 查询参数的Map对象
|
|
|
|
|
* @param yonghu YonghuEntity对象,可能用于条件筛选等
|
|
|
|
|
* @param request Http请求对象
|
|
|
|
|
* @return 返回包含用户列表分页信息的R对象
|
|
|
|
|
* 后端列表
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/page")
|
|
|
|
|
public R page(@RequestParam Map<String, Object> params, YonghuEntity yonghu,
|
|
|
|
|
HttpServletRequest request) {
|
|
|
|
|
// 创建用于构建查询条件的EntityWrapper对象
|
|
|
|
|
public R page(@RequestParam Map<String, Object> params,YonghuEntity yonghu,
|
|
|
|
|
HttpServletRequest request){
|
|
|
|
|
|
|
|
|
|
EntityWrapper<YonghuEntity> ew = new EntityWrapper<YonghuEntity>();
|
|
|
|
|
|
|
|
|
|
// 调用服务类的方法进行分页查询,并进行排序、条件筛选等操作
|
|
|
|
|
PageUtils page = yonghuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, yonghu), params), params));
|
|
|
|
|
request.setAttribute("data", page);
|
|
|
|
|
PageUtils page = yonghuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, yonghu), params), params));
|
|
|
|
|
request.setAttribute("data", page);
|
|
|
|
|
return R.ok().put("data", page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取用户列表(前端)方法
|
|
|
|
|
* 与page方法类似,只是多了@IgnoreAuth注解,可能表示前端访问此接口无需认证
|
|
|
|
|
* @param params 查询参数的Map对象
|
|
|
|
|
* @param yonghu YonghuEntity对象,可能用于条件筛选等
|
|
|
|
|
* @param request Http请求对象
|
|
|
|
|
* @return 返回包含用户列表分页信息的R对象
|
|
|
|
|
* 前端列表
|
|
|
|
|
*/
|
|
|
|
|
@IgnoreAuth
|
|
|
|
|
@IgnoreAuth
|
|
|
|
|
@RequestMapping("/list")
|
|
|
|
|
public R list(@RequestParam Map<String, Object> params, YonghuEntity yonghu,
|
|
|
|
|
HttpServletRequest request) {
|
|
|
|
|
public R list(@RequestParam Map<String, Object> params,YonghuEntity yonghu,
|
|
|
|
|
HttpServletRequest request){
|
|
|
|
|
EntityWrapper<YonghuEntity> ew = new EntityWrapper<YonghuEntity>();
|
|
|
|
|
|
|
|
|
|
PageUtils page = yonghuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, yonghu), params), params));
|
|
|
|
|
request.setAttribute("data", page);
|
|
|
|
|
PageUtils page = yonghuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, yonghu), params), params));
|
|
|
|
|
request.setAttribute("data", page);
|
|
|
|
|
return R.ok().put("data", page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取用户列表方法(另一种实现方式,可能用于特定场景)
|
|
|
|
|
* @param yonghu YonghuEntity对象,用于构建查询条件
|
|
|
|
|
* @return 返回包含用户列表信息的R对象
|
|
|
|
|
/**
|
|
|
|
|
* 列表
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/lists")
|
|
|
|
|
public R list(YonghuEntity yonghu) {
|
|
|
|
|
EntityWrapper<YonghuEntity> ew = new EntityWrapper<YonghuEntity>();
|
|
|
|
|
ew.allEq(MPUtil.allEQMapPre(yonghu, "yonghu"));
|
|
|
|
|
public R list( YonghuEntity yonghu){
|
|
|
|
|
EntityWrapper<YonghuEntity> ew = new EntityWrapper<YonghuEntity>();
|
|
|
|
|
ew.allEq(MPUtil.allEQMapPre( yonghu, "yonghu"));
|
|
|
|
|
return R.ok().put("data", yonghuService.selectListView(ew));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询单个用户信息方法
|
|
|
|
|
* @param yonghu YonghuEntity对象,用于构建查询条件
|
|
|
|
|
* @return 返回包含查询到的用户视图信息的R对象
|
|
|
|
|
/**
|
|
|
|
|
* 查询
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/query")
|
|
|
|
|
public R query(YonghuEntity yonghu) {
|
|
|
|
|
EntityWrapper<YonghuEntity> ew = new EntityWrapper<YonghuEntity>();
|
|
|
|
|
ew.allEq(MPUtil.allEQMapPre(yonghu, "yonghu"));
|
|
|
|
|
YonghuView yonghuView = yonghuService.selectView(ew);
|
|
|
|
|
return R.ok("查询用户成功").put("data", yonghuView);
|
|
|
|
|
public R query(YonghuEntity yonghu){
|
|
|
|
|
EntityWrapper< YonghuEntity> ew = new EntityWrapper< YonghuEntity>();
|
|
|
|
|
ew.allEq(MPUtil.allEQMapPre( yonghu, "yonghu"));
|
|
|
|
|
YonghuView yonghuView = yonghuService.selectView(ew);
|
|
|
|
|
return R.ok("查询用户成功").put("data", yonghuView);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取用户详细信息(后端)方法
|
|
|
|
|
* @param id 用户ID
|
|
|
|
|
* @return 返回包含用户详细信息的R对象
|
|
|
|
|
* 后端详情
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/info/{id}")
|
|
|
|
|
public R info(@PathVariable("id") Long id) {
|
|
|
|
|
public R info(@PathVariable("id") Long id){
|
|
|
|
|
YonghuEntity yonghu = yonghuService.selectById(id);
|
|
|
|
|
return R.ok().put("data", yonghu);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取用户详细信息(前端)方法
|
|
|
|
|
* 与info方法类似,多了@IgnoreAuth注解,可能表示前端访问此接口无需认证
|
|
|
|
|
* @param id 用户ID
|
|
|
|
|
* @return 返回包含用户详细信息的R对象
|
|
|
|
|
* 前端详情
|
|
|
|
|
*/
|
|
|
|
|
@IgnoreAuth
|
|
|
|
|
@IgnoreAuth
|
|
|
|
|
@RequestMapping("/detail/{id}")
|
|
|
|
|
public R detail(@PathVariable("id") Long id) {
|
|
|
|
|
public R detail(@PathVariable("id") Long id){
|
|
|
|
|
YonghuEntity yonghu = yonghuService.selectById(id);
|
|
|
|
|
return R.ok().put("data", yonghu);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 保存用户信息(后端)方法
|
|
|
|
|
* @param yonghu 包含用户信息的YonghuEntity对象
|
|
|
|
|
* @param request Http请求对象
|
|
|
|
|
* @return 返回包含保存结果信息的R对象
|
|
|
|
|
* 后端保存
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/save")
|
|
|
|
|
public R save(@RequestBody YonghuEntity yonghu, HttpServletRequest request) {
|
|
|
|
|
// 设置用户ID为当前时间戳加上一个随机数
|
|
|
|
|
yonghu.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue());
|
|
|
|
|
// 此处原本应有对用户实体的验证逻辑,但被注释掉了
|
|
|
|
|
//ValidatorUtils.validateEntity(yonghu);
|
|
|
|
|
YonghuEntity u = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("zhanghao", yonghu.getZhanghao()));
|
|
|
|
|
if (u!= null) {
|
|
|
|
|
// 若用户已存在,返回错误信息
|
|
|
|
|
return R.error("用户已存在");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
yonghu.setId(new Date().getTime());
|
|
|
|
|
public R save(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
|
|
|
|
|
yonghu.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
|
|
|
|
|
//ValidatorUtils.validateEntity(yonghu);
|
|
|
|
|
YonghuEntity u = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("zhanghao", yonghu.getZhanghao()));
|
|
|
|
|
if(u!=null) {
|
|
|
|
|
return R.error("用户已存在");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
yonghu.setId(new Date().getTime());
|
|
|
|
|
yonghuService.insert(yonghu);
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 保存用户信息(前端)方法
|
|
|
|
|
* 与save方法类似,可能在前端页面操作保存用户信息时调用
|
|
|
|
|
* @param yonghu 包含用户信息的YonghuEntity对象
|
|
|
|
|
* @param request Http请求对象
|
|
|
|
|
* @return 返回包含保存结果信息的R对象
|
|
|
|
|
* 前端保存
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/add")
|
|
|
|
|
public R add(@RequestBody YonghuEntity yonghu, HttpServletRequest request) {
|
|
|
|
|
yonghu.setId(new Date().getTime() + new Double(Math.floor(Math.random() * 1000)).longValue());
|
|
|
|
|
// 此处原本应有对用户实体的验证逻辑,但被注释掉了
|
|
|
|
|
//ValidatorUtils.validateEntity(yonghu);
|
|
|
|
|
YonghuEntity u = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("zhanghao", yonghu.getZhanghao()));
|
|
|
|
|
if (u!= null) {
|
|
|
|
|
// 若用户已存在,返回错误信息
|
|
|
|
|
return R.error("用户已存在");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
yonghu.setId(new Date().getTime());
|
|
|
|
|
public R add(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
|
|
|
|
|
yonghu.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
|
|
|
|
|
//ValidatorUtils.validateEntity(yonghu);
|
|
|
|
|
YonghuEntity u = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("zhanghao", yonghu.getZhanghao()));
|
|
|
|
|
if(u!=null) {
|
|
|
|
|
return R.error("用户已存在");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
yonghu.setId(new Date().getTime());
|
|
|
|
|
yonghuService.insert(yonghu);
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 更新用户信息方法
|
|
|
|
|
* @param yonghu 包含更新后用户信息的YonghuEntity对象
|
|
|
|
|
* @param request Http请求对象
|
|
|
|
|
* @return 返回包含更新结果信息的R对象
|
|
|
|
|
* 修改
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/update")
|
|
|
|
|
@Transactional
|
|
|
|
|
public R update(@RequestBody YonghuEntity yonghu, HttpServletRequest request) {
|
|
|
|
|
// 此处原本应有对用户实体的验证逻辑,但被注释掉了
|
|
|
|
|
public R update(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
|
|
|
|
|
//ValidatorUtils.validateEntity(yonghu);
|
|
|
|
|
yonghuService.updateById(yonghu); // 全部更新
|
|
|
|
|
yonghuService.updateById(yonghu);//全部更新
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除用户信息方法
|
|
|
|
|
* @param ids 要删除的用户ID数组
|
|
|
|
|
* @return 返回包含删除结果信息的R对象
|
|
|
|
|
* 删除
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/delete")
|
|
|
|
|
public R delete(@RequestBody Long[] ids) {
|
|
|
|
|
public R delete(@RequestBody Long[] ids){
|
|
|
|
|
yonghuService.deleteBatchIds(Arrays.asList(ids));
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 提醒接口方法,根据指定条件统计符合要求的用户数量
|
|
|
|
|
* @param columnName 用于筛选的列名
|
|
|
|
|
* @param request Http请求对象
|
|
|
|
|
* @param type 类型参数,可能用于区分不同的提醒逻辑
|
|
|
|
|
* @param map 查询参数的Map对象
|
|
|
|
|
* @return 返回包含符合条件的用户数量的R对象
|
|
|
|
|
* 提醒接口
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/remind/{columnName}/{type}")
|
|
|
|
|
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
|
|
|
|
|
@PathVariable("type") String type, @RequestParam Map<String, Object> map) {
|
|
|
|
|
map.put("column", columnName);
|
|
|
|
|
map.put("type", type);
|
|
|
|
|
|
|
|
|
|
if (type.equals("2")) {
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
Calendar c = Calendar.getInstance();
|
|
|
|
|
Date remindStartDate = null;
|
|
|
|
|
Date remindEndDate = null;
|
|
|
|
|
if (map.get("remindstart")!= null) {
|
|
|
|
|
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
|
|
|
|
|
c.setTime(new Date());
|
|
|
|
|
c.add(Calendar.DAY_OF_MONTH, remindStart);
|
|
|
|
|
remindStartDate = c.getTime();
|
|
|
|
|
map.put("remindstart", sdf.format(remindStartDate));
|
|
|
|
|
}
|
|
|
|
|
if (map.get("remindend")!= null) {
|
|
|
|
|
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
|
|
|
|
|
c.setTime(new Date());
|
|
|
|
|
c.add(Calendar.DAY_OF_MONTH, remindEnd);
|
|
|
|
|
remindEndDate = c.getTime();
|
|
|
|
|
map.put("remindend", sdf.format(remindEndDate));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@RequestMapping("/remind/{columnName}/{type}")
|
|
|
|
|
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
|
|
|
|
|
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
|
|
|
|
|
map.put("column", columnName);
|
|
|
|
|
map.put("type", type);
|
|
|
|
|
|
|
|
|
|
if(type.equals("2")) {
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
Calendar c = Calendar.getInstance();
|
|
|
|
|
Date remindStartDate = null;
|
|
|
|
|
Date remindEndDate = null;
|
|
|
|
|
if(map.get("remindstart")!=null) {
|
|
|
|
|
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
|
|
|
|
|
c.setTime(new Date());
|
|
|
|
|
c.add(Calendar.DAY_OF_MONTH,remindStart);
|
|
|
|
|
remindStartDate = c.getTime();
|
|
|
|
|
map.put("remindstart", sdf.format(remindStartDate));
|
|
|
|
|
}
|
|
|
|
|
if(map.get("remindend")!=null) {
|
|
|
|
|
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
|
|
|
|
|
c.setTime(new Date());
|
|
|
|
|
c.add(Calendar.DAY_OF_MONTH,remindEnd);
|
|
|
|
|
remindEndDate = c.getTime();
|
|
|
|
|
map.put("remindend", sdf.format(remindEndDate));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Wrapper<YonghuEntity> wrapper = new EntityWrapper<YonghuEntity>();
|
|
|
|
|
if(map.get("remindstart")!=null) {
|
|
|
|
|
wrapper.ge(columnName, map.get("remindstart"));
|
|
|
|
|
}
|
|
|
|
|
if(map.get("remindend")!=null) {
|
|
|
|
|
wrapper.le(columnName, map.get("remindend"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int count = yonghuService.selectCount(wrapper);
|
|
|
|
|
return R.ok().put("count", count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Wrapper<YonghuEntity> wrapper = new EntityWrapper<YonghuEntity>();
|
|
|
|
|
if (map.get("remindstart")!= null) {
|
|
|
|
|
wrapper.ge(columnName, map.get("remindstart"));
|
|
|
|
|
}
|
|
|
|
|
if (map.get("remindend")!= null) {
|
|
|
|
|
wrapper.le(columnName, map.get("remindend"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int count = yonghuService.selectCount(wrapper);
|
|
|
|
|
return R.ok().put("count", count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* (按值统计)方法,根据指定的列进行统计并返回结果
|
|
|
|
|
* @param yColumnName 用于统计的列名(纵坐标相关)
|
|
|
|
|
* @param xColumnName 用于分组的列名(横坐标相关)
|
|
|
|
|
* @param request Http请求对象
|
|
|
|
|
* @return 返回包含统计结果的R对象
|
|
|
|
|
* (按值统计)
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/value/{xColumnName}/{yColumnName}")
|
|
|
|
|
public R value(@PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName, HttpServletRequest request) {
|
|
|
|
|
public R value(@PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName,HttpServletRequest request) {
|
|
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
|
params.put("xColumn", xColumnName);
|
|
|
|
|
params.put("yColumn", yColumnName);
|
|
|
|
|
EntityWrapper<YonghuEntity> ew = new EntityWrapper<YonghuEntity>();
|
|
|
|
|
List<Map<String, Object>> result = yonghuService.selectValue(params, ew);
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
for (Map<String, Object> m : result) {
|
|
|
|
|
for (String k : m.keySet()) {
|
|
|
|
|
if (m.get(k) instanceof Date) {
|
|
|
|
|
m.put(k, sdf.format((Date) m.get(k)));
|
|
|
|
|
for(Map<String, Object> m : result) {
|
|
|
|
|
for(String k : m.keySet()) {
|
|
|
|
|
if(m.get(k) instanceof Date) {
|
|
|
|
|
m.put(k, sdf.format((Date)m.get(k)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -384,18 +325,59 @@ public class YonghuController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* (按值统计)时间统计类型方法,根据指定的列和时间统计类型进行统计并返回结果
|
|
|
|
|
* @param yColumnName 用于统计的列名(纵坐标相关)
|
|
|
|
|
* @param xColumnName 用于分组的列名(横坐标相关)
|
|
|
|
|
* @param timeStatType 时间统计类型参数
|
|
|
|
|
* @param request Http请求对象
|
|
|
|
|
* @return 返回包含统计结果的R对象
|
|
|
|
|
* (按值统计)时间统计类型
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/value/{xColumnName}/{yColumnName}/{timeStatType}")
|
|
|
|
|
public R valueDay(@PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName, @PathVariable("timeStatType") String timeStatType, HttpServletRequest request) {
|
|
|
|
|
public R valueDay(@PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName, @PathVariable("timeStatType") String timeStatType,HttpServletRequest request) {
|
|
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
|
params.put("xColumn", xColumnName);
|
|
|
|
|
params.put("yColumn", yColumnName);
|
|
|
|
|
params.put("timeStatType", timeStatType);
|
|
|
|
|
EntityWrapper<YonghuEntity> ew = new EntityWrapper<YonghuEntity>();
|
|
|
|
|
List<Map<String, Object>> result
|
|
|
|
|
List<Map<String, Object>> result = yonghuService.selectTimeStatValue(params, ew);
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
for(Map<String, Object> m : result) {
|
|
|
|
|
for(String k : m.keySet()) {
|
|
|
|
|
if(m.get(k) instanceof Date) {
|
|
|
|
|
m.put(k, sdf.format((Date)m.get(k)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return R.ok().put("data", result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分组统计
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/group/{columnName}")
|
|
|
|
|
public R group(@PathVariable("columnName") String columnName,HttpServletRequest request) {
|
|
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
|
params.put("column", columnName);
|
|
|
|
|
EntityWrapper<YonghuEntity> ew = new EntityWrapper<YonghuEntity>();
|
|
|
|
|
List<Map<String, Object>> result = yonghuService.selectGroup(params, ew);
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
for(Map<String, Object> m : result) {
|
|
|
|
|
for(String k : m.keySet()) {
|
|
|
|
|
if(m.get(k) instanceof Date) {
|
|
|
|
|
m.put(k, sdf.format((Date)m.get(k)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return R.ok().put("data", result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 总数量
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/count")
|
|
|
|
|
public R count(@RequestParam Map<String, Object> params,YonghuEntity yonghu, HttpServletRequest request){
|
|
|
|
|
EntityWrapper<YonghuEntity> ew = new EntityWrapper<YonghuEntity>();
|
|
|
|
|
int count = yonghuService.selectCount(MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, yonghu), params), params));
|
|
|
|
|
return R.ok().put("data", count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|