ZhuDongming
2019-11-12 fdc3b40f19e487604341c661eec471bf9ac45279
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package com.moral.controller;
 
import javax.annotation.Resource;
 
import org.springframework.web.bind.annotation.CrossOrigin;
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.moral.common.bean.PageBean;
import com.moral.common.bean.ResultBean;
import com.moral.entity.AccountRole;
import com.moral.service.AccountRoleService;
import com.moral.service.AccountService;
import com.moral.service.RoleService;
 
@RestController
@RequestMapping("account-role")
@CrossOrigin(origins = "*", maxAge = 3600)
public class AccountRoleController {
    @Resource
    AccountService accountService;
 
    @Resource
    RoleService roleService;
 
    @Resource
    AccountRoleService accountRoleService;
 
    @GetMapping("account-list")
    public ResultBean getAccountList(String accountName) {
        ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
        resultBean.setData(accountService.getAccountList(accountName));
        return resultBean;
    }
 
    @GetMapping("role-list")
    public ResultBean getRoleList(String roleName) {
        ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
        resultBean.setData(roleService.getRoleListByName(roleName));
        return resultBean;
    }
 
    @PostMapping("add-or-modify")
    public ResultBean saveOrUpdate(@RequestBody AccountRole accountRole) {
        accountRoleService.addOrModify(accountRole);
        ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
        return resultBean;
    }
 
    @GetMapping("count-by-example")
    public ResultBean<Integer> countByExample(PageBean pageBean) {
        return new ResultBean<Integer>(accountRoleService.countByExample(pageBean));
    }
 
    @GetMapping("accountRole-list")
    public PageBean getAccountRoleList(PageBean pageBean) {
        return accountRoleService.getAccountRoleList(pageBean);
    }
 
    @PostMapping("delete-by-ids")
    public ResultBean deleteByIds(@RequestBody Integer [] ids){
        accountRoleService.deleteByIds(ids);
        ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
        return resultBean;
    }
}