文章目录
项目介绍
基于SpringBoot的纹理生成图片系统,java项目。
eclipse和idea都能打开运行。
推荐环境配置:eclipse/idea jdk1.8 maven mysql
前端技术:vue,Ajax,Json
后端技术:SpringBoot,MyBatis
本系统共分为两个角色:管理员和用户。
主要功能有:
后台:登录、首页、个人中心、用户管理、基础数据管理、公告管理、轮播图信息
前台:登录注册、首页展示、公告列表、图片列表、点赞、个人中心
提供远程部署、代码讲解等服务
更多精品项目,请查看主页
主要功能截图:
部分代码展示
@RequestMapping("/queryClockInAll2")
public JsonObject queryClockInAll2(Clockinnew clockinnew, HttpServletRequest request,
@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "15") Integer pageSize
){
//获取当前得登录用户
Userinfo userinfo= (Userinfo) request.getSession().getAttribute("user");
String username=userinfo.getUsername();
//根据username获取登录账号得业主id
Owner owner=ownerService.queryOwnerByName(username);
clockinnew.setOwnerId(owner.getId());
PageInfo<Clockinnew> pageInfo= clockinnewService.queryClockInAll(pageNum,pageSize,clockinnew);
return new JsonObject(0,"ok",pageInfo.getTotal(),pageInfo.getList());
}
核心接口,封装具体方法,方便对象的注入
package com.yx.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.github.pagehelper.PageInfo;
import com.yx.model.Clockinnew;
import java.util.Date;
/**
* <p>
* 服务类
* </p>
*
* @author yx
* @since 2021-04-27
*/
public interface IClockInNewService extends IService<Clockinnew> {
PageInfo<Clockinnew> queryClockInAll(int pageNum, int pageSize, Clockinnew clockinnew);
/**
* 查询分页数据
*
* @param page 页码
* @param pageCount 每页条数
* @return IPage<Clockinnew>
*/
IPage<Clockinnew> findListByPage(Integer page, Integer pageCount);
/**
* 添加
*
* @param clockinnew
* @return int
*/
int add(Clockinnew clockinnew);
/**
* 删除
*
* @param id 主键
* @return int
*/
int delete(Long id);
/**
* 修改
*
* @param clockinnew
* @return int
*/
int updateData(Clockinnew clockinnew);
/**
* id查询数据
*
* @param id id
* @return Clockinnew
*/
Clockinnew findById(Long id);
Date queryCountByOwnId(Integer ownerId);
}
@RequestMapping(value="/login",method= RequestMethod.POST)
public String login(Model model, String name, String password){//throws ParseException
Subject subject = SecurityUtils.getSubject();
UsernamePasswordToken token = new UsernamePasswordToken(name,password);
try {
subject.login(token);
User us = userService.getByName(name);
String lastLoginTime = "";
if(us!=null){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//上次时间
Date time = us.getLasttime();
lastLoginTime = sdf.format(time);
//新时间
String format = sdf.format(new Date());
//string转date 不处理时间格式会不理想
ParsePosition pos = new ParsePosition(0);
Date strtodate = sdf.parse(format, pos);
us.setLasttime(strtodate);
userService.update(us);
}
if (us.getStatus()==1){
Session session=subject.getSession();
session.setAttribute("subject", subject);
session.setAttribute("lastLoginTime",lastLoginTime);
return "redirect:index";
}else {
model.addAttribute("error", "账号已被停用!");
return "/login";
}
} catch (AuthenticationException e) {
model.addAttribute("error", "验证失败!");
return "/login";
}
}
@Override
public User getByName(String name) {
UserExample example = new UserExample();
example.createCriteria().andNameEqualTo(name);
List<User> users = userMapper.selectByExample(example);
if (users.isEmpty()) return null;
return users.get(0);
}
package com.byh.biyesheji.dao;
import com.byh.biyesheji.pojo.User;
import com.byh.biyesheji.pojo.UserExample;
import java.util.List;
public interface UserMapper extends SysDao<User>{
List<User> selectByExample(UserExample example);
/**
* 停用管理员账号
* @param name
*/
void enableStatus(String name);
/**
* 开启管理员账号
* @param name
*/
void stopStatus(String name);
}
<select id="selectByExample" resultMap="BaseResultMap" parameterType="com.byh.biyesheji.pojo.UserExample" >
select
<if test="distinct" >
distinct
</if>
<include refid="Base_Column_List" />
from user
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null" >
order by ${orderByClause}
</if>
</select>
设计总结
项目获取方式
精彩专栏推荐订阅:在下方专栏👇🏻
Java精品项目100套