13 changed files with 278 additions and 29 deletions
@ -0,0 +1,67 @@
@@ -0,0 +1,67 @@
|
||||
package vip.xumy.picture.ctrl; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.DeleteMapping; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
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 com.github.pagehelper.Page; |
||||
import com.github.pagehelper.PageHelper; |
||||
|
||||
import vip.xumy.admin.verify.controller.PublicController; |
||||
import vip.xumy.admin.verify.pojo.User; |
||||
import vip.xumy.core.pojo.base.BasePageParam; |
||||
import vip.xumy.core.pojo.com.AjaxResponse; |
||||
import vip.xumy.core.pojo.com.PageResponse; |
||||
import vip.xumy.picture.service.MyUserService; |
||||
|
||||
/** |
||||
* Do not use for any commercial purposes without permission |
||||
* |
||||
* @author: mengyxu |
||||
* @date: 2022年1月7日 |
||||
*/ |
||||
|
||||
@RestController |
||||
@RequestMapping("my/user") |
||||
public class MyUserController { |
||||
@Autowired |
||||
private MyUserService userService; |
||||
|
||||
@GetMapping |
||||
public PageResponse<User> save(BasePageParam param, HttpServletRequest request) { |
||||
User user = (User) request.getSession().getAttribute(PublicController.KEY); |
||||
PageResponse<User> rsp = new PageResponse<>(); |
||||
if (!"1".equals(user.getPermission())) { |
||||
rsp.setRows(new ArrayList<User>()); |
||||
rsp.setTotal(0L); |
||||
} else { |
||||
Page<User> pages = PageHelper.startPage(param.getPage(), param.getSize()); |
||||
List<User> list = userService.list(); |
||||
rsp.setRows(list); |
||||
rsp.setTotal(pages.getTotal()); |
||||
} |
||||
return rsp; |
||||
} |
||||
|
||||
@PostMapping |
||||
public AjaxResponse save(@RequestBody User user) { |
||||
userService.save(user); |
||||
return AjaxResponse.successed(); |
||||
} |
||||
|
||||
@DeleteMapping |
||||
public AjaxResponse delete(@RequestBody User user) { |
||||
userService.delete(user.getUserId()); |
||||
return AjaxResponse.successed(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
package vip.xumy.picture.mapper; |
||||
|
||||
import java.util.List; |
||||
|
||||
import org.apache.ibatis.annotations.Delete; |
||||
import org.apache.ibatis.annotations.Insert; |
||||
import org.apache.ibatis.annotations.Select; |
||||
|
||||
import vip.xumy.admin.verify.pojo.User; |
||||
|
||||
/** |
||||
* @author:mengyxu |
||||
* @date:2020年10月28日 |
||||
*/ |
||||
|
||||
public interface MyUserMapper { |
||||
|
||||
@Select({ "SELECT * FROM user" }) |
||||
List<User> list(); |
||||
|
||||
@Delete({ "DELETE FROM user WHERE user_id = #{id}" }) |
||||
void delete(String id); |
||||
|
||||
@Insert({ "INSERT INTO user VALUES (#{userId}, #{name}, #{password}, #{desc}, '0')" }) |
||||
int save(User user); |
||||
|
||||
} |
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
package vip.xumy.picture.service; |
||||
|
||||
import java.util.List; |
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.util.DigestUtils; |
||||
|
||||
import vip.xumy.admin.verify.pojo.User; |
||||
import vip.xumy.picture.mapper.MyUserMapper; |
||||
|
||||
/** Do not use for any commercial purposes without permission |
||||
* @author: mengyxu |
||||
* @date: 2022年1月7日 |
||||
*/ |
||||
|
||||
@Service |
||||
public class MyUserService { |
||||
@Autowired |
||||
private MyUserMapper userMapper; |
||||
@Autowired |
||||
private PictureService pictureService; |
||||
|
||||
public List<User> list() { |
||||
return userMapper.list(); |
||||
} |
||||
|
||||
public void save(User user) { |
||||
user.setPassword(DigestUtils.md5DigestAsHex(user.getPassword().getBytes())); |
||||
userMapper.save(user); |
||||
} |
||||
|
||||
public void delete(String id) { |
||||
userMapper.delete(id); |
||||
pictureService.deleteAll(id); |
||||
} |
||||
|
||||
} |
@ -1,11 +1,14 @@
@@ -1,11 +1,14 @@
|
||||
export default { |
||||
menuGroups: [], |
||||
menuGroups: [{ |
||||
name: '主页', |
||||
id: 'home', |
||||
child: [] |
||||
}], |
||||
sizes: {}, |
||||
userInfo: {}, |
||||
showHeader: true, |
||||
size: 'small', |
||||
dict: {}, |
||||
handlers: {}, |
||||
host: {}, |
||||
network: "traHost" |
||||
conf: {} |
||||
} |
||||
|
@ -0,0 +1,109 @@
@@ -0,0 +1,109 @@
|
||||
<template> |
||||
<div id="user"> |
||||
<Template ref="template" name="用户" :url="url" :flag="flag" :terms="terms" :props="props" :rules="rules" |
||||
:actions="actions"></template> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import { |
||||
Vue, |
||||
Component, |
||||
Prop |
||||
} from "vue-property-decorator"; |
||||
import Template from '@/components/template/manage.vue'; |
||||
import { |
||||
userName, |
||||
password, |
||||
name |
||||
} from '@/static/tool/validate.js'; |
||||
|
||||
@Component({ |
||||
components: { |
||||
Template |
||||
} |
||||
}) |
||||
export default class User extends Vue { |
||||
url = 'my/user' |
||||
flag = { |
||||
list: true, |
||||
save: true, |
||||
update: false, |
||||
del: true |
||||
} |
||||
rules = { |
||||
userId: [{ |
||||
required: true, |
||||
message: '请输入用户名', |
||||
trigger: 'blur' |
||||
}, |
||||
{ |
||||
validator: userName, |
||||
trigger: 'blur' |
||||
} |
||||
], |
||||
password: [{ |
||||
required: true, |
||||
message: '请输入密码', |
||||
trigger: 'blur' |
||||
}, |
||||
{ |
||||
validator: password, |
||||
trigger: 'blur' |
||||
} |
||||
], |
||||
name: [{ |
||||
required: true, |
||||
message: '请输入用户姓名', |
||||
trigger: 'blur' |
||||
}, |
||||
{ |
||||
validator: name, |
||||
trigger: 'blur' |
||||
} |
||||
], |
||||
desc: [{ |
||||
required: false, |
||||
max: 64, |
||||
message: '备注不得超过64位', |
||||
trigger: 'blur' |
||||
} |
||||
] |
||||
}; |
||||
terms = []; |
||||
props = [{ |
||||
code: 'userId', |
||||
name: '用户名', |
||||
readOnly: true, |
||||
width: 180 |
||||
}, { |
||||
code: 'password', |
||||
name: '密码', |
||||
tableHide: true, |
||||
modifyHide: true |
||||
}, { |
||||
code: 'name', |
||||
name: '姓名', |
||||
width: 120 |
||||
}, { |
||||
code: 'desc', |
||||
name: '备注', |
||||
width: 180 |
||||
}]; |
||||
actions = []; |
||||
created() {} //生命周期 - 创建完成(可以访问当前this实例) |
||||
mounted() {} //生命周期 - 挂载完成(可以访问DOM元素) |
||||
beforeCreate() {} //生命周期 - 创建之前 |
||||
beforeMount() {} //生命周期 - 挂载之前 |
||||
beforeUpdate() {} //生命周期 - 更新之前 |
||||
updated() {} //生命周期 - 更新之后 |
||||
beforeDestroy() {} //生命周期 - 销毁之前 |
||||
destroyed() {} //生命周期 - 销毁完成 |
||||
activated() {} //如果页面有keep-alive缓存功能,这个函数会触发 |
||||
} |
||||
</script> |
||||
<style scoped> |
||||
#user { |
||||
padding: 0px 100px; |
||||
} |
||||
</style> |
Loading…
Reference in new issue